<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/*         Additional security & Abstraction layer conversion           */
/*                           2003 chatserv                              */
/*      http://www.nukefixes.com -- http://www.nukeresources.com        */
/************************************************************************/
defined('MAXIMUS') or Header("Location: ../../index.php");

$module_name = "ePetitions";
get_lang($module_name);

if(!isset($pid)) {
    exit();
}

include_once("includes/ePetitions.php");

function PrintPage($pid) {
    global $user, $admin, $site_logo, $nukeurl, $sitename, $datetime, $prefix, $db, $module_name;
    $pid = intval($pid);


	if($row = $db->sql_fetchrow($db->sql_query("SELECT ePetitionId,name,hidesigner,view,enabled,voters,timestart,timeend,createdtime,hideemail FROM ".$prefix."_nsngrept_petitions WHERE ePetitionId='$pid'")))
	{
		$hidesigner=intval($row['hidesigner']);
		$view=intval($row['view']);
		$voters=intval($row['voters']);
		$enabled=intval($row['enabled']);
		$timestart=intval($row['timestart']);
		$timeend=intval($row['timeend']);
		$createdtime=$row['createdtime'];
		$hideemail=intval($row['hideemail']);

		$user_groups_cache=load_usergroups_cache($user);
		if($view==0 || cached_is_visible_for_user($user_groups_cache,$view,$user,$admin)==1)
		{
		    echo "
				<html>
				<head><title>$sitename - $title</title></head>
				<body bgcolor=\"#ffffff\" text=\"#000000\">
				<table border=\"0\" align=\"center\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" >
					<tr><td>
									<center>
									<img src=\"images/$site_logo\" border=\"0\" alt=\"\"><br /><br />
									<font class=\"content\">
									<b>$title</b></font><br />
									<font class=tiny><b>"._PDATE."</b> $createdtime<br /><br />
									</center>
									<font class=\"content\">";

									NSNePetitionsView($pid,0);

									if($hidesigner==0 || cached_is_visible_for_user($user_groups_cache,$hidesigner,$user,$admin)==1)
									{
										echo "<br />";
											NSNePetitionsShowSigners($pid, "", "AND validationString=''",cached_is_visible_for_user($user_groups_cache,$hideemail,$user,$admin));
									}

									echo "</font>
						<br /><br /><center>
						<font class=\"content\">
						"._NEP_COMESFROM." $sitename<br />
						<a href=\"$nukeurl\">$nukeurl</a><br /><br />
						"._NEP_THEURL."<br />
						<a href=\"$nukeurl/modules.php?name=$module_name&op=more_info&ePetitionId=$pid\">$nukeurl/modules.php?name=$module_name&op=more_info&ePetitionId=$pid</a>
						</font>
					</td></tr>
				</table>
				</body>
				</html>
			";
		}
		else
		{
				echo "<center><b>"._NEP_EPETITIONSFORBIDDEN."</b></center>";
		}
	}
	die();
}
PrintPage($pid);