mapi_init_distribution.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. define("CTL",'ctl');
  10. define("ACT",'act');
  11. if(!defined('APP_ROOT_PATH'))
  12. define('APP_ROOT_PATH', str_replace('system/mapi_init_distribution.php', '', str_replace('\\', '/', __FILE__)));
  13. require APP_ROOT_PATH.'system/define.php';
  14. if(IS_DEBUG){
  15. ini_set("display_errors", 1);
  16. error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
  17. }
  18. else
  19. error_reporting(0);
  20. //require APP_ROOT_PATH.'public/directory_init.php';
  21. require_once APP_ROOT_PATH."system/cache/Rediscache/Rediscache.php";
  22. $redisdb = new Rediscache($GLOBALS['distribution_cfg']['RDB_CLIENT'], $GLOBALS['distribution_cfg']['RDB_PORT'],$GLOBALS['distribution_cfg']['RDB_PASSWORD']);
  23. if (PHP_VERSION >= '5.0.0')
  24. {
  25. $begin_run_time = @microtime(true);
  26. }
  27. else
  28. {
  29. $begin_run_time = @microtime();
  30. }
  31. @set_magic_quotes_runtime (0);
  32. define('MAGIC_QUOTES_GPC',get_magic_quotes_gpc()?True:False);
  33. if(!defined('IS_CGI'))
  34. define('IS_CGI',substr(PHP_SAPI, 0,3)=='cgi' ? 1 : 0 );
  35. if(!defined('_PHP_FILE_')) {
  36. if(IS_CGI) {
  37. //CGI/FASTCGI模式下
  38. $_temp = explode('.php',$_SERVER["PHP_SELF"]);
  39. define('_PHP_FILE_', rtrim(str_replace($_SERVER["HTTP_HOST"],'',$_temp[0].'.php'),'/'));
  40. }else {
  41. define('_PHP_FILE_', rtrim($_SERVER["SCRIPT_NAME"],'/'));
  42. }
  43. }
  44. if(!defined('APP_ROOT')) {
  45. // 网站URL根目录
  46. $_root = dirname(_PHP_FILE_);
  47. $_root = (($_root=='/' || $_root=='\\')?'':$_root);
  48. $_root = str_replace("/system","",$_root);
  49. $_root = str_replace("/wap","",$_root);
  50. $_root = str_replace("/mapi","",$_root);
  51. define('APP_ROOT', $_root );
  52. }
  53. //引入时区配置及定义时间函数
  54. if(function_exists('date_default_timezone_set')){
  55. if(app_conf('DEFAULT_TIMEZONE')){
  56. date_default_timezone_set(app_conf('DEFAULT_TIMEZONE'));
  57. }else{
  58. date_default_timezone_set('PRC');
  59. }
  60. }
  61. //引入数据库的系统配置及定义配置函数
  62. require APP_ROOT_PATH.'system/common.php';
  63. define("NOW_TIME",get_gmtime()); //当前UTC时间戳
  64. define("CLIENT_IP",get_client_ip()); //当前客户端IP
  65. define("SITE_DOMAIN",get_domain()); //站点域名
  66. define("TIME_ZONE",app_conf('DEFAULT_TIMEZONE')); //时区
  67. $sys_config = require APP_ROOT_PATH.'system/config.php';
  68. //end 分布式
  69. function app_conf($name)
  70. {
  71. if(isset($GLOBALS['sys_config'][$name])){
  72. return stripslashes($GLOBALS['sys_config'][$name]);
  73. }else{
  74. return false;
  75. }
  76. }
  77. //定义$_SERVER['REQUEST_URI']兼容性
  78. if (!isset($_SERVER['REQUEST_URI']))
  79. {
  80. if (isset($_SERVER['argv']))
  81. {
  82. $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0];
  83. }
  84. else
  85. {
  86. $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
  87. }
  88. $_SERVER['REQUEST_URI'] = $uri;
  89. }
  90. filter_request($_GET);
  91. filter_request($_POST);
  92. //end 引入数据库的系统配置及定义配置函数
  93. require APP_ROOT_PATH.'system/db/db.php';
  94. //es_session::start();
  95. unset($_REQUEST['rewrite_param']);
  96. unset($_GET['rewrite_param']);
  97. require_once APP_ROOT_PATH."system/cache/Rediscache/Rediscache.php";
  98. //定义缓存
  99. require APP_ROOT_PATH."system/cache/CacheRediscacheService.php";
  100. $cache = new CacheRediscacheService(true);
  101. //$cache->celar_con();
  102. //end 定义缓存
  103. //定义DB
  104. define('DB_PREFIX', app_conf('DB_PREFIX'));
  105. if(IS_LONG_LINK){
  106. $pconnect = true;
  107. }else{
  108. $pconnect = false;
  109. }
  110. $db = new mysql_db(app_conf('DB_HOST').":".app_conf('DB_PORT'), app_conf('DB_USER'),app_conf('DB_PWD'),app_conf('DB_NAME'),'utf8',$pconnect);
  111. //end 定义DB
  112. //end 定义模板引擎
  113. $_REQUEST = array_merge($_GET,$_POST);
  114. filter_request($_REQUEST);