why isnt this working?

Thread Solved

Join Date: Apr 2009
Posts: 281
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training

why isnt this working?

 
0
  #1
Oct 24th, 2009
  1. <?php
  2. $documentroot = $_SERVER['DOCUMENT_ROOT'];
  3.  
  4. $username = "Administrator";
  5. $dir = $documentroot . '/' . $username;
  6. function rmdir_r ( $dir, $DeleteMe = TRUE )
  7. {
  8. if ( ! $dh = @opendir ( $dir ) ) return;
  9. while ( false !== ( $obj = readdir ( $dh ) ) )
  10. {
  11. if ( $obj == '.' || $obj == '..') continue;
  12. if ( ! @unlink ( $dir . '/' . $obj ) ) rmdir_r ( $dir . '/' . $obj, true );
  13. }
  14.  
  15. closedir ( $dh );
  16. if ( $DeleteMe )
  17. {
  18. @rmdir ( $dir );
  19. }
  20. }
  21. ?>

it supposed to delete all files int eh directory and delete tehd riectory but its not doing anything!!!!!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 793
Reputation: darkagn has a spectacular aura about darkagn has a spectacular aura about darkagn has a spectacular aura about 
Solved Threads: 109
darkagn's Avatar
darkagn darkagn is offline Offline
Master Poster
 
1
  #2
Oct 24th, 2009
Try adding the following line to your script, anywhere after the line $dir = $documentroot . '/' . $username; but not inside the function:
  1. rmdir_r($dir);
Basically, the code inside the function doesn't execute until the function is called.
Last edited by darkagn; Oct 24th, 2009 at 9:43 am.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 281
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training
 
0
  #3
Oct 24th, 2009
am maa gawwd! thanks so much. i dont really use functions so i was confised by the whole thing! thanks now i can continue my site!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC