routes.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <?php
  2. use Slim\Container;
  3. use App\Middleware\Auth;
  4. use App\Middleware\Guest;
  5. use App\Middleware\Admin;
  6. use App\Middleware\Api;
  7. use App\Middleware\Mu;
  8. use App\Middleware\Mod_Mu;
  9. use Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware;
  10. $configuration = [
  11. 'settings' => [
  12. 'debug' => DEBUG,
  13. 'whoops.editor' => 'sublime',
  14. 'displayErrorDetails' => DEBUG
  15. ]
  16. ];
  17. $container = new Container($configuration);
  18. // Init slim php view
  19. $container['renderer'] = static function ($c) {
  20. return new Slim\Views\PhpRenderer();
  21. };
  22. $container['notFoundHandler'] = static function ($c) {
  23. return static function ($request, $response) use ($c) {
  24. return $response->withAddedHeader('Location', '/404');
  25. };
  26. };
  27. $container['notAllowedHandler'] = static function ($c) {
  28. return static function ($request, $response, $methods) use ($c) {
  29. return $response->withAddedHeader('Location', '/405');
  30. };
  31. };
  32. if (DEBUG == false) {
  33. $container['errorHandler'] = static function ($c) {
  34. return static function ($request, $response, $exception) use ($c) {
  35. return $response->withAddedHeader('Location', '/500');
  36. };
  37. };
  38. }
  39. $app = new Slim\App($container);
  40. $app->add(new WhoopsMiddleware());
  41. // Home
  42. $app->post('/spay_back', App\Services\Payment::class . ':notify');
  43. $app->get('/spay_back', App\Services\Payment::class . ':notify');
  44. $app->get('/', App\Controllers\HomeController::class . ':index');
  45. $app->get('/indexold', App\Controllers\HomeController::class . ':indexold');
  46. $app->get('/404', App\Controllers\HomeController::class . ':page404');
  47. $app->get('/405', App\Controllers\HomeController::class . ':page405');
  48. $app->get('/500', App\Controllers\HomeController::class . ':page500');
  49. $app->post('/notify', App\Controllers\HomeController::class . ':notify');
  50. $app->get('/tos', App\Controllers\HomeController::class . ':tos');
  51. $app->get('/staff', App\Controllers\HomeController::class . ':staff');
  52. $app->post('/telegram_callback', App\Controllers\HomeController::class . ':telegram');
  53. $app->post('/tomato_back/{type}', 'App\Services\Payment:notify');
  54. $app->get('/tomato_back/{type}', 'App\Services\Payment:notify');
  55. // User Center
  56. $app->group('/user', function () {
  57. $this->get('', App\Controllers\UserController::class . ':index');
  58. $this->get('/', App\Controllers\UserController::class . ':index');
  59. $this->post('/checkin', App\Controllers\UserController::class . ':doCheckin');
  60. $this->get('/node', App\Controllers\UserController::class . ':node');
  61. $this->get('/tutorial', App\Controllers\UserController::class . ':tutorial');
  62. $this->get('/announcement', App\Controllers\UserController::class . ':announcement');
  63. $this->get('/donate', App\Controllers\UserController::class . ':donate');
  64. $this->get('/lookingglass', App\Controllers\UserController::class . ':lookingglass');
  65. $this->get('/node/{id}', App\Controllers\UserController::class . ':nodeInfo');
  66. $this->get('/node/{id}/ajax', App\Controllers\UserController::class . ':nodeAjax');
  67. $this->get('/profile', App\Controllers\UserController::class . ':profile');
  68. $this->get('/invite', App\Controllers\UserController::class . ':invite');
  69. $this->get('/detect', App\Controllers\UserController::class . ':detect_index');
  70. $this->get('/detect/log', App\Controllers\UserController::class . ':detect_log');
  71. $this->get('/disable', App\Controllers\UserController::class . ':disable');
  72. $this->get('/shop', App\Controllers\UserController::class . ':shop');
  73. $this->post('/coupon_check', App\Controllers\UserController::class . ':CouponCheck');
  74. $this->post('/buy', App\Controllers\UserController::class . ':buy');
  75. // Relay Mange
  76. $this->get('/relay', App\Controllers\RelayController::class . ':index');
  77. $this->get('/relay/create', App\Controllers\RelayController::class . ':create');
  78. $this->post('/relay', App\Controllers\RelayController::class . ':add');
  79. $this->get('/relay/{id}/edit', App\Controllers\RelayController::class . ':edit');
  80. $this->put('/relay/{id}', App\Controllers\RelayController::class . ':update');
  81. $this->delete('/relay', App\Controllers\RelayController::class . ':delete');
  82. $this->get('/ticket', App\Controllers\UserController::class . ':ticket');
  83. $this->get('/ticket/create', App\Controllers\UserController::class . ':ticket_create');
  84. $this->post('/ticket', App\Controllers\UserController::class . ':ticket_add');
  85. $this->get('/ticket/{id}/view', App\Controllers\UserController::class . ':ticket_view');
  86. $this->put('/ticket/{id}', App\Controllers\UserController::class . ':ticket_update');
  87. $this->post('/buy_invite', App\Controllers\UserController::class . ':buyInvite');
  88. $this->post('/custom_invite', App\Controllers\UserController::class . ':customInvite');
  89. $this->get('/edit', App\Controllers\UserController::class . ':edit');
  90. $this->post('/password', App\Controllers\UserController::class . ':updatePassword');
  91. $this->post('/wechat', App\Controllers\UserController::class . ':updateWechat');
  92. $this->post('/ssr', App\Controllers\UserController::class . ':updateSSR');
  93. $this->post('/theme', App\Controllers\UserController::class . ':updateTheme');
  94. $this->post('/mail', App\Controllers\UserController::class . ':updateMail');
  95. $this->post('/sspwd', App\Controllers\UserController::class . ':updateSsPwd');
  96. $this->post('/method', App\Controllers\UserController::class . ':updateMethod');
  97. $this->post('/hide', App\Controllers\UserController::class . ':updateHide');
  98. $this->get('/sys', App\Controllers\UserController::class . ':sys');
  99. $this->get('/trafficlog', App\Controllers\UserController::class . ':trafficLog');
  100. $this->get('/kill', App\Controllers\UserController::class . ':kill');
  101. $this->post('/kill', App\Controllers\UserController::class . ':handleKill');
  102. $this->get('/logout', App\Controllers\UserController::class . ':logout');
  103. $this->get('/backtoadmin', App\Controllers\UserController::class . ':backtoadmin');
  104. $this->get('/code', App\Controllers\UserController::class . ':code');
  105. $this->get('/alipay', App\Controllers\UserController::class . ':alipay');
  106. $this->post('/code/f2fpay', App\Services\Payment::class . ':purchase');
  107. $this->get('/code/codepay', App\Services\Payment::class . ':purchase');
  108. $this->get('/code_check', App\Controllers\UserController::class . ':code_check');
  109. $this->post('/code', App\Controllers\UserController::class . ':codepost');
  110. $this->post('/gacheck', App\Controllers\UserController::class . ':GaCheck');
  111. $this->post('/gaset', App\Controllers\UserController::class . ':GaSet');
  112. $this->get('/gareset', App\Controllers\UserController::class . ':GaReset');
  113. $this->get('/telegram_reset', App\Controllers\UserController::class . ':telegram_reset');
  114. $this->post('/resetport', App\Controllers\UserController::class . ':ResetPort');
  115. $this->post('/specifyport', App\Controllers\UserController::class . ':SpecifyPort');
  116. $this->post('/pacset', App\Controllers\UserController::class . ':PacSet');
  117. $this->post('/unblock', App\Controllers\UserController::class . ':Unblock');
  118. $this->get('/bought', App\Controllers\UserController::class . ':bought');
  119. $this->delete('/bought', App\Controllers\UserController::class . ':deleteBoughtGet');
  120. $this->get('/url_reset', App\Controllers\UserController::class . ':resetURL');
  121. $this->get('/inviteurl_reset', App\Controllers\UserController::class . ':resetInviteURL');
  122. //Reconstructed Payment System
  123. $this->post('/payment/purchase', App\Services\Payment::class . ':purchase');
  124. $this->get('/payment/return', App\Services\Payment::class . ':returnHTML');
  125. // Crypto Payment - BTC, ETH, EOS, BCH, LTC etch
  126. $this->post('/payment/bitpay/purchase', App\Services\BitPayment::class . ':purchase');
  127. $this->get('/payment/bitpay/return', App\Services\BitPayment::class . ':returnHTML');
  128. // getPcClient
  129. $this->get('/getPcClient', App\Controllers\UserController::class . ':getPcClient');
  130. })->add(new Auth());
  131. $app->group('/payment', function () {
  132. $this->get('/notify', App\Services\Payment::class . ':notify');
  133. $this->post('/notify', App\Services\Payment::class . ':notify');
  134. $this->post('/notify/{type}', App\Services\Payment::class . ':notify');
  135. $this->post('/status', App\Services\Payment::class . ':getStatus');
  136. $this->post('/bitpay/notify', App\Services\BitPayment::class . ':notify');
  137. $this->post('/bitpay/status', App\Services\BitPayment::class . ':getStatus');
  138. });
  139. // Auth
  140. $app->group('/auth', function () {
  141. $this->get('/login', App\Controllers\AuthController::class . ':login');
  142. $this->post('/qrcode_check', App\Controllers\AuthController::class . ':qrcode_check');
  143. $this->post('/login', App\Controllers\AuthController::class . ':loginHandle');
  144. $this->post('/qrcode_login', App\Controllers\AuthController::class . ':qrcode_loginHandle');
  145. $this->get('/register', App\Controllers\AuthController::class . ':register');
  146. $this->post('/register', App\Controllers\AuthController::class . ':registerHandle');
  147. $this->post('/send', App\Controllers\AuthController::class . ':sendVerify');
  148. $this->get('/logout', App\Controllers\AuthController::class . ':logout');
  149. $this->get('/telegram_oauth', App\Controllers\AuthController::class . ':telegram_oauth');
  150. $this->get('/login_getCaptcha', App\Controllers\AuthController::class . ':getCaptcha');
  151. })->add(new Guest());
  152. // Password
  153. $app->group('/password', function () {
  154. $this->get('/reset', App\Controllers\PasswordController::class . ':reset');
  155. $this->post('/reset', App\Controllers\PasswordController::class . ':handleReset');
  156. $this->get('/token/{token}', App\Controllers\PasswordController::class . ':token');
  157. $this->post('/token/{token}', App\Controllers\PasswordController::class . ':handleToken');
  158. })->add(new Guest());
  159. // Admin
  160. $app->group('/admin', function () {
  161. $this->get('', App\Controllers\AdminController::class . ':index');
  162. $this->get('/', App\Controllers\AdminController::class . ':index');
  163. $this->get('/trafficlog', App\Controllers\AdminController::class . ':trafficLog');
  164. $this->post('/trafficlog/ajax', App\Controllers\AdminController::class . ':ajax_trafficLog');
  165. // Node Mange
  166. $this->get('/node', App\Controllers\Admin\NodeController::class . ':index');
  167. $this->get('/node/create', App\Controllers\Admin\NodeController::class . ':create');
  168. $this->post('/node', App\Controllers\Admin\NodeController::class . ':add');
  169. $this->get('/node/{id}/edit', App\Controllers\Admin\NodeController::class . ':edit');
  170. $this->put('/node/{id}', App\Controllers\Admin\NodeController::class . ':update');
  171. $this->delete('/node', App\Controllers\Admin\NodeController::class . ':delete');
  172. $this->post('/node/ajax', App\Controllers\Admin\NodeController::class . ':ajax');
  173. $this->get('/ticket', App\Controllers\Admin\TicketController::class . ':index');
  174. $this->get('/ticket/{id}/view', App\Controllers\Admin\TicketController::class . ':show');
  175. $this->put('/ticket/{id}', App\Controllers\Admin\TicketController::class . ':update');
  176. $this->post('/ticket/ajax', App\Controllers\Admin\TicketController::class . ':ajax');
  177. // Relay Mange
  178. $this->get('/relay', App\Controllers\Admin\RelayController::class . ':index');
  179. $this->get('/relay/create', App\Controllers\Admin\RelayController::class . ':create');
  180. $this->post('/relay', App\Controllers\Admin\RelayController::class . ':add');
  181. $this->get('/relay/{id}/edit', App\Controllers\Admin\RelayController::class . ':edit');
  182. $this->put('/relay/{id}', App\Controllers\Admin\RelayController::class . ':update');
  183. $this->delete('/relay', App\Controllers\Admin\RelayController::class . ':delete');
  184. $this->get('/relay/path_search/{id}', App\Controllers\Admin\RelayController::class . ':path_search');
  185. $this->post('/relay/ajax', App\Controllers\Admin\RelayController::class . ':ajax_relay');
  186. // Shop Mange
  187. $this->get('/shop', App\Controllers\Admin\ShopController::class . ':index');
  188. $this->post('/shop/ajax', App\Controllers\Admin\ShopController::class . ':ajax_shop');
  189. $this->get('/bought', App\Controllers\Admin\ShopController::class . ':bought');
  190. $this->delete('/bought', App\Controllers\Admin\ShopController::class . ':deleteBoughtGet');
  191. $this->post('/bought/ajax', App\Controllers\Admin\ShopController::class . ':ajax_bought');
  192. $this->get('/shop/create', App\Controllers\Admin\ShopController::class . ':create');
  193. $this->post('/shop', App\Controllers\Admin\ShopController::class . ':add');
  194. $this->get('/shop/{id}/edit', App\Controllers\Admin\ShopController::class . ':edit');
  195. $this->put('/shop/{id}', App\Controllers\Admin\ShopController::class . ':update');
  196. $this->delete('/shop', App\Controllers\Admin\ShopController::class . ':deleteGet');
  197. // Ann Mange
  198. $this->get('/announcement', App\Controllers\Admin\AnnController::class . ':index');
  199. $this->get('/announcement/create', App\Controllers\Admin\AnnController::class . ':create');
  200. $this->post('/announcement', App\Controllers\Admin\AnnController::class . ':add');
  201. $this->get('/announcement/{id}/edit', App\Controllers\Admin\AnnController::class . ':edit');
  202. $this->put('/announcement/{id}', App\Controllers\Admin\AnnController::class . ':update');
  203. $this->delete('/announcement', App\Controllers\Admin\AnnController::class . ':delete');
  204. $this->post('/announcement/ajax', App\Controllers\Admin\AnnController::class . ':ajax');
  205. // Detect Mange
  206. $this->get('/detect', App\Controllers\Admin\DetectController::class . ':index');
  207. $this->get('/detect/create', App\Controllers\Admin\DetectController::class . ':create');
  208. $this->post('/detect', App\Controllers\Admin\DetectController::class . ':add');
  209. $this->get('/detect/{id}/edit', App\Controllers\Admin\DetectController::class . ':edit');
  210. $this->put('/detect/{id}', App\Controllers\Admin\DetectController::class . ':update');
  211. $this->delete('/detect', App\Controllers\Admin\DetectController::class . ':delete');
  212. $this->get('/detect/log', App\Controllers\Admin\DetectController::class . ':log');
  213. $this->post('/detect/ajax', App\Controllers\Admin\DetectController::class . ':ajax_rule');
  214. $this->post('/detect/log/ajax', App\Controllers\Admin\DetectController::class . ':ajax_log');
  215. $this->get('/auto', App\Controllers\Admin\AutoController::class . ':index');
  216. $this->get('/auto/create', App\Controllers\Admin\AutoController::class . ':create');
  217. $this->post('/auto', App\Controllers\Admin\AutoController::class . ':add');
  218. $this->delete('/auto', App\Controllers\Admin\AutoController::class . ':delete');
  219. $this->post('/auto/ajax', App\Controllers\Admin\AutoController::class . ':ajax');
  220. // IP Mange
  221. $this->get('/block', App\Controllers\Admin\IpController::class . ':block');
  222. $this->get('/unblock', App\Controllers\Admin\IpController::class . ':unblock');
  223. $this->post('/unblock', App\Controllers\Admin\IpController::class . ':doUnblock');
  224. $this->get('/login', App\Controllers\Admin\IpController::class . ':index');
  225. $this->get('/alive', App\Controllers\Admin\IpController::class . ':alive');
  226. $this->post('/block/ajax', App\Controllers\Admin\IpController::class . ':ajax_block');
  227. $this->post('/unblock/ajax', App\Controllers\Admin\IpController::class . ':ajax_unblock');
  228. $this->post('/login/ajax', App\Controllers\Admin\IpController::class . ':ajax_login');
  229. $this->post('/alive/ajax', App\Controllers\Admin\IpController::class . ':ajax_alive');
  230. // Code Mange
  231. $this->get('/code', App\Controllers\Admin\CodeController::class . ':index');
  232. $this->get('/code/create', App\Controllers\Admin\CodeController::class . ':create');
  233. $this->post('/code', App\Controllers\Admin\CodeController::class . ':add');
  234. $this->get('/donate/create', App\Controllers\Admin\CodeController::class . ':donate_create');
  235. $this->post('/donate', App\Controllers\Admin\CodeController::class . ':donate_add');
  236. $this->post('/code/ajax', App\Controllers\Admin\CodeController::class . ':ajax_code');
  237. // User Mange
  238. $this->get('/user', App\Controllers\Admin\UserController::class . ':index');
  239. $this->get('/user/{id}/edit', App\Controllers\Admin\UserController::class . ':edit');
  240. $this->put('/user/{id}', App\Controllers\Admin\UserController::class . ':update');
  241. $this->delete('/user', App\Controllers\Admin\UserController::class . ':delete');
  242. $this->post('/user/changetouser', App\Controllers\Admin\UserController::class . ':changetouser');
  243. $this->post('/user/ajax', App\Controllers\Admin\UserController::class . ':ajax');
  244. $this->post('/user/create', App\Controllers\Admin\UserController::class . ':createNewUser');
  245. $this->post('/user/buy', App\Controllers\Admin\UserController::class . ':buy');
  246. $this->get('/coupon', App\Controllers\AdminController::class . ':coupon');
  247. $this->post('/coupon', App\Controllers\AdminController::class . ':addCoupon');
  248. $this->post('/coupon/ajax', App\Controllers\AdminController::class . ':ajax_coupon');
  249. $this->get('/profile', App\Controllers\AdminController::class . ':profile');
  250. $this->get('/invite', App\Controllers\AdminController::class . ':invite');
  251. $this->post('/invite', App\Controllers\AdminController::class . ':addInvite');
  252. $this->post('/chginvite', App\Controllers\AdminController::class . ':chgInvite');
  253. $this->get('/sys', App\Controllers\AdminController::class . ':sys');
  254. $this->get('/logout', App\Controllers\AdminController::class . ':logout');
  255. $this->post('/payback/ajax', App\Controllers\AdminController::class . ':ajax_payback');
  256. })->add(new Admin());
  257. // mu
  258. $app->group('/mod_mu', function () {
  259. $this->get('/nodes/{id}/info', App\Controllers\Mod_Mu\NodeController::class . ':get_info');
  260. $this->get('/users', App\Controllers\Mod_Mu\UserController::class . ':index');
  261. $this->post('/users/traffic', App\Controllers\Mod_Mu\UserController::class . ':addTraffic');
  262. $this->post('/users/aliveip', App\Controllers\Mod_Mu\UserController::class . ':addAliveIp');
  263. $this->post('/users/detectlog', App\Controllers\Mod_Mu\UserController::class . ':addDetectLog');
  264. $this->post('/nodes/{id}/info', App\Controllers\Mod_Mu\NodeController::class . ':info');
  265. $this->get('/nodes', App\Controllers\Mod_Mu\NodeController::class . ':get_all_info');
  266. $this->post('/nodes/config', App\Controllers\Mod_Mu\NodeController::class . ':getConfig');
  267. $this->get('/func/detect_rules', App\Controllers\Mod_Mu\FuncController::class . ':get_detect_logs');
  268. $this->get('/func/relay_rules', App\Controllers\Mod_Mu\FuncController::class . ':get_relay_rules');
  269. $this->post('/func/block_ip', App\Controllers\Mod_Mu\FuncController::class . ':addBlockIp');
  270. $this->get('/func/block_ip', App\Controllers\Mod_Mu\FuncController::class . ':get_blockip');
  271. $this->get('/func/unblock_ip', App\Controllers\Mod_Mu\FuncController::class . ':get_unblockip');
  272. $this->post('/func/speedtest', App\Controllers\Mod_Mu\FuncController::class . ':addSpeedtest');
  273. $this->get('/func/autoexec', App\Controllers\Mod_Mu\FuncController::class . ':get_autoexec');
  274. $this->post('/func/autoexec', App\Controllers\Mod_Mu\FuncController::class . ':addAutoexec');
  275. $this->get('/func/ping', App\Controllers\Mod_Mu\FuncController::class . ':ping');
  276. //============================================
  277. })->add(new Mod_Mu());
  278. // res
  279. $app->group('/res', function () {
  280. $this->get('/captcha/{id}', App\Controllers\ResController::class . ':captcha');
  281. });
  282. $app->group('/link', function () {
  283. $this->get('/{token}', App\Controllers\LinkController::class . ':GetContent');
  284. });
  285. $app->group('/user', function () {
  286. $this->post('/doiam', App\Services\Payment::class . ':purchase');
  287. })->add(new Auth());
  288. $app->group('/doiam', function () {
  289. $this->post('/callback/{type}', App\Services\Payment::class . ':notify');
  290. $this->get('/return/alipay', App\Services\Payment::class . ':returnHTML');
  291. $this->post('/status', App\Services\Payment::class . ':getStatus');
  292. });
  293. // Vue
  294. $app->get('/logout', App\Controllers\VueController::class . ':vuelogout');
  295. $app->get('/globalconfig', App\Controllers\VueController::class . ':getGlobalConfig');
  296. $app->get('/getuserinfo', App\Controllers\VueController::class . ':getUserInfo');
  297. $app->post('/getuserinviteinfo', App\Controllers\VueController::class . ':getUserInviteInfo');
  298. $app->get('/getusershops', App\Controllers\VueController::class . ':getUserShops');
  299. $app->get('/getallresourse', App\Controllers\VueController::class . ':getAllResourse');
  300. $app->get('/getnewsubtoken', App\Controllers\VueController::class . ':getNewSubToken');
  301. $app->get('/getnewinvotecode', App\Controllers\VueController::class . ':getNewInviteCode');
  302. $app->get('/gettransfer', App\Controllers\VueController::class . ':getTransfer');
  303. $app->get('/getCaptcha', App\Controllers\VueController::class . ':getCaptcha');
  304. $app->post('/getChargeLog', App\Controllers\VueController::class . ':getChargeLog');
  305. $app->get('/getnodelist', App\Controllers\VueController::class . ':getNodeList');
  306. $app->get('/nodeinfo/{id}', App\Controllers\VueController::class . ':getNodeInfo');
  307. /**
  308. * chenPay
  309. */
  310. $app->group('/user', function () {
  311. $this->get('/chenPay', App\Services\Payment::class . ':purchase');
  312. $this->get('/orderDelete', App\Controllers\UserController::class . ':orderDelete');
  313. })->add(new Auth());
  314. $app->group('/chenPay', function () {
  315. $this->get('/status', App\Services\Payment::class . ':getStatus');
  316. });
  317. $app->group('/admin', function () {
  318. $this->get('/editConfig', App\Controllers\AdminController::class . ':editConfig');
  319. $this->post('/saveConfig', App\Controllers\AdminController::class . ':saveConfig');
  320. })->add(new Admin());
  321. // chenPay end
  322. // Run Slim Routes for App
  323. $app->run();