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

$objLicense	= new License($objDB);
$objST          = new settings($objDB);
$siteTitle      = $objST->select();

$message	= "";

$PG_TITLE=$objST->ClientFilePathName($_SERVER['PHP_SELF']);

function isNotNull($value) { 
    if (is_array($value)) {
        if (sizeof($value) > 0) {
            return true;
        } else {
            return false;
        }
    } else {
        if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) {
            return true;
        } else {
            return false;
        }
    }
}

//if logo empty shows site title in the logo place
if(trim($siteTitle['sitelogo'])!='') {
    //checking logo default or not
    switch($siteTitle['sitelogo']) {
        case "logo_default.gif":
            $showLogoTop='24';
            break;

        default:
            $showLogoTop='3';
            break;
    }//end swich

    $showLogoImgTtl='<img src="../images/'.$siteTitle['sitelogo'].'" width="'.$width.'" height="'.$height.'" alt="'.$siteTitle['sitename'].'" title="'.$siteTitle['sitename'].'" border="0">';
}//end if
else {
    $showLogoTop='24';
    $showLogoImgTtl=$siteTitle['sitename'];
}//end else

$ShowContent=($_POST['ddlContent']!='')?$_POST['ddlContent']:'index.php';
$ddlContent=($_POST['ddlContent']!='')?$_POST['ddlContent']:'index.php';

if($PG_TITLE=='settings.php') {
    $onBodyLd='onLoad="showHint(\''.$ddlStyles.'\');"';
}//end if
if($PG_TITLE=='metatags.php') {
    $onBodyLd='onLoad="ShowTitle(\''.$ShowContent.'\');"';
}//end if

//checking user login status
if (isset($_SESSION['adminlogged']) && $_SESSION['adminlogged']=="YES") {
    $shwLink='settings.php';
}//end if
else {
    $shwLink='index.php';
}//end else

$table=TABLEPREFIX."lookup";
$var_domain	= strtoupper(trim($_SERVER['HTTP_HOST']));
$error = '';

if($objLicense->FCE74825B5A01C99B06AF231DE0BD667D($var_domain,$table)) {
    header("Location:index.php");
    exit;
}

