Attaching Files in phpMyFAQ 2.0.7

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

grahamar
Posts: 8
Joined: Tue Mar 24, 2009 5:11 pm

Attaching Files in phpMyFAQ 2.0.7

Post by grahamar »

Hi,

I have a problem when I try ti attach files when editing the FAQ content.
I get the Browse/Upload window and after selecting the file to upload I get the following message:
Add an attachment to the issue

An error occurred while attaching the file.

Close this window


I did check the file permission of the phpMYFAQ directory, the attachment directory and the attachment.php file ( I set them all to 777 to test) - but still get the same error.

Can you advise on what other steps to take?

Thank you.

Graham
Thorsten
Posts: 15815
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Attaching Files in phpMyFAQ 2.0.7

Post by Thorsten »

Hi,

please enable the debug mode in inc/Init.php and set the mode to "true". Then try it again and look at possible error messages.

Thanks!

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
grahamar
Posts: 8
Joined: Tue Mar 24, 2009 5:11 pm

Re: Attaching Files in phpMyFAQ 2.0.7

Post by grahamar »

HI,

Here is what is displayed with the debug set to true after I click Upload to upload the attachment.
Can you help me understand what this is telling me?
Thanks
Graham


Notice: Constant PMF_ROOT_DIR already defined in /opt/coolstack/apache2/htdocs/pmwiki/faq/gscwiki/admin/attachment.php on line 30

Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in /opt/coolstack/apache2/htdocs/pmwiki/faq/gscwiki/inc/PMF_User/CurrentUser.php on line 300

Add an attachment to the issue

An error occurred while attaching the file.

Close this window

PMF_Configuration->getAll() in line 87:

SELECT
config_name, config_value
FROM
faqconfig


PMF_User->getUserById() in line 416:

SELECT
user_id,
login,
account_status
FROM
faquser
WHERE
user_id = 1


PMF_User->getUserById() in line 416:

SELECT
pass
FROM
faquserlogin
WHERE
login = 'admin'


PMF_UserData->load() in line 331:

SELECT
last_modified, display_name, email
FROM
faquserdata
WHERE
user_id = 1


PMF_CurrentUser->getSessionInfo() in line 423:

SELECT
session_id,
session_timestamp,
ip
FROM
faquser
WHERE
user_id = 1


PMF_CurrentUser->updateSessionId() in line 434:

UPDATE
faquser
SET
session_id = 'b6a8cbb87bd1529ac913e46
Thorsten
Posts: 15815
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Attaching Files in phpMyFAQ 2.0.7

Post by Thorsten »

Hi,

please remove line 30 in admin/attachement.php and try it again. Thanks!

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
grahamar
Posts: 8
Joined: Tue Mar 24, 2009 5:11 pm

Re: Attaching Files in phpMyFAQ 2.0.7

Post by grahamar »

Hi,

I commented out line 30 .. but still have the same issue.
Here is the error message this time:

Add an attachment to the issue

An error occurred while attaching the file.

Close this window

PMF_Configuration->getAll() in line 87:

SELECT
config_name, config_value
FROM
faqconfig


PMF_User->getUserById() in line 416:

SELECT
user_id,
login,
account_status
FROM
faquser
WHERE
user_id = 1


PMF_User->getUserById() in line 416:

SELECT
pass
FROM
faquserlogin
WHERE
login = 'admin'


PMF_UserData->load() in line 331:

SELECT
last_modified, display_name, email
FROM
faquserdata
WHERE
user_id = 1


PMF_CurrentUser->getSessionInfo() in line 423:

SELECT
session_id,
session_timestamp,
ip
FROM
faquser
WHERE
user_id = 1


PMF_PermBasic->getAllRightsData() in line 77:

SELECT
right_id,
name,
description,
for_users,
for_groups
FROM
faqright
ORDER BY
right_id ASC


PMF_PermBasic->getUserRights() in line 309:

SELECT
faqright.right_id AS right_id
FROM
faqright,
faquser_right,
faquser
WHERE
faqright.right_id = faquser_right.right_id AND
faquser.user_id = 1 AND
faquser.user_id = faquser_right.user_id
Thorsten
Posts: 15815
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Attaching Files in phpMyFAQ 2.0.7

Post by Thorsten »

Hi,

please take a look at line 141 for this code

Code: Select all

        if (@move_uploaded_file($_FILES["userfile"]["tmp_name"], PMF_ROOT_DIR."/attachments/".$_REQUEST["id"]."/".$_FILES["userfile"]["name"])) {
and change it to

Code: Select all

        if (move_uploaded_file($_FILES["userfile"]["tmp_name"], PMF_ROOT_DIR."/attachments/".$_REQUEST["id"]."/".$_FILES["userfile"]["name"])) {
Thanks.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
grahamar
Posts: 8
Joined: Tue Mar 24, 2009 5:11 pm

Re: Attaching Files in phpMyFAQ 2.0.7

Post by grahamar »

Hi,

In removing and replacing the line suggested I now get this error message:

Add an attachment to the issue

Warning: move_uploaded_file() [function.move-uploaded-file]: SAFE MODE Restriction in effect. The script whose uid is 0 is not allowed to access /opt/coolstack/apache2/htdocs/pmwiki/faq/gscwiki/attachments/71 owned by uid 80 in /opt/coolstack/apache2/htdocs/pmwiki/faq/gscwiki/admin/attachment.php on line 144

An error occurred while attaching the file.

Thanks

Graham
Thorsten
Posts: 15815
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Attaching Files in phpMyFAQ 2.0.7

Post by Thorsten »

Hi,

you have to disable your safe mode in PHP.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
grahamar
Posts: 8
Joined: Tue Mar 24, 2009 5:11 pm

Re: Attaching Files in phpMyFAQ 2.0.7

Post by grahamar »

Hi,

Thanks for the tip. I don't want to disable Safe Mode - as the PHP instance I have uses it for other applications.
I assume then that the attachments part won't work - unless there is a workaround.

Regards

Graham
Thorsten
Posts: 15815
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Attaching Files in phpMyFAQ 2.0.7

Post by Thorsten »

Hi,

please wait... who's the owner of the script admin/attachment.php?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
grahamar
Posts: 8
Joined: Tue Mar 24, 2009 5:11 pm

Re: Attaching Files in phpMyFAQ 2.0.7

Post by grahamar »

Hi,

It's root - as per ....

-rwxrwxrwx 1 root root 8296 Mar 25 11:05 attachment.php

Regards

Graham
Thorsten
Posts: 15815
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Attaching Files in phpMyFAQ 2.0.7

Post by Thorsten »

Hi,

that's very bad... please use another user than root for PHP scripts!

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
grahamar
Posts: 8
Joined: Tue Mar 24, 2009 5:11 pm

Re: Attaching Files in phpMyFAQ 2.0.7

Post by grahamar »

HI,

o.k. will do - it's on a single user development box at the moment - so I haven't been too careful with that. :oops:
Is changing the user/owner likely to fix this issue.?

Thanks

Graham
Thorsten
Posts: 15815
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Attaching Files in phpMyFAQ 2.0.7

Post by Thorsten »

Hi,
grahamar wrote:Is changing the user/owner likely to fix this issue.?
after changing the owner it should work...

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
grahamar
Posts: 8
Joined: Tue Mar 24, 2009 5:11 pm

Re: Attaching Files in phpMyFAQ 2.0.7

Post by grahamar »

Thanks - I 'll change it and if further problems occur I'll come back to you.
Appreciate the prompt assistance.

Graham
Post Reply