/** This method sets the application timezone @access public @throws Exception object @static @return void */ public static function set_timezone() { try { date_default_timezone_set(Application::config("general->application_timezone")); } catch (Exception $e) { throw $e; } }
/** * 配置cookie参数 * * @param array $config */ public static function init_cookie_params() { $config = \Core\Application::config()->cookie; foreach (self::$config as $key => $val) { if (isset($config[$key])) { self::$config[$key] = $config[$key]; } } }
/** * @return \Core\Database */ public static function database() { static $database = NULL; if (is_null($database)) { $config = \Core\Application::config()->database['master']; $database = new \Core\Database($config['db_target'], $config['user_name'], $config['password'], $config['params']); } return $database; }
/** * 配置微信接口参数 * * @param array $config * @return \WX\Platform\Common */ public static function init_config_params() { static $singleton = null; if (is_null($singleton)) { $config = \Core\Application::config()->weixin; $model = get_called_class(); $singleton = new $model($config['appid'], $config['appsecret'], $config['token']); } return $singleton; }
/** * 初始化 * @param int $corp_agent_id * @param string $corp_id * @param string $corp_secret * @param string $token * @param string $open_log */ public function __construct() { $config = \Core\Application::config()->enterprise; $this->corpid = $config['corpid']; $this->corpsecret = $config['corpsecret']; $this->corpagentid = $config['corpagentid']; $this->token = $config['token']; $this->encodingaeskey = $config['encodingaeskey']; $this->open_log = $config['open_log']; }
/** * 初始化 */ public function __construct() { $config = \Core\Application::config()->redcash; $this->appid = $config['appid']; $this->cert = $config['cert']; $this->ca = $config['ca']; $this->key = $config['key']; $this->api_key = $config['api_key']; $this->mchid = $config['mchid']; }
/** * 如果没有配置日志路径则不写日志, * 使用php内置的error_log记录错误日志 * * @param string $message * @return bool */ function log_message($message, $dir = NULL) { if (is_null($dir)) { $dir = \Core\Application::config()->log_dir; } $client_ip = client_ip(); if (!is_dir($dir)) { @mkdir($dir, 0755, TRUE); } $file = $dir . '/' . date('Y-m-d') . '.log'; return error_log(date('H:i:s ') . $client_ip . " {$message}\n", 3, $file); }
} /** This method sets the database property array @access private @throws Exception object @param string $ke @param array $arrValue @return void */ private function set_database($key, $arrValue) { try { if (is_string($arrValue["enabled"]) && Utility::check_bool($arrValue["enabled"]) && filter_var($arrValue["enabled"], FILTER_VALIDATE_BOOLEAN)) { $this->Databases[$key] = new PDOHandler($arrValue['dbms'], $arrValue['host'], $arrValue['user'], $arrValue['password'], $arrValue['database_name']); }
/** * 获取上传的文件 */ public function picture() { $file = \Ext\Uploader::get('file'); if (!empty($file)) { if ($file->is_successed()) { $to_path_file = '/' . time() . '.' . $file->file_ext(); $file->move(\Core\Application::config()->upload_dir . $to_path_file); echo json_encode(array('link' => \Core\Application::config()->upload_url . $to_path_file)); } else { echo $file->error_code(); } } exit; }
<?php ini_set('display_errors', "On"); date_default_timezone_set('Asia/Chongqing'); // 定义框架使用的常量和方法 require realpath(__DIR__ . '/../library/core/application.php'); // 定义框架使用的常量和方法 require realpath(__DIR__ . '/../library/core/uri.php'); // manage 后台管理模块 if (\Core\URI::part(0) == 'manage') { // 设置模块url别名和操作系统路径 \Core\Application::bind_module('manage', realpath(__DIR__ . '/../manage')); } else { // 设置模块url别名和操作系统路径 \Core\Application::bind_module('', realpath(__DIR__ . '/../application')); } // 设置自动加载目录 \Core\Application::init_include_path(array(W_APPLICATION_PATH, W_LIBRARY_PATH)); //初始化自动加载 \Core\Application::init_autoload(); // 分发请求 \Core\Application::dispatch(\Core\Application::config()->route_maps, \Core\URI::get_url_path());
> </a> <div class="media-body"> <h4 class="media-heading"><?php echo $admin->admin_name; ?> </h4> 欢迎您的到来 <br> <a href='/manage/main/out'>退出</a> </div> </div> </div> <ul id="nav" class="list-group"> <?php $menu = \Core\Application::config()->menu; echo \Model\Framework::get_menu($menu); ?> </ul> <div> </div> </div> <div class="col-md-10 col-md-offset-2"> <div class="col-md-10 col-md-offset-2 content-title navbar-fixed-top"> <div class="pull-left"> <?php echo \Model\Framework::get_active_item($menu); ?> </div>
/** Auth method @access public @throws Exception object !@Service.ContentType = json !@Service.Validate.RequestMethod = POST */ public function auth() { try { $login = Application::config("service->auth_name_label"); $password = Application::config("service->auth_password_label"); $addDatetime = Utility::get_datetime(); $apiBC = new ApiBC(); $apiUserTokenVO = new ApiUserTokenVO(); $apiUserTokenVO->User = new UserVO(); $apiUserTokenVO->User->Email = $this->Post->{$login}; $apiUserTokenVO->User->Password = $this->Post->{$password}; $apiUserTokenVO->UserAgent = $this->Headers->{'Client-User-Agent'}; $apiUserTokenVO->ClientIp = $this->Headers->{'Client-Ip'}; $apiUserTokenVO->AddDatetime = $addDatetime; //Params for logging $params = ["user_table_label" => $this->Application->config("service->user_table"), "auth_user_id_label" => $this->Application->config("service->auth_user_id_label"), "user_active_label" => $this->Application->config("service->user_active_label"), "entity" => $this->Application->request_structure("entity"), "service" => $this->Application->request_structure("webMethod"), "parameter" => $this->Application->request_structure("parameter"), "http_verb" => $this->Application->Url->RequestMethod, "client_ip" => $this->Headers->{"Client-Ip"}, "server_ip" => Utility::get_client_ip(), "api_key" => $this->Headers->{"Api-Key"}, "content" => json_encode($this->Post), "add_datetime" => $addDatetime]; parent::response(["token" => $apiBC->auth_user($apiUserTokenVO, $params)]); } catch (Exception $ex) { parent::response($ex); } }
/** Check authorization token @access public @throws Exception object @param array $param @return void */ public function check_authorization_token($param = []) { try { $apiToken = explode(" ", $param["user_token"]); if ($apiToken[0] != Application::config("service->authorization_prefix")) { HttpHandler::header(401); } $apiToken[1] = $apiToken[1]; $param["user_token"] = $apiToken[1]; $result = $this->ApiDAO->check_authorization_token($param); if ($result->UserId == 0) { HttpHandler::header(401); } else { $param["user_id"] = $result->UserId; $param["add_datetime"] = Utility::get_datetime(); $this->ApiDAO->insert_system_log($param); $result->ApiToken = $apiToken[1]; } return $result; } catch (Exception $e) { throw $e; } }
/** * 设置cookie配置 * @param array $config */ public static function init_cookie_params() { $config = \Core\Application::config()->session; session_set_cookie_params($config['expire'], $config['path'], $config['domain'], $config['secure'], $config['httponly']); }