MobileServer.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 16/3/10
  6. * Time: 下午9:08
  7. */
  8. namespace fcgisrv;
  9. require_once(BASE_ROOT_PATH . '/helper/area_helper.php');
  10. require_once(BASE_CORE_PATH . '/framework/function/http.php');
  11. require_once(BASE_ROOT_PATH . '/mobile/index.php');
  12. require_once(BASE_ROOT_PATH . '/helper/session_helper.php');
  13. require_once(BASE_ROOT_PATH . '/helper/sensitive_word/dfa.php');
  14. require_once(BASE_ROOT_PATH . '/helper/exceptionex.php');
  15. require_once(BASE_ROOT_PATH . '/helper/session_helper.php');
  16. require_once(BASE_HELPER_PATH . '/fcgisrv/BaseServer.php');
  17. require_once(BASE_HELPER_PATH . '/session.php');
  18. use DFAFilter;
  19. use area_helper;
  20. use Log;
  21. use session;
  22. use session_helper;
  23. use Base;
  24. use UnloginException;
  25. use Exception;
  26. use mobileControl;
  27. use errcode;
  28. class MobileServer extends BaseServer
  29. {
  30. static private $stInstance = NULL;
  31. static public function instance()
  32. {
  33. if(self::$stInstance == NULL) {
  34. self::$stInstance = new MobileServer('mobile');
  35. }
  36. return self::$stInstance;
  37. }
  38. public function __construct($subPath)
  39. {
  40. parent::__construct($subPath);
  41. $exfiles = [
  42. 'web_wxnotify.php',
  43. 'wxnotify.php','pub_wxnotify.php','alipay_notify_url.php','dispatch_notify.php','kdniao_notify.php',
  44. 'cmbpay_notify.php','cmbpay_sign.php','wxauthor.php','api/wxLogin/index.php','api/wxLogin/callback.php',
  45. 'signature.php',
  46. 'refill_tianjt.php','refill_suhctm.php','refill_suhcpdd.php','refill_gftd.php',
  47. 'refill_beixt.php','refill_bxtwt.php','refill_bjb.php','refill_xyz.php',
  48. 'refill_zzx.php','refill_inner.php','refill_jiec.php','refill_yifa.php',
  49. 'bridge_shr.php','refill_weit.php','refill_afand.php','refill_afandeng.php',
  50. 'refill_afandnew.php','refill_lingzh.php','refill_lingzhdl.php','refill_tongy.php',
  51. 'refill_weiyi.php','refill_tonglu.php','refill_xc.php','refill_xunyin.php',
  52. 'refill_yunling.php','refill_wantong.php','refill_zhongst.php',
  53. 'refill_luqian.php','refill_afandfs.php','refill_yunlingfs.php',
  54. 'refill_tiancheng.php','refill_xunao.php','refill_weiyiman.php'
  55. ];
  56. $this->setExFiles($exfiles);
  57. }
  58. protected function preLooper()
  59. {
  60. parent::preLooper();
  61. DFAFilter::instance();
  62. area_helper::instance();
  63. }
  64. public function handle_req($file)
  65. {
  66. try
  67. {
  68. if(file_exists($file))
  69. {
  70. if(defined('CROSS_DOAMIN') && CROSS_DOAMIN == true) {
  71. $host = 'http://192.168.1.130:3333';
  72. fcgi_header("Access-Control-Allow-Headers:DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept-Language, Origin, Accept-Encoding");
  73. fcgi_header("Content-Type: text/html; charset=UTF-8");
  74. fcgi_header("Access-Control-Allow-Credentials: true");
  75. fcgi_header("Access-Control-Allow-Origin: {$host}");
  76. fcgi_header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,PATCH');
  77. }
  78. if($this->is_exclude($file)) {
  79. Log::record("Call {$file}",Log::DEBUG);
  80. include $file;
  81. }
  82. else
  83. {
  84. if(!isset($_GET['act'])) {
  85. $_GET['act'] = 'index';
  86. }
  87. if(!isset($_GET['op'])) {
  88. $_GET['op'] = 'index';
  89. }
  90. if(!isset($_POST['act'])) {
  91. $_POST['act'] = 'index';
  92. }
  93. if(!isset($_POST['op'])) {
  94. $_POST['op'] = 'index';
  95. }
  96. //部分控制器不需要使用session.
  97. $act = $_GET['act'];
  98. if($act != 'refill') {
  99. session::instance()->start();
  100. Log::record("member_id=" . session_helper::memberid(),Log::DEBUG);
  101. }
  102. Base::mobile_control();
  103. }
  104. }
  105. else
  106. {
  107. Log::record("Can Not call file: {$file}",Log::DEBUG);
  108. fcgi_header("Content-Type: text/html; charset=UTF-8");
  109. echo "no such file.";
  110. }
  111. }
  112. catch (UnloginException $ex) {
  113. mobileControl::outerr(errcode::ErrUnLogin,errcode::msg(errcode::ErrUnLogin),'','android');
  114. }
  115. catch (Exception $ex) {
  116. mobileControl::outerr($ex->getCode(),$ex->getMessage(),'','android');
  117. Log::record("run_looper exception catch code={$ex->getCode()} msg={$ex->getMessage()} trace={$ex->getTraceAsString()}",Log::ERR);
  118. }
  119. session::instance()->end();
  120. }
  121. }