Example #1
0
function loadSerializedCommandListFromCache()
{
    $path = getCacheDir() . '/command-list.ser';
    if (!file_exists($path)) {
        return [];
    }
    $command_list = unserialize(file_get_contents($path));
    return $command_list;
}
Example #2
0
  public function generateOutput() {
   $xls = $this->loadXls(getCacheDir()."template.xls");
   $colCount = PHPExcel_Cell::columnIndexFromString($xls->getHighestColumn());
   $rowCount = $xls->getHighestRow();
   
//   echo ("Cols: ".$colCount.", rows: ".$rowCount.".<br>");
   
   $IDs = getFromCache('ids');
   
   $filename        = getCacheDir()."result.xls";
   $filename_client = getrootdir().getCacheSubdir()."result.xls";
   
   $output = new PHPExcel;                               // Create new PHPExcel object
   $output->getProperties()->setCreator("CF")
          ->setLastModifiedBy("CF")
          ->setTitle("Office 2007 XLS Test Document")
          ->setSubject("Office 2007 XLS Test Document")
          ->setDescription("Test document for Office 2007 XLS, generated using PHP classes.")
          ->setKeywords("CF")
          ->setCategory("Test result file");
   
   $i = 0;
   $n = 1;
   
   $srcrow = array();
   
   for ($col=0; $col<$colCount; $col++) {
    $output->setActiveSheetIndex(0)->setCellValueByColumnAndRow($col, 1, $xls->getCellByColumnAndRow($col,1)->getValue());
    $srcrow[] = $xls->getCellByColumnAndRow($col,2)->getValue();
   }
   
   $colnames = getColNames();
   
   $i=2;
   
   foreach ($IDs as $id) {
    $col=0;
    
    $thisrecord = $this->cache[(string)$id];
    
    foreach ($srcrow as $c) {
     if ((substr($c,0,1)=="%") && (substr($c,strlen($c)-1,1)=="%")) {
      $colname = substr($c,1,strlen($c)-2);
      $buf = $thisrecord->$colname;
     } else {
      $buf = $c;
     }
     
     $output->setActiveSheetIndex(0)->setCellValueByColumnAndRow($col, $i, $buf);
     $col++;
    }
    
    $i++;
   }
   
   $objWriter = PHPExcel_IOFactory::createWriter($output, 'Excel5');
   $objWriter->save($filename);
   
   return ($filename_client);
   
  }
Example #3
0
/**
* One Line Description
*
* @command pestle_clear_cache
*/
function pestle_cli($argv)
{
    $cache_dir = getCacheDir();
    rename($cache_dir, $cache_dir . '.' . time());
    getCacheDir();
}
Example #4
0
/**
 * Combine files
 *
 * @param array $files
 * @param string $prefix
 * @param string $ext
 * @return string
 */
function combineFiles(array $files, $prefix, $ext)
{
    $baseDir = getBaseDir($prefix) . '/';
    $cacheDir = getCacheDir();
    $filesKey = md5(serialize($files)) . '.' . $ext;
    $noCache = empty($_GET['nocache']) ? false : true;
    if (!$noCache && file_exists($cacheDir . $filesKey) && filemtime($cacheDir . $filesKey) + getRefreshTime() > time()) {
        $allData = file_get_contents($cacheDir . $filesKey);
    } else {
        $allData = '';
        foreach ($files as $file) {
            if (!file_exists($baseDir . $file)) {
                continue;
            }
            $data = file_get_contents($baseDir . $file);
            if ($ext == 'css') {
                $data = translateUrlInCss($data, $file, $prefix);
            }
            if ($allData) {
                $allData .= "\n\n";
            }
            $allData .= $data;
        }
        if ($ext == 'css') {
            $allData = minifyCss($allData);
        } else {
            $allData = minifyJs($allData);
        }
        if (!$noCache) {
            file_put_contents($cacheDir . $filesKey, $allData);
        }
    }
    echo $allData;
}
Example #5
0
function cacheCommandList($lookup)
{
    $cache_dir = getCacheDir();
    file_put_contents($cache_dir . '/command-list.ser', serialize($lookup));
}
Example #6
0
 function eraseCacheSecure($id) {
  $path = getCacheDir();
  @mkdirr ($path);
  return unlink($path.$id."&".session_id().".dat");
 }