Example #1
0
File: log.php Project: pihizi/qf
 static function add($message, $ident = 'common')
 {
     //export nothing
     $log_path = Log::get_path($ident);
     @File::check_path($log_path);
     $time = date('Y/m/d H:i:s');
     $host = $_SERVER['REMOTE_ADDR'];
     if (!$host) {
         $host = $_SERVER['REMOTE_HOST'];
     }
     if (!$host) {
         $host = 'LOCALHOST';
     }
     $mode = PHP_SAPI;
     $uri = $_SERVER['REQUEST_URI'];
     $pid = posix_getpid();
     @file_put_contents($log_path, "{$time} {$mode} {$host}{$uri} [{$pid}] \t{$message}\n", FILE_APPEND);
 }
Example #2
0
File: file.php Project: pihizi/qf
 static function copy_r($source, $dest, $mode = 0755)
 {
     $dh = @opendir($source);
     if ($dh) {
         while ($name = readdir($dh)) {
             if ($name == '.' || $name == '..') {
                 continue;
             }
             $path = $source . '/' . $name;
             if (is_dir($path)) {
                 File::copy_r($path, $dest . '/' . $name);
             } else {
                 $dest_path = $dest . '/' . $name;
                 File::check_path($dest_path, $mode);
                 @copy($path, $dest_path);
             }
         }
         @closedir($dh);
     }
 }
Example #3
0
File: js.php Project: pihizi/qf
 static function load($js, $params = NULL)
 {
     static $_lamda_cache;
     $output = '';
     if (is_array($js)) {
         foreach ($js as $j) {
             $output .= self::load($j, $params);
         }
         return $output;
     }
     $output = '<script type="text/javascript">(function(){';
     $js_key = md5($js);
     $params = (array) $params;
     ksort($params);
     if (!isset($_lamda_cache[$js_key])) {
         list($category, $path) = explode(':', $js, 2);
         if (!$path) {
             $path = $category;
             $category = NULL;
         }
         $path = PRIVATE_BASE . 'js/' . $path . '.js';
         $path = Core::file_exists($path, $category);
         if (!$path) {
             return '';
         }
         $mtime = filemtime($path);
         $lamda = 'jslamda_' . $js_key;
         $prefix_path = Config::get('system.tmp_dir') . 'js/';
         $locale = Config::get('system.locale');
         if ($locale) {
             $prefix_path .= $locale . '_';
         }
         $mode = Config::get('page.js_mode');
         if ($mode) {
             $prefix_path .= $mode . '_';
         }
         $cache_file = $prefix_path . $lamda;
         $re_cache = TRUE;
         if (file_exists($cache_file)) {
             $cache_mtime = filemtime($cache_file);
             if ($cache_mtime > $mtime) {
                 $re_cache = FALSE;
             }
         } else {
             File::check_path($cache_file);
         }
         if ($re_cache) {
             $cache = 'Q.' . $lamda . '=function(_oO){';
             $i = 0;
             foreach ($params as $k => $v) {
                 $cache .= sprintf('var %s = _oO[%d]; ', $k, $i);
                 $i++;
             }
             $cache .= JS::format(@file_get_contents($path));
             $cache .= '};';
             @file_put_contents($cache_file, $cache);
         } else {
             $cache = @file_get_contents($cache_file);
         }
         $output .= $cache;
         $_lamda_cache[$js_key] = $lamda;
     } else {
         $lamda = $_lamda_cache[$js_key];
     }
     $vars = array();
     foreach ($params as $k => $v) {
         $vars[] = $v;
     }
     $output .= 'Q.' . $lamda . '(' . json_encode($vars) . ');';
     $output .= '})();</script>';
     return $output;
 }