public static function factry() { $config = array('host' => config('DB_HOST'), 'db_name' => config('DB_NAME'), 'user' => config('DB_USER'), 'pwd' => config('DB_PWD'), 'port' => config('DB_PORT'), 'prefix' => config('DB_PREFIX')); $dbType = 'Db' . ucwords(config('DB_TYPE')); loadCore('db/drivers/' . $dbType); return new $dbType($config); }
/** * 服务器列表 */ public function cIndex() { $this->_modelServers = $this->getGlobal('model/Servers', 'Model_Servers'); $sqlSearch = $this->_modelServers->getFindClass(); $sqlSearch->set_tableName($this->_modelServers->tName()); $search = $this->getR('s'); $sqlSearch->addConditions(array('game_mark' => $search['game_mark'], 'server_id' => $search['server_id'], 'status' => $search['status'], 'pay_status' => $search['pay_status'])); if ($search['start_time'] && $search['end_time']) { $search['start_time'] = strtotime($search['start_time']); $search['end_time'] = strtotime($search['end_time']); $sqlSearch->set_conditions("open_time between {$search['start_time']} and {$search['end_time']}"); } $sqlSearch->setPageLimit($this->getR('page')); $conditions = $sqlSearch->get_conditions(); $sql = $sqlSearch->createSql(); $dataList = $this->_modelServers->select($sql); if ($dataList) { foreach ($dataList as &$val) { $val['word_game_mark'] = $this->_games[$val['game_mark']]['name']; $val['open_time'] = $val['open_time'] ? date('Y-m-d H:i:s', $val['open_time']) : ''; $val['word_status'] = $this->_status[$val['status']]; $val['word_pay_status'] = $this->_payStatus[$val['pay_status']]; } $this->assign('dataList', $dataList); loadCore('help/Page'); $page = new Page(array('total' => $this->_modelServers->findCount($conditions))); $this->assign('pageBox', $page->show()); } $this->_status[''] = '所有'; $this->_payStatus[''] = '所有 '; $this->assign('status', $this->_status); $this->assign('payStatus', $this->_payStatus); $this->display(VIEW_PAGE); }
/** * @return Db */ private function _getDb() { if (is_null($this->_db)) { loadCore('db/Db'); $this->_db = Db::instance(); } return $this->_db; }
public function __construct() { ob_start(); header('Content-type:text/html;charset=utf-8'); //设置字符集 $this->_rootPath = TPL_ROOT_PATH . '/' . config('TMPL_DEFAULT_THEME'); loadCore('html/HtmlForm'); $this->_htmlForm = new HtmlForm(); }
/** * @return View */ private function _getView() { if (is_null(self::$view)) { $viewName = 'View' . config('TMPL_ENGINE_TYPE'); loadCore("view/{$viewName}"); self::$view = new $viewName(); $this->registerGlobal('view', self::$view); } return self::$view; }
/** * 记录日志 并且会过滤未经设置的级别 * @param string $message 日志信息 * @param string $level 日志级别 * @param boolean $record 是否强制记录 * @return void */ static function record($message, $level = self::ERR, $record = false) { if ($record || in_array($level, config('LOG_RECORD_LEVEL'))) { $now = date(self::$format); self::$log[] = "{$now} {$level}: {$message}\r\n"; if (config('APP_DEBUG')) { //如果为debug模式的话 loadCore('Trace'); Trace::addLog("{$now} {$level}: {$message}"); } } }
public static function init() { // 设置系统时区 PHP5支持 if (function_exists('date_default_timezone_set')) { date_default_timezone_set(config('DEFAULT_TIMEZONE')); } set_error_handler(array('App', 'appError')); set_exception_handler(array('App', 'appException')); loadCore('Trace'); loadCore('Dispatcher'); Dispatcher::dispatch(); Trace::write(); }
/** * 用户列表 */ public function cIndex() { $this->_modelUser = $this->getGlobal('model/User', 'Model_User'); $requestClass = RegistryRequest::getInstance(); $requestClass->absInt($requestClass->get('page')); $sqlSearch = $this->_modelUser->getFindClass(); $sqlSearch->set_tableName($this->_modelUser->tName()); $sqlSearch->addConditions($requestClass->get('search_where')); $sqlSearch->setPageLimit($requestClass->get('page'), config('PAGE_SIZE')); $sqlSearch->set_orderBy('id desc'); $sql = $sqlSearch->createSql(); $dataList = $this->_modelUser->select($sql, 'id'); $conditions = $sqlSearch->get_conditions(); $this->assign('dataList', $dataList); loadCore('help/Page'); $page = new Page(array('total' => $this->_modelUser->findCount($conditions), 'perpage' => config('PAGE_SIZE'))); $this->assign('pageBox', $page->show()); $this->display(VIEW_PAGE); }
/** * 资讯显示列表 */ public function cIndex() { $this->_modelNews = $this->getGlobal('model/News', 'Model_News'); $users = params('adminuser/id_vuser'); $sqlSearch = $this->_modelNews->getFindClass(); $sqlSearch->clearAll(); $sqlSearch->set_tableName($this->_modelNews->tName()); $search = $this->getR('s'); $sqlSearch->addConditions(array('type' => $search['type'], 'game_type' => $search['game_type'], 'is_top' => $search['is_top'], 'user_id' => $search['user_id'])); if ($search['start_time'] && $search['end_time']) { $search['start_time'] = strtotime($search['start_time']); $search['end_time'] = strtotime($search['end_time']); $sqlSearch->set_conditions("time between {$search['start_time']} and {$search['end_time']}"); } $sqlSearch->setPageLimit($this->getR('page')); $sqlSearch->set_orderBy('is_top desc, time desc'); $conditions = $sqlSearch->get_conditions(); $sql = $sqlSearch->createSql(); $dataList = $this->_modelNews->select($sql); if ($dataList) { foreach ($dataList as &$val) { $val['word_type'] = $this->_type[$val['type']]; $val['word_game_type'] = $this->_gameTypes[$val['game_type']]; $val['word_is_top'] = $this->_isTop[$val['is_top']]; $val['time'] = $val['time'] ? date('Y-m-d H:i:s', $val['time']) : ''; $val['word_user_id'] = $users[$val['user_id']]; } $this->assign('dataList', $dataList); loadCore('help/Page'); $page = new Page(array('total' => $this->_modelNews->findCount($conditions))); $this->assign('pageBox', $page->show()); } $this->_type[''] = '所有'; $this->_isTop[''] = '所有'; $this->assign('users', $users); $this->assign('type', $this->_type); $this->assign('isTop', $this->_isTop); $this->display(VIEW_PAGE); }
public static function getUrlParams() { loadCore('registry/RegistryRequest'); self::$_registryRequest = RegistryRequest::getInstance(); switch (config('URL_MODEL')) { case URL_COMMON: //默认模式 self::_common(); break; case URL_PATHINFO: //pathinfo模式 break; case URL_REWRITE: //伪静态模式 break; case URL_COMPAT: //兼容模式 break; default: throwException('事件分发错误,请检测URL配置'); break; } }
<?php loadCore('registry/Registry'); class RegistrySession extends Registry { /** * session数组 * @var array */ private $_params = array(); /** * 当前对象 * @var RegistrySession */ private static $_instance = null; /** * @return RegistrySession */ public static function getInstance() { if (is_null(self::$_instance)) { self::$_instance = new RegistrySession(); } return self::$_instance; } private function __construct() { session_start(); $this->_getAllParams(); } private function _getAllParams()
/** * 获取用户对象 * @param $userId * @return UserClass */ public function getUserClass($userId = null) { static $userClasses = array(); if (is_null($userId)) { //获取当前登陆用户 if (is_numeric(self::$_curLoginUserId) && is_string(self::$_curLoginUser) && is_string(self::$_curLoginIp)) { //角色压力,避免重复解密cookie $userId = self::$_curLoginUserId; $user = self::$_curLoginUser; $ip = self::$_curLoginIp; } else { $param = $this->getC(config('USER_COOKIE_KEY')); loadCore('crypt/Des'); $param = Des::decrypt($param, config('USER_KEY')); list($userId, $user, $ip) = explode('|', $param); if (!is_numeric($userId) || !is_string($user) || !is_string($ip)) { //解析cookie失败,返回 false return false; } } } if (is_object($userClasses[$userId])) { return $userClasses[$userId]; } $fileClass = config('USERCLASS_PATH') . '/' . substr(md5($userId), 0, 1) . "/{$userId}.userclass"; if (!file_exists($fileClass)) { return false; } import('object/UserClass'); $userClass = file_get_contents($fileClass); $userClasses[$userId] = unserialize($userClass); return $userClasses[$userId]; }
/** * 调试输出 * @param $var * @param $echo */ function dump($var, $echo = false) { if (!config('APP_DEBUG')) { return; } $str = '<pre>' . print_r($var, true) . '</pre>'; if ($echo) { echo $str; } else { loadCore('Trace'); Trace::addLog($str); } }
<?php loadCore('html/Html'); /** * 表单解释类 * @author php-朱磊 * */ class HtmlForm extends Html { /** * 生成checkbox * @param $array name:chekcbox名称.options:选项.selected:选中数组.gule:间隔,默认 * @param $params */ public function checkbox($array, $params = null) { $name = $array['name']; $chkecboxArr = $array['options']; $selected = (array) $array['selected']; $gule = $array['gule'] ? $array['gule'] : ' '; $checkboxs = array(); if (!is_null($params)) { //附加属性 $appendParams = ''; foreach ($params as $key => $val) { $appendParams .= " {$key}='{$val}' "; } } foreach ($chkecboxArr as $key => $val) { $isSelected = in_array($key, $selected) ? "checked='checked'" : '';