Hashcheck on user object fails

I am trying to figure out why some Zenphoto installs fail on this object when not set on security "MD5" and not others installs ..
Looking for some insight (I can login just fine on zenphoto but fails on others things from a plugin..
==============
TEST CODE
$user = 'admin';
$password = 'password ';
function newAdministrator($name, $valid=1) {
$user = new Zenphoto_Administrator($name, $valid);
return $user;
}

function getAnAdmin($criteria) {
$selector = array();
foreach ($criteria as $match=>$value) {
if (is_numeric($value)) {
$selector[] = $match.$value;
} else {
$selector[] = $match.db_quote($value);
}
}
$sql = 'SELECT * FROM '.prefix('administrators').' WHERE '.implode(' AND ',$selector).' LIMIT 1';
$admin = query_single_row($sql,false);
if ($admin) {
return newAdministrator($admin['user'], $admin['valid']);
} else {
return NULL;
}
}

$hash = $_zp_authority->passwordHash($user, $password);
$userobj = $_zp_authority->getAnAdmin(array('`user`=' => $user, '`pass`=' => $hash, '`valid`=' => 1));
echo 'Current User Object: '.$userobj.'</BR>';
$hashcheck = getAnAdmin(array('`user`=' => $user, '`valid`=' => 1));
echo ("check hash: ".$userobj->get('passhash')).'</BR>';
$hash_type = getOption('strong_hash');
echo ("Hashtype: " .$hash_type).'</BR>';

<b>Fatal error</b>: Call to a member function get() on a non-object in <b>/public_html/philbertphotos.com/signature/themes/ZenSignature/image.php</b> on line <b>47</b>

Comments

  • For now I fixed the issue by using the function "getAnAdmin" I found someone using for ZenLdap and it fixes the problem even if it may not be the best way. This should correct aa lot of login issues that myself and others were having.
Sign In or Register to comment.