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

/**************************************************************************
 *                                                                        *
 *                                                                        *
 *         Solution: eBlog                                                *
 *          Release: 1.7                                                  *
 *             File: admin/settings.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'];

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

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

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

	$conn = mysql_connect($dbhost, $dbuser, $dbpass);
	mysql_select_db($dbname);
		
		// 1: Show Settings
		if($action == "form"){
		
	// construct page map
	$thisPageNav = "&nbsp;<img src=\"../images/icons/prev_$blog_dir.gif\">&nbsp;<a href=\"settings.php\"><font face=\"tahoma\" style=\"font-size: 10pt;\">$lang_admin_link_2</font></a>";
	
	
	// construct quick links menu
	$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=\"#general\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_settingsCat1</font></a></td>
	 </tr>
	  
	 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
	 <td><a href=\"#admin\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_settingsCat2</font></a></td>
	 </tr>
	  
	 
	 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
	 <td><a href=\"#social\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_settingsCat3</font></a></td>
	 </tr>
	  
	 
	 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
	 <td><a href=\"#thumbs\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_settingsCat4</font></a></td>
	 </tr>	
	  
	 
	 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
	 <td><a href=\"#display\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_settingsCat5</font></a></td>
	 </tr>	
	 
	  
	 <tr><td valign =\"top\" width=\"22\"><img src=\"../images/icons/icon_bullet.gif\"></td>
	 <td><a href=\"#security\"><font style=\"font-size: 0.7em;\" face=\"Tahoma\">$lang_admin_settingsCat6</font></a></td>
	 </tr>						 					 				 					 					 
	 
	 
	 </table>";	
	 
	 
	// load social links
	$settings_socialLinks = "";
		$query  = "SELECT * FROM eblog_social ORDER BY id ASC";
		$result = mysql_query($query);
		$totalSocial = 0;
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			$totalSocial++;
			
			$reminder = $totalSocial%2;
			if($reminder == 0)
			$bgColor = "#f2f2f2";
			else
			$bgColor = "#dadada";
			
			$social_id = $row['id'];
			$social_name = $row['name'];
			$social_link = $row['link'];
			$social_image = "../".$row['image'];
			$settings_socialLinks = $settings_socialLinks . "<tr bgcolor=\"$bgColor\"><td><font face=\"tahoma\" size=\"2\">$social_name:</font></td><td><table width=\"100%\" border=\"0\"><tr><td><img title=\"$social_name\" src=\"$social_image\"></td><td><input type=\"text\" name=\"social_$totalSocial\" size=\"50\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$social_link\" disabled></td><td><a title=\"$social_name\" rel=\"gb_page_center[640, 220]\" href=\"settings.php?action=EditSocial&id=$social_id\"><img title=\"$lang_admin_edit\" border=\"0\" src=\"../images/icons/icon_fix.gif\"></a></td><td><a href=\"settings.php?action=RemoveSocial&id=$social_id\"><img title=\"$lang_admin_delete\" border=\"0\" src=\"../images/icons/icon_remove.gif\"></a></td></tr></table></td></tr>";
		}
	
			if($bgColor == "#dadada")
			$bgColor = "#f2f2f2";
			else
			$bgColor = "#dadada";
	
	
	// Load language
	$settings_lang = "<select name=\"lang\" style=\"width: 180;  height:21\">";
	$path = "./../lang";
	$newLang = $lang.".php";
	$dir_handle = @opendir($path);
	while (false !== ($file = readdir($dir_handle))) {
		$last = substr($file,strlen($file)-4,strlen($file));
		$toShow = substr($file,0,strlen($file)-4);
		if($last == ".php"){
		if($file == $newLang){
		$settings_lang = $settings_lang . "<option value=\"$toShow\" SELECTED>$toShow</option>";
		}
		else{
		$settings_lang = $settings_lang . "<option value=\"$toShow\">$toShow</option>";
		}
		}
	}
	$settings_lang = $settings_lang . "</select>";
	
	
	
	
	
	
	// Load templates
	$settings_template = "<select name=\"template\" style=\"width: 180;  height:21\">";
	$path = "./../templates";
	$dir_handle = @opendir($path);
	while (false !== ($file = readdir($dir_handle))) {
	
		if(($file!= ".")&&($file!= "..")){
			
			$fullTestPath = "./../templates/$file/layout.html";
			if(file_exists($fullTestPath)){
				if($file == $template){
				$settings_template = $settings_template . "<option value=\"$file\" SELECTED>$file</option>";
				}
				else{
				$settings_template = $settings_template . "<option value=\"$file\">$file</option>";
				}
			}
		}
	}
	$settings_template = $settings_template . "</select>";
	
	
	
	
	
	
	// Load Pop-Up Status 
	$settings_popup = "<select name=\"popup\" style=\"width: 180;  height:21\">";
	
	$counter = 1;
	$options = array(1 => $lang_admin_settings_popup_option1, 2 => $lang_admin_settings_popup_option2, 3 => $lang_admin_settings_popup_option3, 4 => $lang_admin_none);
	
	while($counter <5){
		
		$currentSelection = $options[$counter];
		
		if($counter == $popup)
		{
		$settings_popup = $settings_popup . "<option value=\"$counter\" SELECTED>$currentSelection</option>";
		}
		else
		{
		$settings_popup = $settings_popup . "<option value=\"$counter\">$currentSelection</option>";
		}	
		$counter++;
	}
	$settings_popup = $settings_popup . "</select>";
	
	
	// Load countries
	$settings_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 == $location)
		{
		$settings_location = $settings_location . "<option value=\"$ThisRowID\" SELECTED>$ThisRowName</option>";
		}
		else
		{
		$settings_location = $settings_location . "<option value=\"$ThisRowID\">$ThisRowName</option>";
		}	
	}
	$settings_location = $settings_location . "</select>";
	
	
	
	
	// Load sort options
	$settings_sortBy = "<select name=\"sortBy\" style=\"width: 180;  height:21\">";
	
	$counter = 1;
	$options2 = array(1 => $lang_admin_settings_sortBy_option1, 2 => $lang_admin_settings_sortBy_option2, 3 => $lang_admin_settings_sortBy_option3);
	
	while($counter <4){
		
		$currentSelection = $options2[$counter];
		
		if($counter == $sort_by)
		{
		$settings_sortBy = $settings_sortBy . "<option value=\"$counter\" SELECTED>$currentSelection</option>";
		}
		else
		{
		$settings_sortBy = $settings_sortBy . "<option value=\"$counter\">$currentSelection</option>";
		}	
		$counter++;
	}
	$settings_sortBy = $settings_sortBy . "</select>";
	
	
	
	$settings_sortOrder = "<select name=\"sortOrder\" style=\"width: 180;  height:21\">";
	
	$counter = 1;
	$options3 = array(1 => $lang_admin_settings_sortOrder_option1, 2 => $lang_admin_settings_sortOrder_option2);
	
	while($counter <3){
		
		$currentSelection = $options3[$counter];
		
		if($counter == $sort_order)
		{
		$settings_sortOrder = $settings_sortOrder . "<option value=\"$counter\" SELECTED>$currentSelection</option>";
		}
		else
		{
		$settings_sortOrder = $settings_sortOrder . "<option value=\"$counter\">$currentSelection</option>";
		}	
		$counter++;
	}
	$settings_sortOrder = $settings_sortOrder . "</select>";
	
	
	
	// set conditions for radio buttons
	if($enable1==1)
	$radio_condition_2_1 = "checked";
	else
	$radio_condition_2_2 = "checked";
	
	if($enable2==1)
	$radio_condition_3_1 = "checked";
	else
	$radio_condition_3_2 = "checked";
	
	
	if($enable3==1)
	$radio_condition_4_1 = "checked";
	else
	$radio_condition_4_2 = "checked";
	
	if($enable4==1)
	$radio_condition_5_1 = "checked";
	else
	$radio_condition_5_2 = "checked";
	
	
	if(($enable1==0)&&($enable2==0)&&($enable3==0)&&($enable4==0))
	{
	$radio_condition_1_2 = "checked";
	$radio_condition_2_1 = "disabled";
	$radio_condition_2_2 = "disabled";
	$radio_condition_3_1 = "disabled";
	$radio_condition_3_2 = "disabled";
	$radio_condition_4_1 = "disabled";
	$radio_condition_4_2 = "disabled";
	$radio_condition_5_1 = "disabled";
	$radio_condition_5_2 = "disabled";
	}
	else
	$radio_condition_1_1 = "checked";
	
	
	if($enableThumb==1)
	$radio_condition_6_1 = "checked";
	else
	$radio_condition_6_2 = "checked";
	
	
	if($allowComments==1)
	$radio_condition_7_1 = "checked";
	else
	$radio_condition_7_2 = "checked";
	
	if($autoValidate==1)
	$radio_condition_8_1 = "checked";
	else
	$radio_condition_8_2 = "checked";
	
	// Construct the form					 
	$settings_form= "
					<div>
					<form method=\"post\" action=\"settings.php?action=save\" name=\"FullForm\">
					<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"  border=\"1\">
					
					
					<tr bgcolor=\"9b196c\" background=\"../images/icons/disc_bar.gif\">
					<td colspan = \"2\" background=\"../images/icons/disc_bar.gif\">
					<font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">
					<a name=\"general\">$lang_admin_settingsCat1<a>
					</font>
					</td>
					</tr>
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_blogName:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"name\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000; width:100%;\" value=\"$blog_name\">
					</td>				
					</tr>
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_blogURL:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"url\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000; width:100%;\" value=\"$site_url\">
					</td>				
					</tr>
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_lang:
					</font>
					</td>
					<td>
					$settings_lang
					</td>				
					</tr>
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_location:
					</font>
					</td>
					<td>
					$settings_location
					</td>				
					</tr>				
					
					
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_template:
					</font>
					</td>
					<td>
					$settings_template
					</td>				
					</tr>
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_popup:
					</font>
					</td>
					<td>
					$settings_popup
					</td>				
					</tr>
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_meta:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"meta\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; width:100%; border: 1px solid #000000;\" value=\"$meta\">
					</td>				
					</tr>
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_css:
					</font>
					</td>
					<td>
					<textarea name=\"css\" rows=\"5\" MAXLENGTH=\"10000\" style=\"font-family: Tahoma; font-size: 12px; color: #000000;  width:420px; border: 1px solid #000000; resize: none;\">$css</textarea>
					</td>				
					</tr>
					
																
					
					
					
					
					
					
					
					
					
					<tr bgcolor=\"9b196c\" background=\"../images/icons/disc_bar.gif\">
					<td colspan = \"2\" background=\"../images/icons/disc_bar.gif\">
					<font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">
					<a name=\"admin\">$lang_admin_settingsCat2</a>
					</font>
					</td>
					</tr>
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_username:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"username\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; width:100%; border: 1px solid #000000;\" value=\"$DBusername\" MAXLENGTH=\"20\">
					</td>				
					</tr>
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_password:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"password\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; width:100%; border: 1px solid #000000;\" MAXLENGTH=\"20\" value=\"\"><br><font size=\"2\" face=\"tahoma\">$lang_admin_changePasswordInstructions</font>
					</td>				
					</tr>		
					
	
	
	
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_email:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"email\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; width:100%; border: 1px solid #000000;\" value=\"$admin_email\" MAXLENGTH=\"100\">
					</td>				
					</tr>
					
					<SCRIPT LANGUAGE=\"JavaScript\">
					function Disable() {
					FullForm.g1[0].disabled=true;
					FullForm.g1[1].disabled=true;
					FullForm.g2[0].disabled=true;
					FullForm.g2[1].disabled=true;
					FullForm.g3[0].disabled=true;
					FullForm.g3[1].disabled=true;
					FullForm.g4[0].disabled=true;
					FullForm.g4[1].disabled=true;												
					}
					function Enable(){
					FullForm.g1[0].disabled=false;
					FullForm.g1[1].disabled=false;
					FullForm.g2[0].disabled=false;
					FullForm.g2[1].disabled=false;
					FullForm.g3[0].disabled=false;
					FullForm.g3[1].disabled=false;
					FullForm.g4[0].disabled=false;
					FullForm.g4[1].disabled=false;												
					}
					</SCRIPT>
	
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_emailWhen1:
					</font>
					</td>
					<td>
					<input type=\"radio\" name=\"allow\" value=\"0\" onClick=\"Enable()\" $radio_condition_1_1><font size=\"2\" face=\"tahoma\">$lang_admin_yes</font>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type=\"radio\" name=\"allow\" value=\"1\" onClick=\"Disable()\" $radio_condition_1_2><font size=\"2\" face=\"tahoma\">$lang_admin_no</font>
					</td>				
					</tr>		
					
					
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_emailWhen2:
					</font>
					</td>
					<td>
					<input type=\"radio\" name=\"g1\" value=\"1\" $radio_condition_2_1><font size=\"2\" face=\"tahoma\">$lang_admin_yes</font>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type=\"radio\" name=\"g1\" value=\"0\" $radio_condition_2_2><font size=\"2\" face=\"tahoma\">$lang_admin_no</font>
					</td>				
					</tr>
					
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_emailWhen3:
					</font>
					</td>
					<td>
					<input type=\"radio\" name=\"g2\" value=\"1\" $radio_condition_3_1><font size=\"2\" face=\"tahoma\">$lang_admin_yes</font>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type=\"radio\" name=\"g2\" value=\"0\" $radio_condition_3_2><font size=\"2\" face=\"tahoma\">$lang_admin_no</font>
					</td>				
					</tr>
					
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_emailWhen4:
					</font>
					</td>
					<td>
					<input type=\"radio\" name=\"g3\" value=\"1\" $radio_condition_4_1><font size=\"2\" face=\"tahoma\">$lang_admin_yes</font>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type=\"radio\" name=\"g3\" value=\"0\" $radio_condition_4_2><font size=\"2\" face=\"tahoma\">$lang_admin_no</font>
					</td>				
					</tr>
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_emailWhen5:
					</font>
					</td>
					<td>
					<input type=\"radio\" name=\"g4\" value=\"1\" $radio_condition_5_1><font size=\"2\" face=\"tahoma\">$lang_admin_yes</font>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type=\"radio\" name=\"g4\" value=\"0\" $radio_condition_5_2><font size=\"2\" face=\"tahoma\">$lang_admin_no</font>
					</td>				
					</tr>												
													
					
					
					
					
					
	
	
	
	
	
					<tr bgcolor=\"9b196c\" background=\"../images/icons/disc_bar.gif\">
					<td colspan = \"2\" background=\"../images/icons/disc_bar.gif\">
					<font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">
					<a name=\"social\">$lang_admin_settingsCat3</a>
					</font>
					</td>
					</tr>
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"Tahoma\">
					$lang_admin_settings_addSocial:
					</font>
					</td>
					<td>
					<font size=\"2\" face=\"Tahoma\">
					<a href=\"settings.php?action=AddSocial\" title=\"$lang_admin_settings_addSocial\" rel=\"gb_page_center[640, 220]\">$lang_admin_settings_clickToAddSocial</a>
					</font>
					</td>				
					</tr>				
					
					$settings_socialLinks
					
	
					
					
					<tr bgcolor=\"$bgColor\">
					<td width=\"150\">
					<font size=\"2\" face=\"Tahoma\">
					$lang_admin_settings_myFriendsList:
					</font>
					</td>
					<td>
					<font size=\"2\" face=\"Tahoma\">
					<a href=\"settings.php?action=Friends\" title=\"$lang_admin_settings_myFriendsList\" rel=\"gb_page_center[640, 500]\">$lang_admin_settings_manageFriends</a>
					</font>
					</td>				
					</tr>				
					
					
					
					
					
					
					<tr bgcolor=\"9b196c\" background=\"../images/icons/disc_bar.gif\">
					<td colspan = \"2\" background=\"../images/icons/disc_bar.gif\">
					<font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">
					<a name=\"thumbs\">$lang_admin_settingsCat4</a>
					</font>
					</td>
					</tr>
									
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_useThumbs:
					</font>
					</td>
					<td>
					<input type=\"radio\" name=\"g6\" value=\"1\" $radio_condition_6_1><font size=\"2\" face=\"tahoma\">$lang_admin_yes</font>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type=\"radio\" name=\"g6\" value=\"0\" $radio_condition_6_2><font size=\"2\" face=\"tahoma\">$lang_admin_no</font>
					</td>				
					</tr>
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_thumbWidth:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"width\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$thumb_width\" MAXLENGTH=\"3\"><font size=\"2\" face=\"tahoma\">&nbsp;$lang_admin_pixels</font>
					</td>				
					</tr>
					
					
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_thumbHeight:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"height\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$thumb_height\" MAXLENGTH=\"3\"><font size=\"2\" face=\"tahoma\">&nbsp;$lang_admin_pixels</font>
					</td>				
					</tr>
					
					
					
																				
									
					
					
					
					
					
					
					
					
					
					
					
					<tr bgcolor=\"9b196c\" background=\"../images/icons/disc_bar.gif\" background=\"../images/icons/disc_bar.gif\">
					<td colspan = \"2\" background=\"../images/icons/disc_bar.gif\">
					<font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">
					<a name=\"display\">$lang_admin_settingsCat5</a>
					</font>
					</td>
					</tr>
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_wrappedWords:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"wrap\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$wrap\"><font size=\"2\" face=\"tahoma\">&nbsp;$lang_admin_lpl</font>
					</td>				
					</tr>				
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_WindowWidth:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"ww\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$ww\" MAXLENGTH=\"3\"><font size=\"2\" face=\"tahoma\">&nbsp;$lang_admin_pixels</font>
					</td>				
					</tr>
					
					
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_WindowHeight:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"wh\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$wh\" MAXLENGTH=\"3\"><font size=\"2\" face=\"tahoma\">&nbsp;$lang_admin_pixels</font>
					</td>				
					</tr>
									
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_cellPerRowII:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"topicPR\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$topicPR\" MAXLENGTH=\"2\"><font size=\"2\" face=\"tahoma\"></font>
					</td>				
					</tr>					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_cellPerRowI:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"cellPR\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$cellPR\" MAXLENGTH=\"2\"><font size=\"2\" face=\"tahoma\"></font>
					</td>				
					</tr>				
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_topicsPerPage:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"topicsPP\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$topicsPP\" MAXLENGTH=\"2\"><font size=\"2\" face=\"tahoma\"></font>
					</td>				
					</tr>
					
					
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_monthsPerList:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"monthsPL\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$monthsPL\" MAXLENGTH=\"2\"><font size=\"2\" face=\"tahoma\"></font>
					</td>				
					</tr>	
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_gpp:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"gpp\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$GPP\" MAXLENGTH=\"2\"><font size=\"2\" face=\"tahoma\"></font>
					</td>				
					</tr>	
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_bw:
					</font>
					</td>
					<td>
	<input type=\"text\" name=\"bw\" size=\"5\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$bw\" MAXLENGTH=\"3\"><font size=\"2\" face=\"tahoma\">&nbsp;$lang_admin_pixels</font>
					</td>				
					</tr>									
					
								
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_sortBy:
					</font>
					</td>
					<td>
	$settings_sortBy
					</td>				
					</tr>
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_sortOrder:
					</font>
					</td>
					<td>
	$settings_sortOrder
					</td>				
					</tr>	
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_allowComments:
					</font>
					</td>
					<td>
					<input type=\"radio\" name=\"g7\" value=\"1\" $radio_condition_7_1><font size=\"2\" face=\"tahoma\">$lang_admin_yes</font>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type=\"radio\" name=\"g7\" value=\"0\" $radio_condition_7_2><font size=\"2\" face=\"tahoma\">$lang_admin_no</font>
					</td>				
					</tr>
					
					
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_autoValidateComments:
					</font>
					</td>
					<td>
					<input type=\"radio\" name=\"g8\" value=\"1\" $radio_condition_8_1><font size=\"2\" face=\"tahoma\">$lang_admin_yes</font>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type=\"radio\" name=\"g8\" value=\"0\" $radio_condition_8_2><font size=\"2\" face=\"tahoma\">$lang_admin_no</font>
					</td>				
					</tr>
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_badWords:
					</font>
					</td>
					<td>
					<textarea name=\"badwords\" rows=\"5\" MAXLENGTH=\"10000\" style=\"font-family: Tahoma; font-size: 12px; color: #000000;  width:420px; border: 1px solid #000000; resize: none;\">$badWords</textarea>
					<br>
					<font size=\"2\" face=\"tahoma\">
					$lang_admin_settings_badWordsInstructions
					</font>
					</td>				
					</tr>
					
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_replaceBadWords:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"replace\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; width:100%; border: 1px solid #000000;\" value=\"$replaceWords\" MAXLENGTH=\"10\">
					</td>				
					</tr>
					
					
					
					
					
					
					
					
					
					<tr bgcolor=\"9b196c\" background=\"../images/icons/disc_bar.gif\" background=\"../images/icons/disc_bar.gif\">
					<td colspan = \"2\" background=\"../images/icons/disc_bar.gif\">
					<font color=\"#ffffff\" size=\"2\" face=\"Tahoma\">
					<a name=\"security\">$lang_admin_settingsCat6</a>
					</font>
					</td>
					</tr>
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_loginAttempts:
					</font>
					</td>
					<td>
					<input type=\"text\" name=\"attempts\" size=\"8\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" MAXLENGTH=\"5\" value=\"$limit\"><font size=\"2\" face=\"Tahoma\">&nbsp;$lang_admin_settings_attemptsPerUser</font>
					</td>				
					</tr>
					
					
					<tr bgcolor=\"dadada\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_showBlacklist:
					</font>
					</td>
					<td>
					<a href=\"settings.php?action=ShowBlacklist\"  title=\"$lang_admin_settings_showBlacklist\" rel=\"gb_page_center[640, 300]\">
					<font size=\"2\" face=\"Tahoma\">
					$lang_admin_settings_clickToShowBL
					</font>
					</a>
					</td>				
					</tr>					
					
					
					<tr bgcolor=\"f2f2f2\">
					<td width=\"150\">
					<font size=\"2\" face=\"tahoma\">
						$lang_admin_settings_clearBlacklist:
					</font>
					</td>
					<td>
					<a href=\"settings.php?action=ClearBlacklist\"  title=\"$lang_admin_settings_clearBlacklist\" rel=\"gb_page_center[640, 300]\">
					<font size=\"2\" face=\"Tahoma\">
					$lang_admin_settings_clickToClearBL
					</font>
					</a>
					</td>				
					</tr>				
					
					
					
					
					
					
								
					
					</table>
					<br>
					<center><input type=\"submit\" value=\"$lang_admin_saveSettings\"></center>
					</form>
					</div>
	";
	
	 
		
		$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_eBlogSettings, $settings_form	
		
		);
		$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_eBlogSettings}", "{settings_form}"			
		
		);	
		
		$header = $new_template->load_template ("../templates/$defaultTemplate/admin/header.html");
		$home = $new_template->load_template ("../templates/$defaultTemplate/admin/settings.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: Save Settings
		else if($action == "save"){
		
			// Get data from form
			$site_name		    = $_POST['name'];	
			$site_url			= $_POST['url'];
			$admin_username		= $_POST['username'];
			$admin_password		= $_POST["password"];
			$admin_email		= $_POST['email'];
			$meta_tag 			= htmlspecialchars($_POST['meta']);	
			$css				= $_POST['css'];
			$bad_words			= htmlspecialchars($_POST['badwords']);
			$replace_words	    = $_POST['replace'];
			$allow_comments		= $_POST['g7'];
			$login_attempts		= $_POST['attempts'];
			$lang				= $_POST['lang'];
			$location           = $_POST['location'];
			$template			= $_POST['template'];
			$popup				= $_POST['popup'];
			$enable1			= $_POST['g1'];
			$enable2  	 	    = $_POST['g2'];	
			$enable3			= $_POST['g3'];
			$enable4			= $_POST['g4'];
			$enableThumb		= $_POST['g6'];
			$thumb_width		= $_POST['width'];
			$thumb_height		= $_POST['height'];
			$sort_by			= $_POST['sortBy'];
			$sort_order			= $_POST['sortOrder'];
			$auto_validate	    = $_POST['g8'];
			$topicsPP    	    = $_POST['topicsPP'];
			$monthsPL   	    = $_POST['monthsPL'];
			$cellPR				= $_POST['cellPR'];
			$topicPR			= $_POST['topicPR'];
			$ww                 = $_POST['ww'];
			$wh                 = $_POST['wh'];
			$bw                 = $_POST['bw'];
			$gpp                = $_POST['gpp'];
			$wrap               = $_POST['wrap'];
				
				
			// Check for invalid data
			$erorr = 0;
			$erorrMesage = "";
			
			if(empty($site_name))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code202 . "<br>";
				$erorr++;
			}
			
			else if(empty($site_url))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code303 . "<br>";
				$erorr++;
			}
			
			else if(empty($admin_username))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code404 . "<br>";
				$erorr++;
			}
			
			else if(empty($admin_email))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code606 . "<br>";
				$erorr++;
			}
			
			else if(empty($login_attempts))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code111 . "<br>";
				$erorr++;
			}	
			else if (!is_numeric ($topicsPP))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code140 . "<br>";
				$erorr++;
			}
			else if (!is_numeric ($monthsPL))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code141 . "<br>";
				$erorr++;
			}	
			else if (!is_numeric ($cellPR))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code142 . "<br>";
				$erorr++;
			}
			else if (!is_numeric ($topicPR))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code143 . "<br>";
				$erorr++;
			}	
			else if (!is_numeric ($gpp))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code152 . "<br>";
				$erorr++;
			}
			else if (!is_numeric ($wrap))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code157 . "<br>";
				$erorr++;
			}			
			
			else if (!is_numeric ($bw))
			{
				$erorrMesage = $erorrMesage . $lang_erorr_code153 . "<br>";
				$erorr++;
			}																							
			else if ($admin_email != "" && !preg_match("/([\w\.\-]+)(\@[\w\.\-]+)(\.[a-z]{2,4})+/i", $admin_email)) {
				$erorrMesage = $erorrMesage . $lang_erorr_code707 . "<br>";
				$erorr++;
			}
			else if (!is_numeric ($login_attempts)){
				$erorrMesage = $erorrMesage . $lang_erorr_code112 . "<br>";
				$erorr++;
			} 
			else if (!is_numeric ($ww)){
				$erorrMesage = $erorrMesage . $lang_erorr_code144 . "<br>";
				$erorr++;
			} 
			else if (!is_numeric ($wh)){
				$erorrMesage = $erorrMesage . $lang_erorr_code145 . "<br>";
				$erorr++;
			} 
			else if (!is_numeric ($thumb_width)){
				$erorrMesage = $erorrMesage . $lang_erorr_code147 . "<br>";
				$erorr++;
			} 
			else if (!is_numeric ($thumb_height)){
				$erorrMesage = $erorrMesage . $lang_erorr_code148 . "<br>";
				$erorr++;
			} 								
			else{}	
			
			
			
			if($erorr > 0)
			{
				$static_value = array ($blog_dir, $blog_windows_encoding, $lang_admin_adminPanel, $lang_erorr_code113, $erorrMesage,$lang_erorr_goBack2);
				$static_name = array ("{blog_dir}","{blog_windows_encoding}", "{lang_admin_adminPanel}", "{lang_blog_systemMessage}", "{erorrMessageToShow}", "{lang_admin_tryAgain}");
				$file = $new_template->load_template ("../templates/$defaultTemplate/admin/error.html");		
				$template = $new_template->replace_static($static_name, $static_value, $file);	
				echo $template;
			}
			else
			{
				$sql="UPDATE eblog_settings SET site_name='$site_name' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET site_url='$site_url' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET admin_username='$admin_username' WHERE id = '1'";
				$result=mysql_query($sql);
				
				if(!empty($admin_password)){
				$admin_password = md5($_POST["password"]);
				$sql="UPDATE eblog_settings SET admin_password='$admin_password' WHERE id = '1'";
				$result=mysql_query($sql);
				}
				
				$sql="UPDATE eblog_settings SET admin_email='$admin_email' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET meta_tag='$meta_tag' WHERE id = '1'";
				$result=mysql_query($sql);	
				
				$sql="UPDATE eblog_settings SET css='$css' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET bad_words='$bad_words' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET replace_words='$replace_words' WHERE id = '1'";
				$result=mysql_query($sql);
				
				
				$sql="UPDATE eblog_settings SET wrap='$wrap' WHERE id = '1'";
				$result=mysql_query($sql);
				
						
				$sql="UPDATE eblog_settings SET allow_comments='$allow_comments' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET login_attempts='$login_attempts' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET lang='$lang' WHERE id = '1'";
				$result=mysql_query($sql);	
				
				
				$sql="UPDATE eblog_settings SET location='$location' WHERE id = '1'";
				$result=mysql_query($sql);			
				
				
				$sql="UPDATE eblog_settings SET template='$template' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET popup='$popup' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET enable1='$enable1' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET enable2='$enable2' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET enable3='$enable3' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET enable4='$enable4' WHERE id = '1'";
				$result=mysql_query($sql);	
				
																	
				$sql="UPDATE eblog_settings SET enableThumb='$enableThumb' WHERE id = '1'";
				$result=mysql_query($sql);
			
				$sql="UPDATE eblog_settings SET thumb_width='$thumb_width' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET thumb_height='$thumb_height' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET ww='$ww' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET wh='$wh' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET gpp='$gpp' WHERE id = '1'";
				$result=mysql_query($sql);		
				
				$sql="UPDATE eblog_settings SET bw='$bw' WHERE id = '1'";
				$result=mysql_query($sql);		
				
				$sql="UPDATE eblog_settings SET topicsPP='$topicsPP' WHERE id = '1'";
				$result=mysql_query($sql);					
				
				$sql="UPDATE eblog_settings SET monthsPL='$monthsPL' WHERE id = '1'";
				$result=mysql_query($sql);	
				
				$sql="UPDATE eblog_settings SET cellPR='$cellPR' WHERE id = '1'";
				$result=mysql_query($sql);	
				
				$sql="UPDATE eblog_settings SET topicPR='$topicPR' WHERE id = '1'";
				$result=mysql_query($sql);								
				
				$sql="UPDATE eblog_settings SET sort_by='$sort_by' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET sort_order='$sort_order' WHERE id = '1'";
				$result=mysql_query($sql);
				
				$sql="UPDATE eblog_settings SET auto_validate='$auto_validate' WHERE id = '1'";
				$result=mysql_query($sql);	
				
				echo "<meta http-equiv=\"refresh\" content=\"0;url=settings.php\">";			
			}			
				
		}
		
		
		
		
		// 3: Add Social
		else if ($action=="AddSocial"){
			echo "
			<html dir=\"$blog_dir\">
			<head>
			<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">
			<script language=\"javascript\">
			function updateImage () {
				var menu = document.getElementById(\"variety\");
				var cookieImage = document.getElementById(\"cookieImage\");
				cookieImage.src = '../images/social/'+ menu.options[menu.options.selectedIndex].value;
				}
				
		  function checkForm(form){
		  
		  if(form.name.value == \"\"){
		  alert( \"$lang_erorr_code114\" );
		  form.name.focus();
		  return false;
		  }
		  
		  if(form.link.value == \"\"){
		  alert( \"$lang_erorr_code115\" );
		  form.link.focus();
		  return false;
		  }
		  
		  return true;
		  }
			
			</script>
			</head>
			
			<body onload=\"updateImage();\">
			<br>
			<form method=\"post\" action=\"settings.php?action=InsertSocial\"  onsubmit=\"return checkForm(this);\">
			<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"  border=\"1\">
			
			<tr bgcolor=\"#f2f2f2\"><td><font face=\"tahoma\" size=\"2\">$lang_admin_socialName:</font></td><td><input type=\"text\" name=\"name\" size=\"55\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000; background-color: #ffffff\"></td></tr>
			
			
			<tr bgcolor=\"#dadada\"><td><font face=\"tahoma\" size=\"2\">$lang_admin_socialLink:</font></td><td><input type=\"text\" name=\"link\" size=\"55\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000; background-color: #ffffff\"><br><font size=\"2\" face=\"tahoma\">$lang_admin_example: http://www.twitter.com/example</font></td></tr>
			
			
			
			<tr bgcolor=\"#f2f2f2\"><td><font face=\"tahoma\" size=\"2\">$lang_admin_socialImage:</font></td><td>
			<table width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"><tr><td>
			<select id=\"variety\" name=\"variety\" onchange=\"updateImage();\">";
			
			
			$path = "./../images/social";
			$dir_handle = @opendir($path);
			$counter = 0;
			while (false !== ($file = readdir($dir_handle))) {
				$counter++;
				$basename = explode(".", $file);
				$filename = $basename[0];
				$last = substr($file,strlen($file)-4,strlen($file));
				if($last == ".png"){
				echo "<option value=\"$file\">$filename</option>";
				}
			}


			
			echo "</select>	
			</td><td width=\"100%\">		
			<img id=\"cookieImage\"/>
			</td></tr></table>
			
			</td></tr>
			</table><br>
			<center><input type=\"submit\" value=\"$lang_admin_add\"></center>
			</form>
			</body>
			</html>
			";		
		}
		
		
		
		
		// 4: Insert Social
		else if($action == "InsertSocial"){
			$name = $_POST['name'];
			$link = $_POST['link'];
			$images = "images/social/". $_POST['variety'];
			
			$query  = "SELECT id FROM eblog_social ORDER BY id ASC";
			$result = mysql_query($query);
			while($row = mysql_fetch_array($result, MYSQL_ASSOC))
			{
				$newID = $row['id'];
			}
			$newID++;
		    mysql_query("INSERT INTO eblog_social  VALUES ('$newID', '$name', '$link', '$images')");
		    
			echo "<meta http-equiv=\"refresh\" content=\"0;url=settings.php?action=refresh\">";		
		}
		
		
		
		
		// 5: Edit Social
		else if($action == "EditSocial"){
			
			$result = mysql_query("SELECT id, name, link, image FROM eblog_social WHERE id = '$id'");	
			$row = mysql_fetch_row($result);
			$rowID = $row[0];
			$rowName = $row[1];
			$rowLink = $row[2];
			$rowImage = $row[3];			
			
			echo "
			<html dir=\"$blog_dir\">
			<head>
			<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">
			<script language=\"javascript\">
			function updateImage () {
				var menu = document.getElementById(\"variety\");
				var cookieImage = document.getElementById(\"cookieImage\");
				cookieImage.src = '../images/social/'+ menu.options[menu.options.selectedIndex].value;
				}
				
		  function checkForm(form){
		  
		  if(form.name.value == \"\"){
		  alert( \"$lang_erorr_code114\" );
		  form.name.focus();
		  return false;
		  }
		  
		  if(form.link.value == \"\"){
		  alert( \"$lang_erorr_code115\" );
		  form.link.focus();
		  return false;
		  }
		  
		  return true;
		  }
			
			</script>
			</head>
			
			<body onload=\"updateImage();\">
			<br>
			<form method=\"post\" action=\"settings.php?action=UpdateSocial&id=$id\"  onsubmit=\"return checkForm(this);\">
			<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"  border=\"1\">
			
			<tr bgcolor=\"#f2f2f2\"><td><font face=\"tahoma\" size=\"2\">$lang_admin_socialName:</font></td><td><input type=\"text\" name=\"name\" value=\"$rowName\" size=\"55\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000; background-color: #ffffff\"></td></tr>
			
			
			<tr bgcolor=\"#dadada\"><td><font face=\"tahoma\" size=\"2\">$lang_admin_socialLink:</font></td><td><input type=\"text\" name=\"link\" value=\"$rowLink\" size=\"55\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000; background-color: #ffffff\"><br><font size=\"2\" face=\"tahoma\">$lang_admin_example: http://www.twitter.com/example</font></td></tr>
			
			
			
			<tr bgcolor=\"#f2f2f2\"><td><font face=\"tahoma\" size=\"2\">$lang_admin_socialImage:</font></td><td>
			<table width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"><tr><td>
			<select id=\"variety\" name=\"variety\" onchange=\"updateImage();\">";
			
			
			$path = "./../images/social";
			$dir_handle = @opendir($path);
			$counter = 0;
			while (false !== ($file = readdir($dir_handle))) {
				$counter++;
				$basename = explode(".", $file);
				$filename = $basename[0];
				$last = substr($file,strlen($file)-4,strlen($file));
				if($last == ".png"){
				$temp = "images/social/" . $file;
				if($temp == $rowImage)
				echo "<option value=\"$file\" selected>$filename</option>";
				else
				echo "<option value=\"$file\">$filename</option>";
				}
			}


			
			echo "</select>	
			</td><td width=\"100%\">		
			<img id=\"cookieImage\"/>
			</td></tr></table>
			
			</td></tr>
			</table><br>
			<center><input type=\"submit\" value=\"$lang_admin_update\"></center>
			</form>
			</body>
			</html>
			";		
		}	
		
		
					
		
		// 6: Update Social
		else if($action == "UpdateSocial"){
			$name = $_POST['name'];
			$link = $_POST['link'];
			$image = "images/social/". $_POST['variety'];
			
			$query = "UPDATE eblog_social SET `name` = '$name' WHERE `id` = '$id'";
			mysql_query($query);
			
			$query = "UPDATE eblog_social SET `link` = '$link' WHERE `id` = '$id'";
			mysql_query($query);
			
			$query = "UPDATE eblog_social SET `image` = '$image' WHERE `id` = '$id'";
			mysql_query($query);									

			echo "<meta http-equiv=\"refresh\" content=\"0;url=settings.php?action=refresh\">";		
		}
		
		
		
		
		
		// 7: Remove Social
		else if($action == "RemoveSocial"){
			mysql_query("DELETE FROM eblog_social WHERE id=$id");
			echo "<meta http-equiv=\"refresh\" content=\"0;url=settings.php#social\">";		
		}
		
		
		
				
			
		// 8: Add Friend
		else if($action == "AddFriend"){
				
			$name   = $_POST["name"];
			$url = $_POST["url"];
			$icon = basename($_FILES['icon']['name']);
			
			if(!empty($icon)){		
					$thumbNewName = '../uploads/friends/'.$icon;
					if (file_exists($thumbNewName))
					{
						$timeNow = date("dmyHis");
						$thumbNewName = '../uploads/friends/'. $timeNow . '_' . $icon;	
					}
					else
					{
						$thumbNewName = '../uploads/friends/'.$icon;
					}
					
					// upload picture	
					if(move_uploaded_file($_FILES['icon']['tmp_name'],$thumbNewName))
					{
						$addToDB = 0;
					}
					else
					{
						$addToDB = 1;
					}					
				}
				
				
				if($addToDB == 0){
					$query  = "SELECT id FROM eblog_friends ORDER BY id ASC";
					$result = mysql_query($query);	
					while($row = mysql_fetch_array($result, MYSQL_ASSOC))
					{
						$newID = $row['id'];
					}
					$newID = $newID + 1;				
					mysql_query("INSERT INTO eblog_friends  VALUES ('$newID', '$name','$url','$thumbNewName')");
				}		

			    echo "<meta http-equiv=\"refresh\" content=\"0;url=settings.php?action=Friends\">";		
		}
		
		
		
		
		// 9: Update Friend
		else if($action == "UpdateFriend"){
			$name = $_POST['name'];
			$url = $_POST['url'];
			$icon = $_POST['icon'];
			
			$query = "UPDATE eblog_friends SET `name` = '$name' WHERE `id` = '$id'";
			mysql_query($query);
			
			$query = "UPDATE eblog_friends SET `url` = '$url' WHERE `id` = '$id'";
			mysql_query($query);
			
			if(!empty($icon)){
			$query = "UPDATE eblog_friends SET `icon` = '$icon' WHERE `id` = '$id'";
			mysql_query($query);
			}									

			echo "<meta http-equiv=\"refresh\" content=\"0;url=settings.php?action=Friends\">";		
		}
		
		
		
		
		// 10: Remove Friend
		else if($action == "DeleteFriend"){
			mysql_query("DELETE FROM eblog_friends WHERE id=$id");
			echo "<meta http-equiv=\"refresh\" content=\"0;url=settings.php?action=Friends\">";
		}
		
		
		
		// 11: List Friend
		else if($action == "Friends"){
			echo "
			<html dir=\"$blog_dir\">
			<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">
			<head>
			
			<script type=\"text/javascript\">	
			function checkform ( form )
			{
			if (form.name.value == \"\") {
			alert( \"$lang_erorr_noName\" );
			form.name.focus();
			return false ;
			}
			if (form.url.value == \"\") {
			alert( \"$lang_erorr_noURL\" );
			form.url.focus();
			return false ;
			}
			if (form.icon.value == \"\") {
			alert( \"$lang_erorr_noThumb\" );
			form.icon.focus();
			return false ;
			}						
			return true;
			}
			
			function checkformII( form )
			{
			if (form.name.value == \"\") {
			alert( \"$lang_erorr_noName\" );
			form.name.focus();
			return false ;
			}
			if (form.url.value == \"\") {
			alert( \"$lang_erorr_noURL\" );
			form.url.focus();
			return false ;
			}					
			return true;
			}			
			</script>
			
			</head>
			
			<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellspacing=\"0\" cellpadding=\"5\"  border=\"1\">			
			<tr bgcolor=\"#dadada\"><td>
			
			<form method=\"post\" enctype=\"multipart/form-data\" action=\"settings.php?action=AddFriend\" onsubmit=\"return checkform(this);\">
			<table cellspacing=\"0\" cellpadding=\"2\">
			<tr><td height = \"30\" colspan=\"10\"><b><font face=\"tahoma\" size=\"2\">$lang_admin_addNewFriend</font></b></td></tr>
			<tr>
			
			<td><font face=\"tahoma\" size=\"2\">$lang_admin_newFriendName:</font></td>
			<td><input type=\"text\" name=\"name\" style=\"width:90px; font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\"></td>
			<td width=\"8\"></td>

			
			<td><font face=\"tahoma\" size=\"2\">$lang_admin_newFriendURL:</font></td>
			<td><input type=\"text\" name=\"url\" style=\"width:90px; font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\"></td>
			<td width=\"8\"></td>

			
			<td><font face=\"tahoma\" size=\"2\">$lang_admin_newFriendIcon:</font></td>
			<td><input type=\"file\"  name=\"icon\" style=\"width:190px;\"></td>
			<td width=\"8\"></td>
			
			<td width=\"10\"><input type=\"submit\" value=\"$lang_admin_add\"></td>						
			
			</tr>
			</table>
			</form>
			
			</td></tr>
			</table><br>
			
			<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"5\"  border=\"1\">			
			";
			

			$counter = 0;
			$query  = "SELECT id, name, url, icon FROM eblog_friends";
			$result = mysql_query($query);
			while($row = mysql_fetch_array($result, MYSQL_ASSOC))
			{
				$rowID = $row['id'];
				$rowName = $row['name'];
				$rowURL = $row['url'];
				$rowIcon = $row['icon'];
				
				
				$reminder = $counter%2;
				if($reminder == 0)
				$bgColor = "#f2f2f2";
				else
				$bgColor = "#dadada";
				
				echo "<form method=\"post\" action=\"settings.php?action=UpdateFriend&id=$rowID\" onsubmit=\"return checkformII(this);\"><tr bgcolor=\"$bgColor\"><td>
						
						<table cellPadding=\"5\"  border=\"0\">
						<tr>
						<td><img src=\"$rowIcon\" style=\"max-width:100px;\">
						<input type=\"hidden\" value=\"$rowIcon\" name=\"icon\">
						</td>
						<td><input type=\"text\" name=\"name\" style=\"width:200px; font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$rowName\"></td>
						<td><input type=\"text\" name=\"url\" style=\"width:200px; font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\" value=\"$rowURL\"></td>
						<td width=\"8\"></td>
						<td><input type=\"image\" src=\"../images/icons/icon_save.gif\">&nbsp;<a href=\"settings.php?action=DeleteFriend&id=$rowID\"><img src=\"../images/icons/icon_remove.gif\"></a></td>						
						<tr>
						</table>
						
						</td></tr></form>";
				
				$counter++;
			}			
			
			
			if($counter < 1)
			{
				echo "<tr bgcolor=\"#f2f2f2\"><td><center><font face=\"tahoma\" size=\"2\">$lang_admin_noFriends</font></center></td></tr>";
			}
			
			echo "</table>";	
		
		}
		
		
		
		// 12: Force Window to Refresh
		else if($action == "refresh"){
			echo " 
			<script type=\"text/javascript\">
			top.parent.location = \"settings.php?section=social\";
			</script>
			";		
		}
		
		
		
		
		// 13: Show Blacklist
		else if($action == "ShowBlacklist"){
		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_confirmDeleteIP\")
			if (question !=\"0\"){
				window.location = \"settings.php?action=DeleteIP&id=\" + toDelete;
			}
		}
		</script>
		<table bordercolor=\"#727272\" style=\"border-collapse: collapse\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"2\"  border=\"1\">";
		
		$query  = "SELECT id, ip, date FROM eblog_blacklist ORDER BY id DESC";
		$result = mysql_query($query);
		$counter = 0;
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			$counter++;
			$reminder = $counter%2;
			
			if($reminder == 0)
			$bgColor = "#f2f2f2";
			else
			$bgColor = "#dadada";
			
			$id	= $row['id'];
			$ip	= $row['ip'];
			$date	= $row['date'];
			echo "<tr bgcolor=\"$bgColor\"><td><table width=\"100%\" border=\"0\"><tr><td width=\"25\"><font face=\"tahoma\" size=\"2\">$id:</font></td><td><font face=\"tahoma\" size=\"2\">$ip</font></td><td width=\"150\"><font face=\"tahoma\" size=\"2\">$date</font></td><td width=\"16\"><a href=\"#\" onClick=\"rusure($id); return false;\"><img src=\"../images/icons/icon_remove.gif\" title=\"$lang_admin_delete\"></a></td></tr></table></td></tr>";
			
		}		
		
		if($counter < 1)
		{
			echo "<tr bgcolor=\"f2f2f2\"><td><font face=\"tahoma\" size=\"2\">$lang_admin_emptyBlackList</font></td></tr>";
		}
		
		
		echo "</table></html>";
		
		}
		
		
		
		
		
		// 14: Clear Blacklist
		else if($action == "ClearBlacklist"){
			echo "<br><br><br><center><img src=\"../images/loading.gif\"><br><br><font size=\"2\" face=\"tahoma\">$lang_admin_clearingBlacklist</font></center>";
			
			$sql = "TRUNCATE TABLE `eblog_blacklist`";
			mysql_query($sql);						
			echo "<meta http-equiv=\"refresh\" content=\"1;url=settings.php?action=ShowBlacklist\">";
		}
		
		
		
		// 15: Delete given record from blacklist
		else if($action == "DeleteIP"){
			mysql_query("DELETE FROM eblog_blacklist WHERE id=$id");
			echo "<meta http-equiv=\"refresh\" content=\"0;url=settings.php?action=ShowBlacklist\">";		
		}																		
		else
		{
			echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php\">";
		}
	
	mysql_close($conn);
 }
  else{   
    echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php\">";
 }
			
?>
Return current item: eBlog