这些函数是在一个视频站点中复制下来的,发布出来做一个备份,也许以后能用的上,至于函数的作用可以看一下具体代码,这里就不做解析了。 //解密js escape加密字符串 function unescape ( $str ) { $ret = ; $len = strlen ( $str ); for ( $i = 0 ; $i $len
这些函数是在一个视频站点中复制下来的,发布出来做一个备份,也许以后能用的上,至于函数的作用可以看一下具体代码,这里就不做解析了。
//解密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.=' .$link.'" class="img" title="'.$title.'" > .$img.'" width="165" alt="'.$title.'" height="124" /> .$time.' '
.$title.' ';
}
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.='
.
$img.'" width="128" height="182" alt="'.$title.'">
';
}
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.='.$cfg_templets_skin.'/images/star0.gif">';
}
for($i=0;$i$star2;$i++){
$html.='.$cfg_templets_skin.'/images/star2.gif">';
}
for($i=0;$i$star1;$i++){
$html.='.$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('/(.*?)/',$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;
}