Page 1 of 1

More IRC Modular help

Posted: Sat Jun 19, 2004 9:37 am
by Samurai
Here is what I'm trying to do with this script. I am trying to make the bot pasre entries from a HTML calendar and display them in an IRC channel one line at a time ffor the following 2 weeks of events. This is the output I am looking for:
[Jun 20th 2004] Bomb/TS Practice 10:00pm EST
The problem is not with the output format, but it only displays one line, and not the entire 2 weeks. Any suggestions?

Code: Select all

<?php

$loaded_modules[basename(__FILE__)] = array("title"           => "Calendar Webparser",
					    "author"          => "Santan!c",
					    "function_prefix" => "!calendar",
					    "function_name"   => "calendar_lookup",
				            "type"            => "command"
					    );

function calendar_lookup($params, $target)
{
	$buffer = '';
	$month = 'null';
	$app = 'none';
	$day = 'none';
	$namelist="";
	$url = "http://www.clanems.com/calendar.html";
	if ($lines = file($url))
	{
		$httperror=0;
		foreach($lines as $line_num => $line)
		{
			if ($next)
			{
				if (strlen(trim(strip_tags($line))))
				{
					$name=trim(strip_tags($line));
					$name=str_replace("&nbsp;","",$name);

					if (strstr($month,'null'))
					{
						list($month, $year) = split(" ",$name);
					}

					if (strlen($namelist))
					{
						if (!is_numeric($name))
						{
							$namelist.=" ".$name;
							
						}
						else
						{
							$x=0;
							$namelist.="\n". date("[M jS Y]",mktime(0,0,0,date("m"),$name,$year));
						}
		    		}
					else
					{
						$namelist=$namelist.$name;
					}
				}
			}
			if (strstr($line,'Start Calendar'))
			{
				$next=1;
			}
		}
	}
	else
	{
    	$httperror=1;
	}

	if ($httperror)
	{
		echo "ERROR";
	}
	else
	{

		$needle = date("[M jS Y]", mktime(0,0,0,date("m"),date("j"),$year));
		$endneedle = date("[M jS Y]", mktime(0,0,0,date("m"),$day+14,$year));
		$pos = strpos($namelist, $needle);
		$endpos = strpos($namelist,$endneedle);
		if($endpos<=$pos)
		{
			$endpos=strlen($namelist)-$pos;
		}
		else
			$endpos=$endpos-$pos;
		$namelist=substr($namelist,$pos, $endpos);
		$namelist=ereg_replace(",","",$namelist);
		$namelist=ereg_replace("\[".date("M")." [0-9]+[a-z][a-z] ".$year."\]    \n","",$namelist);
		$namelist=ereg_replace("\[".date("M")." [0-9]+[a-z][a-z] ".$year."\]$","",$namelist);
	}
    $list=split("\n",$namelist);
	for($x=0; $x< count($list); $x++)
	{
		reply($list[$x], $target);
	}
}
?>

Posted: Mon Jun 21, 2004 11:37 pm
by kettle_drum
Without seeing more i cant really help. It could be anything from the way your posting th data to the server to you not parsing the data from the calendar correctly.