Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- include 'config.php';
- if ($_GET[done] == 1) {
- session_start();
- mysql_connect("$server", "$username", "$password") or die ($theError);
- mysql_select_db("$database") or die ($theError);
- function secure($variable) {
- $variable = addslashes(trim($variable));
- return $variable;
- }
- $username = secure($_POST['username']);
- $password = secure($_POST['password']);
- if((!$username) || (!$password)){
- echo "Please enter ALL of the information! <br />";
- if ($_GET[action] == admin) {
- echo'<br><div class=form align="center"><form name="form" method="post" action="login.php?done=1&action=admin">
- <b>Username:</b><br>
- <input type="text" name="username"><br>
- <b>Password:</b><br>
- <input type="password" name="password"><br><br>
- <input type="submit" name="submit" value="Log in">
- </form></div><br>';}
- else {
- include 'content/login_form.php';}
- }
- else {
- $password = md5($password);
- $sql = mysql_query("SELECT * FROM ava_users WHERE username='$username' AND password='$password' AND activate='1'");
- $login_check = mysql_num_rows($sql);
- if($login_check > 0){
- while($row = mysql_fetch_array($sql)){
- foreach( $row AS $key => $val ){
- $$key = stripslashes( $val );
- $user_id = ''.$row['id'].'';
- }
- if(isset($_POST['remember'])){
- setcookie("ava_username", $username, time()+60*60*24*100);
- setcookie("ava_code", $password, time()+60*60*24*100);
- setcookie("ava_userid", $user_id, time()+60*60*24*100);
- }
- else {
- setcookie("ava_username", $username);
- setcookie("ava_code", $password);
- setcookie("ava_userid", $user_id); }
- if ($_GET[action] == admin) {header("Location: admin/index.php");}
- else if ($_GET['nexttask']) {
- if ($_GET['nexttask'] == 'login') {
- header("Location: index.php");}
- else {
- header("Location: index.php?task=".$_GET['nexttask']."&id=".$_GET['nextid']."");}}
- else {header("Location: index.php");}
- }
- } else {
- echo "<B>".LOGIN_ERROR."<br /><br></B>";
- include 'content/login_form.php';
- }}}
- else if ($_GET[action] == logout)
- {setcookie("ava_username", "", time()-60*60*24*100);
- setcookie("ava_userid", "", time()-60*60*24*100);
- setcookie("ava_code", "", time()-60*60*24*100);
- header("Location: index.php");}
- else {
- include 'content/login_form.php';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement