fcgi_run.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. define('BASE_ROOT_PATH',str_replace('\\','/',dirname(__FILE__)));
  3. define('MOBILE_SERVER',true);
  4. require_once (BASE_ROOT_PATH . '/fooder.php');
  5. function pays_execute($file)
  6. {
  7. static $exfiles = array('wxnotify.php','alipay_notify_url.php');
  8. $name = basename($file);
  9. return in_array($name,$exfiles);
  10. }
  11. function run_fcgi()
  12. {
  13. require_once(BASE_ROOT_PATH.'/mobile/index.php');
  14. Base::mobile_init();
  15. while(($ret = fcgi_accept()) >= 0)
  16. {
  17. ob_start();
  18. define('StartTime',microtime(true));
  19. define('TIMESTAMP',time());
  20. try
  21. {
  22. init_request();
  23. Log::record(request_helper::req_uri(),Log::DEBUG);
  24. $file = request_helper::script_file();
  25. if(file_exists($file))
  26. {
  27. if(pays_execute($file)) {
  28. echo("Content-Type: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8; charset=UTF-8\r\n\r\n");
  29. include $file;
  30. } else {
  31. echo("Content-Type: text/html; charset=UTF-8\r\n\r\n");
  32. Base::mobile_control();
  33. }
  34. }
  35. } catch (Exception $ex) {
  36. joutput_error($ex->getCode(),$ex->getMessage().'@@@@@'.$ex->getTraceAsString());
  37. }
  38. $contents = ob_get_clean();
  39. fcgi_echo($contents);
  40. Log::record($contents,Log::DEBUG);
  41. fcgi_finish();
  42. }
  43. fcgi_fini();
  44. }
  45. run_fcgi();
  46. ?>