You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
973 B

  1. <?php
  2. namespace App\Http\Controllers\Home;
  3. use App\Http\Controllers\Home\CommonController;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Http\Request;
  6. use App\Common\Helper;
  7. class AdController extends BaseController
  8. {
  9. public function __construct()
  10. {
  11. parent::__construct();
  12. }
  13. public function detail($id)
  14. {
  15. $where = function ($query) use ($id) {
  16. $query->where('id', '=', $id)->orWhere('flag', '=', $id);
  17. };
  18. $post = cache("index_ad_detail_$id");
  19. if (!$post) {
  20. $time = time();
  21. $post = DB::table('ad')->where($where)->first();
  22. if (!$post) {
  23. exit('not found');
  24. }
  25. if ($post->is_expire == 1 && $post->end_time < $time) {
  26. exit('expired');
  27. }
  28. cache("index_ad_detail_$id", $post, 2592000);
  29. }
  30. if (Helper::is_mobile_access()) {
  31. if ($post->content_wap) {
  32. exit($post->content_wap);
  33. }
  34. }
  35. exit($post->content);
  36. }
  37. }