Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Member Login
- */
- chdir(constant("PHP_DIR")) or die("Fatal Runtime Error.");
- $errors = Globals::add("errors",new Errors());
- if(isset($_SESSION['login_details']))
- {
- $username = $_SESSION['login_details']['username'];
- $password = $_SESSION['login_details']['password'];
- if(!isset($_SESSION['login_details']['valid_key']) OR $_SESSION['login_details']['valid_key'] == false)
- {
- if(isset($_SESSION['login_details']['multiple']) AND $_SESSION['login_details']['multiple'])
- {
- if(Vars::$conf->security->multiple_account_auto_suspend)
- {
- $row = Bux::getDbInstance()->fetchOne("SELECT * FROM suspension WHERE user = '".$username."'");
- if(!$row)
- {
- Bux::getDbInstance()->query("INSERT INTO suspension (user, days, reason, time) VALUES ('".$username."', '5000', '', '".time()."');");
- }
- }
- $errors->add('Multiple account detected, you have been suspended. Contact support if you believe this is a mistake');
- }
- else
- {
- $errors->add('The authentication validation was unable to complete, please try again and do not refresh the page before validation has been completed');
- }
- unset($_SESSION['login_details']);
- }
- else
- {
- unset($_SESSION['login_details']);
- User::login($username,$password);
- if($errors->isEmpty())
- {
- $Db = Bux::getDbInstance();
- // Hook : START
- Plugins::runMethod('login'); // Method Hook
- $hook = 'after_login'; // Include Hook
- include RUN_HOOK;
- // Hook : END
- $Db->query("UPDATE tb_users SET lastlogdate = ".time().", lastiplog = '".User::getRealIP()."' WHERE username = '".User::name()."'");
- Router::redirect("Account");
- #echo 'valid';
- #exit;
- }
- }
- }
- $login = Form::create("login");
- $login->formOpen();
- $login->noTable();
- $login->add()->input("text")->name("username")->label("Username")->value()->required()->wrapOpen("<label>")->class("right")->wrapClose('</label><br/><br/>');
- $login->add()->input("password")->name("password")->label("Password")->required()->class("right")->wrapOpen("<label>")->wrapClose('</label><br/><br/><a href="lost" class="right">Forgot Username/Password?</a><br/><br/>');
- $login = ZeCaptcha::form($login);
- $login->add()->input("submit")->value("Login")->class("login");
- $login->formClose();
- // If account is not activated and user has clicked the send activation link:
- if(isset($_GET["ract"]) && isset($_SESSION["ract"]))
- {
- if($_SESSION["ract"] === true)
- {
- require_once("includes/layout_header.php");
- echo HTML::head('Login Activation');
- echo Message::error('Activation Mail already sent!','instant',0);
- echo HTML::foot();
- require_once("includes/layout_footer.php");
- }
- else
- {
- $Db = Bux::getDbInstance();
- $ract = $Db->fetchOne("SELECT id, username, email, acode FROM tb_users WHERE username = '".$_SESSION["ract"]."'");
- $body = "You have requested a new activation email
- Activation link: ".Router::getHost()."act?i=".$ract["id"]."&c=".$ract["acode"]."
- Please visit the activation link in order for your account to be activated.
- Failure to activate your account within 3 days will result in your account being automatically deleted.
- ------------------------------------------------------------------------------
- This email was sent from ".Router::getHost()." if you did not register for an account, please disregard this email.";
- require_once("includes/layout_header.php");
- echo HTML::head('Login Activation');
- if(mail($ract["email"], Vars::$conf->site->name." - Login Activation", $body, "From: \"Auto-Response\" <".Vars::$conf->site->email_reply.">\r\n" . "X-Mailer: PHP/" . phpversion()))
- {
- echo Message::success('Mail sent successfully','instant',0);
- }
- else
- {
- echo Message::error('Mail could not be sent','instant',0);
- }
- $_SESSION["ract"] = true;
- echo HTML::foot();
- require_once("includes/layout_footer.php");
- }
- }
- require_once("includes/layout_header.php");
- if(!empty($_POST))
- {
- sleep(Vars::$conf->site->login_delay);
- $username = Form::getOneRawPost("username","login");
- $password = Form::getOneRawPost("password","login");
- $errors->setOpenWrapper("<font color='red'>");
- $errors->setCloseWrapper("</font>");
- $code = Form::getOneRawPost("captcha","login");
- $key = Form::getOneRawPost("key","login");
- if( ! ZeCaptcha::validate_captcha($key,$code))
- {
- $errors->add('<div class="error">Wrong verification image.</div>');
- }
- elseif(!Sanitize::validateAlpha($username) || !Sanitize::validateAlpha($password))
- {
- $errors->add('<div class="error">Invalid username/password.</div>');
- }
- else
- {
- if($errors->isEmpty())
- {
- if( ! User::is_valid_login($username,$password))
- {
- echo '<div class="error">Invalid username/password.</div>';
- }
- else
- {
- $_SESSION['login_details'] = array(
- 'username' => $username,
- 'password' => $password,
- 'valid_key'=> false,
- );
- ?><h3 class="h">Just a moment...</h3>
- <div class="info">Please wait while your login is being authenticated....</div>
- <script type="text/javascript" src="<?php echo Router::getHost();?>scripts/swfobject-2.2.min.js"></script>
- <script type="text/javascript" src="<?php echo Router::getHost();?>zoaks.js"></script>
- <?php
- if($user = Bux::getDbInstance()->fetchOne("SELECT * FROM tb_users WHERE username = '".mysql_real_escape_String($username)."'"))
- {
- if($user['super_cookie_key'] == '')
- {
- $evercookie = md5($user['id']) . sha1($user['id'] . $user['username'] . rand() . uniqid(mt_rand(0,100000)));#mt_rand(1,10000);
- Bux::getDbInstance()->query("UPDATE tb_users SET super_cookie_key = '".$evercookie."' WHERE id = ".$user['id']);
- }
- else
- {
- $evercookie = $user['super_cookie_key'];
- }
- $canIHazCookieKey = 'id';
- ?>
- <script type="text/javascript">
- $(function(){
- var _0xe924= new evercookie();
- _0xe924.get("<?php echo $canIHazCookieKey;?>", function(value) {
- var ckey = value;
- if(!ckey || '<?php echo $user['super_cookie_key'];?>' == '')
- {
- _0xe924.set("<?php echo $canIHazCookieKey;?>", "<?php echo $evercookie;?>");
- ckey = '<?php echo $evercookie;?>';
- }
- $.post('<?php echo Router::getHost().'scripts/sc/verify.php';?>',{"c" : ckey },function(data){
- setTimeout(function(){
- window.location.href = '<?php echo Router::getHost();?>login';
- },500);
- });
- });
- });
- </script>
- <?php
- }
- }
- require_once("includes/layout_footer.php");
- exit;
- }
- }
- }
- ?>
- <h3 class="h">Account Login</h3>
- <?php
- echo Message::get();
- if(!$errors->isEmpty())
- {
- $errors->dump();
- if($errors->exists(1))
- {
- echo '<a href="'.Router::selfHost().'?ract">Click here to resend activation email</a>';
- }
- }
- $z = ZeCaptcha::form(true,null,array('name_code'=>'login_captcha','name_key'=>'login_key'));
- ?>
- <form name="login" method="POST" action="">
- <input type="hidden" name="login_submit" value="Login">
- <div id="login-w1">
- <div class="form-w1">
- <div class="form-group-w1 first">
- <span class="form-number">1</span>
- <div class="form-row-w1"><label>Username: </label> <span><input type="text" name="login_username" /></span></div>
- <div class="form-row-w1"><label>Password: </label> <span><input type="password" name="login_password" /></span></div>
- <div class="clear"></div>
- </div>
- <div class="form-group-w1 last">
- <span class="form-number">2</span>
- <div class="form-row-captcha">
- <?php echo $z;?>
- </div>
- </div>
- <div class="form-submit-w1">
- <div class="form-submit">
- <input type="submit" value="Login">
- <a href="#" onclick="$(this).closest('form').submit(); return false;">Access Account</a>
- </div>
- <div class="form-submit-links">
- <a href="lost">Forgot Login?</a>
- </div>
- <div class="clear"></div>
- </div>
- </div>
- </div>
- </form>
- <?php
- require_once("includes/layout_footer.php");
- ?>
Add Comment
Please, Sign In to add comment