HomeController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace App\Controllers;
  3. use App\Models\InviteCode;
  4. use App\Models\User;
  5. use App\Models\Code;
  6. use App\Models\Payback;
  7. use App\Models\Paylist;
  8. use App\Services\Auth;
  9. use App\Services\Config;
  10. use App\Utils\Tools;
  11. use App\Utils\Telegram;
  12. use App\Utils\Tuling;
  13. use App\Utils\TelegramSessionManager;
  14. use App\Utils\QRcode;
  15. use App\Utils\Pay;
  16. use App\Utils\TelegramProcess;
  17. use App\Utils\Spay_tool;
  18. /**
  19. * HomeController
  20. */
  21. class HomeController extends BaseController
  22. {
  23. public function index()
  24. {
  25. return $this->view()->display('index.tpl');
  26. }
  27. public function code()
  28. {
  29. $codes = InviteCode::where('user_id', '=', '0')->take(10)->get();
  30. return $this->view()->assign('codes', $codes)->display('code.tpl');
  31. }
  32. public function down()
  33. {
  34. }
  35. public function tos()
  36. {
  37. return $this->view()->display('tos.tpl');
  38. }
  39. public function staff()
  40. {
  41. return $this->view()->display('staff.tpl');
  42. }
  43. public function telegram($request, $response, $args)
  44. {
  45. $token = "";
  46. if (isset($request->getQueryParams()["token"])) {
  47. $token = $request->getQueryParams()["token"];
  48. }
  49. if ($token == Config::get('telegram_request_token')) {
  50. TelegramProcess::process();
  51. } else {
  52. echo("不正确请求!");
  53. }
  54. }
  55. public function page404($request, $response, $args)
  56. {
  57. $pics=scandir(BASE_PATH."/public/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/404/");
  58. if (count($pics)>2) {
  59. $pic=$pics[rand(2, count($pics)-1)];
  60. } else {
  61. $pic="4041.png";
  62. }
  63. $newResponse = $response->withStatus(404);
  64. $newResponse->getBody()->write($this->view()->assign("pic", "/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/404/".$pic)->display('404.tpl'));
  65. return $newResponse;
  66. }
  67. public function page405($request, $response, $args)
  68. {
  69. $pics=scandir(BASE_PATH."/public/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/405/");
  70. if (count($pics)>2) {
  71. $pic=$pics[rand(2, count($pics)-1)];
  72. } else {
  73. $pic="4051.png";
  74. }
  75. $newResponse = $response->withStatus(405);
  76. $newResponse->getBody()->write($this->view()->assign("pic", "/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/405/".$pic)->display('405.tpl'));
  77. return $newResponse;
  78. }
  79. public function page500($request, $response, $args)
  80. {
  81. $pics=scandir(BASE_PATH."/public/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/500/");
  82. if (count($pics)>2) {
  83. $pic=$pics[rand(2, count($pics)-1)];
  84. } else {
  85. $pic="5001.png";
  86. }
  87. $newResponse = $response->withStatus(500);
  88. $newResponse->getBody()->write($this->view()->assign("pic", "/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/500/".$pic)->display('500.tpl'));
  89. return $newResponse;
  90. }
  91. public function pay_callback($request, $response, $args)
  92. {
  93. Pay::callback($request);
  94. }
  95. }