Adding file within function without having to call file. php
i have stumbled across an issue and really need some help
i have got a function below which i am using in a wordpress plugin.
here is the code.
// Base function
function isd_s3player() {
// Plugin Url
$s3url = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
echo '<object type="application/x-shockwave-flash" data="'.$s3url.'dewplayer-playlist.swf" width="235" height="200" id="dewplayer" name="dewplayer">
<param name="wmode" value="transparent" />
<param name="wmode" value="transparent" />
<param name="movie" value="'.$s3url.'dewplayer-playlist.swf" />
<param name="flashvars" value="showtime=true&autoreplay=true&xml='.$s3url.'playlist.php&autostart=1" />
</object>';
}
ok the problem i am having is i cant passed the database variable to the playlist.php which the dewplayer needs to call within the function.
is their a way to somehow use or set the playlist.php in this function without having to call it seperatly???
Here is my playlist.php
<?php
$bucket = get_option("isd-bucket");
$folder = get_option("isd-folder");
//include the S3 class
if (!class_exists('S3'))require_once('s3/S3.php');
//AWS access info
if (!defined('awsAccessKey')) define('awsAccessKey', 'amazon key');
if (!defined('awsSecretKey')) define('awsSecretKey', 'amazon secret key');
//instantiate the class
$s3 = new S3(awsAccessKey, awsSecretKey);
// Get the contents of our bucket
$bucket_contents = $s3->getBucket($bucket,$folder);
header("Content-type: text/xml");
$xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$xml_output .= '<playlist version="1" xmlns="http://xspf.org/ns/0/">\n';
$xml_output .= "<trackList>\n";
foreach ($bucket_contents as $file){
$fname = $file['name'];
$furl = "http://$amazon_bucket.s3.amazonaws.com/".urlencode($fname);
if(preg_match("/\.mp3$/i", $furl))
{
if (isset($outputted[$furl])) {
continue;
}
$xml_output .= "\t<track>\n";
$xml_output .= "\t\t<location>" . $furl . "</location>\n";
$xml_output .= "\t\t<creator>" . $fname . "</creator>\n";
$xml_output .= "\t\t<album>" . $fname . "</album>\n";
$xml_output .= "\t\t<title>" . basename($fname) . "</title>\n";
$xml_output .= "\t\t<annotation>I love this song</annotation>\n";
$xml_output .= "\t\t<duration>32000</duration>\n";
$xml_output .= "\t\t<image>covers/smetana.jpg</image>\n";
$xml_output .= "\t\t<info></info>\n";
$xml_outpu开发者_如何学Ct .= "\t\t<link>" . $furl . "</link>\n";
$xml_output .= "\t</track>\n";
$outputted[$furl] = true;
}
}
$xml_output .= "</trackList>";
echo $xml_output;
?>
ok so as you can see right at the top i am trying to grab two option from the database but it doesnt allow you to do it this way within wordpress.
So i guess what i am asking is their a way to completely skip the playlist.php file and do everything within the function???
Any help??
Managed to get it working dont no why i have to do it the way but here it is.
function
$bucket = get_option("isd-bucket"); $folder = get_option("isd-folder");
$test = $bucket." ".$folder;
and in playlist
$bucket = $_GET["name"];
$pieces = explode(" ", $bucket);
$bucket_contents = $s3->getBucket($pieces[0],$pieces[1]);
if anyone nows why it wont work the other way please let me know
精彩评论