Empire of Sports Europe
▓░░▓░░░▓░░▓▓▓░▓░░░▓▓▓░▓▓▓▓▓░░▓▓░░░▓▓░░▓▓▓░░░░░░
▓░▓░▓░░▓░░▓░░░▓░░░▓░░░▓░░░▓░░▓░▓░▓░▓░░▓░░░░░░░░
▓▓░░░▓░▓░░▓▓░░▓░░░▓░░░▓░░░▓░░▓░░▓░░▓░░▓▓▓░░░░░░
▓░░░░░▓▓░░▓░░░▓░░░▓░░░▓░░░▓░░▓░░░░░▓░░▓░░░░░░░░
▓░░░░░░▓░░▓▓▓░▓▓▓░▓▓▓░▓▓▓▓▓░░▓░░░░░▓░░▓▓▓░░░░░░
Hello and welcome to EOS-EU - First English Speaking Fansite of Empire of Sports!
Register to obtain full access to the website.
We hope you will enjoy the portal.

EOS-EU Team


Welcome to the first English Speaking Community FanSite of Empire of Sports :)
 
HomePortalCalendarGalleryFAQSearchMemberlistUsergroupsHOMEPORTALFORUMLog inRegister

Share | 

1pɔɹɐsɥǝɹ


 

 login with email-Without db

View previous topic View next topic Go down 
AuthorMessage
Jo_Oker
Administrator
Administrator
avatar


PostSubject: login with email-Without db   Sat May 18, 2013 7:14 pm

_login.php
Code:
<?php
require('_login_users.php');
require('_login_class.php');
$login = new login_class;
$today_ts = strtotime("now");
$today_m = date('n', $today_ts);
$pass_login = FALSE;
$login->domain_code = $domain_code;
$login->today_ts = $today_ts;
$login->today_m = $today_m;
$login->users = $users;
$login->num_1 = $random_num_1;
$login->num_2 = $random_num_2;
$login->num_3 = $random_num_3;
if (!$login->verify_settings()) {
   echo '<strong>Invalid Admin Settings for Login Script</strong><br />Check your settings and retry logging in';
   exit();
}
if (isset($_COOKIE[$domain_code.'_uid']) && $_COOKIE[$domain_code.'_uid']!='' && isset($_COOKIE[$domain_code.'_cid']) && $_COOKIE[$domain_code.'_cid']!='') {
   $key_uid = $login->cleanse_input($_COOKIE[$domain_code.'_uid']);
   $key_cid = $login->cleanse_input($_COOKIE[$domain_code.'_cid']);
   
   if (!$login->verify_login($key_uid, $key_cid)) {
      $login->error_message = 'Login has expired';
   } else {
      $pass_login = TRUE;   
   }
}

if (!$pass_login) {
   $need_login = TRUE;
   if (isset($_POST['login'])) {
      $login_user = $login->cleanse_input($_POST['username']);
      if ($login->check_login($login_user)) {
         $login->encryption_key($login_user);
         $need_login = FALSE;
      } else {
         $login->error_message = 'Invalid login username';   
         $need_login = TRUE;
      }
   }
   if ($need_login) {
      require('_login_page.php');
      exit();
   }
}
?>

