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; }
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; } }
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'); }
/** * 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')); }
function init() { $this->dirname = dirname(__FILE__) . '/data'; $this->FW = XSystem::factory(XUtil::makePath($this->dirname, "site.ini"), array('root' => $this->dirname)); }
<?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);
<?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");