Sorry, was a bit confused when I tried to explain what the page does, since I'm working on like 10 pages at the time.
The page I'm talkig about is checking if the users status is set to 1 or not (if they have been activated).
It's also setting a couple of Session stuff to be used later on following pages.
But here is the code that is corrupted.
(oh, by the way, the ++ thing is working. So I don't need to change that.)
PHP Code:
<?php require_once('Connections/connection_code.php'); ?>
<?php
session_start();
$MM_authorizedUsers = "1";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "wrong.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
$colname_rs_user = "1";
if (isset($_SESSION['MM_Username'])) {
$colname_rs_user = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_website_com, $website_com);
$query_rs_user = sprintf("SELECT * FROM table_user WHERE username = '%s'", $colname_rs_user);
$rs_user = mysql_query($query_rs_user, $website_com) or die(mysql_error());
$row_rs_user = mysql_fetch_assoc($rs_user);
$totalRows_rs_user = mysql_num_rows($rs_user);
if($row_rs_user['status'] = 1){
// Register some session variables!
session_register('usr_id');
$_SESSION['usr_id'] = $row_rs_user['user_id'];
session_register('usrname');
$_SESSION['usrname'] = $row_rs_user['username'];
session_register('passwrd');
$_SESSION['passwrd'] = $row_rs_user['password'];
session_register('typ');
$_SESSION['typ'] = $row_rs_user['type'];
session_register('state');
$_SESSION['state'] = $row_rs_user['status'];
session_register('updated');
$_SESSION['updated'] = $row_rs_user['updated'];
$usr_id = $row_rs_user['user_id'];
mysql_query("UPDATE table_user SET usr_times=usr_times++1, usr_last=now() WHERE user_id='$usr_id'");
//mysql_free_result($rs_user);
header("Location: index_in.php"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
} else {
//mysql_free_result($rs_user);
header("Location: status_no.php");
exit;
}
?>
A lot of code is generated by Dreamweaver (which is what I'm working with here).
Bookmarks