edu_select_video_check.auto_cache.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. class edu_select_video_check_auto_cache extends auto_cache
  3. {
  4. private $key = "edu:select:video:check:";
  5. public function load($param)
  6. {
  7. $sex = intval($param['sex_type']);
  8. $city = strim($param['area_type']);
  9. $cate_id = intval($param['cate_id']);
  10. $has_private = intval($param['has_private']);//1:包括私密直播
  11. $is_classify = intval($param['is_classify']);//分类
  12. $order = strim($param['order']);//排序字段
  13. $sort = strim($param['sort']);//排序方式
  14. $limit = strim($param['limit']);//获取范围个数
  15. if ($city == '热门' || $city == 'null') {
  16. $city = '';
  17. }
  18. $this->key .= $sex . '_' . $city . '_' . $cate_id . '_' . $has_private;
  19. if ($order) {
  20. $this->key .= '_' . $order;
  21. }
  22. if ($sort) {
  23. $this->key .= '_' . $sort;
  24. }
  25. if ($limit) {
  26. $this->key .= '_' . $limit;
  27. }
  28. $list = $GLOBALS['cache']->get($this->key, true);
  29. $key_bf = $this->key . '_bf';
  30. if ($list === false) {
  31. $is_ok = $GLOBALS['cache']->set_lock($this->key);
  32. if (!$is_ok) {
  33. $list = $GLOBALS['cache']->get($key_bf, true);
  34. } else {
  35. $m_config = load_auto_cache("m_config");//初始化手机端配置
  36. $has_is_authentication = intval($m_config['has_is_authentication']) ? 1 : 0;
  37. if ($has_is_authentication && $m_config['ios_check_version'] == '') {
  38. $sql = "SELECT v.id AS room_id, v.sort_num, v.group_id, v.user_id, v.city, v.title, v.cate_id, v.live_in, v.video_type, v.create_type, v.room_type,
  39. (v.robot_num + v.virtual_watch_number + v.watch_number) as watch_number, u.head_image,u.thumb_head_image,v.live_image,v.xpoint,v.ypoint,ev.tags,
  40. ev.is_verify,ev.deal_id,ev.edu_cate_id,ev.booking_class_id,u.v_type, u.v_icon, u.nick_name,u.user_level,v.is_live_pay,v.live_pay_type,v.live_fee,u.create_time as user_create_time FROM " . DB_PREFIX . "video v
  41. LEFT JOIN " . DB_PREFIX . "user u ON u.id = v.user_id LEFT JOIN " . DB_PREFIX . "edu_video_info as ev ON ev.video_id = v.id
  42. where v.live_in in (1,3) and u.is_authentication = 2 and u.is_hot_on =0 and (u.mobile = '13888888888' or u.mobile = '13999999999') ";
  43. } else {
  44. $sql = "SELECT v.id AS room_id, v.sort_num, v.group_id, v.user_id, v.city, v.title, v.cate_id, v.live_in, v.video_type, v.create_type, v.room_type,
  45. (v.robot_num + v.virtual_watch_number + v.watch_number) as watch_number, u.head_image,u.thumb_head_image,v.live_image, v.xpoint,v.ypoint,ev.tags,
  46. ev.is_verify,ev.deal_id,ev.edu_cate_id,ev.booking_class_id,u.v_type, u.v_icon, u.nick_name,u.user_level,v.is_live_pay,v.live_pay_type,v.live_fee,u.create_time as user_create_time FROM " . DB_PREFIX . "video v
  47. LEFT JOIN " . DB_PREFIX . "user u ON u.id = v.user_id LEFT JOIN " . DB_PREFIX . "edu_video_info as ev ON ev.video_id = v.id
  48. where v.live_in in (1,3) and u.is_hot_on =0 and (u.mobile = '13888888888' or u.mobile = '13999999999') ";
  49. }
  50. if ($is_classify) {
  51. $sql .= " and v.classified_id = " . $is_classify; //分类
  52. }
  53. if ($has_private == 1) {
  54. $sql .= ' and v.room_type in (1,3)'; //1:私密直播;3:直播
  55. } else {
  56. $sql .= ' and v.room_type = 3'; //1:私密直播;3:直播
  57. }
  58. if ($sex == 1 || $sex == 2) {
  59. $sql .= ' and v.sex = ' . $sex;
  60. }
  61. if ($city != '') {
  62. $sql .= " and v.province = '" . $city . "'";
  63. }
  64. if ($cate_id > 0) {
  65. $sql .= " and ev.edu_cate_id = '" . $cate_id . "'";
  66. }
  67. if ($has_private != 1 && (defined('OPEN_ROOM_HIDE') && OPEN_ROOM_HIDE == 1) && intval($m_config['open_room_hide']) == 1) {
  68. $sql .= " and v.province <> '火星' and v.province <>''";
  69. }
  70. if ($order) {
  71. $sql .= " order by v." . $order;
  72. if ($sort) {
  73. $sql .= " " . $sort;
  74. }
  75. } else {
  76. $sql .= " order by v.sort_num desc,v.sort desc";
  77. }
  78. if ($limit) {
  79. $sql .= " limit " . $limit . "";
  80. }
  81. $list = $GLOBALS['db']->getAll($sql, true, true);
  82. foreach ($list as $k => $v) {
  83. //判断用户是否为今日创建的新用户,是:1,否:0
  84. if (date('Y-m-d') == date('Y-m-d', $list[$k]['user_create_time'] + 3600 * 8)) {
  85. $list[$k]['today_create'] = 1;
  86. } else {
  87. $list[$k]['today_create'] = 0;
  88. }
  89. if ($v['live_image'] == '') {
  90. $list[$k]['live_image'] = get_spec_image($v['head_image']);
  91. $list[$k]['head_image'] = get_spec_image($v['head_image']);
  92. } else {
  93. $list[$k]['live_image'] = get_spec_image($v['live_image']);
  94. $list[$k]['head_image'] = get_spec_image($v['head_image'], 150, 150);
  95. }
  96. if ($v['thumb_head_image'] == '') {
  97. $list[$k]['thumb_head_image'] = get_spec_image($v['head_image'], 150, 150);
  98. } else {
  99. //$list[$k]['thumb_head_image'] = get_abs_img_root($v['thumb_head_image']);
  100. $list[$k]['thumb_head_image'] = get_spec_image($v['thumb_head_image'], 150, 150);
  101. }
  102. if (!$v['tags']) {
  103. $list[$k]['tags'] = array();
  104. } else {
  105. $list[$k]['tags'] = explode(',', $v['tags']);
  106. }
  107. $list[$k]['is_verify'] = intval($v['is_verify']);
  108. $list[$k]['deal_id'] = intval($v['deal_id']);
  109. $list[$k]['edu_cate_id'] = intval($v['edu_cate_id']);
  110. }
  111. $GLOBALS['cache']->set($this->key, $list, 10, true);
  112. $GLOBALS['cache']->set($key_bf, $list, 86400, true);//备份
  113. //echo $this->key;
  114. }
  115. }
  116. if ($list == false) {
  117. $list = array();
  118. }
  119. return $list;
  120. }
  121. public function rm()
  122. {
  123. $GLOBALS['cache']->clear_by_name($this->key);
  124. }
  125. public function clear_all()
  126. {
  127. $GLOBALS['cache']->clear_by_name($this->key);
  128. }
  129. }
  130. ?>