<?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); 
} 
//include "../includes/htmltop.php";
if(!isset($_SERVER['REQUEST_URI'])) {
	if(isset($_SERVER['SCRIPT_NAME']))
		$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
	else
		$_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];

	if($_SERVER['QUERY_STRING']){
		$_SERVER['REQUEST_URI'] .=  '?'.$_SERVER['QUERY_STRING'];
	}
}

if(strcasecmp(basename($_SERVER['REQUEST_URI']),"install.php")==0){
;
}else{
	if (INSTALLED ===true) {
		;
	}else{
		if(strstr($_SERVER['PHP_SELF'],'admin') == TRUE || strstr($_SERVER['PHP_SELF'],'artists') == TRUE || strstr($_SERVER['PHP_SELF'],'affiliates') == TRUE)
		{
			header("Location:../install/install.php");
			//exit;
		}
		else
		{
			header("Location:./install/install.php");
		}	
	}
}
$message ="";
if ($_POST["btnGo"] == "Submit") {
	$txtAdminPass  = trim($_POST['txtAdminPass']);
	$txtLicenseKey  = trim($_POST['txtLicenseKey']);
	if ($txtLicenseKey != "" && $txtAdminPass != "") {
		$sqlSelect	= "SELECT * FROM ".$tableprefix."settings WHERE admin_password ='".md5($txtAdminPass)."'";
		$res =	mysql_query($sqlSelect);
		if(mysql_num_rows($res) > 0){	
			if (strlen($txtLicenseKey) == '30') {
				$sql = "UPDATE ".$tableprefix."settings SET vLicenceKey='" . addslashes($txtLicenseKey) . "'";
				mysql_query($sql);
				header("Location:index.php");
				exit;
			}else
				$message = "Invalid key. Please enter a valid key";
		}else
			$message = "Invalid admin password. Please enter a valid admin password";
	}else
		$message = "Please enter new key";
}
if(basename($_SERVER['PHP_SELF']) == "payment.php" || basename($_SERVER['PHP_SELF']) == "yourpay_payment.php") 
{
?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="https://www.w3.org/1999/xhtml">
	<head>

<?php
}
else
{
?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>

<?php
}
?>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo htmlentities(SITE_NAME);?></title>

<!--Rating css begins-->

<link href="./style/rating.css" rel="stylesheet" type="text/css">

<!--Rating css ends-->

<?php

if(strstr($_SERVER['PHP_SELF'],'admin') == TRUE || strstr($_SERVER['PHP_SELF'],'artists') == TRUE || strstr($_SERVER['PHP_SELF'],'affiliates') == TRUE || strstr($_SERVER['PHP_SELF'],'install') == TRUE)
{
	/*display the active template*/
	if (INSTALLED===true) {
	
	$active_template = displayTemplate();
	}

	//fetching header,footer class from active template // Don't remove it 
	$filename="../themes/".$active_template[4];
	$css_file=file_get_contents("$filename");
	$heder_style=explode("\n",strstr($css_file,'.subheading'));
	$acitve_color=explode("background-color:",$heder_style[2]);
	$header_style=substr($acitve_color[1],0,strlen($acitve_color[1])-1);
	// footer color 
	$footer_style=explode("\n",strstr($css_file,'.copyright_area'));
	$f_color=explode("background-color:",$footer_style[2]);
	$footer_bgcolor=substr($f_color[1],0,strlen($f_color[1])-1);
	// select font color
	$font_style=explode("\n",strstr($css_file,'.copyright_area'));
	$fnt_color=explode("color:",$font_style[3]);
	$font_color=substr($fnt_color[1],0,strlen($fnt_color[1])-1);
	
	$footer_style=explode("\n",strstr($css_file,'.copyright_area'));
	$f_color=explode("background-color:",$footer_style[2]);
	$footer_bgcolor=substr($f_color[1],0,strlen($f_color[1])-1);
	// loginarea color
	$login_style=explode("\n",strstr($css_file,'#login_area'));
	$l_color=explode("background-color:",$login_style[4]);
	$login_bgcolor=substr($l_color[1],0,strlen($l_color[1])-1);
	// End fetching Footer,header classes 
?>

<script src="../js/javascript_check.js"></script>
<link href="../style/template1-admin.css" rel="stylesheet" type="text/css">
<!--Template admin css begins-->
<style>
.header{
	height:85px;
	border:solid 1px #E1E1E1;
	border-bottom:solid 15px <?php echo $header_style;?>;
	background:#fff url(../images/header_grdnt.gif) repeat-x left top;
	margin-bottom:5px;
}
.copyright
{
	background-color:<?php echo $footer_bgcolor;?>;
	border:solid 1px #C4C3C3;
	height:25px;
	color:<?php echo $font_color;?>;
	padding-top:8px;

}
.login_btm_lnks1{
	font:11px Tahoma, Arial;
	color:<?php echo $font_color;?>;
	margin-bottom:5px;	
}
.login_btm_lnks1 A:link{
	font:11px Tahoma, Arial;
	color:<?php echo $font_color;?>;
	margin-bottom:5px;
	text-decoration:none;	
	 

}
.login_btm_lnks1 A:visited{
	font:11px Tahoma, Arial;
	color:<?php echo $font_color;?>;
	margin:8px 0px 5px;	
	margin-bottom:5px;	
	text-decoration:none;
}

#login_area_new{
	width:178px;
	height:179px;
	color:<?php echo $font_color;?>;
	background-color:<?php echo $login_bgcolor;?>;
	padding:20px 15px 0px;
}

