public function __construct() { $this->startTime = time(); $this->eventListener = new Core_EventListener(); $script = array_shift($_SERVER['argv']); array_shift($_SERVER['argv']); array_unshift($_SERVER['argv'], $script); $_SERVER['argc'] = count($_SERVER['argv']); $this->argv = $_SERVER['argv']; $cmd = Core_Config::getInstance()->get('default/phpunit_command'); $this->PUOptions[self::CFG_PHPUNIT_CMD] = $cmd ? $cmd : $this->PUOptions[self::CFG_PHPUNIT_CMD]; $maxThread = Core_Config::getInstance()->get('default/max_thread'); $this->PUOptions[self::CFG_MAX_THREAD] = $maxThread ? $maxThread : $this->PUOptions[self::CFG_MAX_THREAD]; $plugins = Core_Config::getInstance()->get('plugin'); foreach ($plugins as $name => $isEnabled) { if ($isEnabled) { $className = $name; if (strpos($className, 'Plugin_') !== 0) { $className = 'Plugin_' . $className; } $className = __NAMESPACE__ . '\\' . $className; $this->pluginList[] = new $className($this); } } $this->runDaemon = new Core_RunDaemon(); }
/** * @param string $cpzonename zone name * @param string $sessionid session id * @return boolean false for invalid request */ private function disconnectSession($cpzonename, $sessionid) { $zoneid = -1; foreach ($this->config->object()->captiveportal->children() as $zone => $zoneobj) { if ($zone == $cpzonename) { $zoneid = $zoneobj->zoneid; } } if ($zoneid == -1) { // not a valid zone return false; } $db = new DB($cpzonename); $db_clients = $db->listClients(array("sessionid" => $sessionid)); $ipfw_tables = $this->rules->getAuthUsersTables($zoneid); if (sizeof($db_clients) > 0) { if ($db_clients[0]->ip != null) { // only handle disconnect if we can find a client in our database $exec_commands[] = "/sbin/ipfw table " . $ipfw_tables["in"] . " delete " . $db_clients[0]->ip; $exec_commands[] = "/sbin/ipfw table " . $ipfw_tables["out"] . " delete " . $db_clients[0]->ip; $this->shell->exec($exec_commands); // TODO: cleanup dummynet pipes $db_clients[0]->pipeno_in/out // TODO: log removal // ( was : captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], "DISCONNECT");) } $db->removeSession($sessionid); } return true; }
function parallel_runner_loader($className) { $namespace = ''; if (strpos($className, '\\') > 0) { $tmp = explode('\\', $className); $namespace = $tmp[0]; $className = $tmp[1]; } if (!empty($namespace) && $namespace != __NAMESPACE__) { return; } $path = str_replace(array('\\', '_'), '/', $className) . '.php'; $filename = PATH_LIB . '/' . $path; if (strpos($className, 'PHPUnit_') === 0) { $src = rtrim(Core_Config::getInstance()->get('src/phpunit/phpunit'), '/') . '/'; $filename = $src . $path; } else { if (strpos($className, 'File_Iterator') === 0) { $src = rtrim(Core_Config::getInstance()->get('src/phpunit/php_file_iterator'), '/') . '/'; $filename = $src . $path; } else { if (strpos($className, 'PHP_CodeCoverage') === 0) { $src = rtrim(Core_Config::getInstance()->get('src/phpunit/php_code_coverage'), '/') . '/'; $filename = $src . $path; } } } if (file_exists($filename)) { require_once $filename; } }
public function __construct() { $config = Core_Config::load('redis'); if (!isset($config['default'])) { throw new Core_Exception_Fatal('没有找到 ' . $module . ' 模块的 redis 配置信息,请检查 redis.conf.php'); } $this->_config = $config['default'] + $this->_config; }
/** * 获取API调用的客户端,无需token * @return Core_Open_Client */ public static function getNoneTokenClient() { if (isset(self::$noneTokenClient)) { return self::$noneTokenClient; } //获取安装时候的key $akey = Core_Config::get('appkey', 'basic'); $skey = Core_Config::get('appsecret', 'basic'); if (empty($akey) || empty($skey)) { Core_Fun::error('key丢失', 102); } self::$noneTokenClient = new Core_Open_Client($akey, $skey); return self::$noneTokenClient; }
/** * 取得DB连接 * * @param string $dbName * @return void */ public static function get($dbName) { // 获取数据库连接配置 $dbConf = Core_Config::load('Db'); if (!$dbConf || !is_array($dbConf)) { throws("Empty DB CONFIG please check db.conf.php file", 'sql'); } $dbServer = $dbConf[$dbName]; if (!$dbServer) { throws('Invalid DB configuration [' . $dbName . '], plz check: db.conf.php', 'sql'); } if (!isset(self::$_dbs[$dbName])) { // 创建数据库连接实例 self::$_dbs[$dbName] = new Com_Db_Pdo($dbServer, $dbConf['persistent'], $dbConf['emulate_prepare']); } return self::$_dbs[$dbName]; }
public function editAction() { //$table = isset($params['data_base']) ? $params['data_base'] : 'data_entry'; $cfgcm = Core_Config::get("cm"); $entry = $this->reqs->params; $id = isset($entry['id']) ? $entry['id'] : ''; $dbentry = Core_Dao::factory(array('name' => 'data_entry')); $entry = $dbentry->getById($id); $dbcat = Core_Dao::factory(array('name' => 'taxonomy_term_user')); $cats = $dbcat->getList(array('uid' => 1, 'vid' => 1), array(), 1000); if (!strlen($entry['terms'])) { $entry['terms'] = ""; } //$entry['published'] = date("Y:m:d h:i:s", strtotime($entry['published'])); //$entry['updated'] = date("Y:m:d h:i:s", strtotime($entry['updated'])); $params = array('reqs' => $this->reqs, 'entry' => $entry, 'cats' => $cats); $this->view->content = $this->view->render('node/edit', $params); $this->response('app/layout'); }
protected function __construct() { if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } require SYS_PATH . 'Core' . DS . 'Bootstrap.php'; // 加载配置助手类 require SYS_PATH . 'Core' . DS . 'Config.php'; // 加载核心函数 require SYS_PATH . 'Core' . DS . 'Function.php'; // 加载类加载助手类 require SYS_PATH . 'Core' . DS . 'Loader.php'; // 加载全局变量 Core_Config::load("Global"); // 框架初始化 Core_Bootstrap::init(); // 设置文件检索目录 set_include_path('.' . PATH_SEPARATOR . APP_PATH . PATH_SEPARATOR . APP_PATH . DS . 'Library' . PATH_SEPARATOR . SYS_PATH); // 类的自动加载 spl_autoload_register(array($this, 'autoload')); }
/** * 获取哈希分表名(拆分数量无上限) * 后缀为十六进制,从 _0~_f, _00~_ff, _000~_fff ... 会补全0前缀 * * @param string $orgTableName * @param string $hashKey * @param int $hashNum 分表数量,无上限 * @return string */ public static function tableName($orgTableName, $hashKey, $hashNum = null) { if (!$hashKey) { return $orgTableName; } $tblConf = Core_Config::load('table'); // 分库数量,缺省1 if ($hashNum === null) { $hashNum = isset($tblConf[$orgTableName]['hash_num']) ? $tblConf[$orgTableName]['hash_num'] : 1; } if ($hashNum <= 1) { return $orgTableName; } // 拆表没有上限,分表后缀是十六进制,会补全0前缀 if (in_array($hashNum, array(16, 256, 4096))) { $tblSuffix = substr(md5($hashKey), 0, log($hashNum, 16)); } else { $tblSuffix = str_pad(dechex(hexdec(substr(md5($hashKey), 0, 4)) % $hashNum), ceil(log($hashNum, 16)), '0', STR_PAD_LEFT); } return $orgTableName . '_' . $tblSuffix; }
public static function parse($pathInfo) { $routerConfig = Core_Config::load('Router'); if (NULL == $pathInfo) { $pathInfo = self::getPathInfo(); } $pathInfos = $pathInfo ? explode('/', trim($pathInfo, '/')) : array(); if (!$pathInfos) { return $routerConfig["DefaultDispatchInfo"]; } $controller = array_shift($pathInfos); $controller = $controller ? ucfirst($controller) : $routerConfig["DefaultDispatchInfo"]["controller"]; $action = array_shift($pathInfos); $action = $action ? $action : $routerConfig["DefaultDispatchInfo"]["action"]; // 解析GET参数,例如: // _directory/controller/action/k1/v1/k2/v2 // 从 action 后的 key1 开始为 k/v 组合参数串 // *因为前面已经两次 array_shift 弹出数组头元素 // 所以此时的 $pathInfos 数组值已经是: array(k1, v1, k2, v2),那么再转为关联数组即可 array(k1 => v1, k2 => v2) $params = $pathInfos ? Helper_Array::assoc($pathInfos) : array(); // 解析pathinfo风格URL return array('controller' => $controller, 'action' => $action, 'params' => $params); }