<?

/* ------------------------------------------------------------------- */
/*

*************************************************
*			UWAGA! SKRYPT NIE JEST DARMOWY.			*
*		DALSZE ROZPOWSZECHNIANIE BEZ ZGODY 			*
*			FIRMY ArtGlobal JEST ZABRONIONE.			*
*************************************************

*************************************************
*	WWW.ArtGlobal.PL		PRODUCENT OPROGRAMOWANIA	*
*	NAZWA SKRYPTU:		NIERUCHOMOSCI 6.0			*
*	WERSJA FINALNA:	04.10.2010						*
*	KONTAKT:				kontakt@artglobal.pl			**
*************************************************

Copyright (c) 2010 ArtGlobal. Wszelkie prawa zastrzeżone.

*/
/* ------------------------------------------------------------------- */

include('config.inc.php');

if ( $_GET['act'] == 'logout' )
{
        $_SESSION['AdminIsLogin'] = null;
        $_SESSION['AdminId'] = null;
        $_SESSION['AdminFunction'] = null;
        $_SESSION = null;
        session_destroy();
        header("Location: login.php");
}
if ( $_POST['get-login'] == 'ok' )
{
        $login = htmlspecialchars( $_POST['login'] );
        $pass = htmlspecialchars( $_POST['pass'] );
        $pass_md5 = md5( $pass );
        
        $sql = "SELECT * FROM admins WHERE login = '$login' AND pass = '$pass_md5' AND block = '0'";
        $q = mysql_query( $sql );
        $i = mysql_num_rows( $q );
        $db = mysql_fetch_array( $q );
        
        if ( $login == null )
        {
                $error[1] = '';
        }
        else if ( $pass == null )
        {
                $error[2] = '';
        }
        else if ( $i == 0 && $login != $db['login'] && $pass_md5 != $db['pass'] )
        {
                $error[1] = '';
                $error[2] = '';
        }
        else
        {
                $_SESSION['AdminIsLogin'] = 'ba2b3a2';
                $_SESSION['AdminId'] = $db['id'];
                $_SESSION['AdminFunction'] = $db['function'];
                
                $sql = "UPDATE `admins` SET `date_login` = NOW() WHERE `id` = '".$db['id']."'";
                mysql_query( $sql );
                
                if ( $db['function'] == 'admin' )
                {
                        header("Location: administrator.php");
                }
               /* if ( $db['function'] == 'mod' )
                {
                        header("Location: moderator.php");
                }*/
        }
}
$smarty -> assign('error', $error);
$smarty -> display('adm-login.tpl');
?>
