Пример #1
0
 /**
  * Set logs base directory
  * @param string $a_path
  * @return Zoombi_Log
  */
 public function &setPath($a_path)
 {
     if (!is_string($a_path) || !Zoombi_Folder::exist($a_path)) {
         return $this;
     }
     $this->m_path = $a_path;
     return $this;
 }
Пример #2
0
 /**
  * Return array of files
  * @param string $a_dir Directory
  * @return array
  */
 public static function files($a_dir)
 {
     if (isset($this)) {
         return Zoombi_Folder::files($this->m_dir);
     }
     if (!Zoombi_Folder::exist($a_dir)) {
         return array();
     }
     $result = array();
     foreach (scandir($a_dir) as $file) {
         if ($file == '.' || $file == '..') {
             continue;
         }
         $result[] = $file;
     }
     return $result;
 }
Пример #3
0
 function put($a_key, $a_data)
 {
     $f = new Zoombi_File();
     if (Zoombi_Folder::notexist($this->m_dir)) {
         if (!mkdir($this->m_dir)) {
             Zoombi::getApplication()->triggerError('Failed when create directory');
             return;
         }
     }
     $time = time();
     $key = (string) $a_key;
     $cache = $this->m_dir . $key . '.cache';
     $info = $this->m_dir . $key . '.info';
     if (file_put_contents($cache, $a_data) === false) {
         Zoombi::getApplication()->triggerError('Cache file "' . $cache . '", not written');
         return;
     }
     if (file_put_contents($info, $time) === false) {
         Zoombi::getApplication()->triggerError('Cache info file "' . $info . '", not written');
         return;
     }
 }
Пример #4
0
 function put($a_key, $a_data, $a_expire = self::EXPIRE_MINUTE)
 {
     if (Zoombi_Folder::notexist($this->m_dir)) {
         if (!mkdir($this->m_dir)) {
             Zoombi::getApplication()->triggerError('Failed when create directory');
             return;
         }
     }
     $key = (string) $a_key;
     $cache = $this->m_dir . $key . '.cache';
     $info = $this->m_dir . $key . '.info';
     $time = time();
     $age = intval($a_expire);
     if (file_put_contents($cache, $a_data) === false) {
         Zoombi::getApplication()->triggerError('Cache file "' . $cache . '", not written');
         return;
     }
     if (file_put_contents($info, $time . ':' . $age) === false) {
         Zoombi::getApplication()->triggerError('Cache info file "' . $info . '", not written');
         return;
     }
     return array($time, $age);
 }