<?php !defined('P_W') && exit('Forbidden'); checkVerify('loginhash'); $cookiepre = CookiePre() . '_'; foreach ($_COOKIE as $key => $value) { if (strpos($key, $cookiepre) === 0) { Cookie(substr($key, strlen($cookiepre)), '', 0); } } $referer = strpos($pwServer['HTTP_REFERER'], $db_bbsurl) === 0 ? $pwServer['HTTP_REFERER'] : $db_bbsurl . '/' . $db_bfn; ObHeader($referer);
/** * 设置cookie * * @global string $db_ckpath * @global string $db_ckdomain * @global int $timestamp * @global array $pwServer * @param string $cookieName cookie名 * @param string $cookieValue cookie值 * @param int|string $expireTime cookie过期时间,为F表示1年后过期 * @param bool $needPrefix cookie名是否加前缀 * @return bool 是否设置成功 */ function Cookie($cookieName, $cookieValue, $expireTime = 'F', $needPrefix = true) { global $db_ckpath, $db_ckdomain, $timestamp, $pwServer; static $sIsSecure = null; if ($sIsSecure === null) { if (!$pwServer['REQUEST_URI'] || ($parsed = @parse_url($pwServer['REQUEST_URI'])) === false) { $parsed = array(); } if ($parsed['scheme'] == 'https' || empty($parsed['scheme']) && ($pwServer['HTTP_SCHEME'] == 'https' || $pwServer['HTTPS'] && strtolower($pwServer['HTTPS']) != 'off')) { $sIsSecure = true; } else { $sIsSecure = false; } } if (P_W != 'admincp') { $cookiePath = !$db_ckpath ? '/' : $db_ckpath; $cookieDomain = $db_ckdomain; } else { $cookiePath = '/'; $cookieDomain = ''; } $isHttponly = false; if ($cookieName == 'AdminUser' || $cookieName == 'winduser') { $agent = strtolower($pwServer['HTTP_USER_AGENT']); if (!($agent && preg_match('/msie ([0-9]\\.[0-9]{1,2})/i', $agent) && strstr($agent, 'mac'))) { $isHttponly = true; } } $cookieValue = str_replace("=", '', $cookieValue); strlen($cookieValue) > 512 && ($cookieValue = substr($cookieValue, 0, 512)); $needPrefix && ($cookieName = CookiePre() . '_' . $cookieName); if ($expireTime == 'F') { $expireTime = $timestamp + 31536000; } elseif ($cookieValue == '' && $expireTime == 0) { return setcookie($cookieName, '', $timestamp - 31536000, $cookiePath, $cookieDomain, $sIsSecure); } if (PHP_VERSION < 5.2) { return setcookie($cookieName, $cookieValue, $expireTime, $cookiePath . ($isHttponly ? '; HttpOnly' : ''), $cookieDomain, $sIsSecure); } else { return setcookie($cookieName, $cookieValue, $expireTime, $cookiePath, $cookieDomain, $sIsSecure, $isHttponly); } }
function GetCookie($Var) { return $_COOKIE[CookiePre() . '_' . $Var]; }
function quit() { extract($GLOBALS); if (ereg("^pwbbs", $webdb[passport_type])) { set_cookie(CookiePre() . '_winduser', ""); } else { set_cookie("passport", ""); } set_cookie("token_secret", ""); setcookie("adminID", "", 0, "/"); //同步后台退出 if (defined("UC_CONNECT")) { global $uc_login_code; $uc_login_code = uc_user_synlogout(); } }