Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] sKat Problem
Lethys
post
Post #1





Grupa: Zarejestrowani
Postów: 642
Pomógł: 2
Dołączył: 9.03.2006

Ostrzeżenie: (30%)
XX---


Mam problem , potrzebuje skryptu ktory bedzie kasowal obrazki z folderu sygnaturki starsze niz 2h.

Moj skrypt to :

  1. <?php
  2. $sKat = 'sygnaturki/'; // katalog
  3. $struct = readdir( $sKat );
  4.  
  5. while ( false !== ( $sFile = readdir( $struct ) ) ) 
  6. {
  7. if( ( time() - filemtime( $sFile ) ) > 3600 * 24 * 2 )
  8. {
  9. // .. usuwanie
  10. if( !unlink( $sFile ) )
  11. {
  12. exit( 'Błąd');
  13. }
  14. }
  15. }
  16. ?>


Powinno wszystko dzialac ale jak wpisze w wyszukiwarce namiary na ten plik to skrypt nie dziala i wyskakuje blad ze nie ma takiego katalogu (IMG:http://forum.php.pl/style_emoticons/default/blink.gif) A napewno jest .

Cytat
Warning: readdir(): supplied argument is not a valid Directory resource in /var/www/sites/yoyo.pl/d/o/domena/reset.php on line 3

Warning: readdir(): supplied argument is not a valid Directory resource in /var/www/sites/yoyo.pl/d/o/domena/reset.php on line 5
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Lethys
post
Post #2





Grupa: Zarejestrowani
Postów: 642
Pomógł: 2
Dołączył: 9.03.2006

Ostrzeżenie: (30%)
XX---


Cytat(mike_mech @ 2006-04-07 21:31:28)
  1. <?php
  2.  
  3. $sKat = 'sygnaturki/';
  4. $struct = opendir( $sKat );
  5.  
  6. while ( false !== ( $sFile = readdir( $struct ) ) )
  7. {
  8. if( ( $sFile != '.' && $sFile != '..' ) && ( time() - filemtime( $sKat . '/' . $sFile ) ) > 3600 * 24 * 2 )
  9. {
  10. if( ! unlink( $sKat . '/' . $sFile ) )
  11. {
  12. echo 'Nie można usunąć: ' . $sKat . '/' . $sFile . '<br />';
  13. }
  14. else
  15. {
  16. echo 'Usunięto: ' . $sKat . '/' . $sFile . '<br />';
  17. }
  18. }
  19. }
  20.  
  21. ?>

:?:

Wielkie Thx (IMG:http://forum.php.pl/style_emoticons/default/guitar.gif) Teraz chodzi (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) co prawda nie sprawdza daty i usuwa wszystko z tego katalogu ale ustawie sobie cronjobsa i bedzie git (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
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: 6.10.2025 - 14:49