index.php 3.95 KB
<?
session_start();
?>
<HTML>
<HEAD>
<TITLE>Администратор</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META Name="KEYWORDS" Content="<? echo $keyword; ?>">
<META Name="DESCRIPTION" Content="<? echo $description;?>">
<LINK HREF="./screen.css" TYPE="text/css" REL="stylesheet">
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
</HEAD>
<?
include ("./func.php");
include ("../lib/db_class.php");
include ("../config.php");

$db = new DBClass(SERVER,USER,PASSWORD,DBNAME);

if (isset($_POST['name'])&&isset($_POST['pass']))
{
	$name = $_POST['name'];
 	$pass = $_POST['pass'];
	
	$colum = "name, pass";	
	$table = "users";
	$where = "name = "."'$name'"." and pass = "."'$pass'"."";						
	$query =  $db->select($colum,$table,$where);
					
	if(count($query) > 0)
    {       		
		$_SESSION['valid_user'] = $query[0][name];
	}
	else {
			$message = "Вы ввели неправильный логин или пароль";			
	}	
}
 if ($_GET['action'] == "exit")
 {
  	unset($_SESSION['valid_user']);
 }
 if (!empty($_SESSION['valid_user']))
 {
  	if (isset($_GET['action']))
  	{
  		$action = $_GET['action'];
  	}
	if (isset($_POST['action']))
  	{
  		$action = $_POST['action'];
  	}	
  	if ((!isset($_GET['action']))and(!isset($_POST['action'])))
  	{
  		$action = "hero3_users";
  	}	
	
	$lang="ua";
?>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 RIGHTMARGIN=0 bottommargin=0>
 	<table cellpadding=0 cellspacing=0 width=100% height=100% border = 0 style="border-style:solid; border-width:15px; border-color:#DEDEDE">
  		<tr>
   			<td width="250" valign="top" class = "tabl5" style="padding-top:10; padding-left:10">
    			<?
      				include ("./materials/adm_menu/adm_menu.php");
    			?>
   			</td>
   			<td valign="top">
   				<br><br>
    			<?
     				if (isset($action))
     				{
       					include ("./materials/$action/$action.php");
     				}
    			?>
   			</td>
  		</tr>
 	</table>
 <?
        } else {
?>
<div align="center" valign="middle">
	<form method="post" action="index.php">
		<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
 			<tr>
  				<td align="center" valign="top" style="padding-top:200px">
   					<table cellpadding="0" cellspacing="0" border="0" height="130px">
   						<tr>
     						<td>
    							<table cellpadding="0" cellspacing="0" border="0" width="250px" height="130px" class="login_form">
      								<?
      									if (isset($name))
      									{
     								?>
     										<tr>
      											<td class="text_login_error">
       								<?
       												echo $message;
      								?>
      											</td>
     										</tr>
     								<?
      									}
     								?>
     										<tr>
      											<td align="center">
       												<table cellpadding="0" cellspacing="5" border="0" width="230px">
        												<tr>
         													<td class="text_login" width="50px">
          														<b>Логин:</b>
         													</td>
         													<td>
          														<input type="text" name="name" class="input_text_login">
         													</td>
        												</tr>
        												<tr>
         													<td class="text_login" width="50px">
          														<b>Пароль:</b>
         													</td>
         													<td>
          														<input type="password" name="pass" class="input_text_login">
         													</td>
        												</tr>
        												<tr>
         													<td colspan="2" align="center" style="padding-top:10">
          														<input type="submit" value="Войти" class="button_login_2">
         													</td>
        												</tr>
       												</table>
     											</td>
    										</tr>
   										</table>
     								</td>
    							</tr>
   							</table>
  						</td>
 					</tr>
				</table>
			</form>
		<div>
<?
}
?>
</BODY>
</HTML>