LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 on which code? Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339221 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 the code i just posted above i left out the path code to specify the directory :-\ Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339222 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 I'll try it. Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339223 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 hope it works Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339225 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 it doesn't. :\ After adding in a GET and defining $file, when you clicked delete it would say it was deleting everything, then delete nothing. And before, just (yep, you guessed it) blank Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339226 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 you put the directory and file define at the top of the code? Â paste the code Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339228 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 <?php $file = $_GET['del']; $dir = ($f_user); recursive_delete($dir); function recursive_delete( $dir ) {     if (is_dir($dir)) {      if ($dh = opendir($dir)) {        while (($file = readdir($dh)) !== false ) {             if( $file != "." && $file != ".." )             {                 if( is_dir( $dir . $file ) )                 {                     echo "Entering Directory: $dir$file<br/>";                     recursive_delete( $dir . $file . "/" );                     echo "Removing Directory: $dir$file<br/><br/>";                     rmdir( $dir . $file );                 }                 else                 {                     echo "Deleting file: $dir$file<br/>";                     unlink( $dir . $file );                 }             }        }        closedir($dh);      }     } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339229 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 wait, spotted an error, lemme try something. Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339232 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 Worked. I've got it to delete everything in the folder. Now I need to refine it :\ Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339234 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 Oh, yeah, new code:  <?php $file = $_GET['del']; $dir = ($f_user); recursive_delete($dir); function recursive_delete( $dir ) {     if (is_dir($dir)) {      if ($dh = opendir($dir)) {        while (($file = readdir($dh)) !== false ) {             if( $file != "." && $file != ".." )             {                 if( is_dir( $dir .'/'. $file ) )                 {                     echo "Entering Directory: $dir / $file<br/>";                     recursive_delete( $dir . "/" . $file);                 }                 else                 {                     echo "Deleting file: $dir / $file<br/>";                     unlink( $dir .'/'. $file );                 }             }        }        closedir($dh);      }     } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339235 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 cool glad i was able to help man  < /feels useful >  Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339236 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 It's not over yet :\ Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339238 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 alright ill be right here :-\ Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339239 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 The only thing left to do is get it to delete the one and only file. But I don't know how to go about it. Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339240 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 which file? Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339241 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 the file selected. Sign in (http://reflexprojects.net/rs/upload/secure_page.php) with user: test, passwd: test, upload a file, and try to delete it. That works. Then upload 2 files, and try to delete one. Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339242 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 it doesnt delete anything it just says deleting file.jpg but it doesnt? Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339244 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 ah screw it try this instead see if it works any better: <?php function full_rmdir($dirname)   {   if ($dirHandle = opendir($dirname))     {     $old_cwd = getcwd();     chdir($dirname);         while ($file = readdir($dirHandle))       {       if ($file == '.' || $file == '..') continue;             if (is_dir($file))         {         if (!rmdir_rf($file)) return false;         }       else         {         if (!unlink($file)) return false;         }       }         closedir($dirHandle);     chdir($old_cwd);     if (!rmdir($dirname)) return false;         return true;     }   else     {     return false;     }   } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339246 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 that removes the folder? Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339247 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 the functions claims to get rid of everything inside the folder and the folder itself Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339248 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 I don't want to get rid of the folder, and I want individual files to be deleted :\ Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339250 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 <?php $dir = the target directory $DeleteMe = if true delete also $dir, if false leave it alone function SureRemoveDir($dir, $DeleteMe) { Â Â if(!$dh = @opendir($dir)) return; Â Â while (($obj = readdir($dh))) { Â Â Â Â if($obj=='.' || $obj=='..') continue; Â Â Â Â if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true); Â Â } Â Â if ($DeleteMe){ Â Â Â Â closedir($dh); Â Â Â Â @rmdir($dir); Â Â } } //SureRemoveDir('EmptyMe', false); //SureRemoveDir('RemoveMe', true); ?> Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339251 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 how to I define deleteme? Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339252 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 if it returns true it will delete everything including the folder if false it will just delete all images. Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339254 Share on other sites More sharing options...
LemonInflux Posted September 1, 2007 Author Share Posted September 1, 2007 But I don't want it to delete the folder, and only certain files o_O Quote Link to comment https://forums.phpfreaks.com/topic/67496-_get-from-a-url/page/2/#findComment-339256 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.