MobileServer.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. private $dir_name = 'callback';
  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 = [
  43. 'web_wxnotify.php',
  44. 'wxnotify.php','pub_wxnotify.php','alipay_notify_url.php','dispatch_notify.php','kdniao_notify.php',
  45. 'cmbpay_notify.php','cmbpay_sign.php','wxauthor.php','api/wxLogin/index.php','api/wxLogin/callback.php',
  46. 'signature.php',
  47. 'refill_tianjt.php','refill_suhctm.php','refill_suhcpdd.php','refill_gftd.php',
  48. 'refill_beixt.php','refill_bxtwt.php','refill_bjb.php','refill_xyz.php',
  49. 'refill_zzx.php','refill_inner.php','refill_jiec.php','refill_yifa.php',
  50. 'bridge_shr.php','refill_weit.php','refill_afand.php','refill_afandeng.php',
  51. 'refill_afandnew.php','refill_lingzh.php','refill_lingzhdl.php','refill_tongy.php',
  52. 'refill_weiyi.php','refill_tonglu.php','refill_xc.php','refill_xunyin.php',
  53. 'refill_yunling.php','refill_wantong.php','refill_zhongst.php',
  54. 'refill_luqian.php','refill_afandfs.php','refill_yunlingfs.php',
  55. 'refill_tiancheng.php','refill_xunao.php','refill_weiyiman.php'
  56. ];
  57. $this->setExFiles($exfiles);
  58. }
  59. protected function is_exclude($file)
  60. {
  61. $ret = parent::is_exclude($file);
  62. if ($ret) {
  63. return true;
  64. } else {
  65. $path = BASE_ROOT_PATH . "/" . $this->mSubPath . "/callback";
  66. $basename = basename($file);
  67. $tmp = "{$path}/{$basename}";
  68. return file_exists($tmp);
  69. }
  70. }
  71. protected function preLooper()
  72. {
  73. parent::preLooper();
  74. DFAFilter::instance();
  75. area_helper::instance();
  76. }
  77. public function handle_req($file)
  78. {
  79. try
  80. {
  81. if(file_exists($file))
  82. {
  83. if($this->is_exclude($file)) {
  84. Log::record("Call {$file}",Log::DEBUG);
  85. include $file;
  86. }
  87. elseif(defined('COMPANY_NAME') && COMPANY_NAME === 'XYZ_COMPANY')
  88. {
  89. //部分控制器不需要使用session.
  90. $act = $_GET['act'];
  91. if ($act == 'refill') {
  92. Base::mobile_control();
  93. } else {
  94. fcgi_header("Content-Type: text/html; charset=UTF-8");
  95. echo "no such file.";
  96. }
  97. session::instance()->end(false);
  98. }
  99. else
  100. {
  101. if(!isset($_GET['act'])) {
  102. $_GET['act'] = 'index';
  103. }
  104. if(!isset($_GET['op'])) {
  105. $_GET['op'] = 'index';
  106. }
  107. if(!isset($_POST['act'])) {
  108. $_POST['act'] = 'index';
  109. }
  110. if(!isset($_POST['op'])) {
  111. $_POST['op'] = 'index';
  112. }
  113. //部分控制器不需要使用session.
  114. $act = $_GET['act'];
  115. if($act != 'refill') {
  116. session::instance()->start();
  117. Log::record("member_id=" . session_helper::memberid(),Log::DEBUG);
  118. }
  119. Base::mobile_control();
  120. session::instance()->end(true);
  121. }
  122. }
  123. else
  124. {
  125. Log::record("Can Not call file: {$file}",Log::DEBUG);
  126. fcgi_header("Content-Type: text/html; charset=UTF-8");
  127. echo "no such file.";
  128. }
  129. }
  130. catch (UnloginException $ex) {
  131. mobileControl::outerr(errcode::ErrUnLogin,errcode::msg(errcode::ErrUnLogin),'','android');
  132. }
  133. catch (Exception $ex) {
  134. mobileControl::outerr($ex->getCode(),$ex->getMessage(),'','android');
  135. Log::record("run_looper exception catch code={$ex->getCode()} msg={$ex->getMessage()} trace={$ex->getTraceAsString()}",Log::ERR);
  136. }
  137. }
  138. }