<?php
require_once ("../config.inc.php");
require_once ("../includes/mysql.inc.php");
require_once ("../classes/settings.class.php");

if(isset($_GET['changPassword']))
	{
		$xml = simplexml_load_file('configxml.xml');
		
		if($xml->secretkey==$_GET['changPassword'])
			{
				$objS		= new settings($objDB);
				$admindetails=$objS->select();
				$orpword=$admindetails[adminpassword];
				if(md5($_POST["oldPassword"]) <> $orpword)
					{
						echo 'The current password you entered is wrong!';
						exit();
					}
				if($_POST["newPassword"]==$_POST["confPassword"])
					{
						$objS->update("adminpassword",$_POST["newPassword"],1);
						echo "Password has been changed successfully!";
						exit();
					}
				else
					{
						echo "The New Passwords are not matching!";
						exit();
					}
			}
	}
