MobileServer.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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_HELPER_PATH . '/fcgisrv/BaseServer.php');
  10. require_once (BASE_ROOT_PATH . '/helper/area_helper.php');
  11. require_once (BASE_CORE_PATH . '/framework/function/http.php');
  12. require_once (BASE_ROOT_PATH . '/mobile/index.php');
  13. require_once (BASE_ROOT_PATH . '/helper/session_helper.php');
  14. require_once(BASE_ROOT_PATH . '/helper/sensitive_word/dfa.php');
  15. require_once(BASE_HELPER_PATH . '/session.php');
  16. require_once (BASE_ROOT_PATH . '/helper/session_helper.php');
  17. require_once(BASE_ROOT_PATH . '/helper/exceptionex.php');
  18. require_once(BASE_MOBILE_PATH . '/util/errcode.php');
  19. use DFAFilter;
  20. use area_helper;
  21. use Log;
  22. use session;
  23. use session_helper;
  24. use Base;
  25. use UnloginException;
  26. use Exception;
  27. use mobileControl;
  28. use errcode;
  29. class MobileServer extends BaseServer
  30. {
  31. static private $stInstance = NULL;
  32. static public function instance()
  33. {
  34. if(self::$stInstance == NULL) {
  35. self::$stInstance = new MobileServer('mobile');
  36. }
  37. return self::$stInstance;
  38. }
  39. public function __construct($subPath)
  40. {
  41. parent::__construct($subPath);
  42. $exfiles = ['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_tianx.php','refill_afand.php'
  50. ];
  51. $this->setExFiles($exfiles);
  52. }
  53. protected function preLooper()
  54. {
  55. parent::preLooper();
  56. DFAFilter::instance();
  57. area_helper::instance();
  58. }
  59. public function handle_req($file)
  60. {
  61. try
  62. {
  63. if(file_exists($file))
  64. {
  65. if(defined('CROSS_DOAMIN') && CROSS_DOAMIN == true) {
  66. $host = 'http://192.168.1.130:3333';
  67. 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");
  68. fcgi_header("Content-Type: text/html; charset=UTF-8");
  69. fcgi_header("Access-Control-Allow-Credentials: true");
  70. fcgi_header("Access-Control-Allow-Origin: {$host}");
  71. fcgi_header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,PATCH');
  72. }
  73. if(self::is_exclude($file)) {
  74. Log::record("Call {$file}",Log::DEBUG);
  75. include $file;
  76. }
  77. else
  78. {
  79. if(!isset($_GET['act'])) {
  80. $_GET['act'] = 'index';
  81. }
  82. if(!isset($_GET['op'])) {
  83. $_GET['op'] = 'index';
  84. }
  85. if(!isset($_POST['act'])) {
  86. $_POST['act'] = 'index';
  87. }
  88. if(!isset($_POST['op'])) {
  89. $_POST['op'] = 'index';
  90. }
  91. //部分控制器不需要使用session.
  92. $act = $_GET['act'];
  93. if($act != 'refill') {
  94. session::instance()->start();
  95. Log::record("member_id=" . session_helper::memberid(),Log::DEBUG);
  96. }
  97. Base::mobile_control();
  98. }
  99. }
  100. else
  101. {
  102. fcgi_header("Content-Type: text/html; charset=UTF-8");
  103. echo "no such file.";
  104. }
  105. }
  106. catch (UnloginException $ex) {
  107. mobileControl::outerr(errcode::ErrUnLogin,errcode::msg(errcode::ErrUnLogin),'','android');
  108. }
  109. catch (Exception $ex) {
  110. mobileControl::outerr($ex->getCode(),$ex->getMessage(),'','android');
  111. Log::record("run_looper exception catch code={$ex->getCode()} msg={$ex->getMessage()} trace={$ex->getTraceAsString()}",Log::ERR);
  112. }
  113. session::instance()->end();
  114. }
  115. }