Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[发布] 【视频展厅3.1】在不同分类下 调用相应视频的方法(2011-12-10 13:14更新更新))

[复制链接]
与龙共舞 发表于 2011-11-22 20:53:39 | 显示全部楼层 |阅读模式
本帖最后由 与龙共舞 于 2011-12-10 13:18 编辑

视频展厅交流QQ群:13834101
首页在vgallery.inc.php 最后加入以下代码由于一点小疏忽,导致调用的时候有重复数据,请按下面代码72行,对比你原来的文件 把$t改成$t2就行了 2011-12-10 13:14以后用此代码的不用更改
  1. function getFromWhere($where, $num, $is_cache = 0, $cache_name = null) {

  2. $t  = time();  // 当前时间戳
  3. $t2 = strtotime("+10 minutes", $t); //更新时间 minutes 分钟 / seconds 秒 / days 天

  4. //是否缓存
  5.         if($is_cache == 1){
  6.            if(file_exists(DISCUZ_ROOT.'./data/cache/index_new_'.$cache_name.'.hsk')){        
  7.         @require DISCUZ_ROOT.'./data/cache/index_new_'.$cache_name.'.hsk';
  8.                 if($t <=$ttime ){
  9.                         return $index_new_array;
  10.                    }else{
  11.                                                  //==============================================10分钟 更新缓存
  12.                                                 $query = DB::query("SELECT n.*, t.views as views2, t.replies, p.username  FROM pre_vgallerys n
  13.          LEFT JOIN ".DB::table('forum_thread')." t ON t.tid=n.tid
  14.          LEFT JOIN ".DB::table('common_member')." p ON p.uid=n.uid
  15.          where ".$where." and album=0 and audit=1  ORDER BY id desc limit ".$num);
  16.          $i = 0;

  17.         while($topdata = DB::fetch($query)){
  18.                 $topdata['vsubject'] = addslashes($topdata['vsubject']);
  19.                 $topdata['vsubjectc'] = cutstr($topdata['vsubject'], 26, '..');
  20.                 $topdata['timelong'] = checkthetime($topdata['timelong']);
  21.             $topdata['views'] = $topdata['views2'] ? $topdata['views2'] : $topdata['views'];
  22.                 $topdata['polls'] = $topdata['views2'] ? $topdata['replies'] : $topdata['polls'];
  23.                 $topdata['valuate'] = sprintf("%01.1f", $topdata['valuate']/100);
  24.                 $topdata['key'] = $i;
  25.                 if(substr($topdata['purl'],0,7) != 'http://'){
  26.                         $thepicurl = DISCUZ_ROOT.$topdata['purl'];
  27.                         if(!file_exists("$thepicurl") || !$topdata['purl']){
  28.                                 $topdata['purl'] = "./".MDIR."/noimages.gif";
  29.                         }
  30.                 }
  31.         $cache_str .= "\t".$i."\t=>\t array(\t'vsubject'=>'".$topdata['vsubject']."', \t'vsubjectc'=>'".$topdata['vsubjectc']."', \t'timelong'=>'".$topdata['timelong']."',\t'views'=>'".$topdata['views']."',\t'polls'=>'".$topdata['polls']."',\t'purl'=>'".$topdata['purl']."',\t'id'=>'".$topdata['id']."',\t'username'=>'".$topdata['username']."'),\n";

  32.                 $i++;
  33.                 $index_new_array[] = $topdata;

  34. }
  35.                   $cache_str = "\$ttime = $t2;\n\$index_new_array = array(".$cache_str.");";
  36.                            frwritecocache('index_new_'.$cache_name, $cache_str);
  37.                        return $index_new_array;
  38.                    }        
  39.                 }else{         
  40.                  //==============================================如果没有文件,那么写入
  41.                          $query = DB::query("SELECT n.*, t.views as views2, t.replies, p.username  FROM pre_vgallerys n
  42.          LEFT JOIN ".DB::table('forum_thread')." t ON t.tid=n.tid
  43.          LEFT JOIN ".DB::table('common_member')." p ON p.uid=n.uid
  44.          where ".$where." and album=0 and audit=1  ORDER BY id desc limit ".$num);
  45.          $i = 0;

  46.         while($topdata = DB::fetch($query)){
  47.                 $topdata['vsubject'] = addslashes($topdata['vsubject']);
  48.                 $topdata['vsubjectc'] = cutstr($topdata['vsubject'], 26, '..');
  49.         //        $topdata['timelong'] = checkthetime($topdata['timelong']);
  50.                 $topdata['views'] = $topdata['views2'] ? $topdata['views2'] : $topdata['views'];
  51.                 $topdata['polls'] = $topdata['views2'] ? $topdata['replies'] : $topdata['polls'];
  52.                 $topdata['valuate'] = sprintf("%01.1f", $topdata['valuate']/100);
  53.                 $topdata['key'] = $i;
  54.                 if(substr($topdata['purl'],0,7) != 'http://'){
  55.                         $thepicurl = DISCUZ_ROOT.$topdata['purl'];
  56.                         if(!file_exists("$thepicurl") || !$topdata['purl']){
  57.                                 $topdata['purl'] = "./".MDIR."/noimages.gif";
  58.                         }
  59.                 }
  60.         $cache_str .= "\t".$i."\t=>\t array(\t'vsubject'=>'".$topdata['vsubject']."', \t'vsubjectc'=>'".$topdata['vsubjectc']."', \t'timelong'=>'".$topdata['timelong']."',\t'views'=>'".$topdata['views']."',\t'polls'=>'".$topdata['polls']."',\t'purl'=>'".$topdata['purl']."',\t'id'=>'".$topdata['id']."',\t'username'=>'".$topdata['username']."'),\n";

  61.                 $i++;
  62.                 $index_new_array[] = $topdata;

  63. }
  64.                   $cache_str = "\$ttime = $t2;\n\$index_new_array = array(".$cache_str.");";
  65.                            frwritecocache('index_new_'.$cache_name, $cache_str);
  66.                        return $index_new_array;
  67.                 }
  68.                 }else{
  69.                         //==============================================无缓存
  70.                         $query = DB::query("SELECT n.*, t.views as views2, t.replies, p.username  FROM pre_vgallerys n
  71.          LEFT JOIN ".DB::table('forum_thread')." t ON t.tid=n.tid
  72.          LEFT JOIN ".DB::table('common_member')." p ON p.uid=n.uid
  73.          where ".$where." and album=0 and audit=1  ORDER BY id desc limit ".$num);
  74.          $i = 0;
  75.         while($topdata = DB::fetch($query)){
  76.                 $topdata['vsubject'] = addslashes($topdata['vsubject']);
  77.                 $topdata['vsubjectc'] = cutstr($topdata['vsubject'], 26, '..');
  78.         //        $topdata['timelong'] = checkthetime($topdata['timelong']);
  79.                 $topdata['views'] = $topdata['views2'] ? $topdata['views2'] : $topdata['views'];
  80.                 $topdata['polls'] = $topdata['views2'] ? $topdata['replies'] : $topdata['polls'];
  81.                 $topdata['valuate'] = sprintf("%01.1f", $topdata['valuate']/100);
  82.                 $topdata['key'] = $i;
  83.                 if(substr($topdata['purl'],0,7) != 'http://'){
  84.                         $thepicurl = DISCUZ_ROOT.$topdata['purl'];
  85.                         if(!file_exists("$thepicurl") || !$topdata['purl']){
  86.                                 $topdata['purl'] = "./".MDIR."/noimages.gif";
  87.                         }
  88.                 }
  89.                 $i++;
  90.                 $index_new_array[] = $topdata;

  91. }
  92.                     return $index_new_array;
  93.                 }
  94. }
复制代码

函数getFromWhere的参数说明:
$where 为查询的条件  一般为sid = 分类的id号  比如sid=88
$num 调用视频数量
$is_cache 是否调用缓存 值为1时调用缓存
$cache_name 缓存文件名称后辍 以区别不同的缓存文件

函数中
$t2 = strtotime("+10 minutes", $t); //更新时间 minutes 分钟 / seconds 秒 / days 天
默认为10分钟 可根据需要自行修改

如果在视频展厅插件内调用视频 则在模板里
  1. {eval        
  2. $index_new_name1 = getFromWhere("sid = 88",22, 1, "name1");  //想要调用的视频
  3. }
  4.                 <!--{loop $index_new_name1 $i $datarow}-->        
  5.                          $datarow[vsubject] //视频名称
  6.                         {PDIR}&tion=view&vid=$datarow[id] //视频链接
  7.                         $datarow[purl] //视频图片地址
  8.                         $datarow[views] //浏览次数
  9.                         $datarow[polls] //评论数
  10.                 <!--{/loop}-->
复制代码


模板可根据自己需要修改 注意所有name1 一定要对应 这个例子调用的视频是 sid为88 调用 22个 1是使用缓存
name1为缓存文件名后辍    name1 则生成的缓存文件名为index_new_name1.hsk

视频展厅外调用视频 可参考11楼


1314学习网 发表于 2011-11-22 21:05:08 | 显示全部楼层
支持。。。。
回复

使用道具 举报

jxhjjm 发表于 2011-11-22 21:18:13 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

mengchuanjin 发表于 2011-11-22 21:18:23 | 显示全部楼层
回复

使用道具 举报

zgx850324 发表于 2011-11-22 21:43:26 | 显示全部楼层
支持一下吧,很久不用展厅了
回复

使用道具 举报

a5573192 发表于 2011-11-23 00:11:58 | 显示全部楼层
支持与龙共舞 !今天在群里给你说了下 晚上就出教程了!速度真快!
回复

使用道具 举报

haoshoe 发表于 2011-11-23 08:50:23 | 显示全部楼层
支持与龙共舞 !
回复

使用道具 举报

kaixinma 发表于 2011-11-23 09:12:00 | 显示全部楼层
好好看看,非常好的帖子
回复

使用道具 举报

9#
无效楼层,该帖已经被删除
81336388 发表于 2011-11-23 10:22:43 | 显示全部楼层
选个好的 才有保证 这话没错        http://www.c9c9gua.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-9-28 06:21 , Processed in 0.379466 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表