基于《织梦内容管理系统 DedeCMS V5.7 UTF8 SP2 春哥精简版下载》开发,织梦二次开发实战教程,织梦开发实现多集视频播放,用织梦系统做的小视频网站。废话少续,直接上织梦教程,文章末尾附懒人包。
一、添加字段
用文章模型做视频,一定要添加字段,先给附加表加数据库字段。添加字段 (后台-系统-SQL命令行工具-执行)
ALTER TABLE `#@__addonarticle` ADD `softlinks` text;
二、发布文件
①、打开 /dede/article_add.php 搜索
$query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,templet,userip,body{$inadd_f}) Values('$arcID','$typeid','$redirecturl','$templet','$useip','$body'{$inadd_v})";
改为
//软件链接列表 $urls = ''; //本地链接处理 $softurl = stripslashes($softurl); if($softurl != '') { $urls .= "{dede:link islocal='1' text='{$servermsg}'} {$softurl} {/dede:link}\r\n"; } //其它链接处理 for($i=0; $i<=300; $i++) { if(!empty(${'softurl'.$i})) { $forconfig = empty(${'forconfig'.$i}) ? FALSE : TRUE; if($forconfig) { if(empty(${'need'.$i})) continue; $serverUrl = stripslashes(${'softurlfirst'.$i}); $serverUrl = preg_replace("#\/$#", "", $serverUrl); $softurl = stripslashes(${'softurl'.$i}); if( cn_substr($softurl, 1) != '/' ) $softurl = '/'.$softurl; $softurl = $serverUrl.$softurl; } else { $softurl = stripslashes(${'softurl'.$i}); } $servermsg = str_replace("'", "", stripslashes(${'servermsg'.$i})); $ii = $i+2; if($servermsg=='') $servermsg = '第'.$ii.'集'; if($softurl != '') { $urls .= "{dede:link text='{$servermsg}'} {$softurl} {/dede:link}\r\n"; } } } $urls = addslashes($urls); $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,templet,userip,softlinks,body{$inadd_f}) Values('{$arcID}','{$typeid}','{$redirecturl}','{$templet}','{$useip}','{$urls}','{$body}'{$inadd_v})";
②、打开 /dede/article_edit.php 搜索
$channelid = $arcRow['channel'];
在它上面加入
$newRowStart = 1; $nForm = ''; $daccess = $addRow['daccess']; $needmoney = $addRow['needmoney']; if($addRow['softlinks'] != '') { $dtp = new DedeTagParse(); $dtp->LoadSource($addRow['softlinks']); if(is_array($dtp->CTags)) { foreach($dtp->CTags as $ctag) { if($ctag->GetName()=='link') { $islocal = $ctag->GetAtt('islocal'); if($islocal != 1) $needmsg = "<input type='checkbox' name='del{$newRowStart}' value='1' />删除"; else $needmsg = '<input name="sel1" type="button" id="sel1" value="选取" onClick="SelectSoft(\'form1.softurl'.$newRowStart.'\')" />'; $nForm .= "<div style='line-height:36px'>视频地址{$newRowStart}:<input type='text' name='softurl{$newRowStart}' style='width:280px' value='".trim($ctag->GetInnerText())."' /> 选集名称:<input type='text' name='servermsg{$newRowStart}' value='".$ctag->GetAtt("text")."' style='width:150px' /> <input type='hidden' name='islocal{$newRowStart}' value='{$islocal}' /> {$needmsg} </div>\r\n"; $newRowStart++; } } } $dtp->Clear(); }
继续搜索
$iquery = "UPDATE `$addtable` SET typeid='$typeid',body='$body'{$inadd_f},redirecturl='$redirecturl',templet='$templet',userip='$useip' WHERE aid='$id'";
改为
//软件链接列表 $urls = ''; for($i=1; $i<=300; $i++) { if(!empty(${'softurl'.$i})) { $islocal = empty(${'islocal'.$i}) ? '' : 1; $isneed = empty(${'del'.$i}) ? true : false; $servermsg = str_replace("'",'',stripslashes(${'servermsg'.$i})); $softurl = stripslashes(${'softurl'.$i}); if($servermsg=='') { $servermsg = '第'.$i.'集'; } if($softurl != '') { if($islocal==1) $urls .= "{dede:link islocal='{$islocal}' text='{$servermsg}'} {$softurl} {/dede:link}\r\n" ; else if($isneed) $urls .= "{dede:link text='{$servermsg}'} {$softurl} {/dede:link}\r\n"; else continue; } } } $urls = addslashes($urls); $iquery = "UPDATE `{$addtable}` SET typeid='{$typeid}',body='{$body}'{$inadd_f},redirecturl='{$redirecturl}',templet='{$templet}',softlinks ='{$urls}',userip='{$useip}' WHERE aid='{$id}'";
③、打开 /dede/templets/article_add.htm 搜索
--> </script> </head>
改为
var startNum = 0; function MakeUpload() { var upfield = document.getElementById("uploadfield"); var endNum = parseInt(document.form1.picnum.value) + startNum-1; if(endNum > 300) endNum = 300; for(startNum; startNum<=endNum; startNum++){ upfield.innerHTML += "<div style='line-height:36px'>视频地址"+startNum+":<input type='text' name='softurl"+startNum+"' style='width:280px' value='' /> 选集名称:<input type='text' name='servermsg"+startNum+"' style='width:150px' /></div>\r\n"; } } function ShowHideAddr() { document.getElementById('morelink').style.display = (document.getElementById('morelink').style.display=='block' ? 'none' : 'block'); //document.getElementById('morelink').style.height = '100%'; document.getElementById('btsh3').value = (document.getElementById('morelink').style.display=='block' ? '隐藏地址' : '显示地址'); } --> </script> </head>
继续搜索
文章内容
在它所在的 tr 上面加
<tr> <td height="24" bgcolor="#F9FCEF" class="bline2"><strong> 视频选集列表:</strong></td> </tr> <tr> <td height="24" class="bline"><table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="90" height="30"> 视频地址:</td> <td><input name="softurl" type="text" id="softurl" size="35" /> <input name="sel1" type="button" id="sel1" value="选取" onClick="SelectSoft('form1.softurl')" /> 选集名称: <input name="servermsg" type="text" id="servermsg" value="第1集" style="width:150px" /> </td> </tr> </table></td> </tr> <tr> <td height="24" class="bline" style="padding-left:8px"><table width="800" border="0" cellspacing="0" cellpadding="0" style="margin-bottom:5px;" class="bline"> <tr> <td width="90">增加选集:</td> <td><input name="picnum" type="text" id="picnum" size="8" value="5" /> <input name='kkkup' type='button' id='kkkup2' value='增加地址' onClick="MakeUpload();" /> <input type="button" name="Submit3" id="btsh3" value="隐藏地址" onClick="ShowHideAddr();" /> (最多为300个链接) </td> </tr> </table> <div id="morelink" style="display:block"> <div id='uploadfield' style="width:790px"></div> </div></td> </tr>
④、打开 /dede/templets/article_edit.htm 搜索
--> </script> </head>
改为
var startNum = <?php echo $newRowStart?>; function MakeUpload() { var upfield = document.getElementById('uploadfield'); var endNum = parseInt(document.form1.picnum.value) + startNum; if(endNum > 300) endNum = 300; for(startNum; startNum < endNum; startNum++) { upfield.innerHTML += "<div style='line-height:36px'>视频地址"+startNum+":<input type='text' name='softurl"+startNum+"' style='width:280px' value='' /> 选集名称:<input type='text' name='servermsg"+startNum+"' style='width:150px' /></div>\r\n"; } } function ShowHideAddr() { document.getElementById('morelink').style.display = (document.getElementById('morelink').style.display=='block' ? 'none' : 'block'); document.getElementById('btsh3').value = (document.getElementById('morelink').style.display=='block' ? '隐藏地址' : '显示地址'); } --> </script> </head>
继续搜索
文章内容
在它所在的 tr 上面加
<tr> <td height="24" colspan="4" bgcolor="#F9FCEF"class="bline2"><strong> 视频选集列表:</strong></td> </tr> <tr> <td height="24" colspan="4" class="bline"><table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="72"> 增加选集:</td> <td><input name="picnum" type="text" id="picnum" size="8" value="5" /> <input name='kkkup' type='button' id='kkkup2' value='增加数量' onClick="MakeUpload();" /> <input type="button" name="Submit3" id="btsh3" value="隐藏地址" onClick="ShowHideAddr();" /> (最多为300个链接) </td> </tr> </table></td> </tr> <tr> <td height="24" colspan="4" class="bline" style="padding-left:8px"> <?php echo $nForm; ?> <div id='morelink' style='display:block'> <div id='uploadfield' style='width:800px'></div> </div></td> </tr>
三、添加方法
打开 /include/extend.func.php 在它底部加
function bodyvideo($id) { global $dsql,$cfg_basedir; $imgurls = ''; $row = $dsql->GetOne("SELECT a.id,c.addtable FROM `#@__archives` AS a LEFT JOIN `#@__channeltype` AS c ON a.channel=c.id where a.id='{$id}'"); $result = GetOneArchive($id); $addtable = trim($row['addtable']); $row = $dsql->GetOne("SELECT softlinks FROM `{$addtable}` WHERE aid={$id}"); $dtp = new DedeTagParse(); $dtp->LoadSource($row['softlinks']); if(is_array($dtp->CTags)) { foreach($dtp->CTags as $ctag) { if($ctag->GetName()=="link") { $bigimg .= $ctag->GetAtt('text').'|'.trim($ctag->GetInnerText()).','; } } } $dtp->Clear(); $imgurls = $bigimg; $imgurls = rtrim($imgurls,','); $keywords = explode(',', $imgurls); foreach ($keywords as $key => $keyword) { $i = $key + 1; $link = explode('|',$keyword); if ($i == 1){ $aaabbb .= '<a id="video1" href="'.$result['arcurl'].'">'.$link[0].'</a>'."\n"; } else { $aaabbb .= '<a id="video'.$i.'" href="'.$result['arcurl'].'?aid='.$id.'&mus='.$i.'">'.$link[0].'</a>'."\n"; } } return rtrim($aaabbb); }
四、前端调用
在 plus 目录内新建 video.php 文件,代码如下
<?php error_reporting(0); header('Content-type:text/html;charset=utf-8'); //禁止蜘蛛抓取 $userAgent = $_SERVER['HTTP_USER_AGENT']; $searchEngines = array('python','@','curl','compatible','bot','spider','Baiduspider','bingbot','Sogou','Bytespider','YisouSpider','360Spider','Googlebot'); foreach ($searchEngines as $searchEngine) { if (stripos($userAgent, $searchEngine) !== false) { exit(); } } //禁止蜘蛛抓取 require_once(dirname(__FILE__)."/../include/common.inc.php"); $aid = isset($_GET['amid']) ? $_GET['amid'] : ''; $mus = isset($_GET['amus']) ? $_GET['amus'] : ''; if(empty($aid)) { showMsg('非法操作!', 'javascript:;'); exit(); } if (!empty($aid)){ require_once(DEDEINC.'/arc.archives.class.php'); global $dsql,$cfg_basedir; $imgurls = ''; $row = $dsql->GetOne("SELECT a.id,c.addtable FROM `#@__archives` AS a LEFT JOIN `#@__channeltype` AS c ON a.channel=c.id where a.id='{$aid}'"); $result = GetOneArchive($aid); $addtable = trim($row['addtable']); $row = $dsql->GetOne("SELECT softlinks FROM `{$addtable}` WHERE aid={$aid}"); $dtp = new DedeTagParse(); $dtp->LoadSource($row['softlinks']); if(is_array($dtp->CTags)) { foreach($dtp->CTags as $ctag) { if($ctag->GetName()=="link") { $bigimg .= trim($ctag->GetInnerText()).','; } } } $dtp->Clear(); $imgurls = $bigimg; $imgurls = rtrim($imgurls,','); $keywords = explode(',', $imgurls); $urls = array(); foreach ($keywords as $key => $keyword) { $i = $key + 1; $urls[] .= $keyword; } } $amusukg = ($mus =='') ? 0 : $mus; if($amusukg == 0 || $amusukg == ''){ $mp4url = $urls[0]; }else{ $mp4url = $urls[($amusukg-1)]; } if(empty($mp4url)) { showMsg('非法操作!', 'javascript:;'); exit(); } $ulli .= '$("#video").html(\'<iframe frameborder="0" src="/video?url='.$mp4url.'" allowFullScreen="true"></iframe>\');'; $ahtmll = <<<TPL {$ulli} TPL; echo $ahtmll; exit(); ?>
五、调用标签
在 /templets/default/article_article.htm 模板里面加
<!-- 样式 --> <style type="text/css"> @media (max-width: 670px) {#video iframe{width:100%!important;height:250px!important;}} @media (min-width: 670px) {#video iframe{width:100%!important;height:500px!important;}} </style> <!-- 样式 --> <!-- 播放器 --> <div id="video"></div> <!-- 播放器 --> <!-- 播放列表 --> {dede:field.id function=bodyvideo(@me)/} <!-- 播放列表 --> <!-- jQuery插件库 已调用的可以删掉--> <script type="text/javascript" src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <!-- jQuery插件库 已调用的可以删掉--> <!-- 获取播放链接 --> <script type="text/javascript"> var urllink = new URL(document.location.toString()); var aid = "{dede:field.id/}"; var mus = urllink.searchParams.get("mus"); var amus = (mus == '' || mus == null) ? '?amid='+aid+'' : '?amus='+mus+'&amid='+aid+''; document.writeln('<script type="text\/javascript" src="/plus/video.php'+amus+'"><\/script>'); var gaov = (mus == '' || mus == null) ? 1 : mus; $("#video"+gaov+"").css({color:'#ff6428'});//高亮代码 </script> <!-- 获取播放链接 -->
根据需求修改。
六、加播放器
video 目录是播放器目录,在懒人包内,下载播放器就可以使用了。比如:DPlayer、Ckplayer、哔哩哔哩等均支持。
懒人包下载
关于加密
《视频地址加密的方法,利用blob加密视频地址》教程,视频链接加密,小站长是玩不转的。说实话,mp4格式的视频,没有加密的必要。而blob加密,我试了,小宽带服务器确实是带不动的。
本文结束
评论专区
发表评论
评论列表(无评论)