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

if($delete)
{
	$query = "DELETE FROM $DB_Comments WHERE id='$delete'";
	$result = mysql_query($query, $Link) or queryError("408", mysql_error());
	$message = $sxLang['MessageCommentDeleted'];
}
if($approve)
{
	$query = "UPDATE $DB_Comments SET approved='1' WHERE id='$approve'";
	$result = mysql_query($query, $Link) or queryError("409", mysql_error());
	$message = $sxLang['MessageCommentApproved'];
}
if($unapprove)
{
	$query = "UPDATE $DB_Comments SET approved='0' WHERE id='$unapprove'";
	$result = mysql_query($query, $Link) or queryError("410", mysql_error());
	$message = $sxLang['MessageCommentUnapproved'];
}
if($approvalOn)
{
	$query = "UPDATE $DB_Setup SET setup_value='1' WHERE setup_key='CommentsApproval'";
	$result = mysql_query($query, $Link) or queryError("411", mysql_error());
	$message = $sxLang['MessageCommentApp'];
	$sxSetup['CommentsApproval'] = 1;
}
if($approvalOff)
{
	$query = "UPDATE $DB_Setup SET setup_value='0' WHERE setup_key='CommentsApproval'";
	$result = mysql_query($query, $Link) or queryError("412", mysql_error());
	$message = $sxLang['MessageCommentAppDisabled'];
	$sxSetup['CommentsApproval'] = 0;
}
if($approveAll)
{
	$query = "UPDATE $DB_Comments SET approved='1'";
	$result = mysql_query($query, $Link) or queryError("413", mysql_error());
	$message = $sxLang['MessageCommentAllApproved'];
}
if($approveNone)
{
	$query = "UPDATE $DB_Comments SET approved='0'";
	$result = mysql_query($query, $Link) or queryError("414", mysql_error());
	$message = $sxLang['MessageCommentAllUnapproved'];
}
if($commentsEnable)
{
	$query = "UPDATE $DB_Setup SET setup_value='1' WHERE setup_key='CommentsEnabled'";
	$result = mysql_query($query, $Link) or queryError("415", mysql_error());
	$message = $sxLang['MessageCommentEnabled'];
	$sxSetup['CommentsEnabled'] = 1;
}
if($commentsDisable)
{
	$query = "UPDATE $DB_Setup SET setup_value='0' WHERE setup_key='CommentsEnabled'";
	$result = mysql_query($query, $Link) or queryError("416", mysql_error());
	$message = $sxLang['MessageCommentDisabled'];
	$sxSetup['CommentsEnabled'] = 0;
}
if($requireAuth)
{
	$query = "UPDATE $DB_Setup SET setup_value='1' WHERE setup_key='CommentsAuth'";
	$result = mysql_query($query, $Link) or queryError("417", mysql_error());
	$message = $sxLang['MessageCommentAuthEnabled'];
	$sxSetup['CommentsAuth'] = 1;
}
if($noRequireAuth)
{
	$query = "UPDATE $DB_Setup SET setup_value='0' WHERE setup_key='CommentsAuth'";
	$result = mysql_query($query, $Link) or queryError("418", mysql_error());
	$message = $sxLang['MessageCommentAuthDisabled'];
	$sxSetup['CommentsAuth'] = 0;
}

$query = "SELECT id FROM $DB_Comments";
$result = mysql_query($query, $Link) or queryError("56", mysql_error());
$totalElements = mysql_num_rows($result);

