dedecms拓展函数

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

 

//解密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