<?php
require_once ("../config.inc.php");
require_once ("../includes/mysql.inc.php");
require_once ("../classes/settings.class.php");
$message	= "";
if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objS		= new settings($objDB);
        //$_SESSION['adminlogged']='YES';
        //Redirect to settings if already logged in
        
	// For Cloud Compactability 
	
	
	
       if(isset($_GET['q']) && ISCRIPTSCLOUD )  
       {
       	$xml = simplexml_load_file('configxml.xml');
       	if($xml->secretkey==$_GET['q'])
       	{
       		$admindetails=$objS->select();
       		$objS->set_values($admindetails);
       		$message	= $objS->login(true);
       		header("Location: dashboard.php");
       		exit();
       		       		
       	}
       	
       }  
       
    //End Cloud///
	
        if (isset($_SESSION['adminlogged']) AND $_SESSION['adminlogged'] <> "")
            header("Location: dashboard.php");
        /////////////////////////////////////////
        
	if (isset($_POST['LOG'])) {
		$objS->set_values($_POST);
		$message	= $objS->login();
		if ($message == "") {
			header("Location: dashboard.php");
			exit;
		}
	}
}
include_once('title.inc.php');
?>
<script language="javascript" type="text/javascript">
function validate()
{
	var frm	= document.frmLogin;
	if (frm.adminuser.value == '') {
		alert("Please enter username.");
		frm.adminuser.focus();
		return false;
	}
	if (frm.adminpassword.value == '') {
		alert("Please enter password.");
		frm.adminpassword.focus();
		return false;
	}
	return true;
}
</script>
<div style="height:100%">
<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">Admin Panel</span><form name="frmLogin" method="post" action="" onSubmit="return validate();">
						<table width="35%"  border="0" cellspacing="0" cellpadding="0" class="login-table">
						<?php
							if(isset($message) && $message!='')
							{
						 ?>
                          <tr align="center">
                            <td colspan="2" class="maintext1 warning"><?php echo $message;?></td>
                            </tr>
						 <?php }//end if?>
                          <tr align="left">
                            <td width="44%" align="left" class="maintext2 boldtext2"><label class="label-style01">Username</label> </td>
                            <td width="56%" class="maintext2"><input name="adminuser" type="text"  size="25" maxlength="100" value="<?php echo $objS->adminuser?>" class="textbox txt-bx01"></td>
                          </tr>
                          <tr align="left">
                            <td align="left" class="maintext2 boldtext2"><label class="label-style01">Password</label> </td>
                            <td class="maintext2"><input name="adminpassword" type="password" size="25" maxlength="100" class="textbox txt-bx01"></td>
                          </tr>
                          <tr align="left">
                            <td>&nbsp;</td>
                            <td><table width="106%"  border="0" cellspacing="0" cellpadding="3">
                              <tr>
                                  <td align="right"><span class="maintext3">
                                  <input name="LOG" type="submit" class="loginbutton" value="Login">
                                </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');?>