Looking for help with PHP?

Cassie

New member
I have a page on my website that uses PHP to embed YouTube videos. I'm not the one who set it up and I'm awful with PHP, so I thought I'd ask here.
Anyway, it's called 'player.php'. So if I, say, point my browser to http://www.website.com/player.php?id=dmKeIlJq4gM
It will show the page and have the YouTube video embedded. Here's my PHP script:
$referer = getenv("HTTP_REFERER");
$version='1.01';
$fontface = "Verdana,Arial";
$image = $_GET['id'];
$alt = $_GET['alt'];
if (!$alt){ $alt=''; }
$counter = 0;
$type = 0;
$tag = "";
$commentInfo = array();
$video_detailsInfo = array();
function opening_element($xmlParser, $name, $attribute){ global $tag, $type; $tag = $name;
if($name == "VIDEO_DETAILS"){ $type = 1; }
else if($name == "COMMENT"){ $type = 2; }
}//end opening element
function closing_element($xmlParser, $name){
global $tag, $type, $counter;
$tag = "";
if($name == "COMMENT"){
$type = 0;
$counter++;
}
else if($name == "VIDEO_DETAILS"){
$type = 0;
}
}//end closing_element
function c_data($xmlParser, $data){
global $tag, $type, $video_detailsInfo, $commentInfo, $counter;
$data = trim(htmlspecialchars($data));
if("AUTHOR" || $tag == "TITLE" || $tag == "RATING_AVG" || $tag == "RATING_COUNT" || $tag == "TAGS" || $tag == "DESCRIPTION" || $tag == "UPDATE_TIME" || $tag == "VIEW_COUNT" || $tag == "UPLOAD_TIME" || $tag == "LENGTH_SECONDS" || $tag == "RECORDING_DATE" || $tag == "RECORDING_LOCATION" || $tag == "RECORDING_COUNTRY" || $tag == "COMMENT_LIST" || $tag == "CHANNEL_LIST" || $tag == "AUTHOR" || $tag == "TEXT" || $tag == "TIME"){
if($type == 1){
$video_detailsInfo[strtolower($tag)] = $data;
}//end checking video_details
else if($type == 2){
$commentInfo[$counter][strtolower($tag)] .= $data;
}//end checking for comment
}//end checking tag
}//end cdata funct
$xmlParser = xml_parser_create();
xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, TRUE);
xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, TRUE);
xml_set_element_handler($xmlParser, "opening_element", "closing_element");
xml_set_character_data_handler($xmlParser, "c_data");
$fp = fopen("http://www.youtube.com/feeds/api/videos/video_id=$image");
foreach((array) $fp as $line){
if(!xml_parse($xmlParser, $line)){
die("Could not parse file.");
}
}

And that's all.
Then, for embedding the video:
<object width="320" height="269">
<param name="movie" value="http://www.youtube.com/v/<?php echo"$image" ?>&autoplay=1" />
<embed src="http://www.youtube.com/v/<?php echo"$image" ?>&autoplay=1" type="application/x-shockwave-flash" width="320" height="269"></embed>
</object>

Which all works fine. But I'd like to have the page list info about the video. For the title, I tried:
You are now watching <font color="#404d6c"><b><?php echo $video_detailsInfo["title"];?></b></font>

But that didn't work. Can anyone help?
 
Back
Top