MobileServer.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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','innercb.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. 'rbridge_fulu.php'
  57. ];
  58. $this->setExFiles($exfiles);
  59. }
  60. protected function is_exclude($file)
  61. {
  62. $exister = function ($file,$subex)
  63. {
  64. $path = BASE_ROOT_PATH . "/" . $this->mSubPath . "/{$subex}";
  65. $basename = basename($file);
  66. $tmp = "{$path}/{$basename}";
  67. return file_exists($tmp);
  68. };
  69. $ret = parent::is_exclude($file);
  70. if ($ret) {
  71. return true;
  72. } elseif ($exister($file,'callback')) {
  73. return true;
  74. } elseif ($exister($file,'bridge')) {
  75. return true;
  76. } else {
  77. return false;
  78. }
  79. }
  80. protected function preLooper()
  81. {
  82. parent::preLooper();
  83. DFAFilter::instance();
  84. area_helper::instance();
  85. }
  86. public function handle_req($file)
  87. {
  88. try
  89. {
  90. fcgi_header("Content-Type: text/html; charset=UTF-8");
  91. if(file_exists($file))
  92. {
  93. if($this->is_exclude($file)) {
  94. Log::record("Call {$file}",Log::DEBUG);
  95. include $file;
  96. }
  97. elseif(defined('COMPANY_NAME') && in_array(COMPANY_NAME,['XYZ_COMPANY','ZY_COMPANY']))
  98. {
  99. //部分控制器不需要使用session.
  100. $act = $_GET['act'];
  101. if ($act == 'refill') {
  102. Base::mobile_control();
  103. } else {
  104. echo "no such file.";
  105. }
  106. session::instance()->end(false);
  107. }
  108. else
  109. {
  110. if(!isset($_GET['act'])) {
  111. $_GET['act'] = 'index';
  112. }
  113. if(!isset($_GET['op'])) {
  114. $_GET['op'] = 'index';
  115. }
  116. if(!isset($_POST['act'])) {
  117. $_POST['act'] = 'index';
  118. }
  119. if(!isset($_POST['op'])) {
  120. $_POST['op'] = 'index';
  121. }
  122. //部分控制器不需要使用session.
  123. $act = $_GET['act'];
  124. if($act != 'refill') {
  125. session::instance()->start();
  126. Log::record("member_id=" . session_helper::memberid(),Log::DEBUG);
  127. }
  128. Base::mobile_control();
  129. session::instance()->end(true);
  130. }
  131. }
  132. else
  133. {
  134. Log::record("Can Not call file: {$file}",Log::DEBUG);
  135. echo "no such file.";
  136. }
  137. }
  138. catch (UnloginException $ex) {
  139. mobileControl::outerr(errcode::ErrUnLogin,errcode::msg(errcode::ErrUnLogin),'','android');
  140. }
  141. catch (Exception $ex) {
  142. mobileControl::outerr($ex->getCode(),$ex->getMessage(),'','android');
  143. Log::record("run_looper exception catch code={$ex->getCode()} msg={$ex->getMessage()} trace={$ex->getTraceAsString()}",Log::ERR);
  144. }
  145. }
  146. }