function b1n_logOut() { b1n_logAction('logoff', array(), '', 0); $_SESSION['player'] = ''; unset($_SESSION['player']); return session_destroy(); }
function b1n_sessionGC($life_time) { global $ses_sql; if (isset($_REQUEST['PHPSESSID'])) { $ses_id = $_REQUEST['PHPSESSID']; } else { $ses_id = ''; } $query = "\n SELECT\n ses_id, ses_ip,\n ses_data, ses_last_updated\n FROM\n session\n WHERE\n (CURRENT_TIMESTAMP - ses_last_updated)::interval >\n '" . $life_time . "'::interval"; $rs = $ses_sql->sqlQuery($query); if (is_array($rs)) { // Logging off foreach ($rs as $p) { if (strstr($p['ses_data'], 'pla_id')) { $pla_id = ereg_replace('.*:"pla_id";s:[0-9]+:"([0-9]+)";.*', '\\1', $p['ses_data']); if (!empty($pla_id)) { $aux = "'" . $p['ses_last_updated'] . "'::timestamp + "; $aux .= "'" . $life_time / 2 . " seconds'::interval"; b1n_logAction('logoff', array(), $pla_id, 0, $aux); if (b1n_cmp($ses_id, $p['ses_id'])) { global $lang; b1n_retMsg($lang['session_has_expired']); if (!b1n_cmp($_SERVER['REMOTE_ADDR'], $p['ses_ip'])) { b1n_retMsg($lang['log_cheater']); } } } } } } $query = "\n DELETE FROM session WHERE\n (CURRENT_TIMESTAMP - ses_last_updated)::interval >\n '" . $life_time . "'::interval"; $ses_sql->sqlQuery($query); return true; }
function b1n_mapWithdraw($money) { global $sql; if (!empty($money) && b1n_checkNumeric($money) && $money > 0) { $money = (int) $money; if ($money > $_SESSION['player']['pla_bank_money']) { $money = $_SESSION['player']['pla_bank_money']; } if ($money > 0) { $query = "\n UPDATE player\n SET\n pla_money = pla_money + " . b1n_inBd($money) . ",\n pla_bank_money = pla_bank_money - " . b1n_inBd($money) . "\n WHERE\n pla_id = '" . $_SESSION['player']['pla_id'] . "'"; $rs = $sql->sqlQuery($query); if ($rs) { $aux = array('money' => $money); b1n_logAction('withdraw', $aux); $_SESSION['player']['pla_money'] += $money; $_SESSION['player']['pla_bank_money'] -= $money; } } } }