<?php
if(!defined('IN_TM')) {exit('Access Denied');}
if($_SESSION["admin"]!="Silence"){
	if(empty($_POST['Submit'])) {
		include template('login.htm');
	} else {
		$username = getgpc('username');
		$password = getgpc('password');
		$seccode = getgpc('seccode');
		if(empty($username)){
			$messageid = 1;
			include template('message.htm');
			exit;
		}elseif(empty($password)){
			$messageid = 2;
			include template('message.htm');
			exit;
		}elseif(empty($seccode)){
			$messageid = 3;
			include template('message.htm');
			exit;
		}elseif(submitcheck()){
			$password = md5($password);
			$row_num = $db->num_rows($db->query("SELECT * FROM {$tablepre}admin where username='{$username}' AND password='{$password}'"));
			if($row_num > 0){
 				$admin = $db->fetch_array($db->query("SELECT username, id FROM {$tablepre}admin WHERE username='$username'"));
				$db->query("UPDATE {$tablepre}admin set oltime='$timestamp',lastip='$onlineip' where id='{$admin[id]}'");
 				$_SESSION['admin']="Silence";
 				$_SESSION['adminuser']=$username;
 				$messageid = 4;
 				include template('message.htm');
 				return;
 			}else{
 				$messageid = 5;
				include template('message.htm');
			}
		}else{
			$messageid = 9999;
			include template('message.htm');
		}
	}
}else{
	$messageid = 12;
	include template('message.htm');
}
?>