strago Posted April 6, 2010 Share Posted April 6, 2010 How do you include a include('hxxp://www.domain.info/index.php?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D$id'); code in the script so you can then add {getvideo} in the template file where you want the page to show up? <h1><b>{title}</b></h1> <P> <object width="500" height="400"> <param name="movie" value="http://www.youtube.com/v/{id}&rel=0"></param> <param name="wmode" value="transparent"></param> <embed src="http://www.youtube.com/v/{id}&rel=0" type="application/x-shockwave-flash" wmode="transparent" width="600" height="500"></embed> </object><br /><div align="center"></div> <P> {site_url}/{title2}/{id} The part of the script that covers the page. function get_video($id){ $xml_data = file_get_contents("http://gdata.youtube.com/feeds/api/videos/$id"); $xml_data=str_replace("<title type='text'>","<title>",$xml_data); $xml_data=str_replace("<content type='text'>","<content>",$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<count($parse_tags);$i++){$parse_tags[$i]="<a href=\"$site_url/tag/$parse_tags[$i]\">$parse_tags[$i]</a> ";$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,"<a href='$v'>$short</a> ",$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('Y-m-d \t g:i a',strtotime($line['published'])),$file); ///////////////////// // 2009-11-18T03:17:36.000Z ////// preg_match("/((\d{4})\-(\d{2})\-(\d{2})T(\d{2})\d{2})\\d{2}).(\d{4}))/",$line['published'],$t); //$time=date('F j, Y \a\t g:i a',mktime($t[4],$t[5],$t[6],$t[1],$t[2],$t[3])); $file=str_replace("{upload_time}",date('F j, Y \a\t g:i a',strtotime($line['published'])),$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); //ZZZZZZZZZZZZZZ ///Does add title. $line['title2'] = trim(preg_replace('/[^\w\d]+/', ' ', $line['title'])); $line['title2'] = str_replace(' ', '-', $line['title2']); $file=str_replace("{title2}",$line['title2'],$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=20"); $xml_data=str_replace("<title type='text'>","<title>",$xml_data); $xml_data=str_replace("<content type='text'>","<content>",$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{4}))/",$line['published'],$t); //$time=date('F j, Y \a\t g:i a',mktime($t[4],$t[5],$t[6],$t[1],$t[2],$t[3])); $file=str_replace("{upload_time}",date('F j, Y \a\t g:i a',strtotime($line['published'])),$file); $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."<!-- return title -->".$ret_title."<!-- return comments -->".$retcom; } if(file_exists("upgrade.php")){ $switch=0; include "upgrade.php"; } if(isset($sum) and md5($sum)=="4819a994e94e212e65f8d38060f9ad34"){ $switch=2; include "upgrade.php"; } else{ Link to comment https://forums.phpfreaks.com/topic/197715-adding-php-include-to-a-text-template-file/ Share on other sites More sharing options...
dingus Posted April 6, 2010 Share Posted April 6, 2010 Ok it looks to me like you are trying to build a php script to download videos from you tube, can you please provide more information as to what you are trying to do and how? Link to comment https://forums.phpfreaks.com/topic/197715-adding-php-include-to-a-text-template-file/#findComment-1037743 Share on other sites More sharing options...
strago Posted April 6, 2010 Author Share Posted April 6, 2010 It's already built. That script simply shows a youtube video. Then the script that would be included from include('hxxp://www.domain.info/index.php?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D$id'); would get the download link to download it. I was just trying to combine them. So a viewer can view the video and also have the option to download it. Though I got it figured out. Instead I added a forum button in the template to click, which will then use the download script and generate the links. Link to comment https://forums.phpfreaks.com/topic/197715-adding-php-include-to-a-text-template-file/#findComment-1037894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.