Location: PHPKode > projects > eBlog > admin/guestbook.php
<?php

/**************************************************************************
 *                                                                        *
 *                                                                        *
 *         Solution: eBlog                                                *
 *          Release: 1.7                                                  *
 *             File: admin/guestbook.php                                  *
 *               By: Emuci inc.                                           *
 *          Website: http://www.emuci.com                                 *
 *        Copyright: (C) 2010 Emcui inc.                                  *
 *                                                                        *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *                                                                        *
 *   This script is NOT freeware and is subjected to Emuci terms of use   *
 *   located in the docs folder.                                          *
 *                                                                        *
 *                                                                        *
 *************************************************************************/


include 'global.php';

$action = $_GET['action'];
$spoint = $_GET['spoint'];
$id     = $_GET['id'];
$limit  = $_GET['limit'];
$refresh  = $_GET['refresh'];

if(empty($limit))
{
	$limit = 50;
}	

if($action == "oldest")
$check2 = "selected";
else
$check1 = "selected";	

if(empty($action))
{
	$action = "ShowAll";
}	

if($_SESSION['permission'] == 1){

	// 1: Force parent window to refresh
	if($action == "refresh"){
		echo " 
		<script type=\"text/javascript\">
		top.parent.location = \"guestbook.php\";
		</script>
		";
	}
	
	
	
	// 2: Show list of entries
	else if(($action == "ShowAll")||($action == "oldest")){
	
	
	$thisPageNav = "&nbsp;<img src=\"../images/icons/prev_$blog_dir.gif\">&nbsp;<a href=\"guestbook.php\"><font face=\"tahoma\" style=\"font-size: 10pt;\">$lang_admin_link_5</font></a>";
	
		
	$list_name = $lang_admin_gbTitle;
	
	
	$quicklinks = "<table width=\"100%\" border=\"0\" cellspacing=\"5\" cellpadding=\"1\">
	
						 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
						 <td><a href=\"guestbook.php\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_gbMenu_1</font></a></td>
						 </tr>
						 
						 
						 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
						 <td><a href=\"guestbook.php?action=oldest\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_gbMenu_2</font></a></td>
						 </tr>
						 
						 
						 
						 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
						 <td><a href=\"guestbook.php?action=add\" title=\"$lang_admin_gbMenu_3\" rel=\"gb_page_center[640, 300]\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_gbMenu_3</font></a></td>
						 </tr>
						 					 					 				 					 					 
						 
						 
						 </table>";
						 
						 
			
			
			$list_content = $list_content . "
			<script type=\"text/javascript\">	
			function checkForm()
			{
				var a1   = document.filter.sort.value;
				var a2   = document.filter.limit.value;	
				if(a2 == \"\")
				{
					alert(\"$lang_erorr_code138\");
					document.filter.limit.focus();
				}
				else		
				window.location = \"guestbook.php?action=\" + a1 + \"&limit=\" + a2; 
			}
			
			function goPrev(spoint,limit){
			link = \"guestbook.php?action=ShowAll&limit=\" + limit + \"&spoint=\" + spoint; 
			window.location = link; 
			}
			
			function goPrevII(spoint,limit){
			link = \"guestbook.php?action=oldest&limit=\" + limit + \"&spoint=\" + spoint; 
			window.location = link; 
			}		
			
			function goNext(spoint,limit){
			link = \"guestbook.php?action=ShowAll&limit=\" + limit + \"&spoint=\" + spoint; 
			window.location = link;		
			}
			
			function goNextII(spoint,limit){
			link = \"guestbook.php?action=oldest&limit=\" + limit + \"&spoint=\" + spoint; 
			window.location = link;		
			}		
			
			function confirmDelete(ID2Delete){
				question = confirm(\"$lang_admin_confirmDeleteGB\")
				if (question !=\"0\"){
					top.location = \"guestbook.php?refresh=oldest&action=delete&id=\" + ID2Delete;
				}
			}
			
			function confirmDeleteII(ID2Delete){
				question = confirm(\"$lang_admin_confirmDeleteGB\")
				if (question !=\"0\"){
					top.location = \"guestbook.php?refresh=ShowAll&action=delete&id=\" + ID2Delete;
				}
			}			
			
			function stopRKey(evt) { 
			  var evt = (evt) ? evt : ((event) ? event : null); 
			  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
			  if ((evt.keyCode == 13) && (node.type==\"text\"))  {return false;} 
			} 
			
			document.onkeypress = stopRKey; 		
					
			function change(link){
			alert(link);
			}
			</script>
			
			
			<div>
			<form method=\"post\" name=\"filter\">
			<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"  border=\"1\">
			<tr bgcolor=\"dadada\">
			<td>
			
			<table width=\"100%\" border=\"0\">
			<tr>
			
			<td width=\"120\">
			<font face=\"tahoma\" size=\"2\">$lang_admin_nummberOfEntriesPerPage:</font> 
			</td>
			
			
			<td width=\"20\">
			<input name=\"limit\" maxlength=\"3\" size=\"5\" value=\"$limit\">
			</td>
			
			<td width=\"100\">
			&nbsp;
			</td>
			
			<td width=\"90\">
			<font face=\"tahoma\" size=\"2\">$lang_admin_sortGB:</font> 
			</td>
			
			
			<td width=\"150\">
			<select name=\"sort\">
			<option value=\"ShowAll\" $check1>$lang_admin_sortGB_option1</option>
			<option value=\"oldest\"  $check2>$lang_admin_sortGB_option2</option>
			</select>
			</td>
			
			
			<td>
			&nbsp;
			</td>
			
			
			<td width=\"40\">
			<input type=\"button\" value=\"$lang_admin_resort\" onClick=\"checkForm();\">
			</td>
			
			
			</tr>
			</table>
			
			</td>
			</tr>
			</table>
			</form>
			<br>
			</div>
			
			
			<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"2\"  border=\"1\">
				
					<tr background=\"../images/icons/disc_bar.gif\">
					
					<td background=\"../images/icons/disc_bar.gif\" width=\"7%\" align=\"center\"><font face=\"tahoma\" size=\"2\" color=\"#ffffff\">$lang_admin_status</font></td>
					<td background=\"../images/icons/disc_bar.gif\" width=\"7%\" align=\"center\"><font face=\"tahoma\" size=\"2\" color=\"#ffffff\">$lang_admin_id</font></td>
					<td background=\"../images/icons/disc_bar.gif\" widht=\"22%\" align=\"center\"><font face=\"tahoma\" size=\"2\" color=\"#ffffff\">$lang_admin_date</font></td>
					<td background=\"../images/icons/disc_bar.gif\" width=\"32%\" align=\"center\"><font face=\"tahoma\" size=\"2\" color=\"#ffffff\">$lang_admin_title</font></td>
					<td background=\"../images/icons/disc_bar.gif\" width=\"20%\" align=\"center\"><font face=\"tahoma\" size=\"2\" color=\"#ffffff\">$lang_admin_author</font></td>
					
					<td background=\"../images/icons/disc_bar.gif\" width=\"12%\" align=\"center\"><font face=\"tahoma\" size=\"2\" color=\"#ffffff\">$lang_admin_actions</font></td>
					
					</tr>
					
				";
			
	
	
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		$result = mysql_query("SELECT * FROM eblog_gb", $conn);
		$totalEntries = mysql_num_rows($result);
		
		
		if(empty($spoint))
		{
			$spoint = 0;
		}
		$epoint = $spoint + $limit;
		if($epoint > $totalEntries)
		$epoint = $totalEntries;
		
		
		if($action == "oldest")
		{
			$query  = "SELECT * FROM eblog_gb";
			$redirectURL = "oldest";
		}
		else
		{
			$query  = "SELECT * FROM eblog_gb ORDER BY id DESC";
			$redirectURL = "ShowAll";
		}
		
		
		$counter = 0;
		$result = mysql_query($query);
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			if(($counter < $epoint)&&($counter >= $spoint))
			{	
				$rowID = $row['id'];
				$rowTitle = $row['title'];
				$rowAuthor = $row['author'];
				$rowDate = $row['date'];
				$chunks = explode("-",$rowDate);
				$toGet = $chunks[1];$rowDate = $chunks[0] . " " . $MonthsArray[$toGet] . " " . $chunks[2];
				$rowLocation = $row['location'];
				$rowComment = $row['comment'];
				$rowStatusID = $row['statusID'];
			
				$reminder = $counter%2;
				if($reminder == 0)
				$bgColor = "#f2f2f2";
				else
				$bgColor = "#dadada";
				
				
				if(strlen($rowTitle) > 40){
					$rowTitle = substr($rowTitle, 0, 37).'...';	
				}
				
				if(strlen($rowAuthor) > 18){
					$rowAuthor = substr($rowAuthor, 0, 15).'...';	
				}
						
						
				if($rowStatusID=="0")
				{
					$rowStat = "onhold";
					$rowToChange = "approve";
					$statName = $lang_admin_onhold;
					$toChangeName = $lang_admin_approve;
					$toAct = "Approve";		
				}
				if($rowStatusID=="1")
				{
								$rowStat = "approve";
								$rowToChange = "inactive";
								$statName = $lang_admin_approved;
								$toChangeName = $lang_admin_suspend;
								$toAct = "Suspend";	
				}	
			
				$href = "guestbook.php?id=$rowID&refresh=$redirectURL&action=".$toAct."&limit=". $limit . "&spoint=" . $spoint;
				
				$list_of_entries = $list_of_entries . "
				<tr bgcolor=\"$bgColor\">
				
				<td width=\"7%\" align=\"center\"><img src=\"../images/icons/icon_$rowStat.gif\" title=\"$statName\"></td>
				<td width=\"7%\" align=\"center\"><font face=\"tahoma\" size=\"2\">$rowID</font></td>
				<td widht=\"22%\" align=\"center\"><font face=\"tahoma\" size=\"2\">$rowDate</font></td>
				<td width=\"32%\"><a href=\"guestbook.php?action=edit&id=$rowID\" title=\"$rowTitle\" rel=\"gb_page_center[640, 300]\"><font face=\"tahoma\" size=\"2\">$rowTitle</font></a></td>
				<td width=\"20%\" align=\"center\"><font face=\"tahoma\" size=\"2\">$rowAuthor</font></td>
				
				<td width=\"12%\" align=\"center\">
				<a href=\"$href\"><img src=\"../images/icons/icon_changer.gif\" title=\"$toChangeName\" border=\"0\"></a>
				<a href=\"guestbook.php?action=edit&id=$rowID\" title=\"$rowTitle\" rel=\"gb_page_center[640, 300]\"><img src=\"../images/icons/icon_fix.gif\" border=\"0\" title=\"$lang_admin_edit\"></a>
				<a href=\"#\" onClick=\"confirmDelete($rowID); return false;\"><img src=\"../images/icons/icon_remove.gif\" border=\"0\" title=\"$lang_admin_delete\"></a>
				</td>
				
				</tr>
				";
			}
			
			$counter++;
		}
		if($counter < 1){
		$list_content = $list_content . "<tr bgcolor=\"#f2f2f2\"><td colspan=\"6\"><font face=\"tahoma\" size=\"2\">$lang_admin_noEntriesInGB</font></td></tr>";
		}
		
		$list_of_entries = $list_of_entries . "</table>";
		$list_content = $list_content . $list_of_entries;
		
		// navigation buttons
		if($totalEntries > $limit){
		
			// Calculate next
			$nx = $spoint+$limit;
			if($nx > $totalEntries){
			$disabled2 = "disabled";
			}
			
			
			// Calculate previous
			$pr = $spoint - $limit;
			if($pr < 0){
			$disabled1 = "disabled";
			}
			
			
			if($action=="oldest"){
			$list_content = $list_content . "
			<br>
			<table width=\"100%\" border=\"0\">
			<tr>
			
			<td><input type=\"button\" value=\"$lang_admin_prev\" onClick=\"goPrevII($pr, $limit);\" $disabled1></td>
			<td width=\"100%\">&nbsp;</td>
			<td><input type=\"button\" value=\"$lang_admin_next\" onClick=\"goNextII($nx, $limit);\" $disabled2></td>
			</tr>
			</table>
			";
			}
			else{
			$list_content = $list_content . "
			<br>
			<table width=\"100%\" border=\"0\">
			<tr>
			
			<td><input type=\"button\" value=\"$lang_admin_prev\" onClick=\"goPrev($pr, $limit);\" $disabled1></td>
			<td width=\"100%\">&nbsp;</td>
			<td><input type=\"button\" value=\"$lang_admin_next\" onClick=\"goNext($nx, $limit);\" $disabled2></td>
			</tr>
			</table>
			";
			}		
			
			
					
		}
						 	
	
		$static_value = array ($blog_dir, $blog_windows_encoding, $lang_admin_adminPanel, $JAVA_ALERTS, $blog_slogan, $lang_admin_showHomePage, $lang_admin_link_1, $lang_admin_link_2, $lang_admin_link_3, $lang_admin_link_4, $lang_admin_link_5, $lang_admin_link_6, $lang_admin_link_7, $lang_admin_sync, $lang_admin_search,
		
		$lang_admin_quickLinks,$quicklinks,$lang_admin_readDocumentation,
		$lang_admin_notifications, $notifications, $lang_admin_resolve,
		$lang_admin_kc, $kc, $lang_admin_ReadTheAgreement,
		
		
		$lang_admin_footer1,$lang_admin_footer1_1,$lang_admin_footer1_2,$lang_admin_footer1_3,
		$lang_admin_footer2,$lang_admin_footer2_1,$lang_admin_footer2_2,$lang_admin_footer2_3,$lang_admin_footer2_4,
		$lang_admin_footer3,$lang_admin_footer3_1,$lang_admin_footer3_2,
		$lang_admin_footerRights,
		 
		$lang_admin_home, $thisPageNav,
		
		$list_name, $list_content	
		
		);
		$static_name = array ("{blog_dir}","{blog_windows_encoding}", "{title_name}", "{JAVA_ALERTS}", "{blog_slogan}", "{lang_admin_showHomePage}", "{lang_admin_link_1}", "{lang_admin_link_2}", "{lang_admin_link_3}", "{lang_admin_link_4}", "{lang_admin_link_5}", "{lang_admin_link_6}", "{lang_admin_link_7}", "{lang_admin_sync}", "{lang_admin_search}",
		
		"{lang_admin_quickLinks}","{quicklinks}","{lang_admin_readDocumentation}",
		"{lang_admin_notifications}", "{notifications}", "{lang_admin_resolve}",
		"{lang_admin_kc}", "{kc}", "{lang_admin_ReadTheAgreement}",
		
		
		"{lang_admin_footer1}","{lang_admin_footer1_1}","{lang_admin_footer1_2}","{lang_admin_footer1_3}",
		"{lang_admin_footer2}","{lang_admin_footer2_1}","{lang_admin_footer2_2}","{lang_admin_footer2_3}","{lang_admin_footer2_4}",
		"{lang_admin_footer3}","{lang_admin_footer3_1}","{lang_admin_footer3_2}",
		"{blog_rights}",
		 
		"{lang_admin_home}", "{thisPageNav}",
	
		"{list_name}", "{list_content}"			
		
		);	
		
		$header = $new_template->load_template ("../templates/$defaultTemplate/admin/header.html");
		$home = $new_template->load_template ("../templates/$defaultTemplate/admin/list.html");
		$footer = $new_template->load_template ("../templates/$defaultTemplate/admin/footer.html");		
		$template = $new_template->replace_static($static_name, $static_value, $header.$home.$footer);	
		echo $template;	
		
		mysql_close($conn);
	}
	
	
	
	// 3: Add new entry
	else if($action == "add"){
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
			
		// Load countries
		$location = "<select name=\"location\" style=\"width: 180;  height:21\">";
		$result = mysql_query("SELECT location FROM eblog_settings WHERE id = '1'");	
		$row = mysql_fetch_row($result);
		$rowLocation = $row[0];		
				
		$query  = "SELECT id, name FROM eblog_countries ORDER BY id ASC";
		$result = mysql_query($query);
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			$ThisRowID = $row['id'];
			$ThisRowName = $row['name'];
			if($ThisRowID == $rowLocation)
			{
			$location = $location . "<option value=\"$ThisRowID\" SELECTED>$ThisRowName</option>";
			}
			else
			{
			$location = $location . "<option value=\"$ThisRowID\">$ThisRowName</option>";
			}
		}
		$location = $location . "</select>";			
		
		
		
		// show form
		echo "<html dir=\"$blog_dir\">
		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">
		<script language=\"javascript\">
		  function checkForm(form){
		  
		  if(form.author.value == \"\"){
		  alert( \"$lang_erorr_code126\" );
		  form.author.focus();
		  return false;
		  }				  
		  
		  if(form.title.value == \"\"){
		  alert( \"$lang_erorr_code127\" );
		  form.title.focus();
		  return false;
		  }
		  
		  if(form.comment.value == \"\"){
		  alert( \"$lang_erorr_code128\" );
		  form.comment.focus();
		  return false;
		  }
		  		  
		  
		  return true;
		  }
		  			  
			
			</script>
			<div>
			<form method=\"post\" action=\"guestbook.php?action=save&id=$id\" onsubmit=\"return checkForm(this);\">
			<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"  border=\"1\">
			

			
			<tr bgcolor=\"dadada\">
			<td width=\"150\">
			<font size=\"2\" face=\"tahoma\">
				$lang_admin_author:
			</font>
			</td>
			<td>
			<input type=\"text\" name=\"author\" size=\"57\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" maxlength=\"50\">				
			</td>				
			</tr>	
			
			
			<tr bgcolor=\"f2f2f2\">
			<td width=\"150\">
			<font size=\"2\" face=\"tahoma\">
				$lang_admin_title:
			</font>
			</td>
			<td>
			<input type=\"text\" name=\"title\" size=\"57\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" maxlength=\"50\">
			</td>				
			</tr>
			
			
			<tr bgcolor=\"dadada\">
			<td width=\"150\">
			<font size=\"2\" face=\"tahoma\">
				$lang_admin_content:
			</font>
			</td>
			<td>
			<textarea name=\"comment\" cols=\"55\" rows=\"5\" MAXLENGTH=\"400\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000; resize: none;\"></textarea>
			</td>				
			</tr>	

			
			
			<tr bgcolor=\"f2f2f2\">
			<td width=\"150\">
			<font size=\"2\" face=\"tahoma\">
				$lang_admin_comment_location:
			</font>
			</td>
			<td>
			$location
			</td>				
			</tr>	
			
			
												
			
			
						
			</table>
			<br>
			<center><input type=\"submit\" value=\"$lang_admin_add\"></center>
			</form>
			</div>
			</html>
			";
			mysql_close($conn);	
	}
	
	
	
	// 4: Save new entry
	else if($action == "save"){
	
			$location = $_POST['location'];
			$author = htmlspecialchars($_POST['author']);
			$title = htmlspecialchars($_POST['title']);
			$comment = htmlspecialchars($_POST['comment']);			
			
			$conn = mysql_connect($dbhost, $dbuser, $dbpass);
			mysql_select_db($dbname);
			
			$newID = 1;
			$query  = "SELECT id FROM eblog_gb ORDER BY id ASC";
			$result = mysql_query($query);
			while($row = mysql_fetch_array($result, MYSQL_ASSOC))
			{
				$newID = $row['id'];
			}
			$newID++;
			$date = date("d-m-Y");
			 mysql_query("INSERT INTO eblog_gb  VALUES ('$newID', '$title', '$author', '$date' ,'$location','$comment','1')");
			mysql_close($conn);
			
			echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; url=guestbook.php?action=refresh\">";	
	}
	
	
	
	// 5: Edit entry
	else if($action == "edit"){
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);			

		$result = mysql_query("SELECT * FROM eblog_gb WHERE id = '$id'");	
		$row = mysql_fetch_row($result);
		$rowID = $row[0];
		$rowTitle = $row[1];
		$rowAuthor = $row[2];
		$rowLocation = $row[4];
		$rowComment = $row[5];		
		$rowStatus = $row[6];
		
		if($rowStatus == 1)
		$radio_condition_1 = "checked";
		if($rowStatus == 0)
		$radio_condition_2 = "checked";			
		
		
		$location = "<select name=\"location\" style=\"width: 180px;  height:21px;\">";		
		$query  = "SELECT id, name FROM eblog_countries ORDER BY id ASC";
		$result = mysql_query($query);
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			$ThisRowID = $row['id'];
			$ThisRowName = $row['name'];
			if($ThisRowID == $rowLocation)
			{
			$location = $location . "<option value=\"$ThisRowID\" SELECTED>$ThisRowName</option>";
			}
			else
			{
			$location = $location . "<option value=\"$ThisRowID\">$ThisRowName</option>";
			}
		}
		$location = $location . "</select>";			
		
		
		
		// show form
		echo "<html dir=\"$blog_dir\">
		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">
		<script language=\"javascript\">
		  function checkForm(form){
		  
		  if(form.author.value == \"\"){
		  alert( \"$lang_erorr_code126\" );
		  form.author.focus();
		  return false;
		  }				  
		  
		  if(form.title.value == \"\"){
		  alert( \"$lang_erorr_code127\" );
		  form.title.focus();
		  return false;
		  }
		  
		  if(form.comment.value == \"\"){
		  alert( \"$lang_erorr_code128\" );
		  form.comment.focus();
		  return false;
		  }
		  		  
		  
		  return true;
		  }
		  			  
			
			</script>
			<div>
			<form method=\"post\" action=\"guestbook.php?action=update&id=$id\" onsubmit=\"return checkForm(this);\">
			<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"  border=\"1\">
			

			
			<tr bgcolor=\"dadada\">
			<td width=\"150\">
			<font size=\"2\" face=\"tahoma\">
				$lang_admin_author:
			</font>
			</td>
			<td>
			<input type=\"text\" name=\"author\" size=\"57\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" maxlength=\"50\" value=\"$rowAuthor\">				
			</td>				
			</tr>	
			
			
			<tr bgcolor=\"f2f2f2\">
			<td width=\"150\">
			<font size=\"2\" face=\"tahoma\">
				$lang_admin_title:
			</font>
			</td>
			<td>
			<input type=\"text\" name=\"title\" size=\"57\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" maxlength=\"50\" value=\"$rowTitle\">
			</td>				
			</tr>
			
			
			<tr bgcolor=\"dadada\">
			<td width=\"150\">
			<font size=\"2\" face=\"tahoma\">
				$lang_admin_content:
			</font>
			</td>
			<td>
			<textarea name=\"comment\" cols=\"55\" rows=\"3\" MAXLENGTH=\"400\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000; resize: none;\">$rowComment</textarea>
			</td>				
			</tr>	
			
	<tr bgcolor=\"#dadada\"><td width=\"150\"><font face=\"tahoma\" size=\"2\">$lang_admin_comment_status:</font></td><td>				<input type=\"radio\" name=\"g1\" value=\"1\" $radio_condition_1><font size=\"2\" face=\"tahoma\">$lang_admin_approved</font>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type=\"radio\" name=\"g1\" value=\"0\" $radio_condition_2><font size=\"2\" face=\"tahoma\">$lang_admin_onhold</font></td></tr>					

			
			
			<tr bgcolor=\"f2f2f2\">
			<td width=\"150\">
			<font size=\"2\" face=\"tahoma\">
				$lang_admin_comment_location:
			</font>
			</td>
			<td>
			$location
			</td>				
			</tr>	
			
			
												
			
			
						
			</table>
			<br>
			<center><input type=\"submit\" value=\"$lang_admin_update\"></center>
			</form>
			</div>
			</html>
			";
			mysql_close($conn);	
	}
	
	
	
	// 6: Update entry
	else if($action == "update"){
		$author = htmlspecialchars($_POST['author']);
		$title = htmlspecialchars($_POST['title']);
		$comment = htmlspecialchars($_POST['comment']);
		$location = $_POST['location'];
		$status = $_POST['g1'];
		
		
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);

		$sql="UPDATE eblog_gb SET title='$title' WHERE id = '$id'";
		$result=mysql_query($sql);	
		
		$sql="UPDATE eblog_gb SET author='$author' WHERE id = '$id'";
		$result=mysql_query($sql);	
		
		$sql="UPDATE eblog_gb SET comment='$comment' WHERE id = '$id'";
		$result=mysql_query($sql);	
		
		$sql="UPDATE eblog_gb SET statusID='$status' WHERE id = '$id'";
		$result=mysql_query($sql);	
		
		$sql="UPDATE eblog_gb SET location='$location' WHERE id = '$id'";
		$result=mysql_query($sql);																				
	
		mysql_close($conn);			
		
		echo "<br><br><br><center><img src=\"../images/loading.gif\"></center>";
		
		echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; url=guestbook.php?action=refresh\">";	
	}	
	
	
	
	// 7: Delete entry
	else if($action == "delete"){
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		mysql_query("DELETE FROM eblog_gb WHERE id=$id");
		mysql_close($conn);
		echo "<meta http-equiv=\"refresh\" content=\"0;url=guestbook.php?Action=$refresh\">";	
	}	
	
	
	
	// 8: Approve new entry
	else if($action == "Approve"){
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		$sql="UPDATE eblog_gb SET statusID='1' WHERE id = '$id'";
		$result=mysql_query($sql);
		mysql_close($conn);
		$href = "guestbook.php?action=$refresh&limit=$limit&spoint=$spoint";
		echo "<meta http-equiv=\"refresh\" content=\"0;url=$href\">";	
	}						
	

	// 9: Suspend new entry
	else if($action == "Suspend"){
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		$sql="UPDATE eblog_gb SET statusID='0' WHERE id = '$id'";
		$result=mysql_query($sql);
		mysql_close($conn);
		$href = "guestbook.php?action=$refresh&limit=$limit&spoint=$spoint";
		echo "<meta http-equiv=\"refresh\" content=\"0;url=$href\">";	
	}	
	
	// 10: else, go home
	else
	{
		echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php\">";
	}
	
	
 }
   else{   
    echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php\">";
 }
			
?>
Return current item: eBlog