hi, i am having a problem with a script i was trying to install.
its says
Fatal error: Call to a member function on a non-object in /home/ourtamil/public_html/pibs/index.php on line 58
when i try running the script.
anyone have any idea what might cause this problem?
below is the script i am tryin to install
<?
if ($play_file) {
// The user has clicked on a song in the playlist...
header("Content-type: audio/mpeg");
readfile(trim($play_file));
exit;
} elseif ($show_source) {
// Show the code...
echo "<h1>header.inc</h1>";
show_source("./header.inc");
echo "<h1>$PHP_SELF</h1>";
show_source("./".basename($PHP_SELF));
echo "<h1>footer.inc</h1>";
show_source("./footer.inc");
exit;
}
$path = "home/ourtamil/public_html/pibs/mp3"; / This is the dir where you store your mp3 files /
include "./header.inc"; / This file draws the perty gui /
$tmp = "/tmp"; / This is your temp dir... it will hold your playlist /
$shout_command = "./source $HTTP_HOST 5000 'F00 Radi0' Various [url]http://[/url]$HTTP_HOST 0 0 0 1 192 ";
/ This is the command to connect a media source to your litestream server /
$shout_append = " litestreamSource >/dev/null &";
/ This is appended to $shout_command /
$killall = "source"; / This is what we kill when we restart $shout_command /
function get_greetz() {
/ This function returns an HTML table with links to sites you like /
$greetz = array(
"Litestream" => "www.litestream.net",
"php4.gif" => "www.php.net",
"mandrake.png" => "www.linux-mandrake.com",
"Apache" => "httpd.apache.org"
);
$str = "\n<table width=\"100%\" height=\"10\">\n\t<tr>";
foreach($greetz as $img => $url) {
if (file_exists("images/$img")) {
$img = "<img src=\"images/$img\" border=0 alt=\"$url\">";
}
$str .= "\n\t\t<td align=center><a href=\"$PHP_SELF?show_site=$url\">$img</a></td>";
}
$str .= "\n\t\t<td align=center><a href=\"http://sourceforge.net/projects/pibs/\"><img src=\"http://sourceforge.net/sflogo.php?group_id=21528\" width=88 height=31 border=0></a></td>";
$str .= "\n\t</tr>\n</table>\n";
return $str;
}
function get_cats($path) {
/ This function returns an array of directories directly beneath $music_path /
$d = dir($path);
while ($f = $d->read()) {
if ($f != "." && $f != "..") {
if (is_dir($path."/".$f)) {
$categories[] = $f;
}
}
}
return $categories;
}
function cat_list($music_path) {
$root_music_path = $GLOBALS[music_path];
$tab = " ";
/ This function returns an HTML table/form of your categories /
global $selected_cat,$random_play,$PHP_SELF,$show_subdirs;
$str = "\n\t\t\t\t\t\t<form method='post' action=\"$PHP_SELF\"><table cellspacing=0 cellpadding=0 bgcolor='silver'>";
$str .= "\n\t\t\t\t\t\t<tr height=10><td>view</td><td><select name=show_subdirs onchange='this.form.submit()'><option value=1".($show_subdirs?" selected":"").">recursively</option><option value=0".(!$show_subdirs?" selected":"").">top</option></select></td></tr>";
$bgcolor = 'silver';
foreach ($show_subdirs?recurse_dirs($music_path):get_cats($root_music_path) as $cat) {
$bgcolor = $bgcolor=='silver'?'#E0E0E0':'silver';
$human_cat = false;
$arr = explode("/",str_replace($root_music_path.'/',"",$cat));
$num_paths = count($arr)-1;
for ($counter=0;$counter<$num_paths;$counter++) {
$human_cat .= $tab;
}
$human_cat .= strlen($arr[$num_paths])>22?substr($arr[$num_paths],0,22).'...':$arr[$num_paths];
$str .= "\n\t\t\t\t\t\t<tr height=10 bgcolor='$bgcolor'><td nowrap>$human_cat</td><td><input type=checkbox name=selected_cat[] ".(is_array($selected_cat)?(in_array($cat,$selected_cat)?"checked ":""):"")."value=\"$cat\"></td></tr>";
}
return $str."\n\t\t\t\t\t\t<tr height=10><td>all</td><td><input type=checkbox name=all_cats value='1'></td></tr>\n\t\t\t\t\t\t<tr height=10><td>shuffle</td><td><input type=checkbox name=random_play ".(is_array($selected_cat)?($random_play?"checked ":""):"checked ")."value=1></td></tr>\n\t\t\t\t\t\t<tr height=10><td colspan=2><input class=button type=submit value=submit></td></tr></table></form>\n";
}
function recurse_dirs($dir,$kill_static=true) {
/ This function returns a recursive list of subdirectories /
static $foo = false;
global $music_path;
if ($kill_static) {
$foo = false;
}
if ($d = @dir(strstr($dir,$music_path)?$dir:$music_path.'/'.$dir)) {
while ($f = $d->read()) {
if ($f != "." && $f != "..") {
if (is_dir($dir."/".$f)) {
$foo[] = $dir."/".$f;
recurse_dirs($dir."/".$f,false);
}
}
}
return $foo;
} else {
echo '<br>cannot open '.$dir;
return false;
}
}
function get_mp3($dir) {
/ This function returns an array containing all files in $dir that end in '.mp3' /
global $music_path;
if (substr($dir,-1) != "/") {
$dir .= "/";
}
if ($d = @dir(strstr($dir,$music_path)?$dir:$music_path.'/'.$dir)) {
while ($f = $d->read()) {
if (substr($f,-4) == strtolower(".mp3")) {
$songs[] = $f;
}
}
return $songs;
} else {
echo '<br>cannot open '.$dir;
return false;
}
}
function random_play($arr) {
/ This function either sorts your array of songs or shuffles your array of songs based on POST input /
global $random_play;
if ($random_play) {
srand((double)microtime()1000000);
shuffle($arr);
} else {
usort($arr,"strcasecmp");
}
return $arr;
}
function show_list($list=false) {
/ This function reads in $list and prints HTML containing links to the songs in the playlist
If no $list is given, it looks for one in $tmp /
if ($list) {
$playlist = $list;
} else {
global $tmp;
$lists = dir($tmp);
while ($lst = $lists->read()) {
if (strstr($lst,"playlist")) {
$list = $lst;
}
}
if ($list) {
$playlist = $tmp."/".$list;
} else {
echo "cannot find a playlist";
}
}
if ($playlist) {
$songnum = 0;
echo "\n<table>\n";
foreach (file($playlist) as $thissong) {
echo "\n\t<tr><td>".++$songnum."</td><td nowrap><a href=\"$PHP_SELF?play_file=".urlencode($thissong)."\">".basename($thissong)."</a></td></tr>";
}
echo "\n</table>\n";
}
}
if ($show_list) {
show_list();
} elseif ($show_site) {
echo "\n<iframe src=\"http://$show_site\" height=100% width=85%><a href=\"http://$show_site/\">$show_site</a></iframe>\n";
} elseif ($show_stats) {
$stats = file("http://$HTTP_HOST:8000/");
echo "\n\t\t\t\t\t\t<table>\n";
for ($i=6;$i<19;$i++) {
echo "\t\t\t\t\t\t\t".$stats[$i];
}
echo "\n\t\t\t\t\t\t</table>\n";
} elseif ($all_cats) {
$dirs = recurse_dirs($music_path);
foreach ($dirs as $dir) {
$songs = get_mp3($dir);
if (is_array($songs)) {
$songs = random_play($songs);
foreach ($songs as $song) {
$allsongs[] = $dir."/".$song;
}
}
}
} elseif (is_array($selected_cat)) {
$dirs = array();
foreach($selected_cat as $key => $cat) {
//$selected_cat[$key] = $cat;// = $music_path."/".$cat;
echo "\n<!--\n";
echo "\n".$selected_cat[$key] = strstr($cat,$music_path)?$cat:$music_path.'/'.$cat;
$dirs = array_merge($dirs,recurse_dirs(strstr($cat,$music_path)?$cat:$music_path.'/'.$cat));
echo "\n-->\n";
}
$dirs = array_merge($selected_cat,$dirs);
foreach ($dirs as $dir) {
$songs = get_mp3($dir);
if (is_array($songs)) {
$songs = random_play($songs);
foreach ($songs as $song) {
$allsongs[] = $dir."/".$song;
}
}
}
}
if (is_array($allsongs)) {
killall -9 $killall >/dev/null;
rm -f $tmp/playlist*;
$pls = $tmp."/playlist.".time();
$fp = fopen($pls,"w");
$allsongs = random_play($allsongs);
foreach ($allsongs as $thissong) {
fputs($fp,(strstr($thissong,$music_path)?$thissong:$music_path.'/'.$thissong)."\n");
}
fclose($fp);
show_list($pls);
$shout = $shout_command.$pls.$shout_append;
echo "\n<!-- $shout -->\n";
exec($shout);
}
include "./footer.inc"; / This file prints the bottom of the gui including your greetz */
?>
thank you