/** * Check if visitor has been validated * * @return boolean TRUE if valid */ function auth_isvalid() { if ($_SESSION['sid'] && $_SESSION['uid'] && $_SESSION['valid']) { $hash = user_session_get('', $_SESSION['sid']); if ($_SESSION['sid'] == $hash[key($hash)]['sid'] && $_SESSION['uid'] == $hash[key($hash)]['uid']) { return acl_checkurl($_SERVER['QUERY_STRING'], $_SESSION['uid']); } } return FALSE; }
/** * Check if visitor has been validated * * @return boolean TRUE if valid */ function auth_isvalid() { if ($_SESSION['sid'] && $_SESSION['uid'] && $_SESSION['valid']) { $hash = user_session_get('', $_SESSION['sid']); if ($_SESSION['sid'] == $hash[key($hash)]['sid'] && $_SESSION['uid'] == $hash[key($hash)]['uid']) { return TRUE; } } return FALSE; }
/** * Add account to banned account list * * @param integer $uid * User ID * @return boolean TRUE if user successfully added to banned user list */ function user_banned_add($uid) { global $user_config; // account admin and currently logged in user/admin cannot be ban if ($uid && ($uid == 1 || $uid == $user_config['uid'])) { _log('unable to ban uid:' . $uid, 2, 'user_banned_add'); return FALSE; } $bantime = core_get_datetime(); if (user_session_get($uid)) { if (!user_session_remove($uid)) { return FALSE; } } $item = array($uid => $bantime); if (registry_update(1, 'auth', 'banned_users', $item)) { _log('banned uid:' . $uid . ' bantime:' . $bantime, 2, 'user_banned_add'); return TRUE; } else { return FALSE; } }
/** * Get whose online * * @param integer $status * Account status * @param boolean $online_only * Report whose online only * @param boolean $idle_only * Report whose online with login status idle only * @return array Whose online data */ function report_whoseonline($status = 0, $online_only = FALSE, $idle_only = FALSE) { global $icon_config; $ret = array(); $hashes = user_session_get(); foreach ($hashes as $key => $val) { $c_user = user_getdatabyuid($val['uid']); $c_username = $c_user['username']; $c_status = $c_user['status']; if ($status && $c_status != $status) { continue; } $c_isadmin = ''; if ($c_status == '2') { $c_isadmin = $icon_config['admin']; } $is_idle = FALSE; $is_online = FALSE; $c_idle = (int) (strtotime(core_get_datetime()) - strtotime($val['last_update'])); // last update more than 15 minutes will be considered as idle if ($c_idle > 15 * 60) { $is_idle = TRUE; $c_login_status = $icon_config['idle']; } else { $is_online = TRUE; $c_login_status = $icon_config['online']; } if ($online_only && !$is_online) { continue; } if ($idle_only && !$is_idle) { continue; } $ret[$c_username][] = array('uid' => $c_user['uid'], 'username' => $c_username, 'status' => $c_status, 'icon_isadmin' => $c_isadmin, 'ip' => $val['ip'], 'http_user_agent' => $val['http_user_agent'], 'sid' => $val['sid'], 'hash' => $key, 'login_status' => $c_login_status, 'last_update' => core_display_datetime($val['last_update']), 'action_link' => _a('index.php?app=main&inc=feature_report&route=online&op=kick&hash=' . $key, $icon_config['delete'])); } ksort($ret); return $ret; }