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

/**************************************************************************
 *                                                                        *
 *                                                                        *
 *         Solution: eBlog                                                *
 *          Release: 1.7                                                  *
 *             File: admin/topics.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'];
$id     = $_GET['id'];
$section = $_GET['section'];
$GTP     = $_GET['GTP']; 
$TopicID = $_GET['TopicID'];
$todo = "";


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


if($section != "")
{
	echo "<meta http-equiv=\"refresh\" content=\"0;url=sections.php#$section\">";
}

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

	// 1: Show Main Form
	if($action == "form"){
	
	$conn = mysql_connect($dbhost, $dbuser, $dbpass);
	mysql_select_db($dbname);
	

	
	
	$thisPageNav = "&nbsp;<img src=\"../images/icons/prev_$blog_dir.gif\">&nbsp;<a href=\"topics.php\"><font face=\"tahoma\" style=\"font-size: 10pt;\">$lang_admin_link_4</font></a>";
	
	
	
	$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=\"topics.php?action=add\"   title=\"$lang_admin_addTopic\" rel=\"gb_page_center[640, 500]\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_addTopic</font></a></td>
						 </tr>
						 
						 
						 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
						 <td><a href=\"#list\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_eBlogLastTopict</font></a></td>
						 </tr>
						 
						 
						 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
						 <td><a href=\"#sections\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_eBlogDisplayTopicsInSection</font></a></td>
						 </tr>

					 </table>";
					 
	
	
	
	
	$topics_list = "
	<script language=\"javascript\">
	function rusure(toDelete){
		question = confirm(\"$lang_admin_confirmDeleteTopic\")
		if (question !=\"0\"){
			top.location = \"topics.php?action=Remove&GTP=topics.php&id=\" + toDelete;
		}
	}
	</script>
	<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"4\"  border=\"1\">
	
	<tr background=\"../images/icons/disc_bar.gif\">
	<td width=\"40\" align=\"center\" background=\"../images/icons/disc_bar.gif\"><font style=\"font-size: 0.8em;\" face=\"Tahoma\" color=\"#ffffff\">$lang_admin_id</font></td>
	<td align=\"center\" background=\"../images/icons/disc_bar.gif\"><font style=\"font-size: 0.8em;\" face=\"Tahoma\" color=\"#ffffff\">$lang_admin_name</font></td>
	<td width=\"120\" align=\"center\" background=\"../images/icons/disc_bar.gif\"><font style=\"font-size: 0.8em;\" face=\"Tahoma\" color=\"#ffffff\">$lang_admin_date</font></td>
	<td width=\"60\" align=\"center\" background=\"../images/icons/disc_bar.gif\"><font style=\"font-size: 0.8em;\" face=\"Tahoma\" color=\"#ffffff\">$lang_admin_actions</font></td>
	</tr>
	
	
	";
	$query  = "SELECT * FROM eblog_topics ORDER BY id DESC";
	$result = mysql_query($query);
	$counter = 0;
	$result = mysql_query($query);
	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
			if($counter < 10)
			{
				$reminder = $counter%2;
				if($reminder == 0)
				{
					$bgColor = "#f2f2f2";
				}
				else
				{
					$bgColor = "#dadada";
				}
				
				$rowID = $row['id'];
				$rowSec = $row['sec'];
				$rowTitle = $row['title'];
				$rowDate = $row['date'];
				$chunks = explode("-",$rowDate);
				$toGet = $chunks[1];$rowDate = $chunks[0] . " " . $MonthsArray[$toGet] . " " . $chunks[2];
				
				$topics_list = $topics_list . "
				<tr bgcolor=\"$bgColor\">
				<td width=\"40\" align=\"center\"><font face=\"tahoma\" size=\"2\">$rowID</font></td>
				<td><a href=\"topics.php?action=Edit&id=$rowID\" rel=\"gb_page_center[640, 500]\"><font face=\"tahoma\" size=\"2\">$rowTitle</font></a></td>
				<td width=\"120\" align=\"center\"><font face=\"tahoma\" size=\"2\">$rowDate</font></td>
				<td width=\"60\" align=\"center\"><a href=\"topics.php?action=Edit&id=$rowID\" rel=\"gb_page_center[640, 500]\"><img src=\"../images/icons/icon_fix.gif\" title=\"$lang_admin_edit\" border=\"0\"></a>&nbsp;<a href=\"topics.php?action=ShowComments&id=$rowID\"  title=\"$rowTitle\" rel=\"gb_page_center[640, 300]\"><img src=\"../images/icons/icon_comment.gif\" title=\"$lang_admin_showAllComments\" border=\"0\"></a>&nbsp;<a href=\"#\" onClick=\"rusure($rowID); return false;\"><img src=\"../images/icons/icon_remove.gif\" title=\"$lang_admin_delete\" border=\"0\"></a></td>	
				</tr>";
			}
			$counter++;
		
	}
	if ($counter < 1)
	{
	$topics_list = $topics_list . "<tr bgColor=\"f2f2f2\"><td colspan=\"4\"><font face=\"tahoma\" size=\"2\">$lang_admin_noTopics</font></td></tr>";
	}
	$topics_list = $topics_list . "</table>";	
	
	$query  = "SELECT id, title FROM eblog_sections ORDER BY id ASC";
	$result = mysql_query($query);
	$section_list = "
	<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"4\"  border=\"1\">
	
	<tr background=\"../images/icons/disc_bar.gif\">
	<td width=\"40\" align=\"center\" background=\"../images/icons/disc_bar.gif\"><font style=\"font-size: 0.8em;\" face=\"Tahoma\" color=\"#ffffff\">$lang_admin_id</font></td>
	<td align=\"center\" background=\"../images/icons/disc_bar.gif\"><font style=\"font-size: 0.8em;\" face=\"Tahoma\" color=\"#ffffff\">$lang_admin_name</font></td>
	<td width=\"60\" align=\"center\" background=\"../images/icons/disc_bar.gif\"><font style=\"font-size: 0.8em;\" face=\"Tahoma\" color=\"#ffffff\">$lang_admin_actions</font></td>
	</tr>
	";
	$counter = 0;
	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
		$counter++;
		
		$devider = $counter%2;
		
		if($devider==0)
		$bgColor="#f2f2f2";
		else
		$bgColor="#dadada";
		
		$id	= $row['id'];
		$title	= $row['title'];
		
		
		
		$section_list = $section_list . "<tr bgcolor=\"$bgColor\"><td width=\"40\" align=\"center\"><font face=\"tahoma\" size=\"2\">$id</font></td><td><a href=\"topics.php?action=ShowAll&id=$id\"><font face=\"tahoma\" size=\"2\">$title</font></a></td><td width=\"60\"  align=\"center\"><a href=\"topics.php?action=ShowAll&id=$id\"><img src=\"../images/icons/icon_list.gif\"border=\"0\" title=\"$lang_admin_ShowAllTopics\"></a></td></tr>";	
	}
	
	if ($counter < 1)
	{
	$section_list = $section_list . "<tr bgColor=\"f2f2f2\"><td colspan=\"3\"><font face=\"tahoma\" size=\"2\">$lang_admin_noSections</font></td></tr>";
	}
	
	$section_list = $section_list . "</table>";
	
	
	mysql_close($conn);
	
					 
	
	
		$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,
		
		$lang_admin_eBlogLastTopict, $topics_list,
		$lang_admin_eBlogDisplayTopicsInSection, $section_list
		
		);
		$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}",
	
		"{lang_admin_eBlogLastTopict}", "{topics_list}",
		"{lang_admin_eBlogDisplayTopicsInSection}", "{section_list}"			
		
		);	
		
		$header = $new_template->load_template ("../templates/$defaultTemplate/admin/header.html");
		$home = $new_template->load_template ("../templates/$defaultTemplate/admin/topics.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;	
	}
	
	
	
	// 2: Add new topics
	else if(($action == "add")||($action == "Add")){
	
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
	
	$result = mysql_query("SELECT * FROM  eblog_sections", $conn);
	$numberOfSections = mysql_num_rows($result);
	
	if($numberOfSections < 1)	
	echo "<meta http-equiv=\"refresh\" content=\"0;url=topics.php?action=stop\">";		
		
		$sectionsMenu = "";
		$query  = "SELECT id, title FROM eblog_sections";
		$result = mysql_query($query);		
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			$rowID = $row['id'];
			$rowTitle = $row['title'];
			$sectionsMenu = $sectionsMenu . "<option value=\"$rowID\">$rowTitle</option>";
		}
			
		
		$FORM_DATA_BUTTON = $lang_admin_finishAndAddTopic;	
		$FORM_DATA_PROCESSPAGE = "topics.php?action=Save";
		
		$rowTitle = "";			
		$todo = "printNow";
		
		mysql_close($conn);	
	}
	
	
	// 3: Save new topic
	else if($action == "Save"){
	
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);	
		
		$messageToDisplay = $lang_admin_topicHasNotBeenAdded;
			
		$addToDB = 0;
		$topicTitle   = $_POST["title"];
		$topicContent = $_POST["content"];
		$topicThumb = basename($_FILES['thumb']['name']);
		$topicInner = basename($_FILES['inner']['name']);
		$topicSection = $_POST["section"];	
		$mode = $_POST['mode'];
		
	

		// Thumbnail
		if(!empty($topicThumb)){		
				// If file already exist, rename file
				$thumbNewName = '../uploads/'.'thumbs'.'/'.$topicThumb;
				if (file_exists($thumbNewName))
				{
					$timeNow = date("dmyHis");
					$thumbNewName = '../uploads/'.'thumbs'.'/'. $timeNow . '_' . $topicThumb;	
				}
				else
				{
					$thumbNewName = '../uploads/'.'thumbs'.'/'.$topicThumb;
				}
				
				// upload picture	
				if(move_uploaded_file($_FILES['thumb']['tmp_name'],$thumbNewName))
				{
					$addToDB = 0;
				}
				else
				{
					$addToDB = 1;
				}					
			}
			
			
			
		// Main Picture	
		if(!empty($topicInner)){
				// If file already exist, rename file
				$innerNewName = '../uploads/'.'pictures'.'/'.$topicInner;
				if (file_exists($innerNewName))
				{
					$timeNow = date("dmyHis");
					$innerNewName = '../uploads/'.'pictures'.'/'. $timeNow . '_' . $topicInner;	
				}
				else
				{
					$innerNewName = '../uploads/'.'pictures'.'/'.$topicInner;
				}
				
				// upload picture	
				if(move_uploaded_file($_FILES['inner']['tmp_name'],$innerNewName))
				{
					//$addToDB = 0;
				}
				else
				{
					$addToDB = 1;
				}
		}
	
		
		
		// Prepare data to add to db
		if($addToDB == 0){
		
			$messageToDisplay = $lang_admin_topicHasBeenAdded;
			
			$query  = "SELECT id FROM eblog_topics ORDER BY id ASC";
			$result = mysql_query($query);	
			while($row = mysql_fetch_array($result, MYSQL_ASSOC))
			{
				$newID = $row['id'];
			}
			$newID = $newID + 1;
			$topicTime = date("d-m-Y");
			$viewers = 0;
			
			
			// Insert Data
			mysql_query("INSERT INTO eblog_topics  VALUES ('$newID', '$topicSection', '$topicTitle', '$topicTime','$topicContent', '$thumbNewName', '$innerNewName', '$viewers')");
		}
		
		echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; url=topics.php?action=refresh\">
		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">
		";
		echo $goThere;
		echo "<div align=\"center\"><br><br><br><br><br><br><br><br>";
		echo '<font face=Tahoma size=2>'. $messageToDisplay . '</font>';
		echo "</div></body></html>";
		
		mysql_close($conn);	
	}
	
	
	// 4: Edit given topic
	else if($action == "Edit"){
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		$result = mysql_query("SELECT id, sec, title, date, contents, thumb, main, allviewers FROM eblog_topics WHERE id = '$id'");	
		$row = mysql_fetch_row($result);
		$rowID = $row[0];
		$rowSec = $row[1];
		$rowTitle = $row[2];
		$rowDate = $row[3];
		$rowContent = $row[4];
		$rowThumb = $row[5];
		$rowMain = $row[6];
		$rowViewers = $row[7];	
			
		
		$sectionsMenu = "";
		$query  = "SELECT id, title FROM eblog_sections";
		$result = mysql_query($query);		
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			$newRowID = $row['id'];
			$newRowTitle = $row['title'];
			
			if($newRowID == $rowSec)
			$sectionsMenu = $sectionsMenu . "<option value=\"$newRowID\" SELECTED>$newRowTitle</option>";
			else
			$sectionsMenu = $sectionsMenu .  "<option value=\"$newRowID\">$newRowTitle</option>";
		}
			
		
		$FORM_DATA_BUTTON = $lang_admin_update;	
		$FORM_DATA_PROCESSPAGE = "topics.php?action=Update&id=$id";
					
		$todo = "printNow";
		
		mysql_close($conn);		
	}
	
	
	// 5: Update given topic
	else if($action == "Update"){
	
	$conn = mysql_connect($dbhost, $dbuser, $dbpass);
	mysql_select_db($dbname);				
		
	$rowID = $_POST["id"];
	$rowSec = $_POST["section"];
	$rowTitle = $_POST["title"];
	$rowDate = $_POST["date"];
	$rowContents = $_POST["content"];
	$rowThumb = $_POST["thumb"];
	$rowThumbOld = $_POST["thumbOld"];
	$rowMain = $_POST["inner"];
	$rowOldMain = $_POST["mainOld"];
	$rowViewers = $_POST["viewers"];
	$addToDB = 0;
	$topicThumb = basename($_FILES['thumb']['name']);
	$topicInner = basename($_FILES['inner']['name']);
	$topicSection = $rowSec;

		// Thumbnail
		if(!empty($topicThumb)){		
				// If file already exist, rename file
				$thumbNewName = '../uploads/'.'thumbs'.'/'.$topicThumb;
				if (file_exists($thumbNewName))
				{
					$timeNow = date("dmyHis");
					$thumbNewName = '../uploads/'.'thumbs'.'/'. $timeNow . '_' . $topicThumb;	
				}
				else
				{
					$thumbNewName = '../uploads/'.'thumbs'.'/'.$topicThumb;
				}
				
				// upload picture	
				if(move_uploaded_file($_FILES['thumb']['tmp_name'],$thumbNewName))
				{
					$addToDB = 0;
					$query = "UPDATE eblog_topics SET `thumb` = '$thumbNewName' WHERE `id` = '$id'";
					mysql_query($query);
					
				}
				else
				{
					$addToDB = 1;
				}					
			}
			
			
			
		// Main Picture	
		if(!empty($topicInner)){
				// If file already exist, rename file
				$innerNewName = '../uploads/'.'pictures'.'/'.$topicInner;
				if (file_exists($innerNewName))
				{
					$timeNow = date("dmyHis");
					$innerNewName = '../uploads/'.'pictures'.'/'. $timeNow . '_' . $topicInner;	
				}
				else
				{
					$innerNewName = '../uploads/'.'pictures'.'/'.$topicInner;
				}
				
				// upload picture	
				if(move_uploaded_file($_FILES['inner']['tmp_name'],$innerNewName))
				{
					//$addToDB = 0;
					$query = "UPDATE eblog_topics SET `main` = '$innerNewName' WHERE `id` = '$id'";
					mysql_query($query);					
				}
				else
				{
					$addToDB = 1;
				}
		}
		
		
		
		
		if (empty ($rowDate)){
		$rowDate = date("d-m-Y");	
		}
		
		if (empty ($rowViewers)){
			$rowViewers = 0;	
		}
		
		if (empty ($thumbNewName)){
			$thumbNewName = $rowThumbOld;	
		}

		
		if (empty ($innerNewName)){
			$innerNewName = $rowOldMain;	
		}

					
   if($addToDB == 0){
		$query = "UPDATE eblog_topics SET `date` = '$rowDate' WHERE `id` = '$id'";
		mysql_query($query);
		$query = "UPDATE eblog_topics SET `section` = '$rowSec' WHERE `id` = '$id'";
		mysql_query($query);
		$query = "UPDATE eblog_topics SET `title` = '$rowTitle' WHERE `id` = '$id'";
		mysql_query($query);
		$query = "UPDATE eblog_topics SET `date` = '$rowDate' WHERE `id` = '$id'";
		mysql_query($query);
		$query = "UPDATE eblog_topics SET `contents` = '$rowContents' WHERE `id` = '$id'";
		mysql_query($query);
		$query = "UPDATE eblog_topics SET `allviewers` = '$rowViewers' WHERE `id` = '$id'";
		mysql_query($query);
		
	   mysql_close($conn);
	
		echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; url=topics.php?action=Edit&id=$id\">";
		echo "<br><br><br><br><br><br><center><img src=\"../images/icons/loading.gif\"><br><br><font size=\"2\" face=\"tahoma\">$lang_admin_updatingTopic</font></center>";
		}	
	}
	
	
	
	
	// 6: Remove given topic
	else if($action == "Remove"){
	
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		mysql_query("DELETE FROM eblog_topics WHERE id=$id");
		mysql_query("DELETE FROM eblog_comments WHERE topicID=$rowID");	
		
		mysql_close($conn);
		
		if($GTP == "showall"){
		echo "<meta http-equiv=\"Refresh\" content=\"0;url=topics.php?action=ShowAll&id=$qID\">";
		}
		else{			
		echo "<meta http-equiv=\"Refresh\" content=\"0;url=$GTP\">";
		}	
	}
	
	
	// 7: Approve comment
	else if($action == "Approve"){
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		$sql="UPDATE eblog_comments SET statusID='1' WHERE id = '$id'";
		$result=mysql_query($sql);
		
		mysql_close($conn);
		
		if($GTP == "topics.php")
		echo "<meta http-equiv=\"Refresh\" content=\"0;url=$GTP?action=ShowComments&id=$TopicID\">";
		else				
		echo "<meta http-equiv=\"Refresh\" content=\"0;url=$GTP\">";	
	}
	
	
	// 8: Suspend comment
	else if($action == "Suspend"){
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		$sql="UPDATE eblog_comments SET statusID='0' WHERE id = '$id'";
		$result=mysql_query($sql);
		
		mysql_close($conn);
		
		if($GTP == "topics.php")
		echo "<meta http-equiv=\"Refresh\" content=\"0;url=$GTP?action=ShowComments&id=$TopicID\">";
		else			
		echo "<meta http-equiv=\"Refresh\" content=\"0;url=$GTP\">";	
	}
	
	
	// 9: Delete Comment
	else if($action == "DeleteComment"){
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		mysql_query("DELETE FROM eblog_comments WHERE id=$id");
		
		mysql_close($conn);
		
		if($GTP == "topics.php")
		echo "<meta http-equiv=\"Refresh\" content=\"0;url=$GTP?action=ShowComments&id=$TopicID\">";
		else
		echo "<meta http-equiv=\"Refresh\" content=\"0;url=$GTP\">";	
	}
	
	
	// 10: Show Comments
	else if($action == "ShowComments"){
	
		echo "<html dir=\"$blog_dir\">
			  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">
			  <script language=\"javascript\">
				function rusure(toDelete){
				question = confirm(\"$lang_admin_confirmDeleteTopic\")
				if (question !=\"0\"){
					window.location = \"topics.php?action=Remove&id=\" + toDelete;
				}
				}
			  </script>
			  <div><table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"2\"  border=\"1\">";
			  
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
	
		$query  = "SELECT id, author, date, topicID, statusID FROM eblog_comments ORDER BY id DESC";
		$result = mysql_query($query);		
		$counter = 0;
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{	
			$rowID = $row['id'];
			$rowTopicID = $row['topicID'];
			
			if($rowTopicID == $id){
			$rowAuthor = $row['author'];
			$rowDate = $row['date'];
			$chunks = explode("-",$rowDate);
			$toGet = $chunks[1];$rowDate = $chunks[0] . " " . $MonthsArray[$toGet] . " " . $chunks[2];
			$rowStat = $row['statusID'];
			$reminder = $counter%2;
			
			if($reminder ==0)
			$bgColor = "#f2f2f2";
			else
			$bgColor = "#dadada";
			
			
			if($rowStat=="0")
			{
				$rowStat = "onhold";
				$rowToChange = "approve";
				$statName = $lang_admin_onhold;
				$toChangeName = $lang_admin_approve;
				$toAct = "Approve";
			}
			if($rowStat=="1")
			{
				$rowStat = "approve";
				$rowToChange = "inactive";
				$statName = $lang_admin_approved;
				$toChangeName = $lang_admin_suspend;
				$toAct = "Suspend";					
			}				
			
			echo "<tr bgcolor=\"$bgColor\"><td><table cellPadding=\"0\" width=\"100%\"><tr><td width=\"25\"><img src=\"../images/icons/icon_$rowStat.gif\" title=\"$statName\"></td><td width=\"90\"><font style=\"font-size: 0.8em;\" face=\"Tahoma\">$lang_admin_commentBy:</font></td><td><font style=\"font-size: 0.8em;\" face=\"Tahoma\">$rowAuthor</font></td><td width=\"180\"><font style=\"font-size: 0.8em;\" face=\"Tahoma\">$rowDate</font></td><td width=\"16\"><a href=\"topics.php?action=EditComment&id=$rowID&GTP=topics.php\"><img src=\"../images/icons/icon_fix.gif\" border=\"0\"></a></td><td width=\"16\"><a href=\"topics.php?action=$toAct&id=$rowID&GTP=topics.php&TopicID=$rowTopicID\"><img src=\"../images/icons/icon_$rowToChange.gif\" title=\"$toChangeName\" border=\"0\"></a></td><td width=\"16\"><a href=\"topics.php?action=DeleteComment&id=$rowID&GTP=topics.php&TopicID=$rowTopicID\"><img src=\"../images/icons/icon_remove.gif\" title=\"$lang_admin_removeComment\" border=\"0\"></a>". "</td></tr></table></td></tr>";
			
			$counter++;
			}
		}
		
		
		if($counter < 1)
		{
		echo "<tr bgcolor=\"#f2f2f2\"><td><font face=\"tahoma\" size=\"2\">$lang_admin_noComments</font></td></tr>";
		}
		echo "</table></div></html>";
		
		
		mysql_close($conn);	
	}
	
	
	// 11: Edit Comment
	else if($action == "EditComment"){
	
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		$result = mysql_query("SELECT id, author, date, contents, location, topicID, statusID FROM eblog_comments WHERE id = '$id'");
		$row = mysql_fetch_row($result);
		$rowID = $row[0];
		$rowAuthor = $row[1];
		$rowDate = $row[2];
		$rowContent = $row[3];
		$rowlocation = $row[4];
		$rowTopicID = $row[5];
		$rowStat = $row[6];
		
		$dateChunks = explode("-", $rowDate);
		$day = $dateChunks[0];
		$month = $dateChunks[1];
		$year = $dateChunks[2];
		
		if($rowStat == 1)
		$radio_condition_1 = "checked";
		else
		$radio_condition_2 = "checked";	
			
		
		$result = mysql_query("SELECT title FROM eblog_topics WHERE id = '$rowTopicID'");	
		$row = mysql_fetch_row($result);
		$topic = $row[0];

			

		$location = "<select name=\"location\" style=\"width: 180;  height:21\">";
		$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>";


		$monthListHere = "
				<select name=\"month\"></option>
				<option value='01'>$lang_blog_01</option>
				<option value='02'>$lang_blog_02</option>
				<option value='03'>$lang_blog_03</option>
				<option value='04'>$lang_blog_04</option>
				<option value='05'>$lang_blog_05</option>
				<option value='06'>$lang_blog_06</option>
				<option value='07'>$lang_blog_07</option>
				<option value='08'>$lang_blog_08</option>
				<option value='09'>$lang_blog_09</option>
				<option value='10'>$lang_blog_10</option>
				<option value='11'>$lang_blog_11</option>
				<option value='12'>$lang_blog_12</option>
				</select>		
		";
		$monthListHere = str_replace("$month'","$month' selected",$monthListHere);
		
		mysql_close($conn);		
	
		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.name.value == \"\"){
		  alert( \"$lang_erorr_code118\" );
		  form.name.focus();
		  return false;
		  }
		  
		  
		  if(form.day.value == \"\"){
		  alert( \"$lang_erorr_code119\" );
		  form.day.focus();
		  return false;
		  }

		  

		  if(form.month.value == \"\"){
		  alert( \"$lang_erorr_code120\" );
		  form.month.focus();
		  return false;
		  }
		  
	
		  
				  
		  if(form.year.value == \"\"){
		  alert( \"$lang_erorr_code121\" );
		  form.year.focus();
		  return false;
		  }	
		  
	  
		  
		  if(mynum < 1)
		  {
		  alert( \"$lang_erorr_code121\" );
		  form.year.focus();
		  return false;
		  }		  

		  if(form.content.value == \"\"){
		  alert( \"$lang_erorr_code122\" );
		  form.content.focus();
		  return false;
		  }			  	  		  		  

		  return true;
		  }
	
		</script>
		<form method=\"post\" action=\"topics.php?action=UpdateComment&id=$id\"  onsubmit=\"return checkForm(this);\">
		<div><table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"  border=\"1\">
		
		
		<tr bgcolor=\"#f2f2f2\"><td width=\"150\"><font face=\"tahoma\" size=\"2\">$lang_admin_comment_name:</font></td><td><input type=\"text\" name=\"name\" style=\"font-family: Tahoma; font-size: 12px; width:100%; color: #000000; border: 1px solid #000000;\" value=\"$rowAuthor\"><input type=\"hidden\" name=\"GTP\" value=\"$GTP\"><input type=\"hidden\" name=\"topicID\" value=\"$rowTopicID\"></td></tr>
		
		
		
		
		<tr bgcolor=\"#dadada\"><td width=\"150\"><font face=\"tahoma\" size=\"2\">$lang_admin_comment_date:</font></td><td><input type=\"text\" name=\"day\" size=\"3\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$day\" MAXLENGTH=\"2\"> $monthListHere <input type=\"text\" name=\"year\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$year\" MAXLENGTH=\"4\"></td></tr>
		
		
		
		
		<tr bgcolor=\"#f2f2f2\"><td width=\"150\"><font face=\"tahoma\" size=\"2\">$lang_admin_comment_topic:</font></td><td><input type=\"text\" name=\"topic\" style=\"font-family: Tahoma;  width:100%; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$topic\" 	DISABLED></td></tr>
		
		<tr bgcolor=\"#dadada\"><td width=\"150\"><font face=\"tahoma\" size=\"2\">$lang_admin_comment_content:</font></td><td><textarea name=\"content\" rows=\"3\" MAXLENGTH=\"10000\" style=\"font-family: Tahoma; font-size: 12px; width:100%; color: #000000; border: 1px solid #000000; resize: none;\">$rowContent</textarea></td></tr>
		
		<tr bgcolor=\"#f2f2f2\"><td width=\"150\"><font face=\"tahoma\" size=\"2\">$lang_admin_comment_location:</font></td><td>$location</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>										
		
		
		</table>
		<br>
		<center><input type=\"submit\" value=\"$lang_admin_update\"></center>
		</form>
		</html>
		";	
	}
	
	
	// 12: Update Comment
	else if($action == "UpdateComment"){
		echo "<br><br><br><center><img src=\"../images/icons/loading.gif\"><br><br><font size=\"2\" face=\"tahoma\">$lang_admin_updating</font></center>";
					
		$name  = $_POST['name'];
		$day  = $_POST['day'];
		$month  = $_POST['month'];
		$year  = $_POST['year'];
		$content  = $_POST['content'];
		$location  = $_POST['location'];
		$status  = $_POST['g1'];
		$GTP  = $_POST['GTP'];
		$topicID = $_POST['topicID'];
		$fullDate = $day . "-" . $month . "-" . $year;
		
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		$sql="UPDATE eblog_comments SET author='$name' WHERE id = '$id'";
		$result=mysql_query($sql);	
		
		$sql="UPDATE eblog_comments SET date='$fullDate' WHERE id = '$id'";
		$result=mysql_query($sql);	
		
		$sql="UPDATE eblog_comments SET contents='$content' WHERE id = '$id'";
		$result=mysql_query($sql);	
		
		$sql="UPDATE eblog_comments SET location='$location' WHERE id = '$id'";
		$result=mysql_query($sql);
		
		$sql="UPDATE eblog_comments SET statusID='$status' WHERE id = '$id'";
		$result=mysql_query($sql);													
		
		
		mysql_close($conn);
		
		echo "
		<script type=\"text/javascript\">
		
		function delay(link)
		{
		 top.location = link;
		}

		</script>
		";
		
		if($GTP == "topics.php")
		echo "<meta http-equiv=\"Refresh\" content=\"0;url=$GTP?action=ShowComments&id=$topicID\">";
		else
		echo "<body onload=\"delay('$GTP')\"></body>";	
	}
	
	
	// 13: Show all topics in given section
	else if($action == "ShowAll"){
	
	$conn = mysql_connect($dbhost, $dbuser, $dbpass);
	mysql_select_db($dbname);
	
	$spoint = $_GET['spoint'];
	$limit  = $_GET['limit'];
	$sort   = $_GET['sort'];
	
	if(empty($limit))
	{
		$limit = 50;
	}	
	
	if($sort == "oldest")
	$check2 = "selected";
	else
	$check1 = "selected";


	$result = mysql_query("SELECT title FROM eblog_sections WHERE id = '$id'");	
	$row = mysql_fetch_row($result);
	$ThisSecName = $row[0];		
	
	$thisPageNav = "&nbsp;<img src=\"../images/icons/prev_$blog_dir.gif\">&nbsp;<a href=\"topics.php\"><font face=\"tahoma\" style=\"font-size: 10pt;\">$lang_admin_link_4</font></a>&nbsp;<img src=\"../images/icons/prev_$blog_dir.gif\">&nbsp;<font face=\"tahoma\" style=\"font-size: 10pt;\">$ThisSecName</font>";
	
	
	
	$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=\"topics.php?action=add\"   title=\"$lang_admin_addTopic\" rel=\"gb_page_center[640, 500]\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_addTopic</font></a></td>
						 </tr>
						 
						 
						 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
						 <td><a href=\"topics.php#list\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_eBlogLastTopict</font></a></td>
						 </tr>
						 
						 
						 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
						 <td><a href=\"topics.php#sections\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_eBlogDisplayTopicsInSection</font></a></td>
						 </tr>

					 </table>";
					 

// Load the list
$list_name = $lang_admin_listAllTopicsInSection. ": " . $ThisSecName;
$list_content = "
				<script language=\"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 = \"topics.php?action=ShowAll&sort=\" + a1 + \"&limit=\" + a2 + \"&id=\" +$id; 
		}
		
		function goPrev(spoint,limit){
		link = \"topics.php?action=ShowAll&limit=\" + limit + \"&spoint=\" + spoint + \"&id=\" +$id; 
		window.location = link; 
		}
		
		function goPrevII(spoint,limit){
		link = \"topics.php?action=ShowAll&sort=oldest&limit=\" + limit + \"&spoint=\" + spoint + \"&id=\" +$id; 
		window.location = link; 
		}		
		
		function goNext(spoint,limit){
		link = \"topics.php?action=ShowAll&limit=\" + limit + \"&spoint=\" + spoint + \"&id=\" +$id; 
		window.location = link;		
		}
		
		function goNextII(spoint,limit){
		link = \"topics.php?action=ShowAll&sort=oldest&limit=\" + limit + \"&spoint=\" + spoint + \"&id=\" +$id; 
		window.location = link;		
		}	
						
		function rusure(ID2Delete){
			question = confirm(\"$lang_admin_confirmDeleteTopic\")
			if (question !=\"0\"){
				window.location = \"topics.php?action=Remove&GTP=showall&id=\" + ID2Delete;
			}
		}			  
		
		</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>
				
				
				<div>
				<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"3\"  border=\"1\">

<tr bgcolor=\"9b196c\" background=\"../images/icons/disc_bar.gif\">
<td width=\"15\" align=\"center\" background=\"../images/icons/disc_bar.gif\"><font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">$lang_admin_id</font></td>
<td align=\"center\" background=\"../images/icons/disc_bar.gif\"><font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">$lang_admin_name</font></td>
<td width=\"120\" background=\"../images/icons/disc_bar.gif\" align=\"center\"><font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">$lang_admin_date</font></td>
<td width=\"120\" background=\"../images/icons/disc_bar.gif\" align=\"center\"><font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">$lang_admin_viewers</font></td>
<td width=\"50\" background=\"../images/icons/disc_bar.gif\" align=\"center\"><font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">$lang_admin_actions</font></td>
</tr>								
";

			// Get total entries
			$result = mysql_query("SELECT * FROM eblog_topics", $conn);
			$totalEntries = mysql_num_rows($result);
	
			
			// Define start and end points
			if(empty($spoint))
			{
				$spoint = 0;
			}
			$epoint = $spoint + $limit;
			if($epoint > $totalEntries)
			$epoint = $totalEntries;
			
			
			// set order
			if($sort == "oldest")
			{
				$query  = "SELECT * FROM eblog_topics";
			}
			else
			{
				$query  = "SELECT * FROM eblog_topics ORDER BY id DESC";
			}
			
				
			$result = mysql_query($query);		
			$counter = 0;
			$bgColorCounter = 0;
			while($row = mysql_fetch_array($result, MYSQL_ASSOC))
			{	
				if(($counter < $epoint)&&($counter >= $spoint))
				{	
					$rowSec = $row['sec'];
					session_register('temp');
					$_SESSION['temp'] = $rowSec;
					
					$reminder = $bgColorCounter%2;
					if($reminder == 0)
					$bgColor = "#f2f2f2";
					else
					$bgColor = "#dadada";
					
					if($rowSec == $id){
						$rowID = $row['id'];
						$rowTitle = $row['title'];
						$rowDate = $row['date'];
						$chunks = explode("-",$rowDate);
						$toGet = $chunks[1];$rowDate = $chunks[0] . " " . $MonthsArray[$toGet] . " " . $chunks[2];
						$rowViewers = $row['allviewers'];
						
						$list_content = $list_content . "
						<tr bgcolor=\"$bgColor\">
						<td width=\"15\" align=\"center\"><font color=\"#000000\" size=\"2\" face=\"Tahoma\">$rowID</font></td>
						<td><font color=\"#000000\" size=\"2\" face=\"Tahoma\">$rowTitle</font></td>
						<td width=\"120\" align=\"center\"><font color=\"#000000\" size=\"2\" face=\"Tahoma\">$rowDate</font></td>
						<td width=\"120\" align=\"center\"><font color=\"#000000\" size=\"2\" face=\"Tahoma\">$rowViewers</font></td>
						<td width=\"70\" align=\"center\"><font color=\"#000000\" size=\"2\" face=\"Tahoma\"></font>
						<a href=\"topics.php?action=Edit&id=$rowID\" title=\"$rowTitle\" rel=\"gb_page_center[640, 500]\"><img src=\"../images/icons/icon_fix.gif\"  title=\"$lang_admin_edit\" border=\"0\"></a>
	<a href=\"topics.php?action=ShowComments&id=$rowID\"  title=\"$rowTitle\" rel=\"gb_page_center[640, 300]\"><img src=\"../images/icons/icon_comment.gif\" title=\"$lang_admin_showAllComments\" border=\"0\"></a>					
						<a href=\"#\" onClick=\"rusure($rowID); return false;\"><img src=\"../images/icons/icon_remove.gif\"  title=\"$lang_admin_delete\" border=\"0\"></a>
						</td>					
						</tr>					
						";
					$bgColorCounter++;
					}
				}
				$counter++;
			}
			if($bgColorCounter < 1)
			{
			$list_content = $list_content . "<tr bgcolor=\"#f2f2f2\"><td colspan=\"5\"><font face=\"tahoma\" size=\"2\">$lang_admin_noTopics</font></td></tr>";
			}

$list_content = $list_content . "</table></div>";

	// 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($sort=="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>
		";
		}		
	}

	
	
	mysql_close($conn);
	
					 
	
	
		$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;		
	}
												
	
	
	// 14: Force parent window to refresh
	else if($action == "refresh"){
		echo " 
		<script type=\"text/javascript\">
		top.parent.location = \"topics.php\";
		</script>
		";	
	}
	
	
	// 15: No sections found, hide submission form
	else if($action == "stop")
	{
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">";
		echo "<div align=\"center\"><br><br><br><br><br><br><br><br>";
		echo '<font face=Tahoma size=2>'. $lang_admin_stopAddingTopics . '</font>';
		echo "</div></body></html>";	
	}	
	
	// 16: 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\">";
 }
 

 
 // Show the submission form when needed
 if($todo == "printNow")
 {
 	$local_JAVASCRIPT =  "
	<link rel=\"stylesheet\" href=\"js/jquery.wysiwyg.css\" type=\"text/css\" />
	<script type=\"text/javascript\" src=\"js/jquery-1.3.2.js\"></script>
	<script type=\"text/javascript\" src=\"js/jquery.wysiwyg.js\"></script>
	<script type=\"text/javascript\">
	
	if (typeof window.event != 'undefined')
		document.onkeydown = function()
		{
			if (event.srcElement.tagName.toUpperCase() != 'INPUT')
				return (event.keyCode != 8);
		}
	else
		document.onkeypress = function(e)
		{
			if (e.target.nodeName.toUpperCase() != 'INPUT')
				return (e.keyCode != 8);
		}
	
	</script>	
	<script type=\"text/javascript\">
	$(function()
	{
	$('#wysiwyg').wysiwyg();
	});
	</script>	 	
	<script type=\"text/javascript\">	
	
	
	function checkform ( form )
	{
	if (form.title.value == \"\") {
	alert( \"$lang_erorr_noTitle\" );
	form.title.focus();
	return false ;
	}
	if (form.content.value == \"\") {
	alert( \"$lang_erorr_noContent\" );
	form.content.focus();
	return false ;
	}
	if (form.section.value == \"\") {
	alert( \"$lang_erorr_noSection\" );
	form.section.focus();
	return false ;
	}	

	var thumbValue = form.thumb.value;
	var length1 = thumbValue.length;
	var ext1 = thumbValue.substring(length1-4, length1);
	
	if (form.thumb.value != \"\") {
	if((ext1 != \".bmp\")&&(ext1 != \".jpg\")&&(ext1 != \".gif\")&&(ext1 != \".png\")&&
	(ext1 != \".BMP\")&&(ext1 != \".JPG\")&&(ext1 != \".GIF\")&&(ext1 != \".PNG\")&&
	(ext1 != \"jpeg\")&&(ext1 != \"JPEG\")){
	alert(\"$lang_erorr_notAllowedType1\");
	return false ;
	}
	}
	
	var innerValue = form.inner.value;
	var length2 = innerValue.length;
	var ext2 = innerValue.substring(length2-4, length2);
	
	if (form.inner.value != \"\") {
	if((ext2 != \".bmp\")&&(ext2 != \".jpg\")&&(ext2 != \".gif\")&&(ext2 != \".png\")&&
	(ext2 != \".BMP\")&&(ext2 != \".JPG\")&&(ext2 != \".GIF\")&&(ext2 != \".PNG\")&&
	(ext2 != \"jpeg\")&&(ext2 != \"JPEG\")){
	alert(\"$lang_erorr_notAllowedType2\");
	return false ;
	}
	}
	

	return true ;
	}
	
	function confirmDeleteComment() { 
	if (confirm(\"$lang_admin_confirmDeleteComment\")) {
	return true; 
	} else {
	return false;
	} 
	} 

		
	function confirmDeleteTopic(data) { 
	if (confirm(\"$lang_admin_confirmDeleteTopic\")) {
	var toLink = \"advance.php?action=DeleteTopic&ID=\" + data;
	window.location = toLink;
	return true;
	} else {
	return false;
	} 
	} 

		
	function changeto(highlightcolor){
	source=event.srcElement
	if (source.tagName==\"TR\"||source.tagName==\"TABLE\")
	return
	while(source.tagName!=\"TR\")
	source=source.parentElement
	if (source.style.backgroundColor!=highlightcolor&&source.id!=\"ignore\")
	source.style.backgroundColor=highlightcolor
	}
		
	function changeback(originalcolor){
	if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id==\"ignore\")
	return
	if (event.toElement!=source)
	source.style.background=originalcolor
	}
	

	</script>
	";
	
	
	$thisForm =  "
		<html dir=\"$blog_dir\">
		<head>
		<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">		
		$local_JAVASCRIPT
		</head>
		<body onload=\"thisForm=document.frmKey;\">
		<form action=\"$FORM_DATA_PROCESSPAGE\" method=\"post\" enctype=\"multipart/form-data\" onsubmit=\"return checkform(this);\" id=\"frmTest\" name=\"frmKey\">
		<br>			
		<div align=\"center\">
		<table  border=1 width=\"100%\" bordercolor=\"#000000\" style=\"border-collapse: collapse\" cellspacing=\"0\" cellpadding=\"7\">
		
		<tr bgcolor=#f2f2f2>
		<td  valign=\"top\"><font face=\"Tahoma\" size=\"2\">$lang_admin_topicTitle:</font></td>
		<td  valign=\"top\">
		<input type=\"text\" name=\"title\" value=\"$rowTitle\" style=\"font-family: Tahoma; width:100%; font-size: 12px; color: #000000; border: 1px solid #000000;\"><br></td>
		</tr>
		
		
		<tr bgcolor=#dadada>
		<td  valign=\"top\"><font face=\"Tahoma\" size=\"2\">$lang_admin_topicThumb:</font></td>
		<td  valign=\"top\">
		<input type=\"file\"  name=\"thumb\" size=\"18\" value=\"d\">
		</td>
		</tr>
		
		
		<tr bgcolor=#f2f2f2>
		<td  valign=\"top\"><font face=\"Tahoma\" size=\"2\">$lang_admin_topicInnerPicture:</font></td>
		<td  valign=\"top\">
		<input type=\"file\"  name=\"inner\" size=\"18\">
		</td>
		</tr>
		
		<tr bgcolor=#dadada>
		<td  valign=\"top\" dir=\"$blog_dir\"><font face=\"Tahoma\" size=\"2\">$lang_admin_topicSection:</font></td>
		<td  valign=\"top\">
		<select name=\"section\" style=\"width: 180;  height:21\">
		$sectionsMenu
		</select>
		<br>
		</td>
		</tr>
		
		
		</table>
		
		</div>
		
		<br>
		<div align=\"center\">
		<table border=1 bordercolor=black bgcolor=#f2f2f2 cellpadding=\"4\" style=\"margin-left: auto; margin-right: auto; BORDER-COLLAPSE: collapse;\" width=\"100%\"><tr><td>
			
				
		<table dir=\"$blog_dir\" border=0 width=\"100%\" style=\"margin-left: auto; margin-right: auto;\">
		<tr>
		<td width=\"85%\" valign=\"top\">
		<center><textarea name=\"content\"  id=\"wysiwyg\" style=\"font-family: Tahoma; font-size: 12px; outline:none; width:550px; height:180px; color: #000000; border: 1px solid #000000; resize: none;\">$rowContent</textarea></center></td>
		</tr>
		</table>
		</td></tr></table>
		
		<div align=\"center\">
		<br>
		<input type=\"submit\" name=\"submit\" value=\"$FORM_DATA_BUTTON\">
		</div>
		</form>
		</body>
		</html>
		";

	
	echo $thisForm;
 } 
			
?>
Return current item: eBlog