123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace loyalsoft;
- /**
- * Description of config
- * 尝试用这种写法来定义服务器配置
- * @author gwang (email: mail@wanggangzero.cn)
- * @copyright © 2015-2-3, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
- abstract class config {
- protected $testerArr; # 测试号数组
- protected $banedArr; # 封号数组
- public $paydb; # mysql配置
- public $nosql; # nosql配置
- public $stat; # 统计配置
- public $mongo; # MongoDB配置
- /**
- * CDN地址 (没有写继承是因为暂时没有特殊逻辑)
- * @return type
- */
- public static function CDN_host() {
- return "https://loyalsoft.oss-cn-shanghai.aliyuncs.com" . "/jzhj2023/" . PLAT;
- }
- /**
- * 测试号
- * @param string $uid
- * @return bool
- */
- function isTester($uid) {
- return in_array($uid, $this->testerArr);
- }
- /**
- * 封号
- * @param string $uid
- */
- function isBaned($uid) {
- return in_array($uid, $this->banedArr);
- }
- // 测试号
- abstract protected function _InitTester();
- // 封号
- abstract protected function _InitBaneder();
- /**
- * 初始化paydb
- */
- abstract protected function _InitPaydb();
- /**
- * redis配置
- */
- abstract protected function _InitNosql();
- /**
- * mongodb配置
- */
- abstract protected function _InitMongoDB();
- /**
- * @return config 单例
- */
- static public function Inst() {
- static $config = null;
- if (is_null($config)) {
- $config = include __DIR__ . '/configs/config_' . PLAT . '.php';
- }
- return $config;
- }
- /**
- * 构造函数负责初始化配置数据
- */
- private function __construct() {
- $this->_InitTester(); # 测试用户
- $this->_InitBaneder(); # 封号用户
- $this->paydb = new \stdclass();
- $this->paydb->persistant = false; # 持久链接 or not.
- $this->paydb->driver = 'mysql'; # Must be MySQL. Don't support other database server yet.
- $this->paydb->encoding = 'UTF8'; # Encoding of database.
- $this->paydb->strictMode = false; # Turn off the strict mode of MySQL.
- // $this->paydb->emulatePrepare = true; # PDO::ATTR_EMULATE_PREPARES
- // $this->paydb->bufferQuery = true; # PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
- $this->paydb->prefix = ''; # 表前缀
- $this->_InitPaydb(); # mysql数据库配置
- $this->nosql = new \stdClass();
- $this->_InitNosql(); # nosql数据库配置
- $this->mongo = new \stdClass();
- $this->_InitMongoDB(); # mongodb
- }
- }
|