<?

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

*************************************************
*			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 register
{
        function isEmpty ( $string )
        {
                if ( empty( $string ) )
                {
                        return false;
                }
                else
                {
                        return true;
                }
        }
        function walidLogin ( $userName, $mysql )
        {
                $sql = "SELECT userId FROM users WHERE userName = '$userName'";
                if ( $mysql -> num( $sql ) == 0 )
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }
        function emailSql ( $email, $mysql )
        {
                $sql = "SELECT userId FROM users WHERE userEmail = '$email'";
                if ( $mysql -> num( $sql ) == 0 )
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }
        function walidEmail ( $email )
        {
                 if ( !ereg("^[^@]{1,64}@[^@]{1,255}$", $email ) )
                 {
                        return false;
                 }
                 else
                 {
                        return true;
                 }
        }
        function walidEmail2 ( $email_1, $email_2 )
        {
                if ( $email_1 !== $email_2 )
                {
                        return false;
                }
                else
                {
                        return true;
                }
        }
        function walidPass ( $pass_1, $pass_2 )
        {
                if ( $pass_1 !== $pass_2 )
                {
                        return false;
                }
                else
                {
                        return true;
                }
        }
        function hash( $userName, $email )
        {
                return md5( $userName . '+' . $email );
        }
        function add ( $userName, $userFunkcja,  $userPass, $userEmail, $userFrom, $mysql )
        {
                $sql = "INSERT INTO `users` (`userName`, `userFunkcja`, `userPass`, `userEmail`, `userFrom`, `userDate`, `userHash`, `userConfirm`) VALUES ('$userName', '$userFunkcja', '" . md5( $userPass ) . "', '$userEmail', '$userFrom', NOW(), '" . $this -> hash( $userName, $userEmail ) . "', '0')";
                $mysql -> q( $sql );
        }
}
?>
