/** * 构造函数 */ public function __construct() { parent::__construct(); if (method_exists($this, "_init")) { $this->_init(); } }
/** * 构造函数 */ public function __construct() { parent::__construct(); $this->getConfig(); $this->alipay_config = $this->getAlipayConfig(); //引入支付官方sdk vendor('alipay_submit', APP_PATH . 'Api/Vendor/InternationalAlipay/', '.class.php'); }
public function __construct() { parent::__construct(); if (isset($_GET['labId'])) { $this->labModel = new LabModel($_GET['labId']); } $this->map = ['id' => '_id']; }
function __construct() { parent::__construct(); if (isset($_GET['labId'])) { $this->model = new LabModel($_GET['labId']); } else { $this->ajaxReturn($this->error('未给出实验室ID')); } }
public function __construct() { parent::__construct(); // $oauth = new ThinkOAuth2(); // $ac = I('request.access_token'); // if(empty($ac)) $this->response(array('info'=> C('errorcode.2001'), 'code'=>2001) , 'json'); // $access_token = $oauth->getAccessToken($ac); // if(empty($access_token)) $this->response(array('info'=>C('errorcode.2002') , 'code'=>2002) , 'json'); // if( time()-$access_token['expires'] < 0 ) $this->response(array('info'=>C('errorcode.2003') , 'code'=>2003) , 'json'); }
public function __construct() { parent::__construct(); $client_id = C('CLIENT_ID'); $client_secret = C('CLIENT_SECRET'); $config = array('client_id' => $client_id, 'client_secret' => $client_secret, 'site_url' => C("SITE_URL")); $client = new OAuth2ClientService($config); $access_token = $client->getAccessToken(); if ($access_token['status']) { $this->assign("access_token", $access_token['info']); } $this->assign("error", $access_token); }
public function __construct() { parent::__construct(); $oauth = new ThinkOAuth2(); $ac = I('request.access_token'); if (empty($ac)) { $this->response(array('info' => '未传入access_token', 'code' => 8001), 'json'); } $access_token = $oauth->getAccessToken($ac); if (empty($access_token)) { $this->response(array('info' => 'access_token错误', 'code' => 8002), 'json'); } }
public function __construct() { //加载错误代码配置 L(include APP_PATH . 'Api/Conf/error_code.php'); parent::__construct(); if (MODULE_NAME == 'ApiBase') { $this->sendHttpStatus(404); exit; } //var_dump($_GET); $this->_type = 'html'; //获取token if ($this->is_check_token) { $this->check_token(); } }
public function __construct() { parent::__construct(); $this->_model = new \Think\Model(); $this->user = new \Home\Model\UserModel(); }
public function __construct() { //支持方法 if (!$this->allowMethod) { $this->allowMethod = explode(",", strtolower(SUPPORTED_METHOD)); } //session token if (I('server.HTTP_TOKEN')) { session(array('id' => I("server.HTTP_TOKEN"), 'expire' => 1800)); session('[start]'); $this->user = I("session.user"); $this->is_super_user = $this->user['is_super_user']; if (isset($_SESSION['user']) && (!get_current_company_id() || !get_current_user_id())) { return $this->login_required(); } } tag('before_controller_construct'); parent::__construct(); // 当前请求 =》 auth_node $this->current_action_all = sprintf("%s.%s.%s.%s", lcfirst(MODULE_NAME), lcfirst(CONTROLLER_NAME), lcfirst(ACTION_NAME), $this->_method); //当前用户所属公司 if ($this->user or true) { $this->company = D("Account/Company")->relation(true)->find(get_current_company_id()); } //当前公司启用应用 $this->activeApps = $this->baseApps; if ($this->company) { $this->activeApps = array_merge($this->activeApps, get_array_by_field($this->company['apps'], "alias")); } //启用应用 AppService::active($this->activeApps, $this->baseApps); //当前模块前端别名 $this->module_alias = __(sprintf('%s.%s', lcfirst(MODULE_NAME), lcfirst(CONTROLLER_NAME))); //导入非当前应用的插件及函数等信息 foreach ($this->activeApps as $app) { $app = ucfirst($app); if ($app == APP_NAME or $app == "common") { continue; } // 插件 if (is_file(APPLICATION_PATH . $app . '/Conf/tags.php')) { \Think\Hook::import(require APPLICATION_PATH . $app . '/Conf/tags.php'); } // 函数 if (is_file(APPLICATION_PATH . $app . '/Common/function.php')) { require_once APPLICATION_PATH . $app . '/Common/function.php'; } } //基本运行配置 $this->bootstrapConfigs = parse_yml(ENTRY_PATH . '/config.yaml'); //当前接口版本 if (I('server.HTTP_API_VERSION')) { define('API_VERSION', I('server.HTTP_API_VERSION')); } else { define('API_VERSION', false); } //当前语言 $this->currentLanguage = $this->bootstrapConfigs["default_language"] ? $this->bootstrapConfigs["default_language"] : 'zh-cn'; if (I("server.HTTP_CLIENT_LANGUAGE")) { $this->currentLanguage = I("server.HTTP_CLIENT_LANGUAGE"); } if (I('get.lang')) { $this->currentLanguage = I('get.lang'); } define('CURRENT_LANGUAGE', $this->currentLanguage); /* * 解析应用配置 * * */ $cachedAppConfig = S("configs/app/all"); if (DEBUG or !$cachedAppConfig) { foreach (new RecursiveFileFilterIterator(APP_PATH, "config.yml") as $item) { $app = lcfirst(basename(dirname($item))); $this->appConfigs[$app] = parse_yml($item); } S("configs/app/all", $this->appConfigs); } else { if (!DEBUG && $cachedAppConfig) { $this->appConfigs = $cachedAppConfig; } } AppService::$allAppConfigs = $this->appConfigs; foreach ($this->appConfigs as $app => $config) { $this->bootstrapConfigs['auth_dont_need_login'] = array_merge_recursive($this->bootstrapConfigs['auth_dont_need_login'], (array) $config['auth_dont_need_login']); $this->bootstrapConfigs['auth_dont_need_check'] = array_merge_recursive($this->bootstrapConfigs['auth_dont_need_check'], (array) $config['auth_dont_need_check']); } // 当前表名 if (!$this->model_name) { $this->model_name = ucfirst(CONTROLLER_NAME); } // 获得用户已授权节点 $authed_nodes = session('authed_nodes'); if (DEBUG || !$authed_nodes) { $authed_nodes = D('Account/Authorize')->get_authed_nodes(); session('authed_nodes', $authed_nodes); } self::$authed_nodes = $authed_nodes; AuthorizeService::set_authed_nodes($authed_nodes); //当前动作权限检测 // @todo event, event_get $current_node_auth_flag = DEBUG ? 1 : $this->check_permission(); if (substr($this->_method, 0, 5) !== 'event' && false === $current_node_auth_flag) { $node_lang = __(lcfirst(MODULE_NAME) . '.METHODS.' . $this->_method) . ' ' . __(lcfirst(MODULE_NAME) . '.' . ucfirst(CONTROLLER_NAME)); return $this->httpError(403, __("common.Permission Denied") . ": " . $node_lang . "({$this->current_action_all})"); } $this->current_node_auth_flag = (int) $current_node_auth_flag; tag('after_controller_construct'); }
/** * 构造函数 */ public function __construct() { parent::__construct(); $this->getConfig(); $this->alipay_config = $this->getAlipayConfig(); }