123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- namespace loyalsoft;
- //use \GAME_ONLINE;
- /**
- * 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配置
- /**
- * 测试号
- * @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 _InitOuterNetPaydb();
- // 初始化外网nosql设置
- abstract protected function _InitOuterNetNosql();
- // 初始化外网MongoDB设置
- abstract protected function _InitOuterMongoDB();
- /**
- * 初始化内网paydb的设置
- */
- private function _InitIntranetPaydb() {
- $this->paydb->host = '192.168.10.16';
- $this->paydb->port = '3306';
- $this->paydb->name = 'ylsj2019_pay';
- $this->paydb->user = 'gwang';
- $this->paydb->password = 'wanggang1985';
- // todo: Ps. 可以设置从库, 主从架构, 主库写入, 从库查询
- }
- /**
- * 初始化paydb
- */
- private function _InitPaydb() {
- $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 = ''; # 表前缀
- if (GAME_ONLINE) { # 外网版的paydb配置
- $this->_InitOuterNetPaydb();
- } else { # 内网版的paydb配置
- $this->_InitIntranetPaydb();
- }
- }
- private function _InitNosql() {
- $this->nosql = new \stdClass();
- if (GAME_ONLINE) { # 外网 配置
- $this->_InitOuterNetNosql();
- } else { # 内网
- $this->nosql->host = '192.168.10.16'; # host/ip
- $this->nosql->port = 6004; # 端口
- $this->nosql->pwd = 'wanggang1985'; # 密钥
- $this->nosql->db = 0; # db索引
- }
- }
- private function _InitMongoDB() {
- $this->mongo = new \stdClass();
- if (GAME_ONLINE) {
- $this->_InitOuterMongoDB();
- } else {
- // $this->mongodb = "mongodb://ylsjMTY0LjkyLjE5NC4x:wanggang1985@192.168.10.16:27017/?authSource=ylsj2019";
- $this->mongo->db = "ylsj2019_TTT";
- $this->mongo->conn = "mongodb://ylsjMTY0LjkyLjE5NC4x:wanggang1985@192.168.10.16:27017/?authSource=ylsj2019";
- }
- }
- private function _InitStatSettings() {
- $stat = new \stdClass(); # 对象初始化
- $stat->usernumber = true; # 玩家数量
- $stat->cmd = true; # 操作记录
- }
- /**
- * @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->_InitPaydb(); # mysql数据库配置
- $this->_InitNosql(); # nosql数据库配置
- $this->_InitStatSettings(); # 统计配置
- $this->_InitMongoDB(); # mongodb
- }
- }
|