/** * @brief * @param * @return * @author fanmengzhe * @date 2011/11/08 11:50:24 * @note */ protected function _getServer($strServer, $strMethod) { $arrServConf = Bd_Passport_Conf::getConf('server'); if (isset($arrServConf['cur_idc'])) { $cur_idc = $arrServConf['cur_idc']; } else { Bd_Passport_Log::warning("cur_idc not exists", -1); return false; } if (isset($arrServConf[$strServer])) { $port = $arrServConf[$strServer]['service_port']; $timeout_c = $arrServConf[$strServer]['service_ctimeout']; $timeout_r = $arrServConf[$strServer]['service_rtimeout']; $timeout_w = $arrServConf[$strServer]['service_wtimeout']; } $ip_cnt = count($arrServConf[$strServer][$cur_idc]); $ip_idx = rand() % $ip_cnt; $ip = $arrServConf[$strServer][$cur_idc][$ip_idx]['ip']; $arrRet = array('ip' => $ip, 'port' => $port, 'timeout_c' => $timeout_c, 'timeout_w' => $timeout_w, 'timeout_r' => $timeout_r); foreach ($arrRet as $key => $val) { if (is_null($val)) { Bd_Passport_Log::warning("{$key} not exists", -1); return false; } } return $arrRet; }
public static function getEngine($strEngine = 'Ral') { if (defined('IS_ODP') && true === IS_ODP) { $strClassName = "Bd_Passport_Interact_Ral"; } else { $engine = Bd_Passport_Conf::getConfEx('engine', 'Ral'); $strEngine = ucfirst(strtolower($engine)); $strClassName = "Bd_Passport_Interact_{$strEngine}"; $filename = dirname(__FILE__) . "/interact/" . $strEngine . ".php"; if (file_exists($filename)) { require_once $filename; } else { Bd_Passport_Log::warning("{$filename} doesn't exist!", E_USER_ERROR); } } if (class_exists($strClassName)) { $instance = new $strClassName(); if (!$instance instanceof Bd_Passport_Interact_IEngine) { Bd_Passport_Log::warning("{$strClassName} isn't instanceof Bd_Passport_Interact_IEngine", E_USER_WARNING); } return $instance; } else { Bd_Passport_Log::warning("{$strClassName} Not Found!", E_USER_WARNING); } }
/** * @brief 初始化passport config。判断运行时环境[ODP|PRO]; * 若运行在ODP 环境,使用Bd_Conf读取configure文件 * 若运行在其他环境,使用Bd_Passport_Inc类(Inc.php)作为配置文件 * @param null * @return null * @author fanmengzhe * @date 2011/11/10 12:02:48 * @note */ protected static function _initConf() { if (defined('IS_ODP') && true === IS_ODP) { self::$_conf = Bd_Conf::getConf('/passport/'); } else { self::$_conf = Bd_Passport_Inc::$conf; } self::$_isInit = true; }
/** * @brief 从passport.conf读取配置文件 * @param string $strField 'tpl', 'psptoken_key_crypt', 'psptoken_key_csrf' * @return string * @author fanmengzhe */ public static function getConf($strField) { if (!in_array($strField, array('tpl', 'psptoken_key_crypt', 'psptoken_key_csrf'))) { return false; } return Bd_Passport_Conf::getConfEx($strField, false); }
protected function __construct() { self::$_appUser = Bd_Passport_Conf::getConf('app_user'); self::$_appPasswd = Bd_Passport_Conf::getConf('app_passwd'); self::$_encoding = Bd_Passport_Conf::getConfEx('internal_encoding', 'utf8'); if (!in_array(self::$_encoding, array('gbk', 'gb18030', 'utf8'))) { self::$_encoding = 'utf8'; } if (is_null(self::$_appUser) || is_null(self::$_appPasswd)) { Bd_Passport_Log::warning("Invalid app_user or app_passwd.", E_USER_ERROR); } if (!defined('LOG_ID')) { define('LOG_ID', Bd_Passport_Util::getLogId()); } if (!defined('CLIENT_IP')) { define('CLIENT_IP', Bd_Passport_Util::getClientIp()); } }
protected function __construct() { self::$_apid = Bd_Passport_Conf::getConf('apid'); self::$_tpl = Bd_Passport_Conf::getConf('tpl'); self::$_pass = Bd_Passport_Conf::getConf('pass'); self::$_is_orp = intval(Bd_Passport_Conf::getConfEx('is_orp', 0)) === 1 ? true : false; if (is_null(self::$_apid)) { Bd_Passport_Log::warning("Apid for session Not Found!", -1); } if (!defined('LOG_ID')) { define('LOG_ID', Bd_Passport_Util::getLogId()); } if (!defined('CLIENT_IP')) { define('CLIENT_IP', Bd_Passport_Util::getClientIp()); } }