Beispiel #1
0
 /**
  * process new uploads, if any
  *
  * This function checks the input queue, and process new files on their arrival.
  *
  * This function is aiming to run silently, therefore errors are logged in a file.
  *
  * @return a string to be displayed in resulting page, if any
  *
  */
 public static function tick_hook()
 {
     global $context;
     // useless if we don't have a valid database connection
     if (!$context['connection']) {
         return;
     }
     // remember start time
     $stamp = get_micro_time();
     // process handx weblog entries, if any
     $count = 0;
     if (($files = Uploads::list_files('inbox/entries')) && @count($files) > 0) {
         foreach ($files as $file) {
             // help the webmaster
             Logger::remember('agents/upload.php: processing ' . $file);
             // create articles
             Uploads::process_handx_weblog($file);
             // no more than 10 entries per tick
             $count += 1;
             if ($count >= 10) {
                 break;
             }
         }
         // remember tick date
         include_once $context['path_to_root'] . 'shared/values.php';
         Values::set('uploads.tick.entries', $count);
     }
     // rebuild index pages
     if ($count) {
         Cache::clear();
     }
     // compute execution time
     $time = round(get_micro_time() - $stamp, 2);
     // report on work achieved
     if ($count > 1) {
         return 'agents/uploads.php: ' . $count . ' files have been processed (' . $time . " seconds)" . BR;
     } elseif ($count == 1) {
         return 'agents/uploads.php: 1 file has been processed (' . $time . " seconds)" . BR;
     } else {
         return 'agents/uploads.php: nothing to do (' . $time . " seconds)" . BR;
     }
 }