Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Editing Pages CHMOD!!!

    Hi,

    I'm having trouble with a script I have made to edit files on my website.

    I was wondering if anybody could help me becaus eit has stopped working.

    This is what I have:
    <?
    $page = stripslashes($_POST['page']);
    $content = stripslashes($_POST['content']);
    $return = stripslashes($_POST['return']);
    $done = "temp_edit.php";
    $fp = fopen($page,"w+") or die ("Error opening file in write mode!");
    $fd = fopen($done,"w+") or die ("Error opening file in write mode!");
    fputs($fp, $content);
    fputs($fd, $return);
    fclose($fp) or die ("Error closing fp!");
    fclose($fd) or die ("Error closing fd!");
    echo"<html><meta http-equiv=\"refresh\" content=\"0; url=editpage.go.php\"></html>";
    ?>


    The only problem is it doesn't open the files. I have this script in the root of the web so it can edit all files in public_html.

    I have been trying many different alternatives but have had no luck.

    The chmod on all the files intended to be edited is 775 but it still doesn't open. It only works when its 777 but I can't use that because anybody could change it.

    Does anybody see what i have done wrong or missed?

    thanks,

    Nick

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    if you want the permissions to be 755 (owner=read/write/execute, group=read/execute,other=read/execute) then the file needs to be owned by the same user that the web-server is running as, which could be anything depending on your server (www-data, www, nobody, apache are some common default apache usernames...). You can either chown the file so as to be owned by this user, if you have root access, or write some php-code that will create the files and run it from your browser.
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    PHP has the chown()/chmod() functions as well that you can use to manipulate the permissions if the file is owned by the webserver's user.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •