Example #1
0
 private function _parseTemplatePath($path)
 {
     $suffix = AXION_CONFIG::GET('axion.view.templatesuffix');
     $path = explode('_', $path);
     $file = array_pop($path);
     $path = implode(DS, $path);
     $templatePath = strtolower($path . DS . $file . '.' . $suffix);
     return $templatePath;
 }
Example #2
0
 public static function getInstance()
 {
     static $_handler = array();
     $dispacherName = AXION_CONFIG::GET('axion.dispatcher.class');
     if (!empty($_handler[$dispacherName])) {
         return $_handler[$dispacherName];
     } else {
         $dispacherInstance = self::factory($dispacherName);
         $_handler[$dispacherName] = $dispacherInstance;
         return $dispacherInstance;
     }
 }
Example #3
0
 private static function factory($handlerName)
 {
     $className = strtolower($handlerName);
     /**@todo 有必要吗?直接给对应对象的详细路径即可 */
     if (in_array($className, array('file', 'memcached'))) {
         $className = 'AXION_CACHE_' . $className;
     }
     $instance = new $className();
     if ($instance instanceof AXION_INTERFACE_CACHE) {
         $config = AXION_CONFIG::get('axion.cache');
         $instance->setOptions($config);
         return $instance;
     } else {
         throw new AXION_EXCEPTION('该对象并非合法的缓存对象');
     }
 }
Example #4
0
 public function __construct()
 {
     if (!class_exists('MEMCACHE', false)) {
         throw new AXION_EXCEPTION('无法找到MEMCACHED扩展');
     }
     $this->instance = new Memcache();
     $config = AXION_CONFIG::get('axion.connections.memcached.servers');
     $count = sizeof($config);
     if ($count > 1 && !array_key_exists('host', $config)) {
         for ($i = 0; $i < $count; $i++) {
             if ($config[$i]['weight'] > $count) {
                 $config[$i]['weight'] = $count;
             }
             $this->instance->addServer($config[$i]['host'], $config[$i]['port'], true, $config[$i]['weight'], 1, 15, true, array('AXION_CACHE_MEMCACHED', 'failure'));
         }
     } else {
         $this->instance->addServer($config['host'], $config['port'], false, 1, 1, 15, true, array('AXION_CACHE_MEMCACHED', 'failure'));
     }
 }
Example #5
0
 public function session_start()
 {
     $sessionConfig = AXION_CONFIG::get('axion.session');
     $this->sessionHandler = $sessionConfig['handler'];
     $this->sessionTimeout = $sessionConfig['timeout'];
     if (!self::$sessionInstance) {
         if (in_array($this->sessionHandler, array('file', 'memcached'))) {
             $class = 'AXION_SESSION_' . $this->sessionHandler;
         } else {
             $class = $this->sessionHandler;
         }
         if (class_exists($class)) {
             self::$sessionInstance = new $class();
         } else {
             throw new AXION_EXCEPTION('无法找到对应的SESSION控制器');
         }
     }
     session_set_save_handler(array(self::$sessionInstance, 'open'), array(self::$sessionInstance, 'close'), array(self::$sessionInstance, 'read'), array(self::$sessionInstance, 'write'), array(self::$sessionInstance, 'destroy'), array(self::$sessionInstance, 'gc'));
     session_start();
 }
Example #6
0
/**
 * 快速打印数据(命令行模式)
 *
 * @param mix $mix_target
 * @param bool $bool_isBreakPoint 开启则打印完成后停止程序执行
 * @return null
 */
function P_cli($mix_target, $bool_isBreakPoint = false, $return = false)
{
    static $_pcount;
    $lable = $return ? $_pcount : ++$_pcount;
    if (is_array($mix_target)) {
        foreach ($mix_target as $k => $v) {
            if (is_bool($v)) {
                $mix_target[$k] = $v == true ? '(bool)true' : '(bool)false';
            }
            if ($v === null) {
                $mix_target[$k] = '(null)';
            }
            if (is_array($v)) {
                $mix_target[$k] = p_cli($v, false, true);
            }
        }
    }
    $result = '';
    if (is_bool($mix_target)) {
        $result = $mix_target == true ? '(bool)true' : '(bool)false';
    }
    if ($mix_target === null) {
        $result = '(null)';
    }
    if ($return) {
        return $mix_target;
    }
    $output = print_r($mix_target, TRUE);
    $debug = debug_backtrace();
    $debug_mode = false;
    if (AXION_CONFIG::get('axion.debug.level') > 0) {
        $debug_mode = cprint('(Debug Mode ON)', COR_BLINK, true);
    }
    $str = '';
    if ($lable) {
        $str .= 'Debug Lable:' . $lable;
        $str = cprint($str, COR_HIGHLIGHT, true);
        echo $str . " " . $debug_mode . "\n";
    }
    $str = 'In ' . $debug[1]['file'] . ' @Line ' . $debug[1]['line'] . "\n";
    $str = cprint($str, COR_RED, true);
    $output = cprint($output, COR_BLUE, true);
    $str .= $output . $result . "\n";
    if ($bool_isBreakPoint) {
        exit($str);
    }
    echo $str;
    return;
}
Example #7
0
 /**
  * 框架析构函数
  *
  */
 public function __destruct()
 {
     /** 防止程序意外退出执行析构函数 */
     if (!defined('APPLICATION_PATH')) {
         exit;
     }
     /** Debug 模式不存储缓存文件列表 */
     if (AXION_CONFIG::get('axion.debug.level') > 0) {
         return;
     }
     /**
      * 存储本次程序新加载的文件列表
      */
     if (self::$new_class_found) {
         file_put_contents(self::$load_cache_file, serialize(self::$loaded_class));
     }
 }
Example #8
0
 public function applicationTeminated()
 {
     $runtime = AXION_UTIL::excuteTime();
     $memUseage = number_format(memory_get_usage() / 1024) . 'k';
     Axion_log::log('程序执行时间:' . $runtime);
     Axion_log::log('本次内存使用:' . $memUseage);
     $logs = Axion_log::getLogPool();
     if (Axion_log::isOverLimit()) {
         array_shift($logs);
         $warningMessage = "超过日志容量限制(" . axion_log::getPoolLimit() . "),日志系统将自头删除数据保障程序工作";
         $warning = array('int_lv' => axion_log::WARNING, 'str_msg' => $warningMessage);
         array_unshift($logs, $warning);
     }
     if (IS_FIREPHP && AXION_CONFIG::get('axion.debug.usefirephp')) {
         $fb = AXION_UTIL_FIREPHP::getInstance(true);
         foreach ($logs as $v) {
             switch ($v['int_lv']) {
                 case Axion_log::WARNING:
                     $fb->warn($v['str_msg']);
                     break;
                 case Axion_log::NOTICE:
                     $fb->info($v['str_msg']);
                     break;
                 case Axion_log::ERROR:
                     $fb->error($v['str_msg']);
                     break;
                 case Axion_log::INFO:
                     $fb->log($v['str_msg']);
                     break;
             }
         }
     } else {
         P($logs);
     }
 }