<?

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

*************************************************
*			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.

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

class session
{
        function session_register ( $userName, $mysql )
        {
                $sql = "SELECT userId, userName, userEmail FROM users WHERE userName = '$userName'";
                $q = $mysql -> q( $sql );
                $db = mysql_fetch_array( $q );
                
                $_SESSION['UserIsLogin'] = md5('-YES-');
                $_SESSION['userId'] = $db['userId'];
                $_SESSION['userName'] = $db['userName'];
                $_SESSION['userEmail'] = $db['userEmail'];
                $_SESSION['adressIp'] = $_SERVER['REMOTE_ADDR'];
        }
        function chesk_session ()
        {
                if ( isset( $_SESSION['UserIsLogin'] ) && $_SESSION['UserIsLogin'] == md5('-YES-') )
                {
                        if ( $_SESSION['adressIp'] == $_SERVER['REMOTE_ADDR'] )
                        {
                                if ( !empty( $_SESSION['UserIsLogin'] ) )
                                {
                                        return true;
                                }
                                else
                                {
                                        return false;
                                }
                        }
                        else
                        {
                                return false;
                                echo 'Próba przejęcia sesji! EXIT!';
                                exit;
                        }
                }
                else
                {
                        return false;
                }
        }
        function logout ()
        {
                $_SESSION['UserIsLogin'] = null;
                $_SESSION['userId'] = null;
                $_SESSION['userName'] = null;
                $_SESSION['userEmail'] = $null;
                $_SESSION['adressIp'] = null;
                session_destroy();
        }
        function clearSearch ()
        {
                $_SESSION['txt'] = '';
                $_SESSION['city'] = '';
                $_SESSION['state'] = '';
                $_SESSION['type'] = '';
                $_SESSION['priceOn'] = '';
                $_SESSION['priceOff'] = '';
								$_SESSION['dziel'] = '';
								$_SESSION['kategoria'] = '';
								$_SESSION['rodzaj'] = '';
								$_SESSION['rynek'] = '';
								$_SESSION['ulica'] = '';
        }
}
?>
