new_video_check.auto_cache.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. class new_video_check_auto_cache extends auto_cache{
  3. private $key = "new:video:check:";
  4. public function load($param)
  5. {
  6. $this->key .= md5(serialize($param));
  7. $key_bf = $this->key.'_bf';
  8. $list = $GLOBALS['cache']->get($this->key,true);
  9. if ($list === false) {
  10. $is_ok = $GLOBALS['cache']->set_lock($this->key);
  11. if(!$is_ok){
  12. $list = $GLOBALS['cache']->get($key_bf,true);
  13. }else{
  14. $m_config = load_auto_cache("m_config");//初始化手机端配置
  15. $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,
  16. (v.robot_num + v.virtual_watch_number + v.watch_number) as watch_number, u.head_image,u.thumb_head_image, v.xpoint,v.ypoint,
  17. u.v_type, u.v_icon, u.nick_name,u.user_level,v.live_image,v.is_live_pay,v.live_pay_type,v.live_fee,u.create_time as user_create_time FROM ".DB_PREFIX."video v
  18. LEFT JOIN ".DB_PREFIX."user u ON u.id = v.user_id where v.live_in in (1,3) and v.room_type = 3 and (u.mobile = '13888888888' or u.mobile = '13999999999')";
  19. if (!empty($param['create_type'])) {
  20. $sql .= ' and v.create_type = ' . $param['create_type'];
  21. }
  22. if((defined('OPEN_ROOM_HIDE')&&OPEN_ROOM_HIDE==1)&&intval($m_config['open_room_hide'])==1){
  23. $sql.= " and v.province <> '火星' and v.province <>''";
  24. }
  25. $sql.=" order by v.create_time desc ";
  26. $list = $GLOBALS['db']->getAll($sql,true,true);
  27. foreach($list as $k=>$v){
  28. //判断用户是否为今日创建的新用户,是:1,否:0
  29. if (date('Y-m-d') == date('Y-m-d',$list[$k]['user_create_time']+3600*8)){
  30. $list[$k]['today_create'] = 1;
  31. }else{
  32. $list[$k]['today_create'] = 0;
  33. }
  34. if($v['live_image']==''){
  35. $list[$k]['live_image'] = get_spec_image($v['head_image']);
  36. $list[$k]['head_image'] = get_spec_image($v['head_image']);
  37. }else{
  38. $list[$k]['live_image'] = get_spec_image($v['live_image']);
  39. $list[$k]['head_image'] = get_spec_image($v['head_image'],150,150);
  40. }
  41. if ($v['thumb_head_image'] == ''){
  42. $list[$k]['thumb_head_image'] = get_spec_image($v['head_image'],150,150);
  43. }else{
  44. //$list[$k]['thumb_head_image'] = get_abs_img_root($v['thumb_head_image']);
  45. $list[$k]['thumb_head_image'] = get_spec_image($v['thumb_head_image'],150,150);
  46. }
  47. }
  48. $GLOBALS['cache']->set($this->key, $list, 10,true);
  49. $GLOBALS['cache']->set($key_bf, $list, 86400, true);//备份
  50. }
  51. }
  52. if ($list == false) $list = array();
  53. return $list;
  54. }
  55. public function rm()
  56. {
  57. $GLOBALS['cache']->clear_by_name($this->key);
  58. }
  59. public function clear_all()
  60. {
  61. $GLOBALS['cache']->clear_by_name($this->key);
  62. }
  63. }
  64. ?>