Author |
Message |
fm5280
New Member


Joined: Jul 11, 2006
Posts: 6
|
Posted:
Sat Jul 15, 2006 9:24 am |
|
I am trying to get the results of a php script to appear in a Block. I have it working using an iframe but I need the block to size dynamically instead of a fixed size as the content varies. when using the outout buffer, nothing appears in the block, not even "no content avialble for this block". Can anyone point out what I am doing wrong or give me an easier way? Here is the code I am using with the iframe part commented out.
Code:<?php
if (eregi("block-CurrentListeners.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
ob_start();
include("modules/geotracker/geotrack.php");
$output = ob_get_contents();
ob_end_clean();
$content = $output;
?>
<?
//old shitz
/*
if (eregi("block-CurrentListeners.php",$_SERVER[PHP_SELF])) {
// Header("Location: ../index.php");
die();
}
$content .= "<p align='center'><center><iframe src=\"modules.php?name=geotracker&file=geotrack\" name=\"geotrack\" scrolling=\"no\" frameborder=\"no\" align=\"top\" width=\"150\" height=\"150\">";
$content .= " . \</iframe></center></p>";
*/
?>
|
|
|
|
|
 |
gregexp
The Mouse Is Extension Of Arm

Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol
|
Posted:
Sat Jul 15, 2006 9:39 am |
|
To be honest, not making any sense for what you are trying to do, include will not put anything into the buffer, unless the included script does??
Whats the goal here?
Just for s*** and gigles, lets see the file your trying to include. |
_________________ For those who stand shall NEVER fall and those who fall shall RISE once more!! |
|
 |
 |
fm5280

|
Posted:
Sat Jul 15, 2006 9:49 am |
|
darklord wrote: | To be honest, not making any sense for what you are trying to do, include will not put anything into the buffer, unless the included script does??
Whats the goal here?
Just for s*** and gigles, lets see the file your trying to include. | sure thingCode:<?
require("modules/geotracker/shoutcast.class.phps");
require("modules/geotracker/geoip.phps");
require("modules/geotracker/config.php");
$index = 1;
is_readable("modules/geotracker/GeoIP.dat") or exit("Error: GeoIP.dat not found!");
function elapsedtime($seconds) {
if ($seconds > 86400) {
$seconds -= 86400;
return(gmdate("j\d H:i:s", $seconds));
} else
return(gmdate("H:i:s", $seconds));
}
$listenersArray["Total"]["current"] = 0;
$listenersArray["Total"]["max"] = 0;
?>
<?
$gi = geoip_open("modules/geotracker/GeoIP.dat", GEOIP_STANDARD);
for ($count = 0; $count < count($serv["host"]); $count++) {
$shoutcast = new ShoutCast();
$shoutcast->name = $serv["name"][$count];
$shoutcast->host = $serv["host"][$count];
$shoutcast->port = $serv["port"][$count];
$shoutcast->passwd = $serv["passwd"][$count];
$listenersArray["$shoutcast->name"]["current"] = "NA";
$listenersArray["$shoutcast->name"]["max"] = "NA";
//echo "<td valign=\"top\">[<b>$shoutcast->name</b>]<b><a href=\"http://$shoutcast->host:$shoutcast->port\" target=\"_blank\">$shoutcast->host:$shoutcast->port</a></b> - ";
if ($shoutcast->openstats()) {
// We got the XML, gogogo!..
if ($shoutcast->GetStreamStatus()) {
$listenersArray["$shoutcast->name"]["current"] = $shoutcast->GetCurrentListenersCount();
$listenersArray["$shoutcast->name"]["max"] = $shoutcast->GetMaxListenersCount();
$listenersArray["Total"]["current"] += $shoutcast->GetCurrentListenersCount();
$listenersArray["Total"]["max"] += $shoutcast->GetMaxListenersCount();
/* echo "
<br> Currently ".$shoutcast->GetCurrentListenersCount()." out of "
.$shoutcast->GetMaxListenersCount()." people listening
<br> listener peak was "
.$shoutcast->GetPeakListenersCount()."
<br>
".$shoutcast->GetWebHitsCount()." webhits<br /> ".$shoutcast->GetStreamHitsCount()." streamhits<br /> average listen time is ".elapsedtime($shoutcast->GetAverageListenTime())."
<br> Current Song: ".$shoutcast->GetCurrentSongTitle()."
";
*/
$listenerssc = $shoutcast->GetListeners();
if (is_array($listenerssc)) {
for ($i=0;$i<sizeof($listenerssc);$i++) {
$country_id = geoip_country_id_by_name($gi, $listenerssc[$i]["hostname"]);
$country_name = $GLOBALS['GEOIP_COUNTRY_NAMES'][$country_id];
if (!$country_id) {
$country_id = 0;
$country_name = "Earth(unidentified)";
}
$from["$country_id"]++;
}
}
/*
else {
echo "
No one is listening right now..
\n";
}
echo " \n";
*/
} else {
echo "Server is up, but no stream available..
\n";
}
}
/* else {
// Ohhh, damnit..
echo $shoutcast->geterror();
echo "\n \n \n";
}
echo " \n";
*/
}
geoip_close($gi);
?>
<?
$c = 0;
arsort($from);
reset($from);
while (list($key, $val) = each($from)) {
$country_code = $GLOBALS['GEOIP_COUNTRY_CODES']["$key"];
$country_name = $GLOBALS['GEOIP_COUNTRY_NAMES']["$key"];
if (!$country_code) {
if (!$key && $key != 0) {
$country_code = $key;
} else {
// I don't want to show unidentified hosts in ranking.
// $country_code = "N/A";
continue;
}
}
/*
if(($c % 2) == 0)
$rowcolor = $lightrow;
else
$rowcolor = $darkrow;
*/ ?>
<b><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="teal">
<?
echo"<img src=\"modules/geotracker/flags/$country_code.GIF\" alt=\"The flag of $country_name\" /> $country_name";
echo " (";
echo $val;
echo ")";
echo "</td>
</tr>
\n";
$countrycount++;
if ($countrycount >= $countrylimit) break;
$c++;
echo "<br>";
}
?>
|
|
|
|
|
 |
gregexp

|
Posted:
Sat Jul 15, 2006 10:14 am |
|
ok so youd like to include this script within a block, this should be easily done without the ob_get function, Let me try some things and I'll get back to you. |
|
|
|
 |
gregexp

|
Posted:
Sat Jul 15, 2006 10:19 am |
|
You should move the ob_end_clean(); below the content statement.
I may be wrong but from my understanding, it will start the output buffering, then clean the output, then the content will call to return the contents of the buffer, remember that the variable isnt being called on until AFTER the buffers been clean,
Know what I mean?
just try this:
Code:<?php
if (eregi("block-CurrentListeners.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
ob_start();
include("modules/geotracker/geotrack.php");
$output = ob_get_contents();
ob_end_clean();
$content = $output;
ob_end_clean();
?>
|
|
|
|
|
 |
fm5280

|
Posted:
Sat Jul 15, 2006 10:38 am |
|
|
|
 |
gregexp

|
Posted:
Sat Jul 15, 2006 11:41 am |
|
My apologies wrong code
Try this:
Code:<?php
if (eregi("block-CurrentListeners.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
ob_start();
include("modules/geotracker/geotrack.php");
$output = ob_get_contents();
$content = $output;
ob_end_clean();
?>
|
|
|
|
|
 |
fm5280

|
Posted:
Sat Jul 15, 2006 11:52 am |
|
|
|
 |
|