Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
fm5280
New Member
New Member



Joined: Jul 11, 2006
Posts: 6

PostPosted: Sat Jul 15, 2006 9:24 am Reply with quote

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>";

*/

?>
 
View user's profile Send private message
gregexp
The Mouse Is Extension Of Arm



Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol

PostPosted: Sat Jul 15, 2006 9:39 am Reply with quote

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!! 
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
fm5280







PostPosted: Sat Jul 15, 2006 9:49 am Reply with quote

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 thing
Code:
<?


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







PostPosted: Sat Jul 15, 2006 10:14 am Reply with quote

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







PostPosted: Sat Jul 15, 2006 10:19 am Reply with quote

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







PostPosted: Sat Jul 15, 2006 10:38 am Reply with quote

ok tried that, it didn't get the desired results. It is kinda hard to explain what happened but nothing showed up in the Current Listener block and it wiped out the formating of the whole page.

my nuke site is here http://fm5280.com/nuke/
and my php site is here http://fm5280.com

the current listeners block is the second one down on the left panel on each one.

What is strange is I can access it (the original code) directly and it produces results http://fm5280.com/nuke/modules.php?name=geotracker&file=geotrack
 
gregexp







PostPosted: Sat Jul 15, 2006 11:41 am Reply with quote

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







PostPosted: Sat Jul 15, 2006 11:52 am Reply with quote

I had stumbled across a solution by putting http://fm5280.com/nuke/modules.php?name=geotracker&file=geotrack in the include and it worked. thanks for your help.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©