Location: PHPKode > projects > SiteX > admin/guestbook_manager.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['EditorRightsGuestbookEdit']))  loginError($sxLang['LoginRequired']);

if($delete)
{
	$query = "DELETE FROM $DB_Guestbook WHERE id='$delete'";
	$result = mysql_query($query, $Link) or queryError("20", mysql_error());
	$message = $sxLang['MessageGuestbookDeleted'];
}
if($approve)
{
	$query = "UPDATE $DB_Guestbook SET approved='1' WHERE id='$approve'";
	$result = mysql_query($query, $Link) or queryError("20", mysql_error());
	$message = $sxLang['MessageGuestbookApproved'];
}
if($unapprove)
{
	$query = "UPDATE $DB_Guestbook SET approved='0' WHERE id='$unapprove'";
	$result = mysql_query($query, $Link) or queryError("20", mysql_error());
	$message = $sxLang['MessageGuestbookUnapproved'];
}

if($clear_all)
{
	$query = "DELETE FROM $DB_Guestbook";
	$result = mysql_query($query, $Link) or queryError("58", mysql_error());
	$message = $sxLang['MessageGuestbookCleared'];
}

$query = "SELECT * FROM $DB_Guestbook";
$result = mysql_query($query, $Link) or queryError("55", mysql_error());
$totalElements = mysql_num_rows($result);

$elements_per_page = $sxThemeConfig['AdminGuestbookEntriesPerPage'];
if(!$page)
	$page = 1;
$start = ($page - 1)*$elements_per_page;

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function confirmDelete(theID,theName){
	if(confirm("<?PHP echo $sxLang['GeneralJSDeleteEntry1']; ?> '"+theName+"' <?PHP echo $sxLang['GeneralJSDeleteEntry2']; ?>")){
		window.location='<?PHP print $PHP_SELF."?page=$page&delete="; ?>'+theID;
	}
}
function confirmClear(){
	if(confirm("<?PHP echo str_replace('<br />', '\n', $sxLang['GuestbookClearWarning']); ?>")){
		window.location='<?PHP print $PHP_SELF."?clear_all=true"; ?>'
	}
}
//-->
</script>     
<div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['GeneralHeadingManage'].' '.getComponentName("3").' '.$sxLang['GeneralHeadingEntries']; ?></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['GeneralHeadingManage'].' '.getComponentName("3").' '.$sxLang['GeneralHeadingEntries']; ?></div>   
   <?PHP echoMessage($message); ?>
	<table border="0" cellspacing="2" cellpadding="5">
	<td align="left" colspan="3">
	  <div style="padding-top:8px;padding-bottom:8px;font-size:10px;"><?PHP pageTurns("$PHP_SELF?", $totalElements, $page, $elements_per_page); ?></div>
	</td>
	<td align="right" colspan="1">
	  <input type="button" name="Clear" value="<?PHP echo $sxLang['AdminLinkGuestbookClear']; ?>" onclick="confirmClear()" />
	</td>
	<tr>
	  <td class="tableColumn"><?PHP echo $sxLang['GeneralItemApproved']; ?></td>
	  <td class="tableColumn"><?PHP echo $sxLang['GeneralItemName']; ?></td>
	  <td class="tableColumn"><?PHP echo $sxLang['GeneralItemDate']; ?></td>
	  <td class="tableColumn"><?PHP echo $sxLang['GeneralItemOptions']; ?></td>
	</tr>
	<?PHP
	$query = "SELECT * FROM $DB_Guestbook ORDER BY timestamp DESC LIMIT $start, $elements_per_page";
	$result = mysql_query($query, $Link) or queryError("20", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		echo '  <tr>';
		if($ROW->approved == 1)
			echo '     <td align="center"><a href="' . $PHP_SELF . '?unapprove=' . $ROW->id . '"><img alt="' . $sxLang['ImgAltApproved'] . '" src="../images/check.gif" style="border: 0;" /></a></td>';
		else
			echo '     <td align="center"><a href="' . $PHP_SELF . '?approve=' . $ROW->id . '"><img alt="' . $sxLang['ImgAltUnapproved'] . '" src="../images/x.gif" style="border: 0;" /></a></td>';
		echo '     <td>' . $ROW->name . '</td>';
		echo '     <td>' . fetchDate($ROW->timestamp, 1, 1) . '</a></td>';
		echo '     <td><a href="guestbook_preview.php?entryid=' . $ROW->id . '" title="' . $sxLang['ButtonPreview'] . '"><img src="../images/admin_preview.gif" style="border: 0;" alt="' . $sxLang['ButtonPreview'] . '" /></a> ';
		echo '         <a href="#" onclick="confirmDelete(' . $ROW->id . ',\'' . addslashes( htmlspecialchars($ROW->name)) . '\')" title="' . $sxLang['ButtonDelete'] . '"><img style="border: 0;" src="../images/admin_delete.gif" alt="' . $sxLang['ButtonDelete'] . '" /></a></td>';
		echo '  </tr>';
	}
	if(mysql_num_rows($result) == 0)
		echo '<tr bgcolor="' . $sxTheme['ColorTableRow'] . '"><td style="width:' . $sxThemeConfig['ContentWidth'] . 'px;" colspan="4"><em>' . $sxLang['NoEntries'] . '</em></td></tr>';

	?>	<td align="left" colspan="4">
	  <div style="padding-top:8px;padding-bottom:8px;font-size:10px;"><?PHP pageTurns("$PHP_SELF?", $totalElements, $page, $elements_per_page); ?></div>
	</td></table>
</div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX