Example #1
0
 public function Process($iTimeLimit)
 {
     $sDateLimit = date('Y-m-d H:i:s', time() - 24 * 3600);
     // Every BulkExportResult older than one day will be deleted
     $sOQL = "SELECT BulkExportResult WHERE created < '{$sDateLimit}'";
     $iProcessed = 0;
     while (time() < $iTimeLimit) {
         // Next one ?
         $oSet = new CMDBObjectSet(DBObjectSearch::FromOQL($sOQL), array('created' => true), array(), null, 1);
         $oSet->OptimizeColumnLoad(array('temp_file_path'));
         $oResult = $oSet->Fetch();
         if (is_null($oResult)) {
             // Nothing to be done
             break;
         }
         $iProcessed++;
         @unlink($oResult->Get('temp_file_path'));
         $oResult->DBDelete();
     }
     return "Cleaned {$iProcessed} old export results(s).";
 }
Example #2
0
         }
     }
 }
 // Read query parameters
 //
 $aArgs = array();
 foreach ($oFilter->GetQueryParams() as $sParam => $foo) {
     $value = utils::ReadParam('arg_' . $sParam, null, true, 'raw_data');
     if (!is_null($value)) {
         $aArgs[$sParam] = $value;
     }
 }
 $oFilter->SetInternalParams($aArgs);
 if ($oFilter) {
     $oSet = new CMDBObjectSet($oFilter, array(), $aArgs);
     $oSet->OptimizeColumnLoad($aAliasToFields);
     switch ($sFormat) {
         case 'html':
             $oP = new NiceWebPage("iTop - Export");
             $oP->add_style('body { overflow: auto; }');
             // Show scroll bars if needed
             // Integration within MS-Excel web queries + HTTPS + IIS:
             // MS-IIS set these header values with no-cache... while Excel fails to do the job if using HTTPS
             // Then the fix is to force the reset of header values Pragma and Cache-control
             header("Pragma:", true);
             header("Cache-control:", true);
             // The HTML output is made for pages located in the /pages/ folder
             // since this page is in a different folder, let's adjust the HTML 'base' attribute
             // to make the relative hyperlinks in the page work
             $sUrl = utils::GetAbsoluteUrlAppRoot();
             $oP->set_base($sUrl . 'pages/');