// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
error_reporting(E_ALL ^ E_NOTICE);
$_SESSION['McMember_MemId'] = "";
$_SESSION['McMember_OrgId'] = "";
// Sessions will expire after this many seconds
$session_expiration = 1800; // 30 minutes
// Get the PHP file containing the DbConnector class
require_once('DbConnector.php');
// Create an instance of DbConnector
$connector = new DbConnector();
function Encrypt($string) {//hash then encrypt a string
$crypted = crypt(md5($string), md5($string));
return $crypted;
}
$ip = (getenv(HTTP_X_FORWARDED_FOR))
? getenv(HTTP_X_FORWARDED_FOR)
: getenv(REMOTE_ADDR);
$theUID=$_POST['username'];
$thePASS=$_POST['password'];
If (!is_null($theUID) && !is_null($thePASS)){
$auth = false;
$qVals11 = "SELECT MemID,Deleted, UPASS FROM mem WHERE UID ='".$theUID."'";
// echo $qVals11;
$result = $connector->query($qVals11);
// Get the result
$nrows = mysql_num_rows($result);
$row = $connector->fetchArray($result);
if ($nrows<1){
$_SESSION['McMember_FailureReason'] = "MemberAccountDoesNotExist".
$_SESSION['McMember_MemId'] = "";
$_SESSION['McMember_OrgId'] = "";
header("Location: Error.php");
}
$pass = $row['UPASS'];
$_SESSION['McMember_MemId'] = $row['MemID'];
$HasBeenDeleted= $row['Deleted'];
if($HasBeenDeleted){
$_SESSION['McMember_FailureReason'] = "MemberAccountHasBeenDeleted".
header("Location: Error.php");
}
// echo $password;
// echo $pass;
if ($pass == (Encrypt($thePASS))) {
$auth = true;
$success = true;
}
if ($auth == true){
$_SESSION['McMember_MemId'] = $row['MemID'];
$qVals10 = "SELECT * FROM oda WHERE MemId =".$row['MemID'];
$result2 = $connector->query($qVals10);
// Get the result
$row = $connector->fetchArray($result2);
if (!empty($row)){
$_SESSION['McMember_OrgId'] =$row['OrgId'];
header("Location: OrgAdmin.php");
}
else{
}
// $_SESSION['McMember_OrgId'] =1;
header("Location: OrgAdmin.php");
}
}
else{
echo "Please ensure that a UserName and Password are entered.
";
echo "FAILURE CODE: ".$_SESSION['McMember_FailureReason'];
$success = false;
}
?>
Please log in below... if ($_SESSION['McMember_LoggedIn'] != "TRUE"){ echo ''; }else{ echo "You are already logged in. Continue"; } ?> |