Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] wywalanie katalogów z serwera
byczek
post
Post #1





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 23.02.2004

Ostrzeżenie: (0%)
-----


Witam mam taki oto kod do usówania userów z bazy ale problem w tym ze na serwerze zostaje katalog usera .Katalog nosi nazwe tak jak login danego usera co dopisac do tego kawałka tak aby i katalog poleciał (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

oto moj kod

  1. <?php
  2. function usun_usera($id) {
  3. $r = mysql_fetch_assoc( mysql_query("SELECT login FROM owners WHERE id='{$id}'") );
  4. $login = $r['login'];
  5. @mysql_query("DELETE FROM owners WHERE id='{$id}'");
  6. if( file_exists('users/'.$login.'/') ) {
  7.  @unlink('users/'.$login.'/');
  8.  @exec('rm -rf /users/'.$login.'/');
  9.  
  10. }
  11. $this->_usun_users_form();
  12.  }
  13.  }
  14. ?>


Aha dodam ze na serwerze jest katalog danego usera a w nim są jeszcze dwa katalogi i kilka plików (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
eai
post
Post #2





Grupa: Zarejestrowani
Postów: 367
Pomógł: 10
Dołączył: 20.05.2005

Ostrzeżenie: (0%)
-----


Jak wszyscy to i ja wrzuce swój kod:
  1. <?php
  2. function DeleteFromDirectory ($Dir)
  3. {
  4. $items = scandir($Dir);
  5.  
  6. if (!empty($items))
  7. {
  8. foreach($items as $file)
  9. {
  10. if(!is_dir($Dir . '/' . $file) && is_file($Dir . '/' .$file))
  11. {
  12.  unlink($Dir . '/' . $file);
  13. }
  14. if(is_dir($Dir . '/' . $file) && !is_file($Dir . '/' .$file))
  15. {
  16.  DeleteFromDirectory ($Dir . '/' . $file);
  17. }
  18. }
  19. }
  20. rmdir($Dir);
  21.  
  22. }
  23. ?>


Ten post edytował eai 8.06.2007, 23:53:37
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 9.10.2025 - 18:25