Category.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Heanup\App\Api\Controller;
  3. use Heanup\App\Api\Config\Site;
  4. use Heanup\App\Api\Controller;
  5. use Heanup\App\Api\Model\Dataoke;
  6. class Category extends Controller
  7. {
  8. protected function main()
  9. {
  10. if (isMobile()) {
  11. header("location: /tao.php");
  12. die();
  13. }
  14. // $id = $this->getQuery()->intval("id");
  15. $id = $this->getQuery()->string("args_0");
  16. $page = $this->getQuery()->string("args_1");
  17. $request = [
  18. 'r' => 'l',
  19. 'site' => 'classify',
  20. 'cid' => $id,
  21. ];
  22. $bids = $this->getQuery()->string("bids");
  23. $original_id = $this->getQuery()->string("original_id");
  24. if ($bids) {
  25. $request['bids'] = $bids;
  26. }
  27. if ($original_id) {
  28. $request['original_id'] = $original_id;
  29. }
  30. if ($page) {
  31. $request['page'] = $page;
  32. }
  33. $sort = $this->getQuery()->string("s");
  34. if ($sort) {
  35. $request['s'] = $sort;
  36. }
  37. $url = Site::getData('site_url') . "/tao.php?" . http_build_query($request);
  38. $content= Dataoke::parse(file_get_contents($url));
  39. $this->setCache($content);
  40. }
  41. protected function after()
  42. {
  43. $id = $this->getQuery()->string("args_0");
  44. $page = $this->getQuery()->string("args_1");
  45. if ($page) {
  46. $site_url = Site::getData('site_url') . "/category/" . $id . "/page_" . $page . ".html";
  47. } else {
  48. $site_url = Site::getData('site_url') . "/category/" . $id . "/index.html";
  49. }
  50. $this->addSitemap($site_url);
  51. }
  52. }