jamesxg1 Posted December 6, 2009 Share Posted December 6, 2009 Hiya peeps, i dont understand this. Login.php (login page) <?php session_start(); error_reporting(-1); include '../includes/login/login.php'; include '../includes/mysql/dbConnector.php'; $m = new DbConnector(); $m->DbConnector(); $login = new memberLogin(); if(isset($_POST['submit']) && isset($_POST['username']) && isset($_POST['password'])): $login->setValues($_POST['username'], $_POST['password']); endif; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Login</title> <!-- CSS --> <link href="assets/css/transdmin.css" rel="stylesheet" type="text/css" media="screen" /> <!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="assets/css/ie6.css" /><![endif]--> <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="assets/css/ie7.css" /><![endif]--> <!-- JavaScripts--> <script type="text/javascript" src="assets/js/jquery.js"></script> <script type="text/javascript" src="assets/js/jNice.js"></script> </head> <body> <div id="wrapper"> <h1></h1> <ul id="mainNav"> <li><a href="#" class="active">ACCOUNT</a></li> </ul> <div id="containerHolder"> <div id="container"> <div id="sidebar"> <ul class="sideNav"> <li><a href="login.php" class="active">Login</a></li> <li><a href="register.php">Register</a></li> <li><a href="lostPassword.php">Lost Password</a></li> <li><a href="lostUsername.php">Lost Username</a></li> <li><a href="suspendedAccount.php">Suspended Account</a></li> </ul> </div> <h2><a href="#">Dashboard</a> » <a href="#" class="active">Login.</a></h2> <div id="main"> <form action="" method="post" class="jNice"> <fieldset> <?php if(isset($error)): echo $error; endif; ?> <p><label>Username:</label><input type="text" class="text-long" name="username"/></p> <p><label>Password:</label><input type="password" class="text-long" name="password"/></p> <input type="submit" value="Submit" name="submit" /> </fieldset> </form> </div> <div class="clear"></div> </div> </div> <p id="footer">Feel free to use and customize it. <a href="http://www.perspectived.com">Credit is appreciated.</a></p> </div> </body> </html> Login.php (processing script) <?php error_reporting(-1); class memberLogin { private $username; private $password; private $error = ''; function setValues($username, $password) { $this->_username = $username; $this->_password = $password; $this->checkLoggedIn(); } function checkLoggedIn() { if(isset($_SESSION['username']) && isset($_SESSION['id']) && isset($_SESSION['access'])): if($_SESSION['access'] == 'A'): echo '<meta http-equiv="refresh" content="0;url=../admin/index.php">'; elseif ($_SESSION['access'] == 'C'): echo '<meta http-equiv="refresh" content="0;url=../user/index.php">'; endif; else: $this->checkDefence(); endif; } function checkDefence() { $this->_now = time() + 50*60; if(isset($_SESSION['bcount']) && isset($_SESSION['tl']) && $_SESSION['bcount'] >= 3) : if($this->_now >= $_SESSION['tl']) { session_unset(); session_destroy(); $this->checkValues(); } else { $_SESSION['tl'] = $_SESSION['tl'] + 1*60; $this->returnError('5'); } else: $this->checkValues(); endif; } function checkValues() { if(!empty($this->_username) && !empty($this->_password)): $this->checkSafe(); else: $this->returnError('1'); endif; } function checkSafe() { $this->_username = strtolower($this->_username); $this->_username = preg_replace("/[&<>%\*\,\.\_\-\^\!\(\)\$\£\+\=\'\#\~\?\/\:\;\{\}\/]/i",'', $this->_username); $this->_username = mysql_real_escape_string(trim($this->_username)); $this->_password = strtolower($this->_password); $this->_password = preg_replace("/[&<>%\*\,\.\_\-\^\!\(\)\$\£\+\=\'\#\~\?\/\:\;\{\}\/]/i",'', $this->_password); $this->_salt = bin2hex(sha1(md5(mhash(MHASH_CRC32, 'pepper65298')))); $this->_password = bin2hex(sha1(md5(mhash(MHASH_CRC32, $this->_salt . $this->_password . $this->_salt)))); $this->_password = mysql_real_escape_string(trim($this->_password)); $this->checkUsername(); } function checkUsername() { $this->_usernameSQL = "SELECT `username` FROM `members` WHERE username = '$this->_username'"; $this->_usernameResult = mysql_query($this->_usernameSQL) or trigger_error('<font color="red" size="6"><b>ERROR ID: 1934</b></font>' . mysql_error(), E_USER_ERROR); if(mysql_num_rows($this->_usernameResult) >= '1'): $this->checkPassword(); else: $this->bruteAttackDefence(); $this->returnError('2'); endif; } function checkPassword() { $this->_passwordSQL = "SELECT `password` FROM `members` WHERE password = '$this->_password' AND username = '$this->_username'"; $this->_passwordResult = mysql_query($this->_passwordSQL) or trigger_error('<font color="red" size="6"><b>ERROR ID: 1935</b></font>' . mysql_error(), E_USER_ERROR); while($this->ps = mysql_fetch_assoc($this->_passwordResult)): if(!$this->_password == $this->ps['password']): $this->bruteAttackDefence(); $this->returnError('3'); else: $this->checkSuspended(); endif; endwhile; } function checkSuspended() { $this->_suspendedSQL = "SELECT `ban`, `bantime` FROM `members` WHERE username = '$this->_username'"; $this->_suspendedResult = mysql_query($this->_suspendedSQL) or trigger_error('<font color="red" size="6"><b>ERROR ID: 1936</b></font>' . mysql_error(), E_USER_ERROR); $this->_nd = date('Y-m-d'); while($this->_sd = mysql_fetch_assoc($this->_suspendedResult)): if($this->_sd['ban'] == '2'): $this->checkStatus(); elseif ($this->_sd['ban'] == '1'): if($this->_nd >= $this->_sd['bantime']): $this->checkStatus(); else: $this->_btime = $this->_sd['bantime']; $this->returnError('4'); $this->bruteAttackDefence(); endif; endif; endwhile; } function checkStatus() { $this->_adminSQL = "SELECT `admin` FROM `members` WHERE username = '$this->_username'"; $this->_adminResult = mysql_query($this->_adminSQL) or trigger_error('<font color="red" size="6"><b>ERROR ID: 1937</b></font>' . mysql_error(), E_USER_ERROR); while($this->_ad = mysql_fetch_assoc($this->_adminResult)): if($this->_ad['admin'] == '2'): $this->memberAdmin(); elseif ($this->_as['admin'] == '1'): $this->memberUser(); endif; endwhile; } function memberAdmin() { $this->_aSetSQL = "SELECT `username`, `id` FROM `members` WHERE username = '$this->_username' AND password = '$this->_password' AND admin = '2'"; $this->_aSetResult = mysql_query($this->_aSetSQL) or trigger_error('<font color="red" size="6"><b>ERROR ID: 1938</b></font>' . mysql_error(), E_USER_ERROR); while($this->_aset = mysql_fetch_assoc($this->_aSetResult)): $_SESSION['username'] = $this->_aset['username']; $_SESSION['id'] = $this->_aset['id']; $_SESSION['access'] = 'A'; endwhile; if(isset($_SESSION['username']) && isset($_SESSION['id']) && isset($_SESSION['access'])): $this->_date = date('Y-m-d'); $this->_time = date('H:i:s'); $this->loginLog(); echo '<meta http-equiv="refresh" content="0;url=../admin/index.php">'; else: $this->returnError('6'); endif; } function memberUser() { $this->_uSetSQL = "SELECT `username`, `id` FROM `members` WHERE username = '$this->_username' AND password = '$this->_password' AND admin = '1'"; $this->_uSetResult = mysql_query($this->_uSetSQL) or trigger_error('<font color="red" size="6"><b>ERROR ID: 1939</b></font>' . mysql_error(), E_USER_ERROR); while($this->_uset = mysql_fetch_assoc($this->_uSetResult)): $_SESSION['username'] = $this->_uset['username']; $_SESSION['id'] = $this->_uset['id']; $_SESSION['access'] = 'C'; endwhile; if(isset($_SESSION['username']) && isset($_SESSION['id']) && isset($_SESSION['access'])): $this->_date = date('Y-m-d'); $this->_time = date('H:i:s'); $this->loginLog(); echo '<meta http-equiv="refresh" content="0;url=../user/index.php">'; else: $this->returnError('6'); endif; } function loginLog() { $this->_lLogSQL = "INSERT INTO `loginlogs` (`username`, `date`, `time`) VALUES('$this->_username', '$this->_date', '$this->_time')"; $this->_lLogResult = mysql_query($this->_lLogSQL) or trigger_error('<font color="red" size="6"><b>ERROR ID: 1940</b></font>' . mysql_error(), E_USER_ERROR); } function bruteAttackDefence() { if(!isset($_SESSION['tl'])): $_SESSION['tl'] = time() + 30*60; if(@$_SESSION['bcount'] < 3): @$_SESSION['bcount'] = $_SESSION['bcount']+1; else: $this->returnError('5'); endif; else: if($_SESSION['bcount'] < 3): $_SESSION['bcount'] = $_SESSION['bcount']+1; else: $this->returnError('5'); endif; endif; } function returnError($error = '') { $this->_error = mysql_real_escape_string(trim($error)); $this->_eGetSQL = "SELECT `description` FROM `errors` WHERE id = '$this->_error' AND page = '1'"; $this->_eGetResult = mysql_query($this->_eGetSQL) or trigger_error('<font color="red" size="6"><b>ERROR ID: 1940</b></font>' . mysql_error(), E_USER_ERROR); while($this->_er = mysql_fetch_assoc($this->_eGetResult)): if($this->_error == '4'): $this->_ctent = '<br /><br />' . $this->_er['description'] . '<br />Account reactivation is due on the ' . $this->_btime . '.<br /><a href="pages/accountsuspended.php">Why is my account suspended?</a>'; echo $this->_ctent; else: echo $this->_er['description']; endif; endwhile; } } ?> Nothing is being returned :S. Many thanks James. Quote Link to comment https://forums.phpfreaks.com/topic/184142-class-is-not-returning-help/ Share on other sites More sharing options...
oni-kun Posted December 6, 2009 Share Posted December 6, 2009 First, I'm not sure what "-1" is for your error reporting, set it to error_reporting(E_ALL); and maybe it'll help? What is not returning? You should tell us what you're trying to do and give us the relevant code and errors. Quote Link to comment https://forums.phpfreaks.com/topic/184142-class-is-not-returning-help/#findComment-972210 Share on other sites More sharing options...
jamesxg1 Posted December 6, 2009 Author Share Posted December 6, 2009 First, I'm not sure what "-1" is for your error reporting, set it to error_reporting(E_ALL); and maybe it'll help? What is not returning? You should tell us what you're trying to do and give us the relevant code and errors. -1 is evey error displayed lol. and $this->returnError() they were returning but now i have implamented the code into my new login script it isnt working. Many thanks James. Quote Link to comment https://forums.phpfreaks.com/topic/184142-class-is-not-returning-help/#findComment-972212 Share on other sites More sharing options...
trq Posted December 6, 2009 Share Posted December 6, 2009 Your going to need to clarify your problem once again I'm afraid. Quote Link to comment https://forums.phpfreaks.com/topic/184142-class-is-not-returning-help/#findComment-972224 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.