Demonic Posted April 1, 2007 Share Posted April 1, 2007 <?php // copydirr.inc.php /* 26.07.2005 Author: Anton Makarenko makarenkoa at ukrpost dot net webmaster at eufimb dot edu dot ua */ function copydirr($fromDir,$toDir,$chmod=0777,$verbose=false) /* copies everything from directory $fromDir to directory $toDir and sets up files mode $chmod */ { //* Check for some errors $errors=array(); $messages=array(); if (!is_writable($toDir)) $errors[]='target '.$toDir.' is not writable'; if (!is_dir($toDir)) $errors[]='target '.$toDir.' is not a directory'; if (!is_dir($fromDir)) $errors[]='source '.$fromDir.' is not a directory'; if (!empty($errors)) { if ($verbose) foreach($errors as $err) echo '<strong>Error</strong>: '.$err.'<br />'; return false; } //*/ $exceptions=array('.','..'); //* Processing $handle=opendir($fromDir); while (false!==($item=readdir($handle))) if (!in_array($item,$exceptions)) { //* cleanup for trailing slashes in directories destinations $from=str_replace('//','/',$fromDir.'/'.$item); $to=str_replace('//','/',$toDir.'/'.$item); //*/ if (is_file($from)) { if (@copy($from,$to)) { chmod($to,$chmod); touch($to,filemtime($from)); // to track last modified time $messages[]='File copied from '.$from.' to '.$to; } else $errors[]='cannot copy file from '.$from.' to '.$to; } if (is_dir($from)) { if (@mkdir($to)) { chmod($to,$chmod); $messages[]='Directory created: '.$to; } else $errors[]='cannot create directory '.$to; copydirr($from,$to,$chmod,$verbose); } } closedir($handle); //*/ //* Output if ($verbose) { /* foreach($errors as $err) echo '<strong>Error</strong>: '.$err.'<br />'; foreach($messages as $msg) echo $msg.'<br />';*/ } //*/ return true; } /* sample usage: WARNING: if You set wrong $chmod then You'll not be able to access files and directories in destination directory. For example: once upon a time I've called the function with parameters: copydir($fromDir,$toDir,true); What happened? I've forgotten one parameter (chmod) What happened next? Those files and directories became inaccessible for me (they had mode 0001), so I had to ask sysadmin to delete them from root account Be careful :-) <?php require('./copydirr.inc.php'); copydirr('./testSRC','D:/srv/Apache2/htdocs/testDEST',0777,true); ?> */ ?> I did the following: $url = $domain; $url = str_replace("_","",$url); mkdir($url, 0777); copydirr('phpbb',$url,0777,true); //echo "<a href='http://uni-code.com/$url'>Your Forum</a>"; So now I got like 10 Directories I can delete :'( Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/ Share on other sites More sharing options...
trq Posted April 1, 2007 Share Posted April 1, 2007 Do you have a question? Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-218972 Share on other sites More sharing options...
Demonic Posted April 1, 2007 Author Share Posted April 1, 2007 O_O, Why doesn't the script allow me to delete the directories meaning when I use the script it copies but everything copied to the directory can't be deleted for some reason. [quote] 550 Could not delete common.php: Permission denied : /public_html/l337/GZ/common.php Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219156 Share on other sites More sharing options...
neel_basu Posted April 1, 2007 Share Posted April 1, 2007 What are the codes you are using to Delete Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219161 Share on other sites More sharing options...
Demonic Posted April 1, 2007 Author Share Posted April 1, 2007 Right Click in FTP Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219162 Share on other sites More sharing options...
neel_basu Posted April 1, 2007 Share Posted April 1, 2007 RIght Click Again and go to file attributes to make sure that the folder is 777 chmod ed. Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219165 Share on other sites More sharing options...
Demonic Posted April 1, 2007 Author Share Posted April 1, 2007 Yeah I tried that: 550 Could not change perms on icon_www.gif: Operation not permitted : /public_html/l337/GZ/templates/subSilver/images/lang_english/0777 icon_www.gif 550 Could not change perms on icon_search.gif: Operation not permitted : /public_html/l337/GZ/templates/subSilver/images/lang_english/0777 icon_search.gif 550 Could not change perms on icon_yim.gif: Operation not permitted : /public_html/l337/GZ/templates/subSilver/images/lang_english/0777 icon_yim.gif 550 Could not change perms on msg_newpost.gif: Operation not permitted : /public_html/l337/GZ/templates/subSilver/images/lang_english/0777 msg_newpost.gif I got the full script in the attachments [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219169 Share on other sites More sharing options...
neel_basu Posted April 1, 2007 Share Posted April 1, 2007 No No I've asked you See Whats the current Premission of those files Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219175 Share on other sites More sharing options...
Demonic Posted April 1, 2007 Author Share Posted April 1, 2007 I'm sorry, They are all Chmodded to 0777 like the script does :S. Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219179 Share on other sites More sharing options...
Demonic Posted April 1, 2007 Author Share Posted April 1, 2007 Bump. Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219384 Share on other sites More sharing options...
MadTechie Posted April 1, 2007 Share Posted April 1, 2007 erm.. 550 Could not change perms on icon_www.gif: Operation not permitted : /public_html/l337/GZ/templates/subSilver/images/lang_english/0777 icon_www.gif this looks wrong to me unless you have a file called "0777 icon_www.gif" Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219387 Share on other sites More sharing options...
Demonic Posted April 2, 2007 Author Share Posted April 2, 2007 Its just how the FTP outputs the information when trying to change permissions. It won't allow permission changes it sucks. Anyone know why I can't delete folders after using this script? Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219508 Share on other sites More sharing options...
neel_basu Posted April 2, 2007 Share Posted April 2, 2007 <?php $file_loc = 'loc/to/file.php';//Location to File that You cannot delete. $gid = filegroup($file_loc); echo "Group Id Of this File ".$gid."\n<br />"; echo "File Parameters\n<br />\n"; print_r(posix_getgrgid($gid)); ?> Tell Whats the output. Dont show the Password. Quote Link to comment https://forums.phpfreaks.com/topic/45106-directory-permissions-denied-using-this-script/#findComment-219601 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.