index.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // ini_set("memory_limit", "3072M");
  3. require_once './protected/common.php';
  4. header("Cache-control: private");
  5. header("Content-type: text/html; charset=" . DEFAULT_CHARSET);
  6. $helper = new RouterHelper();
  7. $className = $helper->getClassName();
  8. $funcName = $helper->getFunName();
  9. define('CONTROLLER_NAME', $className);
  10. define('ACTION_NAME', $funcName);
  11. $is_ajax = $_GET['_from'] == 'ajax';
  12. $actionName = "action{$funcName}";
  13. // 如果带有doc参数则会转化为文档模式
  14. $helper->genDoc($className, $actionName);
  15. if (class_exists($className)) {
  16. $oClass = new $className();
  17. } else {
  18. $msg = "class {$className} is not exist.";
  19. if ($is_ajax) {
  20. $helper->error($actionName, $msg);
  21. } else {
  22. $objBaseController = new BaseController(true);
  23. $objBaseController->go404();
  24. }
  25. }
  26. if (method_exists($oClass, $actionName)) {
  27. $args = $_REQUEST;
  28. $data = $oClass->$actionName($args);
  29. Response::success($data);
  30. } else {
  31. $msg = "method {$actionName} is not exist.";
  32. if ($is_ajax) {
  33. $helper->error($actionName, $msg);
  34. } else {
  35. $objBaseController = new BaseController(true);
  36. $objBaseController->go404();
  37. }
  38. }