MobileServer.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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'
  53. ];
  54. $this->setExFiles($exfiles);
  55. }
  56. protected function preLooper()
  57. {
  58. parent::preLooper();
  59. DFAFilter::instance();
  60. area_helper::instance();
  61. }
  62. public function handle_req($file)
  63. {
  64. try
  65. {
  66. if(file_exists($file))
  67. {
  68. if(defined('CROSS_DOAMIN') && CROSS_DOAMIN == true) {
  69. $host = 'http://192.168.1.130:3333';
  70. 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");
  71. fcgi_header("Content-Type: text/html; charset=UTF-8");
  72. fcgi_header("Access-Control-Allow-Credentials: true");
  73. fcgi_header("Access-Control-Allow-Origin: {$host}");
  74. fcgi_header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,PATCH');
  75. }
  76. if($this->is_exclude($file)) {
  77. Log::record("Call {$file}",Log::DEBUG);
  78. include $file;
  79. }
  80. else
  81. {
  82. if(!isset($_GET['act'])) {
  83. $_GET['act'] = 'index';
  84. }
  85. if(!isset($_GET['op'])) {
  86. $_GET['op'] = 'index';
  87. }
  88. if(!isset($_POST['act'])) {
  89. $_POST['act'] = 'index';
  90. }
  91. if(!isset($_POST['op'])) {
  92. $_POST['op'] = 'index';
  93. }
  94. //部分控制器不需要使用session.
  95. $act = $_GET['act'];
  96. if($act != 'refill') {
  97. session::instance()->start();
  98. Log::record("member_id=" . session_helper::memberid(),Log::DEBUG);
  99. }
  100. Base::mobile_control();
  101. }
  102. }
  103. else
  104. {
  105. Log::record("Can Not call file: {$file}",Log::DEBUG);
  106. fcgi_header("Content-Type: text/html; charset=UTF-8");
  107. echo "no such file.";
  108. }
  109. }
  110. catch (UnloginException $ex) {
  111. mobileControl::outerr(errcode::ErrUnLogin,errcode::msg(errcode::ErrUnLogin),'','android');
  112. }
  113. catch (Exception $ex) {
  114. mobileControl::outerr($ex->getCode(),$ex->getMessage(),'','android');
  115. Log::record("run_looper exception catch code={$ex->getCode()} msg={$ex->getMessage()} trace={$ex->getTraceAsString()}",Log::ERR);
  116. }
  117. session::instance()->end();
  118. }
  119. }