Ejemplo n.º 1
0
 public static function save($file, $content)
 {
     $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
     $file = str_replace('\\', DIRECTORY_SEPARATOR, $file);
     $path = substr($file, 0, strrpos($file, DIRECTORY_SEPARATOR));
     Hi_Tool_Dir::check($path);
     file_put_contents($file, $content);
     return true;
 }
Ejemplo n.º 2
0
 /**
  * 将zipFile抽取到路径$to,如果$to不存在将自动创建
  * 
  * @param unknown_type $zipFile
  * @param unknown_type $to
  */
 public function extract($zipFile, $to)
 {
     Hi_Tool_Dir::check($to);
     $to = Hi_Tool_Dir::standard($to);
     $zip = new ZipArchive();
     $res = $zip->open($zipFile);
     if ($res !== true) {
         return false;
     }
     $zip->extractTo($to);
 }
Ejemplo n.º 3
0
 /**
  * 保存日誌內容到文件
  * 
  * @param $logFile
  * @param $content
  * @return bool
  */
 public static function save($logFile, $content)
 {
     if (!Hi_Tool_Dir::isAbsolute($logFile)) {
         $logFile = Hi_Env::$PATH_LOG . DS . $logFile;
     }
     $dir = dirname($logFile);
     Hi_Tool_Dir::check($dir);
     if (!is_string($content)) {
         $content = var_export($content, true);
     }
     $content = date('Y-m-d H:i:s') . "\t" . $content . "\n";
     $fp = fopen($logFile, 'a');
     fwrite($fp, $content, strlen($content));
     fclose($fp);
     return true;
 }
Ejemplo n.º 4
0
 /**
  * (non-PHPdoc)
  * @see Hi_Cache_Interface::save()
  */
 public function set($id, $content, $lifetime = null)
 {
     if (is_array($content) || is_object($content)) {
         $content = serialize($content);
     }
     if (!is_string($content)) {
         throw new Hi_Cache_Exception("Content is not a string");
     }
     $filePath = $this->getFilePath($id);
     $fileDir = substr($filePath, 0, strrpos($filePath, DIRECTORY_SEPARATOR));
     Hi_Tool_Dir::check($fileDir, true);
     $this->_write($filePath, $content);
     if ($lifetime === null) {
         $lifetime = $this->_lifetime;
     }
     if (intval($lifetime) !== 0) {
         $expireTime = $lifetime + time();
         $this->_setMeta($filePath, strval($expireTime));
     }
     return $filePath;
 }