IndexController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Module\Base;
  4. use Request;
  5. /**
  6. * 页面
  7. * Class IndexController
  8. * @package App\Http\Controllers
  9. */
  10. class IndexController extends Controller
  11. {
  12. private $version = '10161';
  13. public function __invoke($method, $action = '', $child = '', $name = '')
  14. {
  15. $app = $method ? $method : 'main';
  16. if ($app == 'uploads') {
  17. $child = $action . '/' . $child . '/' . $name;
  18. $action = '';
  19. }
  20. if ($action) {
  21. $app .= "__" . $action;
  22. }
  23. return (method_exists($this, $app)) ? $this->$app($child) : Base::ajaxError("404 not found (" . str_replace("__", "/", $app) . ").");
  24. }
  25. /**
  26. * 获取IP地址
  27. * @return array|mixed
  28. */
  29. public function get__ip() {
  30. return Base::getIp();
  31. }
  32. /**
  33. * 是否中国IP地址
  34. * @return array|mixed
  35. */
  36. public function get__cnip() {
  37. return Base::isCnIp(Request::input('ip'));
  38. }
  39. /**
  40. * 获取IP地址详细信息
  41. * @return array|mixed
  42. */
  43. public function get__ipinfo() {
  44. return Base::getIpInfo(Request::input("ip"));
  45. }
  46. /**
  47. * 首页
  48. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  49. */
  50. public function main()
  51. {
  52. return view('main', ['version' => $this->version]);
  53. }
  54. /**
  55. * 清理opcache数据
  56. * @return int
  57. */
  58. public function opcache__reset()
  59. {
  60. opcache_reset();
  61. return Base::time();
  62. }
  63. }