Mam taki kod (nie moj) w ktorym musze wcisnac warunek aby blokowac innego uzytkownika ktory probuje sie zalogowac:
login
function login($showform = true, $redir = '/monitor') {
$_aa['logged_in'] = false;
// If login data present, check the key
if (isset($_COOKIE['aausr'])) { $id = @intval($_COOKIE['aausr']);
if ("$id" == $_COOKIE['aausr']) {
$row = mysql_fetch_assoc(make_user_query
('try_db_query', "SELECT * FROM <TABLE_USER> WHERE `id`='$id' LIMIT 1")); //print_r($row);
if (is_array($row) && ($row['key'] == $_COOKIE['aakey'])) { if ($row['license_id'] > 0) {
$_aa['logged_in'] = ($row['key'] == make_user_query('db_getv', "SELECT * FROM <TABLE_USER> WHERE `id`='" . ($row['license_id']) . "' LIMIT 1"));
} else
$_aa['logged_in'] = true;
if ($_aa['logged_in']) {
$security->setLogged($row);
}
}
}
}
// If not logged in, display form
if (!$_aa['logged_in']) {
if ($_POST['s'] == 'login') {
$_POST['login'] = trim($_POST['login']); $_POST['pass'] = trim($_POST['pass']); //echo "CHeck";
$res = loginCheck($_POST);
//print_r($res);
if ($res['ok'] == 1) {
if ($res['active'] != 3) {
if (!$_COOKIE['pcid']) {
$_COOKIE['pcid'] = md5('dasdas' . rand()); setcookie('pcid', $_COOKIE['pcid'], time() + 1500 * 24 * 3600, '/'); }
$security->setLogged($res['row']);
}
$_aa['logged_in'] = true;
// Update last and current visit times, to enable tracking of new and old results
make_user_query
('try_db_query', $sql = "UPDATE <TABLE_USER> SET `last_visit`='{$_aa['curr_visit']}', `curr_visit`='" . time() . "' WHERE `id`='{$_aa['id']}'");
if ($_aa['license_id'] > 0)
make_user_query('try_db_query', $sql = "UPDATE <TABLE_USER> SET `key`='" . $res['key'] . "' WHERE `id`='{$_aa['license_id']}'");
make_user_query('try_db_query', "INSERT INTO <TABLE_EVENTS> VALUES ('',
'{$_aa['id']}',
NOW(),
'login',
$_aa['last_visit'] = $_aa['curr_visit'];
}
} else
}
if ($_aa['logged_in'] && strlen($redir) > 0
) { header('Location: ' . $redir); } else
return true;
}
logout
function logout($logged_in) {
// if ($logged_in == true) {
// die();
// } else {
$_aa['logged_in'] = false;
unset($_COOKIE['aausr']); $security->setAuthenticated(false);
$security->clear();
containerStart(true);
return message($lg['logged_out'], $lg['logged_out_explain']);
}
// }
}
Niby w bazie jest trzymany last visit current visit ale jak zablokowac na tej podstawie probe logowania innego uzytkownika hmmm?