#!/app/apache/modules/1.3/php/4.0.6/bin/php -q
<?php
	include("../scripts/sqlinfo.inc");
	mysql_connect($host, $user, $pass);
	mysql_select_db("pyrot");
	$date=getdate();
	$mm = $date["mon"];
	$dd = $date["mday"]+3;
	$yyyy = $date["year"];
	$ymd = "$yyyy-$mm-$dd";

	$result=mysql_query("SELECT * FROM event where datum=\"$ymd\"");
	if($r = mysql_fetch_array($result)){
		$mail="Skjutningar på gång för pyrot $ymd (om 3 dagar):\n\n";
		do{
			$mail.=$r["rubrik"] . "\n" . "Plats: " . $r["plats"] . ", " . $r["tid"] .
				"\n" . $r["info"] . "\n\n";
		}while($r=mysql_fetch_array($result));
		$mail.="Mvh\nPyrot";
		$result=mysql_query("SELECT * FROM maillista");
		if($r=mysql_fetch_array($result)){
			do{
				$bcc .= $r["mail"].",";
			}while($r=mysql_fetch_array($result));
			$mail=$mail."\n\n"."-------\nFör att gå ur listan: gå till http://www.pyrot.com/index.php?page=remove_maillist.php"

;
			mail("info@pyrot.com", "Pyrots skutningar $ymd", $mail, "BCC: $bcc\nFrom: \"Pyrot\" <info@pyrot.com");
		}
	}
?>
