<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";

if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}

if(isset($_GET['q'])){
	//echo dirname(__FILE__);
	$xml = simplexml_load_file(dirname(__FILE__).'/configxml.xml');	
	if($xml->secretkey==$_GET['q'])
	{
		$sql=" SELECT nsettings_id,admin_name FROM ".$tableprefix."settings
				   WHERE admin_name = '".mysql_real_escape_string('admin')."'";
		$result=mysql_query($sql) or die(mysql_error());
		if(mysql_num_rows($result) > 0 )
		{
			$row = mysql_fetch_array($result);
			$_SESSION["sess_adminname"] = $row["admin_name"];

			if(isset($_POST['rememberme']))
			{
				$value = array('usr' => base64_encode($txtUserName), 'pwd' => base64_encode($txtPassword));
				setcookie("mcart_admin", json_encode($value), time()+3600*24*30);
			}
			else
			{
				setcookie("mcart_admin", json_encode($value), time() - 3600);
			}
			header("Location:adminmain.php");

			/*---------------Multicart 2.0 Upgradation------------------*/

			/*-------function call to manage the different sessions--------*/

			manageSession(1);

			/*---------------Multicart 2.0 Upgradation------------------*/

			exit;
		}
		else
		{
			$message = "<img src='../images/error.gif' /> &nbsp;The username or password you provided are incorrect. Please check them and try again.";
		}


	}
}


if(isset( $_SESSION["sess_adminname"]) and $_SESSION["sess_adminname"]!= ""){
	$adminname = $_SESSION["sess_adminname"];
	header("Location:adminmain.php");
	exit;
}else{
	header("Location:login.php");
	exit;
}
?>


