944,050 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 394
  • PHP RSS
Oct 24th, 2009
0

why isnt this working?

Expand Post »
PHP Syntax (Toggle Plain Text)
  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!!!!!!
Similar Threads
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009
Oct 24th, 2009
1
Re: why isnt this working?
Try adding the following line to your script, anywhere after the line $dir = $documentroot . '/' . $username; but not inside the function:
php Syntax (Toggle Plain Text)
  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.
Reputation Points: 395
Solved Threads: 192
Veteran Poster
darkagn is offline Offline
1,136 posts
since Aug 2007
Oct 24th, 2009
0
Re: why isnt this working?
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!
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Automatically create pages from files in directory
Next Thread in PHP Forum Timeline: block js injections through php





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC