';
$row = mysqli_fetch_assoc(db_query($sql));
if($row){
if($row['passwort'] == $pw) {
return true; // already bcrypt based!
}
if($row['encrypt_password'] == $row['passwort'] || md5($password) == $row['passwort']){
setPassword($username, $password);
return true;
}
}
return false;
}
function setCookies($nick_name, $password){
$pw = encryptPassword($password);
checkCookies($nick_name, $_COOKIE['yps']);
setcookie('name',$nick_name,time()+864000);
setcookie('passwort',$pw,time()+864000);
setcookie('yps',$nick_name.','.md5($nick_name),time()+864000);
}
function setPassword($username, $password){
$pw = encryptPassword($password);
$sql = 'UPDATE user set passwort = \''.$pw.'\' where nickname = \''.$username.'\'';
// echo $sql.'
';
db_query($sql);
}
function encryptPassword($password){
$pw = password_hash($password, PASSWORD_BCRYPT, array('salt' => $GLOBALS['PW_AES_KEY']));
return $pw;
}
function getUserMetaData($userid) {
$sql = 'SELECT * FROM user_meta_data WHERE user_id = ' . $userid;
$qry = silent_query($sql);
$result = array();
if(!$qry)
{
echo $sql .'
';
return $result;
}
while ($row = mysqli_fetch_assoc($qry)) {
$result[$row['key']] = $row['value'];
}
return $result;
}
function setUserMetaDataEntry($userid, $key, $value) {
$sql = 'UPDATE user_meta_data SET `value` = \''.$value.'\' WHERE user_id = \''.$userid.'\' and `key` = \''.$key.'\'';
$qry = db_query($sql);
if(!qry)
return;
if(db_affected_rows() > 0)
return;
$sql = 'INSERT INTO user_meta_data(user_id, `key`, `value`) values (\''.$userid.'\',\''.$key.'\',\''.$value.'\')';
$qry = db_query($sql);
}
?>