Ejemplo n.º 1
0
 /**
  * 进行命令执行的异常拦截操作
  * @static
  * @author 欧远宁
  * @param string $cmd  命令名
  * @param string $code 错误码
  * @param string $msg  错误内容
  */
 public static function cmd_error($cmd, $code, $msg)
 {
     $cfg = fun::get_cfg('cfg');
     if (key_exists('cmd_inject', $cfg)) {
         call_user_func(array($cfg['cmd_inject'], 'error'), $cmd, $code, $msg);
     }
 }
Ejemplo n.º 2
0
 /**
  * 得到某个库某个表的分库分表信息
  * @static
  * @author 欧远宁
  * @param string $mdl 模块名
  * @param string $tbl 表名
  * @return array('db'=>'库后缀','tbl'=>'表后缀')
  */
 public static function split($mdl, $tbl)
 {
     $cfg = fun::get_cfg('cfg');
     if (!key_exists('dbsplit', $cfg)) {
         return array('', '');
     }
     $db_suf = call_user_func($cfg['dbsplit'], $mdl);
     $tmp = $mdl . $tbl;
     $tbl_suf = call_user_func($cfg['dbsplit'], $mdl, $tbl);
     return array('db' => $db_suf, 'tbl' => $tbl_suf);
 }
Ejemplo n.º 3
0
/**
 * 主入口 
 * @author 欧远宁
 */
define('OP', dirname(__FILE__) . DIRECTORY_SEPARATOR);
//定义系统根目录
define('DS', DIRECTORY_SEPARATOR);
//定义文件系统分隔符
define('TIME', time());
//定义版本
require_once OP . 'cfg' . DS . 'const.php';
require_once OP . 'now' . DS . 'control.php';
spl_autoload_register(array('now\\control', 'autoload'));
//动态加载类
use now\fun;
$now_cfg = fun::get_cfg('now');
mb_internal_encoding($now_cfg['encoding']);
//设置mbstring的编码
date_default_timezone_set($now_cfg['timezone']);
//设定时区
setlocale(LC_ALL, $now_cfg['locale']);
//设置本地化区域及字符集
function _get_ver($arr)
{
    $ip = $_SERVER['SERVER_ADDR'];
    foreach ($arr as $k => $v) {
        foreach ($v as $_ip) {
            if (strpos($_ip, $ip) !== FALSE) {
                return $k;
            }
        }
Ejemplo n.º 4
0
 /**
  * 下载一份现有文件
  * @static
  * @author 欧远宁
  * @param string $name 下载时候显示的名字
  * @param string $head 标题栏位
  * @param array $data  返回的数据
  */
 public static function down($name, $path, $type = 'application/octet-stream')
 {
     header('Content-type: ' . $type);
     //处理中文文件名
     $ua = $_SERVER["HTTP_USER_AGENT"];
     if (preg_match('/MSIE/', $ua)) {
         $name = urlencode($name);
         $name = str_replace("+", "%20", $name);
         header('Content-Disposition: attachment; filename="' . $name . '"');
     } else {
         if (preg_match("/Firefox/", $ua)) {
             header("Content-Disposition: attachment; filename*=\"utf8''" . $name . '"');
         } else {
             header('Content-Disposition: attachment; filename="' . $name . '"');
         }
     }
     //让Xsendfile发送文件
     $cfg = fun::get_cfg('cfg', 'upload');
     if ($cfg && key_exists('send_file', $cfg) && $cfg['send_file'] != '') {
         header($cfg['send_file'] . ': ' . $path);
     } else {
         header('Content-Length: ' . filesize($path));
         readfile($path);
     }
 }