Пример #1
0
 /**
  * garbage collector. remove from session entries older than 30 minutes;
  * @return string
  * @access public
  */
 function garbageCollector()
 {
     // cleanup orphan folders
     $arr = explode('/', $this->baseFolder . $this->folder);
     if (substr($this->folder, -1, 1) == '/' || substr($this->folder, -1, 1) == '\\') {
         array_pop($arr);
     }
     $new = array_pop($arr);
     $f = implode('/', $arr) . '/';
     $fld = new KT_folder();
     $arr = $fld->readFolder($f, false);
     //print_r($arr);
     if (isset($arr['folders']) && count($arr['folders'])) {
         foreach ($arr['folders'] as $entry) {
             if (preg_match("/^(.*)\\w{14}_\\w{8}(.*)/is", $entry['name'])) {
                 $fld = new KT_folder();
                 $files = $fld->readFolder($f . $entry['name']);
                 if (isset($files['files']) && count($files['files']) > 0) {
                     foreach ($files['files'] as $file) {
                         if (filectime($f . $entry['name'] . '/' . $file['name']) < time() - 60 * 30) {
                             $fld->deleteFolderNR($f . $entry['name']);
                             break;
                         }
                     }
                 } else {
                     $fld->deleteFolderNR($f . $entry['name']);
                 }
             }
         }
     }
     if (!isset($_SESSION['tng_upload'])) {
         return;
     }
     // clear old session values;
     foreach ($_SESSION['tng_upload'] as $id => $hash) {
         if (isset($hash['properties']) && $hash['properties']['time'] < time() - 60 * 30) {
             unset($_SESSION['tng_upload'][$id]);
         }
     }
 }