<?php

/***************************************************************************

 event_list.php
 ---------------
 copyright : (C) 2002-2003 The ezContents Development Team

 ***************************************************************************/

/***************************************************************************
 The ezContents Development Team offers no warranties on this script.
 The owner/licensee of the script is solely responsible for any problems
 caused by installation of the script or use of the script.

 All copyright notices regarding ezContents must remain intact on the
 scripts and in the HTML for the scripts.

 For more info on ezContents,
 visit http://www.ezcontents.org/

/***************************************************************************

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the License which can be found within the
 *   zipped package.
 *
 ***************************************************************************/

global $HTTP_SERVER_VARS;
if ( (substr($HTTP_SERVER_VARS["PHP_SELF"],-11) == 'control.php') ||
	 (substr($HTTP_SERVER_VARS["PHP_SELF"],-10) == 'module.php') ||
	 (substr($HTTP_SERVER_VARS["PHP_SELF"],-16) == 'showcontents.php') ) {
	 require_once('./modules/moduleSec.php');
} else {
	require_once('../moduleSec.php');
}

include_once ($GLOBALS["admin_home"]."compile.php");

$isodate = sprintf ("%04d-%02d-%02d", strftime("%Y"), strftime("%m"), strftime("%d"));
$strQuery = ModuleDataQuery($HTTP_POST_VARS["catcode"],"enddate>='".$isodate."'");

$countres = dbRetrieve($strQuery,true,0,0);
$lRecCount = dbRowsReturned($countres);
dbFreeResult($countres);

$nCurrentPage = 0;
if ($HTTP_GET_VARS["page"] != "") { $nCurrentPage = $HTTP_GET_VARS["page"]; }
$nPages = intval(($lRecCount - 0.5) / $GLOBALS["scPerPage"]) + 1;
$lStartRec = $nCurrentPage * $GLOBALS["scPerPage"];
if ($nPages > 1) { SubModuleHdFt($nCurrentPage,$nPages);
} else { echo '<br />'; }


?><center><?php
if ($lRecCount == 0) { ModuleNoEntries();
} else {
	$result = dbRetrieve($strQuery,true,$lStartRec,$GLOBALS["scPerPage"]);
	while ($rsContent = dbFetch($result)) {
		?>
		<table border="0" width="100%" cellspacing="1" cellpadding="3" class="headercontent">
			<tr><td class="header">
					<?php
					if ($rsContent["flag"] != '') {
						echo imagehtmltag($GLOBALS["icon_home"].'flags/',$rsContent["flag"].'.gif',$rsContent["countryname"],0,'R');
					}
					echo htmlspecialchars($rsContent["eventname"]);
					?>
				</td>
			</tr>
			<tr><td class="tablecontent">
					<?php
					if ($rsContent["startdate"] == $rsContent["enddate"]) {
						echo '<b>'.$GLOBALS["tDateOn"].':</b> '.FormatDate(substr($rsContent["startdate"],0,10));
					} else {
						echo '<b>'.$GLOBALS["tDateFrom"].':</b> '.FormatDate(substr($rsContent["startdate"],0,10)).' <b>'.$GLOBALS["tDateTo"].'</b> '.FormatDate(substr($rsContent["enddate"],0,10));
					}
					if ($rsContent["location"] != '') {
						echo '<br /><b>'.$GLOBALS["tLocation"].':</b> '.htmlspecialchars($rsContent["location"]);
					}
					if ($rsContent["countryname"] != '') {
						if ($rsContent["location"] != '') { echo ', '; }
						echo htmlspecialchars($rsContent["location"]);
					}
					if (($rsContent["countryname"] != '') || ($rsContent["location"] != '')) {
						echo '<br />';
					}
					echo '<br />';
					$bEncodeHTML = true;
					echo ext_print(compile($GLOBALS["tqBlock1"].'html'.$GLOBALS["tqBlock2"].$rsContent["comment"].$GLOBALS["tqBlock1"].$GLOBALS["tqCloseBlock"].'html'.$GLOBALS["tqBlock2"], 'N', $GLOBALS["RestrictTags"], 'L'),$bEncodeHTML, 'L', $GLOBALS["RestrictTags"]);
					echo '<br />';
					if ($rsContent["contactname"] != '') { echo '<br /><b>'.$GLOBALS["tContact"].':</b> '.htmlspecialchars($rsContent["contactname"]); }
					if ($rsContent["contactemail"] != '') { echo '<br /><b>'.$GLOBALS["tEMail"].':</b> <a href="mailto:'.htmlspecialchars($rsContent["contactemail"]).'?subject='.htmlspecialchars($rsContent["eventname"]).'">'.htmlspecialchars($rsContent["contactemail"]).'</a>'; }
					if ($rsContent["web_page"] != '') { echo '<br /><b>'.$GLOBALS["tWebPage"].':</b> <a href="'.htmlspecialchars($rsContent["web_page"]).'" target="_blank">'.htmlspecialchars($rsContent["web_page"]).'</a>'; } ?>
				</td>
			</tr>
			<?php
			ShowContentFooter($GLOBALS["scPostedDate"],$GLOBALS["scPostedBy"],$rsContent);
			?>
		</table><br />
		<?php
	}
}
dbFreeResult($result);

?>
</center>
<?php

if ($nPages > 1) {
	SubModuleHdFt($nCurrentPage,$nPages);
}

?>
