Guest User

Untitled

a guest
Jul 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. public function dispatchAppServer($context) {
  3.  
  4. $_ENV = $_SERVER = $context['env'];
  5.  
  6. @parse_str($_ENV['QUERY_STRING'], $_GET);
  7.  
  8. $_GET['ak'] = $_ENV['PATH_INFO'];
  9.  
  10. Ak::unsetStaticVar('AkRequestSingleton');
  11. Ak::unsetStaticVar('AkRouterSingleton');
  12. Ak::unsetStaticVar('AkUrlWriterSingleton');
  13. AkConfig::setOption('Request.remote_ip', '127.0.0.1');
  14.  
  15. try{
  16. $this->Request = AkRequest::getInstance();
  17. $this->Response = new AkResponse();
  18.  
  19. $path = ltrim(str_replace('..', '.', $context['env']['REQUEST_URI']), '/. ');
  20.  
  21. if(!empty($path) && file_exists(AK_PUBLIC_DIR.DS.$path)){
  22. $Controller = new AkActionController();
  23. $Controller->Response = $this->Response;
  24. $Controller->sendFile(AK_PUBLIC_DIR.DS.$path, array('stream'=>false));
  25. return $Controller->Response;
  26. }else{
  27. if($this->Controller = $this->Request->recognize()){
  28. $this->Controller->process($this->Request, $this->Response);
  29. }
  30. return $this->Response;
  31. }
  32. }catch(Exception $e){
  33. if(isset($this->Controller) && method_exists($this->Controller, 'render_error')){
  34. $this->Controller->render_error($e);
  35. }else{
  36. $ExceptionDispatcher = new AkExceptionDispatcher();
  37. $ExceptionDispatcher->renderException($e);
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment