Location: PHPKode > projects > SiteX > admin/polls.php
<?PHP
ob_start();
session_start();

include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");
if((!userEditor())AND(!userAdmin()))  loginError($sxLang['LoginRequired']);
if((userEditor())AND(!$sxSetup['EditorRightsPollsEdit']))  loginError($sxLang['LoginRequired']);

if ($delete)
{
	$query = "DELETE FROM $DB_Polls WHERE id='$delete'";
	$result = mysql_query($query, $Link) or queryError("4626", mysql_error());
	
	$query = "DELETE FROM $DB_Polls_Values WHERE pollid='$delete'";
	$result = mysql_query($query, $Link) or queryError("535", mysql_error());
	
	$message = $sxLang['MessagePollDeleted'];
}

if ((($Add) OR ($AddCurrent)) AND (strlen($name) > 0))
{
	if ($AddCurrent)
	{
		$query = "UPDATE $DB_Polls SET currentpoll='0' WHERE currentpoll='1'";
		$result = mysql_query($query, $Link) or queryError("9741", mysql_error());

		$query = "INSERT INTO $DB_Polls (name, active, currentpoll) VALUES ('$name', '1', '1')";
	}
	else
		$query = "INSERT INTO $DB_Polls (name, active, currentpoll) VALUES ('$name', '0', '0')";

	$result = mysql_query($query, $Link) or queryError("29", mysql_error());
	
	$query = "SELECT * FROM $DB_Polls WHERE name='$name'";
	$result = mysql_query($query, $Link) or queryError("25646", mysql_error());
	$ROW = mysql_fetch_object($result);
	
	header("Location: polls_edit.php?editid=$ROW->id");
	die();
}

if($sxMakeCurrent)
{	
	$query = "UPDATE $DB_Polls SET currentpoll='0' WHERE currentpoll='1'";
	$result = mysql_query($query, $Link) or queryError("9741", mysql_error());
	
	$query = "UPDATE $DB_Polls SET currentpoll='1' WHERE id='$sxMakeCurrent'";
	$result = mysql_query($query, $Link) or queryError("9742", mysql_error());
}

if($sxDisableCurrent)
{	
	$query = "UPDATE $DB_Polls SET currentpoll='0' WHERE currentpoll='1'";
	$result = mysql_query($query, $Link) or queryError("9741", mysql_error());
}

if($sxResetPoll)
{	
	$query = "UPDATE $DB_Polls_Values SET votes='0' WHERE pollid='".intval($sxResetPoll)."'";
	$result = mysql_query($query, $Link) or queryError("9741", mysql_error());
	$message = $sxLang['MessagePollReset'];
}

if($activate)
{	
	$query = "UPDATE $DB_Polls SET active='1' WHERE id='$activate'";
	$result = mysql_query($query, $Link) or queryError("9743", mysql_error());
}

if($deactivate)
{	
	$query = "UPDATE $DB_Polls SET active='0' WHERE id='$deactivate'";
	$result = mysql_query($query, $Link) or queryError("314", mysql_error());
}

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function confirmDelete(theID,theName){
	if(confirm("<?PHP echo $sxLang['GeneralJSDeleteEntry3']; ?> '"+theName+"' <?PHP echo $sxLang['GeneralJSDeleteEntry2']; ?>")){
		window.location='<?PHP print $PHP_SELF."?delete="; ?>'+theID;
	}
}
function confirmReset(theID){
	if(confirm("<?PHP echo $sxLang['PollsJSReset']; ?>")){
		window.location='<?PHP print $PHP_SELF."?sxResetPoll="; ?>'+theID;
	}
}
//-->
</script>     
<div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['PollsHeadingManager']; ?></h1>
   <div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <?PHP echo $sxLang['PollsHeadingManager']; ?></div>   
   <?PHP echoMessage($message); ?>
	<table border="0" cellspacing="2" cellpadding="5">
	  <tr>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemActive']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemCurrent']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemName']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemOptions']; ?></td>
	  </tr>
		<?PHP
		$query = "SELECT * FROM $DB_Polls ORDER BY name ASC";
		$result = mysql_query($query, $Link) or queryError("27", mysql_error());
		while($ROW = mysql_fetch_object($result))
		{
			echo '  <tr bgcolor="' . $sxTheme['ColorTableRow'] . '">';
			
			if($ROW->active)
				echo '     <td><a href="' . "$PHP_SELF?deactivate=$ROW->id" . '" title="' . $sxLang['ImgAltDeactivate'] . '"><img alt="' . $sxLang['ImgAltDeactivate'] . '" src="../images/check.gif" style="border: 0;" /></a></td>';
			else
				echo '     <td><a href="' . "$PHP_SELF?activate=$ROW->id" . '" title="' . $sxLang['ImgAltActivate'] . '"><img alt="' . $sxLang['ImgAltActivate'] . '" src="../images/x.gif" style="border: 0;" /></a></td>';

			if($ROW->currentpoll)
				echo '     <td><a href="' . "$PHP_SELF?sxDisableCurrent=$ROW->id" . '" title="' . $sxLang['ImgAltDeactivate'] . '"><img alt="' . $sxLang['ImgAltDeactivate'] . '" src="../images/check.gif" style="border: 0;" /></a></td>';
			else
				echo '     <td><a href="' . "$PHP_SELF?sxMakeCurrent=$ROW->id" . '" title="' . $sxLang['ButtonSelect'] . '"><img alt="' . $sxLang['ButtonSelect'] . '" src="../images/x.gif" style="border: 0;" /></a></td>';
			
			echo '     <td>' .  htmlspecialchars($ROW->name) . '</td>';
			echo '     <td><a href="polls_edit.php?editid=' . $ROW->id . '" title="' . $sxLang['ButtonEdit'] . '"><img src="../images/admin_edit.gif" style="border: 0;" alt="' . $sxLang['ButtonEdit'] . '" /></a> ';
			echo '         <a href="#" onclick="confirmDelete(' . $ROW->id . ',\'' .  htmlspecialchars(addslashes($ROW->name)) . '\')" title="' . $sxLang['ButtonDelete'] . '"><img src="../images/admin_delete.gif" style="border: 0;" alt="' . $sxLang['ButtonDelete'] . '" /></a> ';
			echo '         <a href="#" onclick="confirmReset(' . $ROW->id . ')" title="' . $sxLang['PollsButtonResetVotes'] . '"><img src="../images/admin_reset.gif" style="border: 0;" alt="' . $sxLang['PollsButtonResetVotes'] . '" /></a> ';
			echo '  </tr>';
		}
		if(mysql_num_rows($result) == 0)
			echo '<tr bgcolor="' . $sxTheme['ColorTableRow'] . '"><td colspan="4"><em>' . $sxLang['NoPolls'] . '</em></td></tr>';
		?></table>
	<form name="sxFormPollsAdd" method="post" action="<?PHP echo $PHP_SELF; ?>">
	  <input name="name" type="text" size="35" maxlength="255" />
	  <input name="Add" type="submit" value="<?PHP echo $sxLang['ButtonAdd']; ?>" style="width:70px;" class="sxButton" />
	  <input name="AddCurrent" type="submit" value="<?PHP echo $sxLang['PollsButtonAddCurrent']; ?>" class="sxButton" />
	</form>
  </div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX