config.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace loyalsoft;
  3. //use \GAME_ONLINE;
  4. /**
  5. * Description of config
  6. * 尝试用这种写法来定义服务器配置
  7. * @author gwang (email: mail@wanggangzero.cn)
  8. * @copyright © 2015-2-3, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  9. */
  10. abstract class config {
  11. protected $testerArr; # 测试号数组
  12. protected $banedArr; # 封号数组
  13. public $paydb; # mysql配置
  14. public $nosql; # nosql配置
  15. public $stat; # 统计配置
  16. public $mongo; # MongoDB配置
  17. /**
  18. * CDN地址 (没有写继承是因为暂时没有特殊逻辑)
  19. * @return type
  20. */
  21. public static function CDN_host() {
  22. return "https://loyalsoft.oss-cn-shanghai.aliyuncs.com" . "/ylsj/" . PLAT;
  23. }
  24. /**
  25. * 测试号
  26. * @param string $uid
  27. * @return bool
  28. */
  29. function isTester($uid) {
  30. return in_array($uid, $this->testerArr);
  31. }
  32. /**
  33. * 封号
  34. * @param string $uid
  35. */
  36. function isBaned($uid) {
  37. return in_array($uid, $this->banedArr);
  38. }
  39. // 测试号
  40. abstract protected function _InitTester();
  41. // 封号
  42. abstract protected function _InitBaneder();
  43. /**
  44. * 初始化paydb
  45. */
  46. abstract protected function _InitPaydb();
  47. /**
  48. * redis配置
  49. */
  50. abstract protected function _InitNosql();
  51. /**
  52. * mongodb配置
  53. */
  54. abstract protected function _InitMongoDB();
  55. /**
  56. * @return config 单例
  57. */
  58. static public function Inst() {
  59. static $config = null;
  60. if (is_null($config)) {
  61. $config = include __DIR__ . '/configs/config_' . PLAT . '.php';
  62. }
  63. return $config;
  64. }
  65. /**
  66. * 构造函数负责初始化配置数据
  67. */
  68. private function __construct() {
  69. $this->_InitTester(); # 测试用户
  70. $this->_InitBaneder(); # 封号用户
  71. $this->paydb = new \stdclass();
  72. $this->paydb->persistant = false; # 持久链接 or not.
  73. $this->paydb->driver = 'mysql'; # Must be MySQL. Don't support other database server yet.
  74. $this->paydb->encoding = 'UTF8'; # Encoding of database.
  75. $this->paydb->strictMode = false; # Turn off the strict mode of MySQL.
  76. // $this->paydb->emulatePrepare = true; # PDO::ATTR_EMULATE_PREPARES
  77. // $this->paydb->bufferQuery = true; # PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
  78. $this->paydb->prefix = ''; # 表前缀
  79. $this->_InitPaydb(); # mysql数据库配置
  80. $this->nosql = new \stdClass();
  81. $this->_InitNosql(); # nosql数据库配置
  82. $this->mongo = new \stdClass();
  83. $this->_InitMongoDB(); # mongodb
  84. }
  85. }