Exemple #1
0
 public function __construct($classDirectory = null)
 {
     parent::__construct();
     $this->classesDir = $classDirectory;
     $this->locatorFile = PHPExt::getTempDir() . '/ClassLocator' . md5(var_export($classDirectory, true)) . '.ser';
     self::$log->trace("Locator File: {$this->locatorFile}");
 }
Exemple #2
0
 public static function output($table, $name = '')
 {
     error_reporting(0);
     if (!is_object($table) && !is_array($table)) {
         exit;
     }
     if ($name == '') {
         $name = 'output' . Invocation::next();
     }
     if (!preg_match('/^.*\\.xls$/i', $name)) {
         $name .= '.xls';
     }
     $fileName = PHPExt::getTempDir() . '/' . $name;
     $workbook = new Spreadsheet_Excel_Writer($fileName);
     $worksheet =& $workbook->addWorksheet(basename($name));
     $rowIdx = 0;
     if ($table instanceof DBTable || is_array($table)) {
         foreach ($table as $row) {
             if ($rowIdx == 0) {
                 foreach (array_keys($row) as $col => $heading) {
                     $worksheet->write($rowIdx, $col, $heading);
                 }
                 $rowIdx++;
             }
             foreach (array_values($row) as $col => $val) {
                 $worksheet->write($rowIdx, $col, $val);
             }
             $rowIdx++;
         }
     } else {
         if ($table instanceof PDOStatement) {
             while ($row = $table->fetch(DB::FETCH_ASSOC)) {
                 if ($rowIdx == 0) {
                     foreach (array_keys($row) as $col => $heading) {
                         $worksheet->write($rowIdx, $col, $heading);
                     }
                     $rowIdx++;
                 }
                 foreach (array_values($row) as $col => $val) {
                     $worksheet->write($rowIdx, $col, $val);
                 }
                 $rowIdx++;
             }
         }
     }
     $workbook->close();
     $workbook->send($name);
     $fp = fopen($fileName, 'rb');
     fpassthru($fp);
     fclose($fp);
     unlink($fileName);
     exit;
 }
Exemple #3
0
 public function fileChecksumRebase()
 {
     DB::exec(DB::DEF, 'TRUNCATE tblFileCheck');
     $dirList = PHPExt::dirSearch(Cfg::get('site_path'), '/^[^_].*$/');
     $len = strlen(Cfg::get('site_path')) + 1;
     $fileCount = 0;
     foreach ($dirList as $fullPath) {
         $fileCount++;
         DB::exec(DB::DEF, 'INSERT INTO tblFileCheck VALUES(?,?,?,?)', [DBMaintenance::dbNextNumber(DB::DEF, 'tblFileCheck'), substr($fullPath, $len), filesize($fullPath), sha1_file($fullPath)]);
     }
     return "Updated {$fileCount} files<br/>" . $this->fileChecksum();
 }
Exemple #4
0
 /**
  * Converts the passed array to the necessary for prepared statement.
  *
  * If the array is associative then
  * it creates a :x,:y style string. If the array is numeric then creates a string with ? eg:
  * <pre>
  * $arr = array ( 'domain' => 0, 'length' => 1, 'tld' => 5, 'pricescore' => 2, 'intprice' => 4 );
  * $params = array ( 'foo' => 'dummy1', 'bar' => 'dummy2' );
  * echo 'INSERT INTO domain_info VALUES(' . DB::in ( $arr, $params ) . ')<br>';
  * echo '<pre>'; print_r ( $params ); echo '</pre>';
  *
  * $arr = array_values ( $arr );
  * $params = array ( 'dummy1', 'dummy2' );
  * echo 'INSERT INTO domain_info VALUES(' . DB::in ( $arr, $params ) . ')<br>';
  * echo '<pre>'; print_r ( $params ); echo '</pre>';
  * </pre>
  * @param mixed $values  Values that will be in the IN.
  * @param mixed &$params Adds to the parameters.
  *
  * @since 1.0
  * @return string
  */
 public static function in($values, &$params = null)
 {
     if (!is_array($params)) {
         $params = [];
     }
     if (PHPExt::is_assoc($values)) {
         foreach ($values as $key => $val) {
             $params[$key] = $val;
         }
         return ':' . join(',:', array_keys($values));
     } else {
         if (!is_array($values)) {
             $values = [$values];
         }
         foreach ($values as $val) {
             $params[] = $val;
         }
         return join(',', array_fill(0, count($values), '?'));
     }
 }