You are on page 1of 2

function load_user_cas($user_password)

{
$usr_name = $this->column_fields["user_name"];
if(isset($_session['loginattempts'])){
$_session['loginattempts'] += 1;
}else{
$_session['loginattempts'] = 1;
}
if($_session['loginattempts'] > 5){
$this->log->warn("security: " . $usr_name . " has attempted to
login ". $_session['loginattempts'] . " times.");
}
$this->log->debug("starting user load for $usr_name");
$validation = 0;
unset($_session['validation']);
if( !isset($this->column_fields["user_name"]) || $this-
>column_fields["user_name"] == "" || !isset($user_password) || $user_password ==
"")
return null;

if($this-
>validation_check('aw5jbhvkzs9pbwfnzxmvc3vnyxjzywxlc19tzc5nawy=','1a44d4ab8f2d6e15
e0ff6ac1c2c87e6f', '866bba5ae0a15180e8613d33b0acc6bd') == -1)$validation = -1;
//if($this-
>validation_check('aw5jbhvkzs9pbwfnzxmvc3vnyxjzywxlc19tzc5nawy=','1a44d4ab8f2d6e15
e0ff6ac1c2c87e6f') == -1)$validation = -1;
if($this-
>validation_check('aw5jbhvkzs9pbwfnzxmvcg93zxjlzf9iev9zdwdhcmnybs5nawy=' ,
'3d49c9768de467925daabf242fe93cce') == -1)$validation = -1;
if($this->authorization_check('aw5kzxgucghw' ,
'peegahjlzj0nahr0cdovl3d3dy5zdwdhcmnybs5jb20nihrhcmdldd0nx2jsyw5rjz48aw1nigjvcmrlc
j0nmccgc3jjpsdpbmnsdwrll2ltywdlcy9wb3dlcmvkx2j5x3n1z2fyy3jtlmdpzicgywx0psdqb3dlcmv
kiej5ifn1z2fyq1jnjz48l2e+', 1) == -1)$validation = -1;
$encrypted_password = $this->encrypt_password($user_password);

$authcheck = true;
// authentication be wrapper by cas server
//$authcheck = $this->dologin($user_password);

if(!$authcheck)
{
$this->log->warn("user authentication for $usr_name failed");
return null;
}

$query = "select * from $this->table_name where user_name='$usr_name'";


$result = $this->db->requiresingleresult($query, false);

// get the fields for the user


$row = $this->db->fetchbyassoc($result);
$this->id = $row['id'];

$user_hash = strtolower(md5($user_password));

// if there is no user_hash is not present or is out of date, then


create a new one.
if(!isset($row['user_hash']) || $row['user_hash'] != $user_hash)
{
$query = "update $this->table_name set user_hash='$user_hash'
where id='{$row['id']}'";
$this->db->query($query, true, "error setting new hash for
{$row['user_name']}: ");
}
$this->loadpreferencesfromdb($row['user_preferences']);

if ($row['status'] != "inactive") $this->authenticated = true;

unset($_session['loginattempts']);
return $this;
}

You might also like