$elements_per_page = $sxThemeConfig['AdminElementsPerPage'];
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."?delete="; ?>'+theID;
	}
}
//-->
</script>     
<div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['CommentsManageHeading']; ?></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['CommentsManageHeading']; ?></div> 
	<?PHP echoMessage($message); ?>
	<div class="sxSection"><?PHP echo $sxLang['CommentsManageSectionGenOptions']; ?></div>
	<table border="0" cellspacing="2" cellpadding="5">
	  <form action="<?PHP echo $PHP_SELF; ?>" method="post" name="form0">
	  <tr> 
		<td width="170" align="right"><strong><?PHP echo $sxLang['CommentsManageItemEnable']; ?></strong></td>
		<td><input name="edit_comments_enabled" type="checkbox" value="1"<?PHP if($sxSetup['CommentsEnabled']) echo ' checked'; ?> onclick="window.location='<?PHP echo $PHP_SELF; if($sxSetup['CommentsEnabled']) echo "?commentsDisable=1"; else echo "?commentsEnable=1"; ?>'" /></td>
	  </tr>
	  <tr> 
		<td width="170" align="right"><strong><?PHP echo $sxLang['CommentsManageItemReqAuth']; ?></strong></td>
		<td><input name="edit_comments_auth" type="checkbox" value="1"<?PHP if($sxSetup['CommentsAuth']) echo ' checked'; ?> onclick="window.location='<?PHP echo $PHP_SELF; if($sxSetup['CommentsAuth']) echo "?noRequireAuth=1"; else echo "?requireAuth=1"; ?>'" /></td>
	  </tr>
	  <tr> 
		<td width="170" align="right"><strong><?PHP echo $sxLang['CommentsManageItemReqApp']; ?></strong></td>
		<td><input name="edit_comments_approval" type="checkbox" value="1"<?PHP if($sxSetup['CommentsApproval']) echo ' checked'; ?> onclick="window.location='<?PHP echo $PHP_SELF; if($sxSetup['CommentsApproval']) echo "?approvalOff=1"; else echo "?approvalOn=1"; ?>'" /></td>
	  </tr>
	  </form>
	</table><br /><br />
	<div class="sxSection"><?PHP echo $sxLang['CommentsManageSectionComments']; ?></div>
   	<span class="sxSmallText"><a href="<?PHP echo $PHP_SELF; ?>?approveAll=1"><?PHP echo $sxLang['CommentsManageApproveAll']; ?></a><br />
	<a href="<?PHP echo $PHP_SELF; ?>?approveNone=1"><?PHP echo $sxLang['CommentsManageUnapproveAll']; ?></a></span><br />
	<div style="padding-top:8px;padding-bottom:8px;font-size:10px;"><?PHP pageTurns("$PHP_SELF?", $totalElements, $page, $elements_per_page); ?></div>
    <table border="0" cellspacing="2" cellpadding="5">
	  <tr>
		<td class="tableColumn"><?PHP echo $sxLang['CommentsManageTableApproved']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['CommentsManageTableName']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['CommentsManageTableSection']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['CommentsManageTableDate']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['CommentsManageTableOptions']; ?></td>
	 </tr>
	<?PHP
	$query = "SELECT * FROM $DB_Comments ORDER BY timestamp DESC LIMIT $start, $elements_per_page";
	$result = mysql_query($query, $Link) or queryError("408", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		$query2 = "SELECT * FROM $DB_Comments_Section WHERE id='$ROW->sectionid'";
		$result2 = mysql_query($query2, $Link) or queryError("407", mysql_error());
		$ROW2 = mysql_fetch_object($result2);
	
		echo '  <tr bgcolor="' . $sxTheme['ColorTableRow'] . '">';
		
		if($ROW->approved == 1)
		{
			echo '     <td align="center"><a href="' . $PHP_SELF . '?unapprove=' . $ROW->id . '">'."\n";
			echo '        <img alt="' . $sxLang['CommentsManageApproved'] . '" src="../images/check.gif" style="border: 0;" /></a></td>'."\n";
		}
		else
		{
			echo '     <td align="center"><a href="' . $PHP_SELF . '?approve=' . $ROW->id . '">'."\n";
			echo '        <img alt="' . $sxLang['CommentsManageUnapproved'] . '" src="../images/x.gif" style="border: 0;" /></a></td>'."\n";
		}
		
		echo '     <td>' . htmlspecialchars($ROW->name) . '</td>'."\n";
		echo '     <td>' .  htmlspecialchars($ROW2->name) . '</td>'."\n";
		echo '     <td>' . fetchDate($ROW->timestamp, 1, 1) . '</a></td>'."\n";
		echo '     <td><a href="comment_preview.php?entryid=' . $ROW->id . '" title="' . $sxLang['ButtonPreview'] . '"><img src="../images/admin_preview.gif" alt="' . $sxLang['ButtonPreview'] . '" style="border: 0;" /></a>'."\n";
		echo '         <a href="';
		
		switch($ROW->sectionid)
		{
			// Journal
			case 1 :
				
				$count = 0; $pageNew = 1;
				
				$query3 = "SELECT * FROM $DB_Journal ORDER BY timestamp DESC";
				$result3 = mysql_query($query3, $Link) or queryError("406", mysql_error());
				while($ROW3 = mysql_fetch_object($result3))
				{
					$count = $count + 1;
					if($ROW3->id == $ROW->rowid)
						$jCount = $count;
				}
				
				// Find page
				while($jCount > $sxSetup['JournalsPerPage'])
				{
					$jCount = $jCount - $sxSetup['JournalsPerPage'];
					$pageNew = $pageNew + 1;
				}
				
				echo '../journal.php?page=' . $pageNew . '&comments=' . $ROW->rowid . '#' . $ROW->rowid;
				break;
				
			case 2 :
				echo '../photo.php?photoid=' . $ROW->rowid . '&comments=' . $ROW->rowid . '#comments';
				break;
		}
		
		echo '" title="' . $sxLang['ButtonGoTo'] . '"><img src="../images/admin_goto.gif" alt="' . $sxLang['ButtonGoTo'] . '" style="border: 0;" /></a> ';
		echo '           <a href="comment_edit.php?entryid=' . $ROW->id . '" title="' . $sxLang['ButtonEdit'] . '"><img src="../images/admin_edit.gif" alt="' . $sxLang['ButtonEdit'] . '" style="border: 0;" /></a>'."\n";
		echo '           <a href="#" title="' . $sxLang['ButtonDelete'] . '"><img src="../images/admin_delete.gif" alt="' . $sxLang['ButtonDelete'] . '" onclick="confirmDelete(' . $ROW->id . ',\'' . addslashes( htmlspecialchars($ROW->name)) . '\')" style="border: 0;" /></a>';
		echo '  </tr>';
	}
	if(mysql_num_rows($result) == 0)
		echo '<tr bgcolor="' . $sxTheme['ColorTableRow'] . '"><td style="width:400px;" colspan="5"><em>' . $sxLang['NoEntries'] . '</em></td></tr>';
	?></table>
    <div style="padding-top:8px;padding-bottom:8px;font-size:10px;"><?PHP pageTurns("$PHP_SELF?", $totalElements, $page, $elements_per_page); ?></div>
	<br />
  </div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX