<?
/*
// solar.php
//
// Version: 0.0.2
//
// Author: Cedric Raguenaud
// Lastmod: 07/08/2001
// Homepage: http://www.dcs.napier.ac.uk/~cedric
//
// This is an PHP include of SSI file
//
// PHP:
// <?
// include("solar.php");
// ?>
//
// SSI:
// <!--#include virtual="solar.php" -->
//
// Feel free to modify the code and e-mail me fixes as you see
// them fit...
//
*/
include_once("Snoopy.class");
// Customize as you like it
$begin = "<td class=\"ItemListSource\" colspan=\"2\">";
$end = "</TABLE>";
$marker1 = "<A href=";
$link_prefix = "o <FONT SIZE=-1>";
$link_postfix = "</FONT><BR>\n";
$cache_time = 7200;
$target = "_top";
$name = "solar";
// End of customizations
$backend = "http://www.newsisfree.com/sources/info/19/";
$time = split(" ", microtime());
srand((double)microtime()*1000000);
$cache_time_rnd = 300 - rand(0, 600);
$cache_info = "";
$db2 = new myDB($config["sqlserver"], $config["sqluser"], $config["sqlpassword"], $config["sqldatabase"]);
if ($db2) {
$query = "select * from boxes where name = '".addslashes($name)."'";
$db2->setQuery($query);
$r2 = $db2->executequery();
if ($r2 >0) {
if ($db2->hasMoreElements()) {
$row2 = $db2->nextElement();
}
}
if ( ($row2["cache"] == "") || (($row2["time"] + $config["cache_time"] - $time[1]) + $cache_time_rnd < 0) ) {
$snoopy = new Snoopy;
$snoopy->fetch($backend);
{
$lines =0;
$text = explode("\n", $snoopy->results);
$index=0;
$header_passed=!1;
$exit=!1;
while(($index < count($text) ) && (!$exit) && ($lines < $config["linesperbox"])) {
$buffer = ltrim(Chop($text[$index]));
$index++;
if ($header_passed) {
if (ereg($marker1, $buffer)) {
$buffer = substr( $buffer, strpos($buffer, "<A href"), strpos($buffer, "</A>")-strpos($buffer, "<A href"))."</a>";
$buffer = eregi_replace("<A href=\"", "<a href=\"http://www.newsisfree.com", $buffer);
$cache_info .= $link_prefix." ".$buffer.$link_postfix;
$lines++;
}
}
if (ereg($begin,$buffer)) {
$header_passed = 1;
}
if ((ereg($end,$buffer)) && ($header_passed)) {
$exit = 1;
}
}
}
$query = "update boxes set cache='".addslashes($cache_info)."', time=".$time[1]." where name = '".addslashes($name)."'";
$db2->setQuery($query);
$r = $db2->executeQuery();
if ($r >0) {
debug("Box ".$name." updated");
} else {
debug("Box ".$name." not updated");
debug(mysql_error());
}
} else {
$cache_info = stripslashes($row2["cache"]);
}
$db2->close();
}
$output = $cache_info;
?>