Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2.  
  3. use Illuminate\Console\Command;
  4. use Symfony\Component\Console\Input\InputOption;
  5. use Symfony\Component\Console\Input\InputArgument;
  6.  
  7. class CleanDirs extends Command {
  8.  
  9. protected $name = 'cleandirs';
  10.  
  11. protected $description = 'Cleans directories.';
  12.  
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17.  
  18. public function fire()
  19. {
  20. $now = time();
  21. foreach(File::directories('public/uploads/temp') as $dir ){
  22. $dirtime = filemtime($dir);
  23.  
  24. if( $now-$dirtime > 3600){
  25. File::deleteDirectory($dir);
  26. $this->info('Directory '.$dir.' was deleted');
  27. }
  28. }
  29. }
  30.  
  31. protected function getArguments()
  32. {
  33. return array(
  34. array('example', InputArgument::OPTIONAL, 'An example argument.'),
  35. );
  36. }
  37.  
  38. protected function getOptions()
  39. {
  40. return array(
  41. array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
  42. );
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement