Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] Kasowanie wszystkich plików w katalogu
s3o
post 7.12.2007, 23:02:35
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 1.03.2007

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


Witam,

jak "masowo" skasować wszystkie pliki w danym katalogu bez konieczności usuwania plików pojedynczo?


pozdrawiam
Michał
Go to the top of the page
+Quote Post
marcio
post 7.12.2007, 23:05:54
Post #2





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


usun katalog i potem zrob go na nowo


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
Go to the top of the page
+Quote Post
s3o
post 7.12.2007, 23:17:52
Post #3





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 1.03.2007

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


Cytat(marcio @ 7.12.2007, 23:05:54 ) *
usun katalog i potem zrob go na nowo


ale w tym katalogu mam kilka podkatalogów a w tych podkatalogach pliki, których usunąć nie mogę
jak to zrobić inaczej?
Go to the top of the page
+Quote Post
marcio
post 7.12.2007, 23:25:49
Post #4





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


oj troszke dlugie do napisania podam kawalek kodu od kolegi mam nadzieje ze nie bedzie na mnie zly ale to jest na klasach wiec potem to sobie przerob:
kawalek kodu z klasy DIR
  1. <?php
  2. function get_file_to_edit()
  3.  {
  4. global $DIR;
  5. $this -> path = $DIR;
  6. $select = '<div id="term" style="border-top:none;"><form method="POST">
  7. <input type="hidden" name="file" value="none"/>
  8. <table cellspacing="0"><tr><td>
  9. <input type="text" name="dir" class="iterm" value="'.$this -> path.'"/>
  10. <input type="submit" name="opt" value="idz" class="submit"/></td></tr><tr><td>
  11. <select name="file" calss="option">';
  12. $d = @opendir($this -> path);
  13.  
  14. while($file = @readdir($d))
  15. {
  16.  if($file != '.' && $file != '..' && substr($this -> get_mod($this -> path.'/'.$file), 0, 1) != 'd')
  17.  $select .= '<option class="option" value="'.$this -> path.'/'.$file.'">'.$file.'</option>';
  18. }
  19.  
  20. $select .= '</select> 
  21. <input type="submit" value="edytuj" name="opt" class="submit"/> 
  22. <input type="submit" value="kasuj" name="opt" class="submit"/> 
  23. <input type="submit" value="pobierz" name="opt" class="submit"/>
  24. </td></tr></table>
  25. </form></div>';
  26.  
  27. return $select;
  28.  }
  29.  
  30. function list_dir()
  31.  {
  32. if(!$this -> safemode)
  33. return shell_exec("ls -lia " . $this -> path);
  34. $tolist = (substr($this -> path, -1) == '/') ? $this->path . '*' : $this->path . '/*';
  35. $all = @glob($tolist);
  36. $list = "";
  37.  
  38. foreach($all as $file)
  39. {
  40.  list ($dev, $inode, $inodep, $nlink, $uid, $gid, $inodev, $size, $atime, $mtime, $ctime, $bsize) = stat($file);
  41.  $owner = @posix_getpwuid($uid);
  42.  $grgid = @posix_getgrgid($gid);
  43.  $list .= $inode." ".$this->get_mod($file)." ".$nlink." ".$owner['name']." ".
  44.  $grgid['name']." ".$size." ".date("d.m.Y H:i ",$mtime)." ".substr($file, strrpos($file, '/')+1)."\n";
  45. }
  46.  
  47. return $list;
  48.  }
  49. ?>

i potem funckje z klasy
  1. <?php
  2. function edit_file($new_content = null)
  3.  {
  4. if(empty($new_content))
  5. {
  6.  if($this -> file_read_mode)
  7.  {
  8. $file_box = @fread(@fopen($this -> file_name, "r"), filesize($this -> file_name));
  9. $ta = array("<textarea>" => "<73x74r34>", "</textarea>" => "</73x74r34>");
  10. $out = '<div id="term"><p class="head">Plik: '.$this -> file_name.'</p><form method="POST">
  11. <input type="hidden" name="DIRECT" value="'.getcwd().'"/>
  12. <input type="hidden" name="opt" value="save"/>
  13. <input type="hidden" name="file" value="'.$this -> file_name.'"/>
  14. <textarea name="new_content" class="termout">'.strtr($file_box, $ta).'</textarea><br>';
  15.  
  16. if($this -> file_write_mode)
  17. $out .= '<input type="submit" class="submit" value="Zapisz"/></form></div><br><br>';
  18.  
  19. else $out .= '</form><b style="color:#f00">Brak uprawnien do zapisu pliku '.$this -> file_name.'</b></div><br><br>';
  20.  
  21. return $out;
  22.  }
  23.  
  24.  else return " ";
  25. }
  26.  
  27. function delete_file()
  28.  {
  29. if($this -> file_write_mode)
  30. {
  31.  if(@unlink($this -> file_name))
  32.  return '<b style="color:#0f0">Skasowano '.$this -> file_name.'</b><br><br>';
  33.  
  34.  else if(@chmod($this -> file_name, 0777))
  35.  {
  36. if(@unlink($this -> file_name))
  37. return '<b style="color:#0f0">Skasowano '.$this -> file_name.'</b><br><br>';
  38.  }
  39. }
  40.  
  41. return '<b style="color:#f00">Nie mozna skasowac'.$this -> file_name.'<br>Brak uprawnien</b><br><br>';
  42.  }
  43. ?>

chyba o to chodzi?questionmark.gif


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
Go to the top of the page
+Quote Post
s3o
post 7.12.2007, 23:40:35
Post #5





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 1.03.2007

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


dzięki za pomoc, wydaje mi się że po przerobieniu będzie ok
pozdrawiam
Go to the top of the page
+Quote Post
marcio
post 8.12.2007, 01:04:17
Post #6





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


nie ma za co ale jak juz przerobisz i bedzie chodzic rzuc kodem na pw


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 13.08.2025 - 23:01