Search.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Search extends Controller
  7. {
  8. public function main()
  9. {
  10. if (isMobile()) {
  11. header("location: /tao.php");
  12. die();
  13. }
  14. $kw = $this->getQuery()->string("kw") ?: $this->getQuery()->string("args_0");
  15. $bids = $this->getQuery()->string("bids");
  16. $cid = $this->getQuery()->string("cid");
  17. $request = [
  18. 'r' => 'l',
  19. 'u' => Site::getData("user_tag")
  20. ];
  21. if ($kw) {
  22. $request['kw'] = urldecode($kw);
  23. }
  24. if ($bids) {
  25. $request['bids'] = $bids;
  26. }
  27. if ($cid) {
  28. $request['cid'] = $cid;
  29. }
  30. $page = $this->getQuery()->string("args_1");
  31. if ($page){
  32. $request['page'] = $page;
  33. }
  34. $sort = $this->getQuery()->string("s");
  35. if ($sort) {
  36. $request['s'] = $sort;
  37. }
  38. $url = Site::getData('site_url') . "/tao.php?" . http_build_query($request);
  39. $content = Dataoke::parse(file_get_contents($url));
  40. $this->setCache($content);
  41. }
  42. }