Forum


Replies: 12   Views: 7719
Problems with permissions on setup
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by msaunders  · 12-12-2012 - 09:35

I have uploaded and set up the scripts outside the main Public_html folder, all seems fine except when i try the basic example

require_once(FULL_PATH.'/app/phpdocx/classes/CreateDocx.inc');

$docx = new CreateDocx();
$docx->addText('DOCX content');
$docx->addText('End DOCX content');
$docx->createDocx(FULL_PATH.'app/word_documents/example.docx');

The FULL_PATH is the real path to my base hosting dir.

I get the following error

Warning: ZipArchive::extractTo() [ziparchive.extractto]: SAFE MODE Restriction in effect. The script whose uid is 512 is not allowed to access app/temp owned by uid 99 in app/phpdocx/classes/CreateDocx.inc on line 1091
2012-12-12 09:21:30,761 FATAL - Error while extracting the Base Template: there may be problems writing in the default tmp folder


I have made an amendment to CreateDocx.inc to specify the exact temp location:
private function getTempDir() {
/*
Marc Comented to specify temp location
if ( !function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir() {
if ($temp = getenv('TMP')) {
return $temp;
}
if ($temp = getenv('TEMP')) {
return $temp;
}
if ($temp = getenv('TMPDIR')) {
return $temp;
}
$temp = tempnam(__FILE__,'');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
return null;
}
} else {
return sys_get_temp_dir();
}
*/
return 'app/temp';
}


I have even opened that folder to permissions 777, and to differant users including nobody(apache user)

Does anyone have any ideas?

Thanks

Marc

Posted by admin  · 11-04-2013 - 12:13

Hello,

This problem:

SAFE MODE Restriction in effect. The script whose uid is 512 is not allowed to access app/temp owned by uid 99 in app/phpdocx/classes/CreateDocx.inc on line 1091

is related to safe mode option that you have in your PHP config. It's a deprecated feature that will be remove in future versions of PHP. As you can see the user uid 512 is not allowed to access temp file due to safe mode owne by user uid 99.
To solve it just desactivate safe mode in your server config and restart it or change user owner to uid 99 for all files of phpdocx.

Regards.

Posted by msaunders  · 11-04-2013 - 12:13

That was me messing around with access with some input from my forum search, once i reset the ownership it comes up with this error

Warning: ZipArchive::extractTo() [ziparchive.extractto]: Unable to access app/temp/150c855129b447/word/_rels in app/phpdocx/classes/CreateDocx.inc on line 1091
2012-12-12 09:57:38,637 FATAL - Error while extracting the Base Template: there may be problems writing in the default tmp folder


It creates the initial folder structure but will not write to it

Posted by msaunders  · 11-04-2013 - 12:13

Any thoughts please??

Posted by admin  · 11-04-2013 - 12:13

Hello,

Have you uploaded all files and folders? It seems your installation is missing of template base files that come with phpdocx pro/corporate.

Regards.

Posted by msaunders  · 11-04-2013 - 12:13

I have uploaded the complete folder including the templates, if the missing templates are the issue then maybe i can tell the script exactally where they are? and not have it rely on finding the base path then the subfolders?

Posted by msaunders  · 11-04-2013 - 12:13

Might the issue be i have uploaded the folder to a place outside the public_html area, but it is still accessable by calling the scripts?

Posted by admin  · 11-04-2013 - 12:13

Hello,

It's a good test. Please move your phpdocx folder to public_html and test one of the example. If it doesn't work try setting a global path to your temp path instead of relative.

Regards.

Posted by msaunders  · 11-04-2013 - 12:13

It still comes up with the same error, even when specifying the exact path to the temp location

Warning: ZipArchive::extractTo() [ziparchive.extractto]: Unable to access /home/extranet/app/temp/150cb558c8ffe4/word/_rels in /home/extranet/public_html/phpdocx/classes/CreateDocx.inc on line 1091
2012-12-14 16:36:28,592 FATAL - Error while extracting the Base Template: there may be problems writing in the default tmp folder

This was after having a copy in the public_html area, so it definatly is not that.

It seems to have issues writing to the created folder path, i have other scripts that use the temporary location to generate files ect, but it seems to the permisisons on the subfolders that are the issue.

Posted by admin  · 11-04-2013 - 12:13

Hello,

Please contact us (http://www.phpdocx.com/contact), we'd like to test your server if you grant us access.

Regards,

Posted by msaunders  · 11-04-2013 - 12:13

The issue with this was all based around safe mode in php, if it set to off then it works correctly, if it is on it fails with

Warning: ZipArchive::extractTo() [ziparchive.extractto]: Unable to access /home/app/temp/150fd624e22f79/word/_rels in /home/app/phpdocx/classes/CreateDocx.inc on line 1113

Posted by admin  · 11-04-2013 - 12:13

Hello,

If you have safe_mode, an option that was deprecated in PHP 5.3 and remove in PHP 5.4, you must always be aware of:

------------------------------------------------------------------------------------------------------------
Safe mode will not permit you to create new files in directories which have different owner than the owner of the script. This typically applies to /tmp, so contrary to Unix intuition, you will not be able to create new files there (even if the /tmp rights are set correctly).
------------------------------------------------------------------------------------------------------------

This is for every script, library, CMS and every other PHP application. PHPDocX is compatible with safe_mode but of course doing needed chages to temp path and files owner

Regards.