You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.2 KiB
71 lines
2.2 KiB
14 years ago
|
<?php
|
||
|
/*
|
||
|
*
|
||
|
* @copyright (c) 2010 animegame.eu
|
||
|
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
include_once($_SERVER['DOCUMENT_ROOT'] . 'ag/include/config/server.inc.php');
|
||
|
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/cheater.inc.php');
|
||
|
|
||
|
|
||
|
function checkSessionPasswort($userid, $password){
|
||
|
$sql = 'SELECT passwort from user where id = \''.$userid.'\'';
|
||
|
$row = mysql_fetch_assoc(mysql_query($sql));
|
||
|
if($row['passwort'] != null){
|
||
|
// echo $password.' == '.$row['passwort'];
|
||
|
return $password == $row['passwort'];
|
||
|
} else{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
function checkCookiePassword($username, $password){
|
||
|
$sql = 'SELECT passwort from user where nickname = \''.$username.'\'';
|
||
|
$row = mysql_fetch_assoc(mysql_query($sql));
|
||
|
if($row['passwort'] != null){
|
||
|
return $password == $row['passwort'];
|
||
|
} else{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function checkLoginPassword($username, $password){
|
||
|
$sql = 'SELECT SHA1(AES_ENCRYPT(\''.$password.'\',\''.$GLOBALS['PW_AES_KEY'].'\')) as encrypt_password, passwort from user where nickname = \''.$username.'\'';
|
||
|
// echo $sql.'<br>';
|
||
|
$row = mysql_fetch_assoc(mysql_query($sql));
|
||
|
if($row){
|
||
|
if($row['encrypt_password'] != $row['passwort'] && md5($password) == $row['passwort']){
|
||
|
setPassword($username, $password);
|
||
|
return true;
|
||
|
} else{
|
||
|
return $row['encrypt_password'] == $row['passwort'];
|
||
|
}
|
||
|
} else{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function setCookies($nick_name, $password){
|
||
|
checkCookies($nick_name, $_COOKIE['yps']);
|
||
|
$row = mysql_fetch_assoc(mysql_query('select SHA1(AES_ENCRYPT(\''.$password.'\',\''.$GLOBALS['PW_AES_KEY'].'\')) as pw'));
|
||
|
setcookie('name',$nick_name,time()+864000);
|
||
|
setcookie('passwort',$row['pw'],time()+864000);
|
||
|
setcookie('yps',$nick_name.','.md5($nick_name),time()+864000);
|
||
|
}
|
||
|
|
||
|
function setPassword($username, $password){
|
||
|
$sql = 'UPDATE user set passwort = SHA1(AES_ENCRYPT(\''.$password.'\',\''.$GLOBALS['PW_AES_KEY'].'\')) where nickname = \''.$username.'\'';
|
||
|
// echo $sql.'<br>';
|
||
|
mysql_query($sql);
|
||
|
}
|
||
|
|
||
|
function encryptPassword($password){
|
||
|
$sql = 'SELECT SHA1(AES_ENCRYPT(\''.$password.'\',\''.$GLOBALS['PW_AES_KEY'].'\')) as pw';
|
||
|
$result = mysql_fetch_assoc(mysql_query($sql));
|
||
|
return $result['pw'];
|
||
|
}
|
||
|
|
||
|
?>
|