Parašė sniuff· 2009 Sau. 3 00:01:50
#5
Dabar žiūrim ką turim:
if (isset($_POST['login']) && isset($_POST['user_name']) && isset($_POST['user_pass'])) {
$user_name = stripinput($_POST['user_name']);
$user_pass = md5(sha1($_POST['user_pass']));
$result = dbquery("SELECT * FROM ".DB_PREFIX."members WHERE user_name='".$user_name."' AND user_pass='".md5($user_pass)."' LIMIT 1");
if (dbrows($result)) {
$data = dbarray($result);
$cookie_value = $data['user_id'].".".$user_pass;
if ($data['user_status'] == 0) {
$cookie_exp = isset($_POST['remember_me']) ? time() + 3600 * 24 * 30 : time() + 3600 * 3;
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie(COOKIE_PREFIX."user", $cookie_value, $cookie_exp, "/", "", "0");
$last_visit = dbquery("UPDATE ".DB_PREFIX."members SET user_last_visit='".time()."' WHERE user_name='".$user_name."'");
redirect(BASEDIR."./", true);
} elseif ($data['user_status'] == 1) {
redirect(BASEDIR."setuser.php?error=1", true);
} elseif ($data['user_status'] == 2) {
redirect(BASEDIR."setuser.php?error=2", true);
}
} else {
redirect(BASEDIR."setuser.php?error=3");
}
}
if (isset($_COOKIE[COOKIE_PREFIX.'user'])) {
die();
$cookie_vars = explode(".", $_COOKIE[COOKIE_PREFIX.'user']);
$cookie_1 = isNum($cookie_vars['0']) ? $cookie_vars['0'] : "0";
$cookie_2 = (preg_match("/^[0-9a-z]{32}$/", $cookie_vars['1']) ? $cookie_vars['1'] : "");
$result = dbquery("SELECT * FROM ".DB_PREFIX."members WHERE user_id='$cookie_1' AND user_pass='".md5($cookie_2)."'");
unset($cookie_vars,$cookie_1,$cookie_2);
if (dbrows($result) != 0) {
$userdata = dbarray($result);
if ($userdata['user_status'] == 0) {
define("THEME", THEMES.$settings['theme']."/");
if (empty($_COOKIE[COOKIE_PREFIX.'last_visit'])) {
setcookie(COOKIE_PREFIX."last_visit", $userdata['user_last_visit'], time() + 3600, "/", "", "0");
$last_visited = $userdata['user_last_visit'];
} else {
$last_visited = $_COOKIE[COOKIE_PREFIX.'last_visit'];
}
} else {
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie(COOKIE_PREFIX."user", "", time() - 7200, "/", "", "0");
setcookie(COOKIE_PREFIX."last_visit", "", time() - 7200, "/", "", "0");
redirect(BASEDIR."1", "script");
}
} else {
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie(COOKIE_PREFIX."user", "", time() - 7200, "/", "", "0");
setcookie(COOKIE_PREFIX."last_visit", "", time() - 7200, "/", "", "0");
redirect(BASEDIR."2", "script");
}
} else {
define("THEME", THEMES.$settings['theme']."/");
$userdata = ""; $userdata['user_level'] = 0; $userdata['user_rights'] = ""; $userdata['user_groups'] = "";
}
Ir kai bandai prisijungti nichuja niekas nesikeičia, neprijungia tiesiog, permeta tiesiog į index.php ir niekas.
Aš suprantu lyg, nenustatytų cookies, nes atidaro, o nereguoja į die()...
Ten kur bold nekreipkit dėmesio.