PHP chmod scripts?

Discussion in 'PHP' started by Adulu, Apr 25, 2009.

  1. #1
    Any php chmod scripts?
    it can chmod all entire directory include subdirectories with files anything.

    thank you
     
    Adulu, Apr 25, 2009 IP
  2. gummyworms

    gummyworms Active Member

    Messages:
    126
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    For single file

    <?php
    // Read and write for owner, nothing for everybody else
    chmod("test.txt",0600);
    
    // Read and write for owner, read for everybody else
    chmod("test.txt",0644);
    
    // Everything for owner, read and execute for everybody else
    chmod("test.txt",0755);
    
    // Everything for owner, read for owner's group
    chmod("test.txt",0740);
    ?> 
    PHP:
    For entire directory

    try
    $cm = chmod($curDir,0777);
    PHP:
    same principle as the files I believe
     
    gummyworms, Apr 25, 2009 IP
  3. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Errors
    host not allowed?
    i using it in shared hosting
     
    Adulu, Apr 25, 2009 IP
  4. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #4
    Yes your host doesnt allow use ftp to do it instead or cpanel
     
    Bohra, Apr 25, 2009 IP
  5. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Cpanel is too slow and it's only for chmod each directory.
    FTP have 1998 files limit that can't chmod all.
    :(
     
    Adulu, Apr 26, 2009 IP
  6. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #6
    Last option is too ask your host
     
    Bohra, Apr 26, 2009 IP
  7. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #7
    or use SSH if you have that enabled...
     
    mfscripts, Apr 26, 2009 IP
  8. oarcadescript

    oarcadescript Peon

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    many FTP clients have bulk CHMOD change, certainly cyberduck for mac does. get a new FTP client=]
     
    oarcadescript, Apr 26, 2009 IP
  9. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ask host? this is cheap hosting plan so don't expect him, i have ask else support but didn't get solve.

    SSH not allowed
    FTP have 1998 files limit and chmod very slowly
     
    Adulu, Apr 26, 2009 IP
  10. octalsystems

    octalsystems Well-Known Member

    Messages:
    352
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #10
    just use

    exec("chmod <$permission> <$folder> -R");
     
    octalsystems, Apr 26, 2009 IP
  11. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Warning: exec() has been disabled for security reasons
     
    Adulu, Apr 26, 2009 IP
  12. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #12
    Unfotunately ftp is the best option for you
     
    Bohra, Apr 26, 2009 IP
  13. Adulu

    Adulu Peon

    Messages:
    2,791
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Yes, Surrender

    thanks for everyone's helps.
     
    Adulu, Apr 26, 2009 IP
  14. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #14
    The error message you got (open basedir restriction) does NOT mean that chmod isn't allowed on your server. I don't know why people are telling you that.

    It means you are trying to chmod a file or directory which is outside of your allowed area. You should check the path you are providing to the chmod() function and make sure it is correct.
     
    SmallPotatoes, Apr 26, 2009 IP
  15. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #15
    this right about open base dir :)

    u must ask host admin to open this security set just for your account ...

    if all efforts failed.. maybe u need to move to new host..

    regards
     
    ghprod, Apr 27, 2009 IP