How to solve php chmod restrictins

Discussion in 'PHP' started by nikolaaa, Apr 23, 2007.

  1. #1
    I'm working on script that will use txt files instead of db.
    Problem is that I have to chmod txt every time I make it.
    On same servers there are restrictins in php for chmod command.

    Is there any solution to solve this?
    Any idea?
     
    nikolaaa, Apr 23, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Try using PHP to CHMOD it, with the error silence operator @. Then use is_writable() to check if it worked. If not, throw an error and tell the user to CHMOD it manually. Also CHMODing the directory you're working in before might help.
     
    nico_swd, Apr 23, 2007 IP
  3. nikolaaa

    nikolaaa Well-Known Member

    Messages:
    1,594
    Likes Received:
    73
    Best Answers:
    0
    Trophy Points:
    145
    #3
    yes yes. there are no solution.
    maybe to generate new php.ini with only one line that remove chmod restriction ??
     
    nikolaaa, Apr 23, 2007 IP
  4. Jim_

    Jim_ Peon

    Messages:
    72
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Have you tried the exec, system, or shell_exec commands? (ex: exec("chmod 0666 ./filename.txt");)
     
    Jim_, Apr 23, 2007 IP
  5. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #5
    Here is what you can do.

    Ask the user to create a directory in mode 777 and then you should be able to chmod files in that folder via PHP.

    Peace,
     
    Barti1987, Apr 23, 2007 IP
  6. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Jim is right you can proceed with Jim. :)
    exec ('chmod -R 777 your site document root address/filename for permission');
     
    Subikar, Apr 23, 2007 IP
  7. pepsipunk

    pepsipunk Well-Known Member

    Messages:
    208
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #7
    if you chmod the folder with the right permissions you shouldn't need to chmod the files to be able to create/write to them

    you might want to change owners (chown) to the http server's username
     
    pepsipunk, Apr 24, 2007 IP
  8. nikolaaa

    nikolaaa Well-Known Member

    Messages:
    1,594
    Likes Received:
    73
    Best Answers:
    0
    Trophy Points:
    145
    #8
    is it possible first to check is that command aloved?
    script must work on all servers.i don't want users to see errors.
     
    nikolaaa, Apr 24, 2007 IP
  9. Jim_

    Jim_ Peon

    Messages:
    72
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #9
    It depends on the security settings in php.ini. As long as safe_mode isn't enabled, it will definitely work.
     
    Jim_, Apr 24, 2007 IP