PHP interesse |
|
hey mijn vraag is of deze code veilig is ?
<? include("_include-config.php");
if(isset($_POST['login'],$_POST['pass'])) {
$dbres = mysql_query("SELECT `login`,`activated` FROM `[users]` WHERE `login`='{$_POST['login']}' AND `pass`=MD5('{$_POST['pass']}')");
if(($data = mysql_fetch_object($dbres)) && $data->activated == 1) {
$validate = md5(rand(0,1000));
setcookie("login",$data->login,time()+60*60*24,"/",".crimewar2004.com");
setcookie("validate",$validate,time()+60*60*24,"/",".crimewar2004.com");
mysql_query("REPLACE INTO `[online]`(`time`,`login`,`IP`,`validate`) values(NOW(),'{$_SERVER['REMOTE_ADDR']}','{$data->login}','$validate')");
$_SESSION['login'] = $data->login;
$_SESSION['IP'] = $_SERVER['REMOTE_ADDR'];
$dbres = mysql_query("SELECT *,UNIX_TIMESTAMP(`signup`) AS `signup` FROM `[users]` WHERE `login`='{$_SESSION['login']}'");
$_SESSION['data'] = mysql_fetch_object($dbres);
}
}
else if($_GET['x'] == "logout") {
mysql_query("DELETE FROM `[online]` WHERE `login`='{$_COOKIE['login']}' AND `validate`='{$_COOKIE['validate']}' AND `IP`='{$_SERVER['REMOTE_ADDR']}'");
setcookie("login",'',time()-24*60*60,"/","");
setcookie("validate",'',time()-24*60*60,"/","");
unset($_SESSION['login']);
unset($_SESSION['IP']);
unset($_SESSION['data']);
} ?>
<? include("_include-config.php"); if(isset($_POST['login'],$_POST['pass'])) { $dbres = mysql_query("SELECT `login`,`activated` FROM `[users]` WHERE `login`='{$_POST['login']}' AND `pass`=MD5('{$_POST['pass']}')"); setcookie("login",$data->login,time()+60*60*24,"/",".crimewar2004.com"); setcookie("validate",$validate,time()+60*60*24,"/",".crimewar2004.com"); mysql_query("REPLACE INTO `[online]`(`time`,`login`,`IP`,`validate`) values(NOW(),'{$_SERVER['REMOTE_ADDR']}','{$data->login}','$validate')"); $_SESSION['login'] = $data->login; $_SESSION['IP'] = $_SERVER['REMOTE_ADDR']; $dbres = mysql_query("SELECT *,UNIX_TIMESTAMP(`signup`) AS `signup` FROM `[users]` WHERE `login`='{$_SESSION['login']}'"); } } else if($_GET['x'] == "logout") { mysql_query("DELETE FROM `[online]` WHERE `login`='{$_COOKIE['login']}' AND `validate`='{$_COOKIE['validate']}' AND `IP`='{$_SERVER['REMOTE_ADDR']}'"); unset($_SESSION['login']); unset($_SESSION['data']); } ?>
doei
|