protected function doDebug() { $data = array('timestamp' => gmdate('r'), 'remote_addr' => @$_SERVER['REMOTE_ADDR'], 'url' => @$_SERVER['REQUEST_URI'], 'have_session' => common_have_session(), 'logged_in' => common_logged_in(), 'is_real_login' => common_is_real_login(), 'user' => common_logged_in() ? common_current_user()->nickname : null, 'headers' => $this->getHttpHeaders(), 'post_data' => $this->sanitizePostData($_POST)); $this->saveDebug($data); }
function common_inject_session($url, $serverpart = null) { if (common_have_session()) { if (empty($serverpart)) { $serverpart = parse_url($url, PHP_URL_HOST); } $currentServer = $_SERVER['HTTP_HOST']; // Are we pointing to another server (like an SSL server?) if (!empty($currentServer) && 0 != strcasecmp($currentServer, $serverpart)) { // Pass the session ID as a GET parameter $sesspart = session_name() . '=' . session_id(); $i = strpos($url, '?'); if ($i === false) { // no GET params, just append $url .= '?' . $sesspart; } else { $url = substr($url, 0, $i + 1) . $sesspart . '&' . substr($url, $i + 1); } } } return $url; }
function common_set_user($user) { global $_cur; if (is_null($user) && common_have_session()) { $_cur = null; unset($_SESSION['userid']); return true; } else { if (is_string($user)) { $nickname = $user; $user = User::staticGet('nickname', $nickname); } else { if (!$user instanceof User) { return false; } } } if ($user) { common_ensure_session(); $_SESSION['userid'] = $user->id; $_cur = $user; return $_cur; } return false; }