Thread: Login Failed
View Single Post
  #4  
Old 05-27-2009, 05:40 PM
Bloodrun's Avatar
Bloodrun Bloodrun is offline
I am, who I am.
 
Join Date: Apr 2009
Posts: 532
Gender: Male
Credits: 29,692
Bloodrun
Send a message via Yahoo to Bloodrun
Default RE: Login Failed

Quote:
Originally Posted by rosepose
They're using the login.php because I don't have a sidebar.
PHP Code:
<?php

// **********************************************************************
// Rusnak PHP Adoptables Script
// Copyright 2009 Brandon Rusnak
// For help and support: http://www.rusnakweb.com/forum/
//
// Redistribution prohibited without written permission
// **********************************************************************

// Wake the sleeping giant

// **********************************************************************
// Basic Configuration Info
// **********************************************************************

include("inc/functions.php");
include(
"inc/config.php");
include(
"lang/lang.php");

$themeurl grabanysetting("themeurl");

// **********************************************************************
// Define our top links by calling getlinks()
// **********************************************************************

$links getlinks();

// **********************************************************************
// Define our ads by calling getads()
// **********************************************************************

$ads getads("login");

// **********************************************************************
// Grab any dynamic article content from the content table
// **********************************************************************

$pagecontent getsitecontent("index");
$article_title $pagecontent[title];
$article_content $pagecontent[content];
$article_content nl2br($article_content);

// **********************************************************************
// Grab any settings that we will need for the current page from the DB
// **********************************************************************

$browsertitle grabanysetting("browsertitle");
$sitename grabanysetting("sitename");
$slogan grabanysetting("slogan");

// **********************************************************************
// Check and see if the user is logged in to the site
// **********************************************************************

$loginstatus logincheck();
$isloggedin $loginstatus[loginstatus];
$loggedinname $loginstatus[username];

// **********************************************************************
// End Prepwork - Output the page to the user
// **********************************************************************

if($isloggedin == "yes"){

$article_title $langislog;
$article_content $langislogfull;

}
else{

//User is not logged in, so let's attempt to log them in...

$username $_POST["username"];
$password $_POST["password"];

//Clean it up

$username preg_replace("/[^a-zA-Z0-9\\040.]/"""$username);

$username secure($username);
$password secure($password);

//User is not logged in

$loginform "<form name='form1' method='post' action='login.php'>
  <p>Username: 
    <input name='username' type='text' id='username'>
</p>
  <p>Password: 
    <input name='password' type='password' id='password'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit'>
  </p>
  <p>Don't have an account?<br>
  <a href='register.php'>Register Free</a>  </p>
  <a href='forgotpass.php'>Forgot your password?  Click Here</a>
</form>"
;



if(
$loggedinname == "" and $password == ""){
// User is viewing login form
$article_title "Member Login:";

$article_content $loginform;
}
else if((
$username != "" and $password == "") or ($username == "" and $password != "") ){

//Something was left blank
$article_title "Login Error:";
$article_content "Something was left blank.  Please try logging in again.<br><br>".$loginform."";

}
else if(
$username != "" and $password != ""){
// Try to log the user in
$password md5($password);

$query "SELECT * FROM ".$prefix."users WHERE username = '$username'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {

$luser=@mysql_result($result,$i,"username");
$lpass=@mysql_result($result,$i,"password");

$i++;
}

if(
$username == $luser and $password == $lpass){
$article_title "Login Successful!";
$article_content "Welcome back ".$username.".  You are now logged in.  <a href='account.php'>Click Here to view or edit your account.</a>";


// Set the cookie
$Month 2592000 time();
setcookie("auser",$username,$Month);
setcookie("apass",$password,$Month);

}
else{
$article_title "Login Failed!";
$article_content "Sorry, we could not log you on with the details specified.  You can <a href='login.php'>try again</a> or <a href='forgotpass.php'>request a password reset.</a>";
$fail 1;
}
}




}


// **********************************************************************
// Begin Template Definition
// **********************************************************************

//Define our current theme
$file $themeurl;

// Do the template changes and echo the ready template
$template file_get_contents($file);

$template replace(':ARTICLETITLE:',$article_title,$template);
$template replace(':ARTICLECONTENT:',$article_content,$template);
$template replace(':ARTICLEDATE:',$article_date,$template);

$template replace(':BROWSERTITLE:',$browsertitle,$template);
$template replace(':SITENAME:',$sitename,$template);

//Define our links
$template replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar "";
$template replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template replace(':ADS:',$ads,$template);

//Get the slogan info
$template replace(':SLOGAN:',$slogan,$template);


echo 
$template;

// **********************************************************************
// End Template Definition
// **********************************************************************



?>
That's it there. I have edited the database once, to chance the max adoption limit of an adoptable, but I don't think that would change anything...?
Hmm, well there is nothing wrong the page.
But what I have noticed when viewing your site, is that it logs you off (or says you have to be logged in) at random intervuls(wow cant spell today)
When I logged in (it let me log in btw) I went to check things out, went from index, to my account, back to index, and it says I was logged out.

So I logged in again, and I started navigating again, and it did the same.

This is something new.
I really don't know what is wrong with this one =/
Reply With Quote