new_video.auto_cache.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. class new_video_auto_cache extends auto_cache{
  3. private $key = "new:video:";
  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' and 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. if(strpos($v['head_image'],'wx.qlogo.cn')!==false){
  36. $list[$k]['live_image'] = strtr($v['head_image'],array('/96'=>'/0'));
  37. }else if(strpos($v['head_image'],'http://q.qlogo.cn/')!==false) {
  38. $list[$k]['live_image'] = strtr($v['head_image'],array('/40'=>'/100'));
  39. }else{
  40. $list[$k]['live_image'] = get_spec_image($v['head_image']);
  41. }
  42. $list[$k]['head_image'] = get_spec_image($v['head_image']);
  43. }else{
  44. $list[$k]['live_image'] = get_spec_image($v['live_image']);
  45. $list[$k]['head_image'] = get_spec_image($v['head_image'],150,150);
  46. }
  47. if(strpos($v['head_image'],'wx.qlogo.cn')!==false){
  48. $list[$k]['thumb_head_image'] = strtr($v['head_image'],array('/96'=>'/46'));
  49. }else{
  50. if ($v['thumb_head_image'] == ''){
  51. $list[$k]['thumb_head_image'] = get_spec_image($v['head_image'],150,150);
  52. }else{
  53. //$list[$k]['thumb_head_image'] = get_abs_img_root($v['thumb_head_image']);
  54. $list[$k]['thumb_head_image'] = get_spec_image($v['thumb_head_image'],150,150);
  55. }
  56. }
  57. if($v['live_in']==1){
  58. if($v['is_live_pay']==0){
  59. $list[$k]['live_state'] = '直播';
  60. }else if($v['is_live_pay']==1){
  61. $list[$k]['live_state'] = '付费直播';
  62. }
  63. }else{
  64. if($v['is_live_pay']==1){
  65. $list[$k]['live_state'] = '付费回播';
  66. }else if($v['is_live_pay']==0&&intval($v['is_gather'])!=1){
  67. $list[$k]['live_state'] = '回播';
  68. }else if(intval($v['is_gather'])==1){
  69. $list[$k]['live_state'] = '直播';
  70. }
  71. }
  72. $list[$k]['nick_name'] = emoji_decode($v['nick_name']);
  73. }
  74. $GLOBALS['cache']->set($this->key, $list, 10,true);
  75. $GLOBALS['cache']->set($key_bf, $list, 86400, true);//备份
  76. }
  77. }
  78. if ($list == false) $list = array();
  79. return $list;
  80. }
  81. public function rm()
  82. {
  83. //$GLOBALS['cache']->clear_by_name($this->key);
  84. }
  85. public function clear_all()
  86. {
  87. //$GLOBALS['cache']->clear_by_name($this->key);
  88. }
  89. }
  90. ?>