RE: [PHP] Please assist - been on this for hours - Permissions on server
But _why_ do you need to write to the root directory? Why not just write to a directory where you *do* have permission to write to? I can already do that. My problem is that I need to move or copy/delete the file from the place I do have permission to write to to the root. I have generated a PHP page but it is no good where it is, I need to automatically move this page and because the owner of the page is HTTPD and NoGROUP it doesn't let me. I get permission errors. I have tried chmod() and chown() the files I've written also to no avail. I'd really appreciate help because I don't know much at all about permissions, changing them or how I can automatically do this. Below is the code I have worked out up to now to generate the page. It's the part after the string which I have now tried about 60 different ways to adjust! function generate_page($formid, $pagename) { // Give the function the string to be generated including formid passed from // previous form $string = ?php \$SECTION_NAME = \goldfish_cms.php\; // include the files from output fns to get functions which design the page include ('output_fns.php'); db_connect(); \$query = \select * from goldfish_content where PageID='$formid'\; \$result = mysql_query(\$query) or die(\Error: Query failure withBR\$queryBR\.mysql_error()); while (\$array = mysql_fetch_array(\$result)) { \$HeadTitle = \\{\$array[\HeadTitle\]}\; \$PageTitle = \\{\$array[\Title\]}\; \$BodyText = \\{\$array[\BodyText\]}\; \$Picture1 = \\{\$array[\PictureOne\]}\; \$Picture2 = \\{\$array[\PictureTwo\]}\; \$CatID = \\{\$array[\CatID\]}\; } // carry the variable head title in the page and do the page header do_html_header(\$HeadTitle); // carry variables into do_html_index() function in output_fns. // Page title = The headline of the page // Body text = The text body, can include html commands. // Picture 1 = picture or graphic that appears above the title if required. // Picture 2 = Picture that appears right hand side on the basic output_fns // CatID = Category which is used for determining which links appear on each page // Section name = Allows you to specify extra functions to output_fns.php to be unique to the page (requires hard coding) do_html_index(\$PageTitle, \$BodyText, \$Picture1, \$Picture2, \$CatID, \$SECTION_NAME); // put the page footer in position do_html_footer(); ?; // Define the filename to write to. $filename = 'test.txt'; // Open the file for overwriting. $fp = fopen($filename, w); // Write the string to the file $write = fputs($fp, $string); // Close the file fclose($fp); // copy the page as a php file $fp2 = fopen($filename, r); $root = /home/root/; copy($filename, $root); // rename the filename in the root directory to the pagename rename($filename, $pagename.php); fclose($fp2); // end of function. } // call the functions. generate_page($formid, $pagename); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Please assist - been on this for hours - Permissions on server
On Thursday 10 July 2003 21:04, Steve Jackson wrote: But _why_ do you need to write to the root directory? Why not just write to a directory where you *do* have permission to write to? I can already do that. My problem is that I need to move or copy/delete the file from the place I do have permission to write to to the root. I have generated a PHP page but it is no good where it is, I need to automatically move this page and because the owner of the page is HTTPD and NoGROUP it doesn't let me. I get permission errors. I have tried chmod() and chown() the files I've written also to no avail. I'd really appreciate help because I don't know much at all about permissions, changing them or how I can automatically do this. The root of the problem (pun intended) is that you're trying to write to the root (/) directory which is usually only possible if you're the root user. Again, the question is _why_ do you need to write to the root directory? Wouldn't your file function if it wasn't in the root directory? Without the system admin giving the required permissions what you're trying to do ought to be impossible (well, you might be able to find an exploit on the system that you can exploit). -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Horngren's Observation: Among economists, the real world is often a special case. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Please assist - been on this for hours - Permissions on server
The root of the problem (pun intended) Oh dear! ;o) is that you're trying to write to the root (/) directory which is usually only possible if you're the root user. Again, the question is _why_ do you need to write to the root directory? Wouldn't your file function if it wasn't in the root directory? I don't particularly need to *write* to the root directory. I do need to move the file to the root directory though as it's part of a CMS system. I can write the file to a directory which is adequately protected, but there has to be a way to move the file after it is written (to the root from said protected directory). The file is designed to be generated by another user. There are easier ways to design a CMS system I realise but this is my goal, to allow a user to simply generate a file which then is placed in the webroot after it has been written. I thought that this would be the easy part. Any more ideas? Thanks for your help Jason I appreciate it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Please assist - been on this for hours - Permissions on server
On Tue, 2003-07-08 at 07:21, Steve Jackson wrote: If I set permissions of my server root to chmod 777 that's a security risk right? How do I set my server to allow me to write a file to my web root from another directory using PHP? Or is it a Unix problem? I have a generator file writes a string to a text file and then renames the text file as a PHP file however it occurred to me while I was doing this that chmod 777 the root might not be a good idea. Anyone have a simple fix or idea for this? Change the ownership on the directory to whichever user apache is running as (this is the User directive in your httpd.conf file). Then you can restrict the permissions on that directory. You could probably make it 600 if you want. Can this be done automatically with PHP? I want a file to be written to the root directory by PHP and not have to get the web server admin to change ownership privaleges on the root. Basically does anyone know how to get PHP to see what the server name and group is and then assign the writing rights to the script? This will allow me to generate a file on the fly. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Please assist - been on this for hours - Permissions on server
On Wednesday 09 July 2003 19:29, Steve Jackson wrote: Change the ownership on the directory to whichever user apache is running as (this is the User directive in your httpd.conf file). Then you can restrict the permissions on that directory. You could probably make it 600 if you want. Can this be done automatically with PHP? I want a file to be written to the root directory by PHP and not have to get the web server admin to change ownership privaleges on the root. Think about it, permissions are there for a reason -- to prevent users from doing what they shouldn't be doing. Basically does anyone know how to get PHP to see what the server name and group is and then assign the writing rights to the script? Run the script as root. Not recommended, unless you know what you're doing. This will allow me to generate a file on the fly. But _why_ do you need to write to the root directory? Why not just write to a directory where you *do* have permission to write to? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The University of California Statistics Department; where mean is normal, and deviation standard. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php