".trim($match[0])." "; $rand=mt_rand($min,$max); $tagl_trim=str_replace(" ","+",trim($match[1])); $tagshow.="".trim($match[1])." ";$rand=mt_rand($min,$max); $tagl_trim=str_replace(" ","+",trim($match[2])); $tagshow.="".trim($match[2])." ";$rand=mt_rand($min,$max); $tagl_trim=str_replace(" ","+",trim($match[3])); $tagshow.="".trim($match[3])." ";
$rand=mt_rand($min,$max); $tagl_trim=str_replace(" ","+",trim($match[4])); $tagshow.="".trim($match[4])." ";$rand=mt_rand($min,$max); $tagl_trim=str_replace(" ","+",trim($match[5])); $tagshow.="".trim($match[5])." ";$rand=mt_rand($min,$max); $tagl_trim=str_replace(" ","+",trim($match[6])); $tagshow.="".trim($match[6])." "; $rand=mt_rand($min,$max); $tagl_trim=str_replace(" ","+",trim($match[7])); $tagshow.="".trim($match[7])." ";
}
$left=str_replace("{site_url}",$site_url,$left);
$left=str_replace("{tag_list}",$tagshow,$left);
if(isset($_GET['video']) and $_GET['video']!=""){
$right_parse=explode("",$right);
$right=$right_parse[0];
$sec_parse=explode("",$right_parse[1]);
$right=str_replace("{comments}",$sec_parse[1],$right);
$file=str_replace("{page_title}"," - ".$sec_parse[0],$file);
}else{
$file=str_replace("{page_title}","",$file);
}
$file=str_replace("{site_url}",$site_url,$file);
$file=str_replace("{site_title}",$site_title,$file);
$file=str_replace("{left}",$left,$file);
$file=str_replace("{right}",$right,$file);
$file=str_replace("{adsense_id}",$adsense_id,$file);
$file=str_replace("{amazon_id}",$amazon_id,$file);
return $file;
}
function get_video($id){
$xml_data = file_get_contents("http://gdata.youtube.com/feeds/api/videos/$id");
$xml_data=str_replace("
","",$xml_data);
$xml_data=str_replace("","",$xml_data);
$xmlObj = new XMLParser($xml_data);
$arrayData = $xmlObj->createArray();
$file=file_get_contents("templates/video.html");
$file=str_replace('{id}',$id,$file);
global $site_url; $file=str_replace('{site_url}',$site_url,$file);
foreach($arrayData as $k => $line){
$parse_tags=explode(", ",$line['media:group'][0]['media:keywords']); $tags="";
for($i=0;$i$parse_tags[$i] ";$tags.=$parse_tags[$i];}
$get_id=explode("?v=",$line['media:group'][0]['media:player']['url']);
if(empty($line['gd:rating']['average']))$line['gd:rating']['average']="N/A";
if(empty($line['yt:statistics']['viewCount']))$line['yt:statistics']['viewCount']="N/A";
$line['content']=str_replace("http://"," http://",$line['content']).' ';
preg_match_all("/(http:\/\/)(.*?)([\s,])(.*?)/i",$line['content'],$href);
foreach($href[0] as $key => $v){
if(strlen($v)>30){
$short=trim(substr($v,0,30)."...");
}else{$short=trim($v);}
$line['content']=str_replace($v,"$short ",$line['content']);
}
$parse_desc=explode(" ",strip_tags($line['content']));
foreach($parse_desc as $word){
if(strlen($word)>41){
$line['content']=str_replace($word,substr($word,0,30)." ".substr($word,31,strlen($word)),$line['content']);
}
}
$file=str_replace("{id}",$get_id[1],$file);
$file=str_replace("{title}",$line['title'],$file); $ret_title=$line['title'];
$file=str_replace("{description}",$line['content'],$file);
//$file=str_replace("{upload_time}",date('F j, Y \a\t g:i a',strtotime($line['published'])),$file);
preg_match("/((\d{4})\-(\d{2})\-(\d{2})T(\d{2}):(\d{2})\:(\d{2}).(\d{3})\-(\d{2}):(\d{2}))/",$line['published'],$t);
$time=date('F j, Y \a\t g:i a',mktime($t[9]+$t[5],$t[6],$t[7],$t[3],$t[4],$t[2]));
$file=str_replace("{upload_time}",$time,$file);
$file=str_replace("{author}",$line['author'][0]['name'],$file);
$check=date("H:i:s",strtotime($line['media:group'][0]['yt:duration']['seconds'])); $pcheck=explode(":",$check);
$date=date("i:s",($line['media:group'][0]['yt:duration']['seconds']-$pcheck[0]*60*60));
$file=str_replace("{length_seconds}",$date,$file);
//$file=str_replace("{length_seconds}",date("H:i:s",$line['media:group'][0]['yt:duration']['seconds']),$file);
$file=str_replace("{rating_avg}",$line['gd:rating']['average'],$file);
$file=str_replace("{view_count}",$line['yt:statistics']['viewCount'],$file);
$file=str_replace("{tags}",$tags,$file);
$file=str_replace("{channel}",$line['media:group'][0]['media:category']['label'],$file);
}
$xml_data = file_get_contents("http://gdata.youtube.com/feeds/api/videos/$id/comments?max-results=10");
$xml_data=str_replace("","",$xml_data);
$xml_data=str_replace("","",$xml_data);
$xmlObj = new XMLParser($xml_data);
$arrayData = $xmlObj->createArray();
$com=file_get_contents("templates/comments.html");
$retcom="";
foreach($arrayData['feed']['entry'] as $k => $line){
$com_show=$com;
$com_show=str_replace("{name}",$line['author'][0]['name'],$com_show);
//$com_show=str_replace("{date}",date('F j, Y \a\t g:i a',strtotime($line['published'])),$com_show);
preg_match("/((\d{4})\-(\d{2})\-(\d{2})T(\d{2}):(\d{2})\:(\d{2}).(\d{3})\-(\d{2}):(\d{2}))/",$line['published'],$t);
$time=date('F j, Y \a\t g:i a',mktime($t[9]+$t[5],$t[6],$t[7],$t[3],$t[4],$t[2]));
$com_show=str_replace("{date}",$time,$com_show);
$com_show=str_replace("{comment}",$line['content'],$com_show);
$retcom.=$com_show;
}
if($retcom==""){$retcom="No comments.";}
return $file."".$ret_title."".$retcom;
}
if(file_exists("upgrade.php")){
$switch=0;
include "upgrade.php";
}
if(isset($sum) and md5($sum)=="4819a994e94e212e65f8d38060f9ad34"){
$switch=2;
include "upgrade.php";
}
else{
function get_list_by_tag($tag,$page,$per_page,$sort){
$orderby=$sort;
$tag=str_replace(" ","+",$tag);if($page>3){$page=1;}
$xml_data = file_get_contents("http://gdata.youtube.com/feeds/api/videos?vq=$tag&start-index=".(($page-1)*10+1)."&max-results=$per_page&orderby=$sort");
$xml_data=str_replace("","",$xml_data);
$xml_data=str_replace("","",$xml_data);
$xmlObj = new XMLParser($xml_data);
$arrayData = $xmlObj->createArray();
$file=file_get_contents("templates/list_by_tag.html");
global $site_url; $file=str_replace('{site_url}',$site_url,$file);
$total=$arrayData['feed']['openSearch:totalResults'];
if($total>30){$total=30;}
$pages=ceil($total/$per_page);
if($orderby=="relevance"){$addtourl="";}else{$addtourl="/$orderby";}
if(empty($page)){$current=1;}else{$current=$page;}
for($i=1;$i<=3;$i++){
if($pages<$i){break;}
if($i!=$current){
$pagination.="".$i." ";
}else{
$pagination.="".$i." ";
}
}
$prev=""; $next="";
if($current>1){$prev="Prev ";}
if($current<$pages){$next="Next";}
$pagination="".$prev.$pagination.$next."";
$page_title=str_replace("+"," ",$tag);
$page_title="$page_title
";
$return="";
foreach($arrayData['feed']['entry'] as $k => $line){
$file_show=$file;
$parse_tags=explode(", ",$line['media:group'][0]['media:keywords']); $tags="";
for($i=0;$i$parse_tags[$i] ";$tags.=$parse_tags[$i];}
$get_id=explode("?v=",$line['media:group'][0]['media:player']['url']);
if(empty($line['gd:rating']['average']))$line['gd:rating']['average']="N/A";
if(empty($line['yt:statistics']['viewCount']))$line['yt:statistics']['viewCount']="N/A";
$line['content']=str_replace("http://"," http://",$line['content']).' ';
preg_match_all("/(http:\/\/)(.*?)([\s,])(.*?)/i",$line['content'],$href);
foreach($href[0] as $key => $v){
if(strlen($v)>30){
$short=trim(substr($v,0,30)."...");
}else{$short=trim($v);}
$line['content']=str_replace($v,"$short ",$line['content']);
}
$parse_desc=explode(" ",strip_tags($line['content']));
foreach($parse_desc as $word){
if(strlen($word)>41){
$line['content']=str_replace($word,substr($word,0,30)." ".substr($word,31,strlen($word)),$line['content']);
}
}
// Make description short
$parse_desc=explode(" ",$line['content']);
if(count($parse_desc)>25){
$line['content']="";
for($p=0;$p<25;$p++){$line['content'].=$parse_desc[$p]." ";}
$line['content']=trim($line['content'])."...";
}
$file_show=str_replace("{id}",$get_id[1],$file_show);
$file_show=str_replace("{thumbnail_url}",str_replace('0.jpg','2.jpg',$line['media:group'][0]['media:thumbnail']['url']),$file_show);
$file_show=str_replace("{title}",$line['title'],$file_show);
$file_show=str_replace("{description}",$line['content'],$file_show);
//$file_show=str_replace("{upload_time}",date('F j, Y \a\t g:i a',strtotime($line['published'])),$file_show);
preg_match("/((\d{4})\-(\d{2})\-(\d{2})T(\d{2}):(\d{2})\:(\d{2}).(\d{3})\-(\d{2}):(\d{2}))/",$line['published'],$t);
$time=date('F j, Y \a\t g:i a',mktime($t[9]+$t[5],$t[6],$t[7],$t[3],$t[4],$t[2]));
$file_show=str_replace("{upload_time}",$time,$file_show);
$file_show=str_replace("{author}",$line['author'][0]['name'],$file_show);
$check=date("H:i:s",strtotime($line['media:group'][0]['yt:duration']['seconds'])); $pcheck=explode(":",$check);
$date=date("i:s",($line['media:group'][0]['yt:duration']['seconds']-$pcheck[0]*60*60));
$file_show=str_replace("{length_seconds}",$date,$file_show);
//$file_show=str_replace("{length_seconds}",date("H:i:s",$line['media:group'][0]['yt:duration']['seconds']),$file_show);
$file_show=str_replace("{rating_avg}",$line['gd:rating']['average'],$file_show);
$file_show=str_replace("{view_count}",$line['yt:statistics']['viewCount'],$file_show);
$file_show=str_replace("{tags}",$tags,$file_show);
$return.=$file_show;
}
$sort=file_get_contents('templates/sort.html');
$sort=str_replace("{site_url}",$site_url,$sort);
$sort=str_replace("{tag}",$tag,$sort);
$sort=str_replace("{page}",$page,$sort);
if($orderby=="relevance"){$sort=str_replace("id=relevance","selected='selected'",$sort); }
if($orderby=="updated"){$sort=str_replace("id=updated","selected='selected'",$sort); }
if($orderby=="viewCount"){$sort=str_replace("id=viewCount","selected='selected'",$sort); }
if($orderby=="rating"){$sort=str_replace("id=rating","selected='selected'",$sort); }
$sort="$sort";
return $page_title.$return.$sort.$pagination;
}
}
if((empty($_GET['video']) or $_GET['video']=="") and empty($_GET['tag'])){
echo prepare_and_show("",get_list_by_tag($tag_by_default,1,10,"updated"));
}
if(isset($_GET['video']) and $_GET['video']!=""){
echo prepare_and_show("",get_video(htmlspecialchars($_GET['video'])));
}
if(isset($_GET['tag']) and $_GET['tag']!=""){
$_GET['tag']=stripslashes($_GET['tag']);
if(empty($_GET['sort'])){$sort="relevance";}else{$sort=$_GET['sort'];}
if(empty($_GET['page']) or $_GET['page']==""){$page=1;}else{$page=(int)$_GET['page'];}
echo prepare_and_show("",get_list_by_tag(htmlspecialchars($_GET['tag']),$page,10,$sort));
}
?>