示例#1
0
 public function open()
 {
     // if logger is not opend now open
     if ($this->_opend === false) {
         $this->_line_format = str_replace(array_keys($this->_format_map), $this->_format_map, $this->_line_format);
         $file = XUtil::makePath($this->_dirname, $this->_filename);
         $this->_fp = fopen($file, $this->_append ? 'a' : 'w');
         flock($this->_fp, LOCK_EX);
     }
     $this->_opend = true;
 }
示例#2
0
 public static function autoLoad($name)
 {
     if (preg_match('/X([A-Z][a-z]+)([A-Z][a-z]+)/', $name, $m)) {
         $dir = strtolower($m[1]);
         $name = strtolower($m[2]) . '.class.php';
         require_once XUtil::makePath($dir, $name);
         return true;
     } elseif (preg_match('/X(.*)/', $name, $m)) {
         $file = strtolower($m[1]) . '.class.php';
         require_once $file;
     }
 }
示例#3
0
文件: log.php 项目: kurari/XSystem
 function testLogMask()
 {
     $handler = XLog::factory('file', 'default', array('append' => 0, 'dirname' => $this->dirname, 'filename' => 'test1.log'), XLOG_WARNING);
     $handler->open();
     $handler->info("TEST");
     $handler->notice("TEST");
     $handler->debug("TEST");
     $handler->warning("TEST");
     $handler->err("TEST");
     $handler->crit("TEST");
     $handler->close();
     $this->assertEquala(3, count(file(XUtil::makePath($this->dirname, 'test1.log'))), 'Log Write Failed');
 }
示例#4
0
 /**
  * gettin resource handler
  *
  * @param string name
  */
 function getResourceHandler($type)
 {
     // if alrady loaded handler exists
     if (isset($this->plugin['resource'][$type])) {
         return $this->plugin['resource'][$type];
     }
     // info
     $fileName = "resource.{$type}.plugin.class.php";
     $class = "XTemplaterResource" . ucfirst($type);
     $file = false;
     // search in plugin directorys
     foreach ($this->pluginDir as $d) {
         $file = XUtil::makePath($d, $fileName);
         if (file_exists($file)) {
             break;
         }
     }
     // if not found
     if ($file == false) {
         return false;
     }
     require_once $file;
     // if class not found
     if (!class_exists($class)) {
         return false;
     }
     // create instance
     $o = new $class($this);
     // save as resource handler
     return $this->registerResourceHandler($type, array($o, 'get'), array($o, 'getExpiredTime'), array($o, 'hasCache'), array($o, 'getCache'), array($o, 'putCache'), array($o, 'gcCache'));
 }
示例#5
0
 function init()
 {
     $this->dirname = dirname(__FILE__) . '/data';
     $this->FW = XSystem::factory(XUtil::makePath($this->dirname, "site.ini"), array('root' => $this->dirname));
 }
示例#6
0
文件: index.php 项目: kurari/XSystem
<?php

require_once '../../lib/base/util.class.php';
XUtil::addIncludePath(XUtil::makePath("../..", 'class'), XUtil::makePath("../..", 'lib'));
require_once 'XSystem.class.php';
$file = "../etc/site.ini";
define("SITE_ROOT", realpath("../"));
$Mes = new XMessage();
$Mes->set('type', 'display');
$Mes->set('app', 'bbs');
$Mes->set('function', 'run');
$Mes->set('data', array());
$FW = XSystem::factory($file, array('site.root' => SITE_ROOT));
$FW->accept($Mes);
示例#7
0
<?php

define('XROOT', realpath(dirname(__FILE__) . '/../'));
require_once XROOT . '/lib/base/util.class.php';
XUtil::addIncludePath(XUtil::makePath(XROOT, 'class'), XUtil::makePath(XROOT, 'lib'));
spl_autoload_register(array('XUtil', 'autoLoad'));
// Error to Exception
function exception_error_handler($errno, $errstr, $errfile, $errline)
{
    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");