MobileServer.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. else
  88. {
  89. //部分控制器不需要使用session.
  90. if(defined('COMPANY_NAME') && COMPANY_NAME === 'XYZ_COMPANY')
  91. {
  92. $act = $_GET['act'];
  93. if ($act == 'refill') {
  94. Base::mobile_control();
  95. } else {
  96. fcgi_header("Content-Type: text/html; charset=UTF-8");
  97. echo "no such file.";
  98. }
  99. session::instance()->end(false);
  100. }
  101. else
  102. {
  103. if(!isset($_GET['act'])) {
  104. $_GET['act'] = 'index';
  105. }
  106. if(!isset($_GET['op'])) {
  107. $_GET['op'] = 'index';
  108. }
  109. if(!isset($_POST['act'])) {
  110. $_POST['act'] = 'index';
  111. }
  112. if(!isset($_POST['op'])) {
  113. $_POST['op'] = 'index';
  114. }
  115. //部分控制器不需要使用session.
  116. $act = $_GET['act'];
  117. if($act != 'refill') {
  118. session::instance()->start();
  119. Log::record("member_id=" . session_helper::memberid(),Log::DEBUG);
  120. }
  121. Base::mobile_control();
  122. session::instance()->end(true);
  123. }
  124. }
  125. }
  126. else
  127. {
  128. Log::record("Can Not call file: {$file}",Log::DEBUG);
  129. fcgi_header("Content-Type: text/html; charset=UTF-8");
  130. echo "no such file.";
  131. }
  132. }
  133. catch (UnloginException $ex) {
  134. mobileControl::outerr(errcode::ErrUnLogin,errcode::msg(errcode::ErrUnLogin),'','android');
  135. }
  136. catch (Exception $ex) {
  137. mobileControl::outerr($ex->getCode(),$ex->getMessage(),'','android');
  138. Log::record("run_looper exception catch code={$ex->getCode()} msg={$ex->getMessage()} trace={$ex->getTraceAsString()}",Log::ERR);
  139. }
  140. }
  141. }