<?php
class admin {
private function enginelogin()
	{echo '<div style="text-align:center;"><form action="index.php" method="post" class="password" >Password : <input type="password" name="password" id="password" /><input type="submit" name="login" value="Login" /></form></div>';	return;		}
 function postcalls ()
{
if(isset($_POST['update'])) 	{ 		$this->enginesavefile(); 	 	}
if(isset($_GET['login'])) 		{ 	 	$this->enginelogin();	 	}
if(isset($_POST['password'])) 	{ 		$this->enginepassword(); 	 }
	return;
}
private function panel(){
include ("panel.php");
	}
private function enginepassword()
	{ if(sha1($_POST['password']) ==  admin_password)
			{	
		$this->	panel();
		}
		else
			{ 
			$this->msgs("Password Invalid","error_msg");
			echo "<meta http-equiv='refresh' content='0;URL=../index.php' />";}
}
private function msgs($msg,$css) {
	echo "<div class='".$css."'>".$msg."</div>";
	}
private function enginesavefile()
	{ if(sha1($_POST['admin_password']) ==  admin_password)
			{
				if($_POST['new_password'] != NULL)
				{ 	$password = sha1($_POST['new_password']); 	}
				else
				{ 	$password = admin_password; }
$content ="<?php 
			\ndefine('site_name','".$_POST['site_name']."');
			\ndefine('site_url','".$_POST['site_url']."');
			\ndefine('sitetitle','".htmlentities($_POST['sitetitle'])."');
			\ndefine('admin_email','".$_POST['admin_email']."');
			\ndefine('admin_password','".$password."');
			\ndefine('index_name_link', '".$_POST['index_name_link']."');
			\ndefine('about_name_link', '".$_POST['about_name_link']."');
			\ndefine('about_content','".$_POST['about_content']."');
			\ndefine('ps_name_link','".$_POST['ps_name_link']."');
			\ndefine('ps_content','".$_POST['ps_content']."');
			\ndefine('news_name_link','".$_POST['news_name_link']."');
			\ndefine('news_content','".$_POST['news_content']."');
			\ndefine('contact_name_link','".$_POST['contact_name_link']."');
			\ndefine('current_template','".$_POST['current_template']."');
			\ndefine('current_language','".$_POST['current_language']."');
			\ndefine('entry_null','".$_POST['entry_null']."');
			\ndefine('email_thanks_msg','".$_POST['email_thanks_msg']."');
			\ndefine('email_from','".$_POST['email_from']."');
			\ndefine('contact_from','".$_POST['contact_from']."');
			\ndefine('new_email_msg','".$_POST['new_email_msg']."');
			\ndefine('bad_caracters','".$_POST['bad_caracters']."');
			\ndefine('long_email','".$_POST['long_email']."');
			?>"; 
	unlink ('../data/vars.php');
	$indicator = fopen("../data/vars.php","w+");
	if ($indicator)
	{
		fwrite($indicator ,$content);
		chmod("../data/vars.php", 0600);
		fclose($indicator);
		echo act_1;
		$this->	panel();
		}
			}
			else
			{	echo error_1;
			$this->	panel();}
	return;
	}
private function select_file($dir,$text_title,$select_type,$extn,$partner){
				chdir($dir);
				$path=getcwd();
				echo $text_title;
				$dir_file=dir($path);
					echo "<select name='".$partner."'>";
						while ($template_file = $dir_file->read())
							{	$sel = explode(".", $select_type);
								$ext = explode(".", $template_file);
									if ($ext[1] == $extn and $template_file != $select_type)
										{  echo "<option value='".$template_file."'>".$ext[0]."</option>";	}
									else { 	$current_template = current_template; $current_lang = current_language;
									}
							};
					echo "<option selected value = ".$select_type.">".$sel[0]."</select>";
				$dir_file->close();
	}
}
?>