_login_class.php
Code:
<?php
class login_class {
   var $domain_code = '';
   var $today_ts = '';
   var $today_m = '';
   var $error_message = NULL;
   var $users = '';
   var $num_1 = '';
   var $num_2 = '';
   var $num_3 = '';
   var $username = '';
   function verify_settings () {
      $verified = TRUE;
      if ($this->num_1<1 || $this->num_1>500) $verified = FALSE;
      elseif ($this->num_2<500 || $this->num_2>1000) $verified = FALSE;
      elseif ($this->num_3<1 || $this->num_3>5) $verified = FALSE;
      foreach ($this->users as $user => $pass) {
         preg_match('/([^A-Za-z0-9-_\s\s+])/', $user, $user_result_{$user});
         if (!empty($user_result_{$user})) $verified = FALSE;
      }
      return $verified;
   }
   function encryption_key ($user) {
      $key_uid = $this->user_encryption($user);
      $key_cid = $this->code_encryption($key_uid);
      setcookie($this->domain_code.'_uid', $key_uid, time() + (86400 * 5));
      setcookie($this->domain_code.'_cid', $key_cid, time() + (86400 * 5));
   }
   function user_encryption ($user) {
      return md5($user);
   }
   function code_encryption ($key_cid, $encrypt = 1) {
      if ($encrypt == 1) {
         $key_code = preg_replace('/([^0-9+])/', '', $key_cid);            
         switch ($this->num_3) {
            case 1:
               $key_code = floor((($key_code + $this->num_2 + (($this->num_1 * 2) * $this->num_2)) / $this->num_1) / $this->num_2);
               break;
            case 2:
               $key_code = ceil(((($this->num_2 + $this->num_1) * $this->num_1 + $key_code + $this->num_2 - (10 * $this->num_1)) / ($this->num_1 * 50))/100000000);
               break;
            case 3:
               $key_code = floor((((($key_code - $this->num_2 + (($this->num_1 * 3) * $this->num_2)) + $this->num_1) / $this->num_2))/100000000);
               break;
         }         
         $key_code = substr($key_code, 0, 10);   
         return $key_code;
      }
   }   
   function check_login ($username) {
      foreach ($this->users as $user) {
         if ($username == $user) {
            $this->username = $username;
            return TRUE;
         }
      }      
      return FALSE;
   }
   function verify_login ($key_uid, $key_cid) {
      if ($key_cid = $this->code_encryption($key_uid)) {
         foreach ($this->users as $username => $password) {
            if ($key_uid == $this->user_encryption($username)) {
               $this->username = $username;
               return TRUE;
            }
         }
      }      
      return FALSE;
   }   
   function error_login () {
      if (isset($this->error_message)) {
         echo '<span class="error">'.$this->error_message.'</span><br /><br />';   
      }
   }
   function cleanse_input($input) {
      $input = trim($input);      
      if (get_magic_quotes_gpc()==1) {
      } else {
         $input = addslashes($input);
      }   
      $input = htmlentities($input);      
      return $input;
   }
}
?>

_login_page.php
Code:
<!DOCTYPE>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="pragma" content="no-cache">
<title>#</title>
<style type="text/css">
body{background-color:black}
   * {
      margin: 0;
      padding: 0;
   }
   
   .login_box {
      width: 220px;
      padding: 10px;
      border: 3px solid #CCC;
      font-family:Arial, Helvetica, sans-serif;
      font-size: 10px;
      margin: 100px auto 10px auto;   
   }
   
   .login_title {
      font-size: 12px;
      font-weight: bold;
      color:white;
   }
   
   .login_text {
      font-size: 18px;
      font-weight: bold;
      color: white;
   }
   
   .login_input {
      width: 210px;
      padding: 5px;
      margin: 2px 0 2px 0;
      border: 1px solid #999;
      font-size: 16px;
   }
   
   .error {
      font-weight: bold;
      color: red;
   }
</style>
</head>

<body>
<form action="" method="post">
<div class="login_box">
    <span class="login_title">Login yourself</span><br />
    <?php $login->error_login(); ?>
    <span class="login_text">Email</span><br />
    <input name="username" type="text" class="login_input" /><br /><br />
   <div align="right"><input name="login" type="submit" value="Login" /></div>
</div>
</form>
</body>
</html>

_login_users.php
Code:
<?php
$domain_code = 'website';
$random_num_1 = 20;
$random_num_2 = 565;
$random_num_3 = 3;
$users = array(
      'somebody@hotmail.com',
      'user2@gmail.com'
   );
?>

index.php
Code:
<?php require('_login.php'); ?>
<!DOCTYPE>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="pragma" content="no-cache">
<title>#</title>
<style>
body{background-color:black}
a:link,a:active,a:visited{color:red;text-decoration:none}
code{background-color:red;}
#welcome{color:white}
#header{border:2px solid white;width:200px;text-align:center;float:left}
#logout{float:right;border:2px solid white;width:50px;box-shadow:5px 5px 5px white}
</style>
</head>
<body>
<div id="header">
<div id="welcome">Welcome  </div><div><code><?php echo $login->username; ?></code></div>
</div>
<div id="logout">
<a href="logout.php">Logout</a>
</div>
</body>
</html>

login.php
Code:
<?php
require('_login.php');
header("LOCATION: index.php");
?>

logout.php
Code:
<?php
require('_login_users.php');
setcookie($domain_code.'_uid', '');
setcookie($domain_code.'_cid', '');
header("LOCATION: login.php");
?>

Demo: Click to see.
login emails:user1@hotmail.com/user2@gmail.com
Back to top Go down
View user profile
 

login with email-Without db

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» login 3 times only?
» My reply from a long email I sent to OUR FRIENDS at GI
» Email from BABW..?
» Jhess (peer to peer and email play)
» Nintendo's E3 press site login

Permissions in this forum:You cannot reply to topics in this forum
Empire of Sports Europe :: PHP-