config.php 3.4 KB

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