More secure logins
config_foodweb.php
Find this around line 19:
define("TABLE_AUTH",TABLE_MEMBER);//authentication tokens are in the member table
Replace that line with this:
define("TABLE_AUTH","auth_users_c");
Find this around line 126:
function login ($username_c, $password) {
Delete the login function and the check_valid_user function, deleting all up though line 150, leaving this:
$font= "<font size=-1 face=arial>";
Add this function right above that:
function check_valid_user() {
if(!$_SESSION['valid_c']){
header( "Location: show_login.php");
exit;
}
}
config_foodweb_orders.php
Find this around line 19:
define("TABLE_AUTH",TABLE_MEMBER);//authentication tokens are in the member table
Replace that line with this:
define("TABLE_AUTH","auth_users_c");
Find this around line 117:
function login ($username_m, $password) {
Delete the login function and the check_valid_user function, deleting all up though line 141, leaving this:
$font= "<font size=-1 face=arial>";
Add this function right above that:
function check_valid_user() {
if(!$_SESSION['valid_m']){
header( "Location: orders_login.php");
exit;
}
}
shop/members/orders_login.php
Find this around line 82:
echo "$site_name";
Replace with:
echo SITE_NAME;
Find this around line 5:
if ($gp == "ds") {
Through this around line 74:
include("template_hdr_orders.php");?>
Delete all of that (make sure not to delete the ../../../config_ line) and replace it with this:
$show_form = "yes";
if ($_POST['gp'] == "ds" && $_POST['username_m'] && $_POST['password']) {
$sql = mysql_query("SELECT username_m FROM ".TABLE_MEMBER."
WHERE username_m = '".mysql_real_escape_string($_POST['username_m'])."'
AND password = md5('".mysql_real_escape_string($_POST['password'])."')");
if (mysql_numrows($sql) != 0) {
$row = mysql_fetch_array($sql);
$_SESSION["username_m"] = $row['username_m'];
$_SESSION["valid_m"] = $row['username_m'];
header("Location: index.php");
exit;
} else {
$msg = "Login incorrect. Please re-enter your login information.";
}
}
$form_block = '
<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="login">
'.$msg.'
<table>
<tr><td><b>Username</b>:</td><td>
<input type="text" name="username_m" size="17" maxlength="20">
</td></tr>
<tr><td><b>Password</b>:</td><td>
<input type="password" name="password" size="17" maxlength="25">
</td></tr>
<tr><td colspan="2" align="right">
<input type="hidden" name="gp" value="ds">
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<div style="text-align:left;font-size:11px;">
<a href="reset_password.php">Forgot your password?</a>
</div>
';
if ($show_form == "yes") {
$display_block = $form_block;
}
include("template_hdr_orders.php");?>
shop/members/index.php
Find this around line 13:
if ($username_m && $password) {
Through this around line 22:
check_valid_user();
Delete all of that (make sure not to delete the ../../../config_ line). Then on line 4, or the next line after session_start();, paste this:
check_valid_user();
Find this around line 321:
Update Your<br>Contact Info</a></b>
Make a new line after it and add this:
<br /><strong><a href="reset_password.php">Change Password</a></strong>
shop/admin/show_login.php
Find this around line 6:
if ($op == "ds") {
Through this around line 66:
include("template_hdr.php");?>
Delete all of that and replace it with this:
$show_form = "yes";
if ($_POST['op'] == "ds" && $_POST['username_c'] && $_POST['password']) {
$sql = mysql_query("SELECT username_c FROM ".TABLE_AUTH."
WHERE username_c = '".mysql_real_escape_string($_POST['username_c'])."'
AND password = md5('".mysql_real_escape_string($_POST['password'])."')");
if (mysql_numrows($sql) != 0) {
$row = mysql_fetch_array($sql);
$_SESSION["username_c"] = $row['username_c'];
$_SESSION["valid_c"] = $row['username_c'];
header("Location: index.php");
exit;
} else {
$msg = "Login incorrect. Please re-enter your login information.";
}
}
$form_block = '
<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="login">
'.$msg.'
<table>
<tr><td><b>Username</b>:</td><td>
<input type="text" name="username_c" size="17" maxlength="20">
</td></tr>
<tr><td><b>Password</b>:</td><td>
<input type="password" name="password" size="17" maxlength="25">
</td></tr>
<tr><td colspan="2" align="right">
<input type="hidden" name="op" value="ds">
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
';
if ($show_form == "yes") {
$display_block = $form_block;
}
include("template_hdr.php");?>
shop/admin/index.php
Find this around line 5:
if ($username_c && $password) {
Through this around line 14:
check_valid_user();
Delete all of that. Then on line 4, or the next line after session_start();, paste this:
check_valid_user();