Exemple #1
0
 /**
  * mysql日志
  *
  * @param unknown $error        	
  * @param unknown $errstr        	
  */
 function mysql($errno, $errstr)
 {
     $out = date(http::time(), "Y-m-d H:i:s") . ' ' . $errno . ' ' . $errstr;
     if (filesystem::path($this->_config['mysql_path'])) {
         file_put_contents($this->_config['mysql_path'], $out);
     }
 }
Exemple #2
0
 /**
  * 文件分割,注意使用此函数注意内存要大于$size,成功则返回小文件路径数组
  *
  * @param unknown $file
  *        	要分割的文件
  * @param unknown $size
  *        	文件大小 单位字节
  * @param unknown $path
  *        	文件保存路径 默认在系统临时目录中
  * @return array|false
  */
 function split($file, $size, $path = NULL, callable $callback)
 {
     $path = filesystem::path($path);
     $array = array();
     if (is_writable($path) && is_dir($path)) {
         $readHandler = fopen($file, 'rb');
         if (!$readHandler) {
             return false;
         }
         $num = 0;
         while (true) {
             $path = empty($path) ? sys_get_temp_dir() : $path;
             $tmppath = tempnam($path, 'data_');
             $writeHandler = fopen($tmppath, 'ab');
             if (!$writeHandler) {
                 return false;
             }
             $data = fread($readHandler, $size);
             if (strlen($data) == 0) {
                 break;
             }
             if (is_callable($callback)) {
                 call_user_func($callback, array($data));
             }
             fwrite($writeHandler, $data);
             $array[] = $tmppath;
         }
         fclose($readHandler);
         fclose($writeHandler);
         return $array;
     }
     return false;
 }