</style>

<!--Template admin css ends-->

<?php
}
else
{

?>
<!--Template home css begins-->
<link href="./themes/<?php echo $active_template[4]?>" rel="stylesheet" type="text/css">
<?php
}
?>
<!--Home page javscript begins-->
<script src="./js/script_homepage.js"></script>
<!--Home page javscript ends-->
<!-- rating star script begins -->
<script type="text/javascript" language="javascript" src="./js/behavior.js"></script>
<script type="text/javascript" language="javascript" src="./js/rating.js"></script>
<script type="text/javascript">AC_FL_RunContent = 0;</script>
<script language="javascript" type="text/javascript" src="./js/AC_RunActiveContent.js"></script>
<link href="favicon.ico" type="image/x-icon" rel="icon"> 
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
<!-- rating star script ends -->
<script language="javascript1.1" type="text/javascript">
// Finction to show license key entry textbox...
function enterNewKey(){
	document.getElementById('adminpass').style.display = '';
	document.getElementById('licensekey').style.display = '';
}
 --> 
</script>
<script language="javascript1.1" type="text/javascript">
function emptyCheck()
{
	if(document.frmLicense.txtAdminPass.value == ""){
		alert('Please enter administrator password');
		document.frmLicense.txtAdminPass.focus();
		return false;	
	}else if(document.frmLicense.txtLicenseKey.value == ""){
		alert('Please enter valid license key');
		document.frmLicense.txtLicenseKey.focus();
		return false;	
	}	
}
</script>
</head>
<body>
		<center>
		
		<div align="left" id="layout">
				
				<!--header area start -->
				
<?php
	$select_settings_value = "SELECT site_logo  FROM ".$tableprefix."settings WHERE 1";
	$result_settings_value = mysql_query($select_settings_value) or die(mysql_error()); 
	$settings_row = mysql_fetch_assoc($result_settings_value);
   $logoimage=$settings_row['site_logo'];
?>

<!--Admin top menu-->

<div align="left" class="header">
<!--header area start -->
	<div align="left" class="logo"><a style="cursor:pointer" href="../index.php">
		<img src="<?php echo $logofolder?>/<?php echo $logoimage?>" alt="" width="125" height="50" border="0" /></a>
	</div>
	
	<div align="right" class="logouts_2">&nbsp;</div>
			

<!--header area end -->
</div>
				
				<!--header area end -->
				
				
				<div align="center" class="main_body">
				<!--main body start -->

			<div align="left" class="content_arealicense">
					<!--content area start -->
							
			  <div align="center" class="license_box">
									<img src="../images/welcome_box_top.gif" alt="" width="645" />
									<div align="center" class="license_txt_area">
											
						<form name=frmLicense method=post action="<?php echo $_SERVER["PHP_SELF"];?>" onSubmit="return emptyCheck();">
							<table width="87%"  border="0" cellspacing="0" cellpadding="5" class="listing_user">
								<tr><td align="center" colspan="3" class="text_information"><?php echo $message;?></td></tr>
								<tr><td align="center" colspan="3" class="maintext">Invalid License (<?php echo getLicense();?>).<br> Please contact <b>support@iscripts.com</b></td></tr>
								<tr>
									<td align="center" colspan="3">Click <a href="javascript: enterNewKey();">here</a> to enter new key
									</td>
								</tr>						
								<tr id="adminpass" style="display:none;">
									<td width="44%" align="right" class="maintext">Admin password</td>
									<td width="20%" align="left">
										<input name="txtAdminPass"  id="txtAdminPass" type="password" class="textbox" size="25" maxlength="40" value="<?php echo htmlentities($txtAdminPass);?>">
									</td>
									<td width="20%" align="left">&nbsp;</td>
								</tr>
								<tr id="licensekey" style="display:none;">
									<td width="33%" align="right" class="maintext">Enter license key </td>
									<td width="30%" align="left">
										<input name="txtLicenseKey"  id="txtLicenseKey" type="text" class="textbox" size="40" maxlength="40" value="<?php echo htmlentities($txtLicenseKey);?>">
									</td>
									<td width="37%" align="left">
										<input type="submit" name="btnGo" value="Submit" class="button">
									</td>
								</tr>
								</table>
							</form>

									</div><img src="../images/welcome_box_btm.gif" alt="" width="645" />
				</div>
							
					<!--content area ends -->
				 </div>
					
					<div align="left" class="clear_float"><img src="images/clear_admin.gif" alt="" width="1" height="1" /></div>
				<!--main body end -->
				</div>

<div align="center" class="copyright">
<table cellpadding="1" cellspacing="1" width="100%">
<tr><td>
		<div align="right" id="copyright_rgt">Powered by <a href="http://www.iscripts.com/multicart" target="_blank"><font color="#F4700E"><b>iScripts Multicart</b></font></a>. A premium product from <a href="http://www.iscripts.com" class="" target="_blank"><font color="#F4700E"><b>iScripts.com</b></font></a></div>
</td></tr>
</table>	
</div>
	<div align="left" class="clear_float"><img src="../images/clear_admin.gif" alt="" width="1" height="1" /></div>
</body>
</html>