if($_REQUEST['submit']) { 
    $license    =   trim($_REQUEST['inputlicense']);
    $password   =   md5(trim($_REQUEST['password']));  

    if(!isNotNull($password)) { 
        $message .= " * Enter Admin Password!" . "<br>"; 
        $error = true;
    }else { 
        $adminValue = $objLicense->FB65FDD43B9A0C83B8499D74B1A31890A($table,$password);
        if(empty($adminValue)){
            $message .= " * Enter a valid Admin Password!" . "<br>";
            $error = true;
        }
    }
    if (!isNotNull($license)) {
        $message .= " * Enter LicenseKey!" . "<br>";
        $error = true;
    }
    if(count($adminValue)>0) {
        $objLicense->F03FD063C610FFF78F127C6DCC52A6524($table,$license);
    }

    if(!$error){
        if($objLicense->FCE74825B5A01C99B06AF231DE0BD667D($var_domain,$table)) {
            header("Location:index.php");
            exit;
        }else{
           $message = "Invalid License Key!<br/> Please Enter A Valid License Key.";
           $error = true;
        }
    }
}


        
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title><?php echo $siteTitle['sitename'];?></title>
        <meta name="keywords" content="<?php echo $siteTitle['metatagKey'];?>">
        <meta name="description" content="<?php echo $siteTitle['metatagDes'];?>">
        <meta name="copyright" content="Copyright (C) www.iScripts.com, 2007. All rights reserved.">
        <meta name="author" content="www.armia.com">
        <!--<meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="PRAGMA" content="no-cache">-->
        <meta http-equiv="Expires" content="Mon, 04 Dec 1999 21:29:02 GMT">
        <link href="../favicon.ico" type="image/x-icon" rel="icon">
        <link href="../favicon.ico" type="image/x-icon" rel="shortcut icon">
        <link href="../styles/<?php echo $siteTitle['styles'];?>" rel="stylesheet" type="text/css">
        <style type="text/css">
            <!--
            .style1 {color: #FFFFFF}
            -->
        </style>
    </head>
    <body <?php echo $onBodyLd;?>>
        <div id="Layer1" style="position:absolute; left:2px; top:<?php echo $showLogoTop;?>px; width:725px; height:120px; z-index:1">
            <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td class="logoo"><a href="<?php echo $shwLink;?>"><?php echo $showLogoImgTtl;?></a></td>
                </tr>
            </table>
        </div>
        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td valign="middle" class="logo">
                    <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="73%" align="right">&nbsp;</td>
                            <td width="27%" align="center" class="headings">&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td class="y">&nbsp;</td>
            </tr>
        </table>
        



<div style="height:100%; min-height:480px">
    <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td valign="top" class="white" style="min-height: 600px;"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="72%" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="5">
                                <tr>
                                    <td><table width="100%"  border="0" cellspacing="0" cellpadding="5">
                                            <tr>
                                                <td width="41%" colspan="2">&nbsp;</td>
                                            </tr>
                                        </table>
                                        <div>
            <table width="100%"  border="0" cellspacing="0" cellpadding="5">
                <tr>
                    <td valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="center">

                                    <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td align="center">  <span class="legend" style="font-family:arial; text-align: left; font-size:16px; color:#666; margin:0 417px 0 474px; padding:5px; display:block; border-bottom:1px solid #ccc">Invalid LicenseKey</span>
                                                <form name="frmLicenseKeyCheck" method="POST" action="">
                                                    <table width="35%"  border="0" cellspacing="0" cellpadding="0" class="login-table">
                                                        <?php
                                                         if($error){
                                                        ?>
                                                        <tr align="center">
                                                            <td colspan="2" class="maintext1 warning"><u><b><font color="#FF0000">Please correct the following errors to continue:</font></b></u></td>
                                                        </tr>
                                                        <tr align="center">
                                                            <td colspan="2" class="maintext1 warning"><?php echo $message;?></td>
                                                        </tr>
                                                        <tr align="center">
                                                            <td colspan="2" class="maintext1 warning">&nbsp;</td>
                                                        </tr>
                                                            <?php }//end if?>
                                                        <tr align="left">
                                                            <td width="44%" align="right" class="maintext2 boldtext2"><label class="label-style01">Admin Password</label> </td>
                                                            <td width="56%" class="maintext2"><input type="password" name="password" id="inputPassword" size="25" maxlength="100" class="textbox txt-bx01" placeholder="Admin Password"></td>
                                                        </tr>
                                                        <tr align="left">
                                                            <td align="right" class="maintext2 boldtext2"><label class="label-style01">License Key</label> </td>
                                                            <td class="maintext2"><input type="text" name="inputlicense" id="inputLicense" placeholder="License Key" size="25" maxlength="100" class="textbox txt-bx01" value="<?php echo $_REQUEST['inputlicense'];?>"></td>
                                                        </tr>
                                                        <tr align="left">
                                                            <td>&nbsp;</td>
                                                            <td><table width="100%"  border="0" cellspacing="0" cellpadding="3">
                                                                    <tr>
                                                                        <td align="right"><span class="maintext3">
                                                                                <input type="submit" name="submit" class="loginbutton" value="Update"  />
                                                                            </span></td>
                                                                    </tr>
                                                                </table></td>
                                                        </tr>
                                                    </table>
                                                </form>

                                                <span class="legend_bottom"></span>
                                            </td>
                                        </tr>
                                    </table>
                                    <table width="100%"  border="0" cellspacing="0" cellpadding="5">
                                        <tr>
                                            <td align="center"><p>&nbsp;</p>
                                                <p>&nbsp;</p>
                                            </td>
                                        </tr>
                                    </table></td>
                            </tr>
                        </table></td>
                </tr>
            </table>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
        
<?php include_once('bottomhtml.php');?>