• 全国400电话网上服务平台
    强大号码库资源任选,方便,快捷,快速开通。
    咨询热线:400-1100-266  

    dedecms拓展函数
    POST TIME:2021-05-24 03:12

    这些函数是在一个视频站点中复制下来的,发布出来做一个备份,也许以后能用的上,至于函数的作用可以看一下具体代码,这里就不做解析了。

     

    //解密js escape加密字符串
    function unescape($str) {  
        $ret = '';  
        $len = strlen ( $str );  
        for($i = 0; $i < $len; $i ++) {  
            if ($str [$i] == '%' && $str [$i + 1] == 'u') {  
                $val = hexdec ( substr ( $str, $i + 2, 4 ) );  
                if ($val < 0x7f)  
                    $ret .= chr ( $val );  
                else if ($val < 0x800)  
                    $ret .= chr ( 0xc0 | ($val >> 6) ) . chr ( 0x80 | ($val & 0x3f) );  
                else  
                    $ret .= chr ( 0xe0 | ($val >> 12) ) . chr ( 0x80 | (($val >> 6) & 0x3f) ) . chr ( 0x80 | ($val & 0x3f) );  
                $i += 5;  
            } else if ($str [$i] == '%') {  
                $ret .= urldecode ( substr ( $str, $i, 3 ) );  
                $i += 2;  
            } else  
                $ret .= $str [$i];  
        }  
        return $ret;  
    }
    //获取视频搜索结果列表
    function get_videolist($str){
      global $cfg_cmsurl;
      $result="";
      foreach(explode('$@#$',$str) as $item){
         if(trim($item)=="") continue;
    	 $arr=explode('$#',$item);
    	 $link=$cfg_cmsurl."/play/".$arr[0];
    	 $title=$arr[1];
    	 $img=get_local_img($arr[2]);
    	 $time=$arr[3];
    	 $result.=' <li><a href="'.$link.'" class="img" title="'.$title.'" > <img src="'.$img.'" width="165" alt="'.$title.'" height="124" /> <label class="bg"></label> <label class="state">'.$time.'</label> </a> <h3>'.$title.'</h3></li> ';
      }
      return $result;
    }
    //获得视频详细信息html
    function get_videodetail($str){
      global $cfg_cmsurl;
      $result="";
      foreach(explode('$@#$',$str) as $item){
         if(trim($item)=="") continue;
    	 $arr=explode('$#',$item);
    	 $link=$cfg_cmsurl."/play/".$arr[0];
    	 $title=$arr[1];
    	 $img=get_local_img($arr[2]);
    	 $nianfen=$arr[3];
    	 $pingfen=$arr[4];
         $star=get_star_html($pingfen);
    	 $column=$arr[5];
    	 $status=$arr[6];
    	 $zhuyan=str_replace('/','',$arr[7]);
    	 $diqu=$arr[8];
    	 $leixing=str_replace('/','',$arr[9]);
    	 $intro=$arr[10];
    	 $result.='<div class="content"> <div class="detail"> <div class="picture"> <div class="pic"><img src="'.$img.'" width="128" height="182" alt="'.$title.'"></div> <span></span> </div> <div class="summary"> <h1><a rel="nofollow" href="'.$link.'">'.$title.'</a><span>('.$column.') '.$nianfen.'</span></h1> <p class="role"><span><strong>主演:</strong>'.$zhuyan.'</span>  </p> <p class="two"> <span><strong>更新:</strong><em>'.$status.'</em></span> <span><strong>类型:</strong>'.$leixing.'</span> <span><strong>地区:</strong>'.$diqu.'</span> </p> <p class="opera"><strong>剧情:</strong>'.$intro.'<span class="synopsis"><a href="'.$link.'" rel="nofollow">详细剧情</a></span></p> <p class="bf"><a title="快速观看" rel="nofollow" href="'.$link.'" class="playlink"></a> <a href="'.$cfg_cmsurl.'/plus/desktop.html?name='.$title.'" rel="nofollow" class="desktop"></a> </p> <div class="pingfen">'.$star.'&nbsp;<strong style="font-size:18px;color:red" id="MARK_B2">'.$pingfen.'</strong></div> </div> <div class="back"></div> </div> </div>';
      }
      return $result;
    }
    function get_star_html($pingfen){
         global $cfg_templets_skin;
    	 $star0=(int)($pingfen/2);
    	 $star1=(int)((10-$pingfen)/2);
    	 $star2=5-$star0-$star1;
    	 $html='';
    	 for($i=0;$i<$star0;$i++){
    	   $html.='<img src="'.$cfg_templets_skin.'/images/star0.gif">';
    	 }
    	 for($i=0;$i<$star2;$i++){
    	   $html.='<img src="'.$cfg_templets_skin.'/images/star2.gif">';
    	 }
    	 for($i=0;$i<$star1;$i++){
    	   $html.='<img src="'.$cfg_templets_skin.'/images/star1.gif">';
    	 }
    	 return $html;
    }
    function get_local_img($url){
       global $cfg_cmsurl;
       $result=$url;
       if(!strstr($url,'http://')&&!strstr($url,'/images/defaultpic.gif')){
        $result=$cfg_cmsurl.$url;
       }elseif(!strstr($url,'/images/defaultpic.gif')){
          //将远程地址替换为伪静态地址
    	   $filename=basename($url);
    	  $result=$cfg_cmsurl.'/static/'.$filename;
       }
       return $result;
    }
    function curl_get($url,$gzip=false){
    	$curl = curl_init();
    	curl_setopt($curl, CURLOPT_URL, $url);
    	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);  //抓取https网页
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); //抓取https网页
    	curl_setopt($curl, CURLOPT_HEADER, false);
    	curl_setopt($curl, CURLOPT_REFERER,$url);
    	curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; SeaPort/1.2; Windows NT 5.1; SV1; InfoPath.2)'); 
    	curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
    	curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookie.txt');
    	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
    	if($gzip) curl_setopt($curl, CURLOPT_ENCODING, "gzip"); 
    	$values = curl_exec($curl);
    	curl_close($curl);
    	return($values);
    }
    function curl_post($url,$post){
    	$curl = curl_init();
    	curl_setopt($curl, CURLOPT_URL, $url);
    	curl_setopt($curl, CURLOPT_HEADER, false);
    	curl_setopt($curl, CURLOPT_REFERER,$url);
    	curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; SeaPort/1.2; Windows NT 5.1; SV1; InfoPath.2)'); 
    	curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
    	curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookie.txt');
    	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
    	curl_setopt($curl, CURLOPT_POST, 1);//post提交方式 
        curl_setopt($curl, CURLOPT_POSTFIELDS, $post); 	//指定post提交的参数
    	$values = curl_exec($curl);
    	curl_close($curl);
    	return($values);
    }
    function get_baidu_keys($type){
       if($type=="all") $url="http://top.baidu.com/buzz?b=1";
       elseif($type=="week") $url="http://top.baidu.com/buzz?b=42";
       $html=curl_get($url);
       $html=iconv("GB2312","UTF-8//IGNORE",$html);
       preg_match_all('/<a class="list-title"(.*?)>(.*?)<\/a>/',$html,$arr);
       $data=$arr[2];
       return $data;
    }
    function get_rewrite_url($url){
      global $rewriteArr,$db;
      $re='';
      if(strstr($url,"list.php")){
        preg_match('/list.php\?tid=([\d]+)/',$url,$arr);
    	$id=$arr[1];
    	$sn=$rewriteArr[$id];
    	$re=preg_replace('/plus\/list.php\?tid=([\d]+)/',$sn.'/',$url);
      }elseif(strstr($url,"view.php")){
        preg_match('/view.php\?aid=([\d]+)/',$url,$arr);
    	$id=$arr[1];
    	//查询出sn
    	$row=$db->GetOne("select urlsn from dede_addonmovie where aid=$id");
    	if(isset($row['urlsn'])) $sn=trim($row['urlsn']);
    	$re=preg_replace('/plus\/view.php\?aid=([\d]+)/',$sn.'/',$url);
      }
      return $re;
    }
    function get_filter_title($typename){
      global $sn,$rewriteArr,$leixing;
      $sn=trim($sn);
      $re='';
      $arr=array_flip($rewriteArr);
      $tid=$arr[$sn];
      if(strstr($leixing,'剧')&&$tid==2) $re=$leixing;
      else  $re=$leixing.$typename;
      return $re;
    } 
    
    关于我们 | 付款方式 | 建站知识 | 增值服务 | 网站模板
    Copyright © 2003-2016
    时间:9:00-21:00 (节假日不休)
    版权所有:巨人网络(扬州)科技有限公司
    总部地址:江苏省信息产业基地11号楼四层
    《增值电信业务经营许可证》 苏B2-20120278
    X

    截屏,微信识别二维码

    微信号:veteran88

    (点击微信号复制,添加好友)

     打开微信

    微信号已复制,请打开微信添加咨询详情!