Location: PHPKode > projects > Open SoCks > boxscripts/nnhck.php3
<?
/*
//	nnhck.php
//
//	Version:	0.0.1
//
//	Author:		Cedric Raguenaud
//	Lastmod:	12/03/2001
//	Homepage:	http://www.dcs.napier.ac.uk/~cedric
//
//	This is an PHP include of SSI file
//
//	PHP:
//	<?
//	include("nnhck.php");
//	?>
//
//	SSI:
//	<!--#include virtual="nnhck.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 = "<th align=\"left\" nowrap=\"nowrap\" class=\"hdr3\">";
$end = "<span class=\"copy\">";
$marker1 = "/cgi/NGoto/";
$marker2 = "<span class=\"strap\">";
$link_prefix	=	"o <FONT SIZE=-1>";
$link_postfix	=	"</FONT><BR>\n";
$cache_time	=	7200;
$target		=	"_top";
$source = "http://www.newsnow.co.uk";
$name		=	"nnhck";

//	End of customizations

$backend	= "http://www.newsnow.co.uk/cgi/NewsNow/NewsLink.News.htm?Theme=Hacking";

$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++;

				$sentences = split("<br />", $buffer);

				for ($i=0; $i<count($sentences); $i++) {
					$buffer = $sentences[$i];

					if ($header_passed) {
						if (eregi($marker1, $buffer)) {
	//						$flag = "<img src=\"".$source."/".substr($buffer, strpos($buffer, "/flags/"), 14)."\">";
							$link = "<a href=\"".$source.substr($buffer, strpos($buffer, "<a href=\"")+9, strpos($buffer, "target")-2-(strpos($buffer, "<a href=\"")+9))."\">";
							$news = substr($buffer, strpos($buffer, ">", strpos($buffer, "<a href=\""))+1, strpos($buffer, "<font size=", strpos($buffer, "<a href=\""))-(strpos($buffer, ">", strpos($buffer, "<a href=\""))+1));
							$news = str_replace("</a>", "", $news);
							$news = str_replace("&nbsp;", "", $news);
							$origin = substr($buffer, strpos($buffer, "<span class=\"src\">")+18, strpos($buffer, "</span>", strpos($buffer, "<span class=\"src\">")+18)-(strpos($buffer, "<span class=\"src\">")+18));
							$origin = str_replace("<nobr>", "", $origin);
							$origin = str_replace("</nobr>", "", $origin);
	
							$news = $link.$news."</a>";
							$cache_info .= $link_prefix.$flag.$news." (".$origin.")".$link_postfix;
							$lines++;
						}
					} 
	
					if (eregi($begin,$buffer)) {
						$header_passed = 1;
					}
					if ((eregi($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;

?>
Return current item: Open SoCks