Fatal Error - unable to redeclare password_hashin line 143

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mirnasim
Forum Newbie
Posts: 1
Joined: Thu Mar 20, 2014 6:06 am

Fatal Error - unable to redeclare password_hashin line 143

Post by mirnasim »

Started getting the below error since the upgrade of PH version:
Fatal error - unable to redeclare password_hash in includes/functions_login.php on line 143
Here is the code below:

140 function password_hash ($password, $salt)
141 {
142 return md5(md5($password) . $salt);
143 }
144
145 function login_spoofer ($username, $admin_username, $admin_password)
146 {
147 global $db;
148 (array) $login_output = NULL;
149
150 $login_query = $db->query("SELECT * FROM " . DB_PREFIX . "admins WHERE
username='" . $admin_username . "' AND password='" . md5($admin_password) . "' AND level='1' LIMIT 0,1");

$is_login = $db->num_rows($login_query);

$login_output['admin_exists'] = false;
if ($is_login)
{
$login_output = login_user($username, '', '', true);
$login_output['admin_exists'] = true;
}

return $login_output;
}

Could you please advise how this can be fixed and the passwords are still checked and validated. The simpler the better as I am very new to this.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Fatal Error - unable to redeclare password_hashin line 1

Post by Celauran »

password_hash is a core function as of PHP 5.5. You'll need to rename your function or, better, make use of the built in.
Post Reply