public static function logout()
{
$blogPath = SJB_Settings::getSettingByName('blog_path');
if (empty($blogPath)) {
return;
}
$url = SJB_System::getSystemSettings('SITE_URL') . $blogPath . '/';
$client = new Zend_Http_Client($url, array('useragent' => SJB_Request::getUserAgent(), 'maxredirects' => 0));
if (isset($_SESSION['wp_cookie_jar'])) {
$client->setCookieJar(@unserialize($_SESSION['wp_cookie_jar']));
}
try {
$response = $client->request();
$matches = array();
if (preg_match('/_wpnonce=([\\w\\d]+)"/', $response->getBody(), $matches)) {
$wpnonce = $matches[1];
$url = $url . 'wp-login.php?action=logout&_wpnonce=' . $wpnonce . '&noSJB=1';
$client->setUri($url);
$response = $client->request();
foreach ($response->getHeaders() as $key => $header) {
if ('set-cookie' == strtolower($key)) {
if (is_array($header)) {
foreach ($header as $val) {
header("Set-Cookie: " . $val, false);
}
} else {
header("Set-Cookie: " . $header, false);
}
}
}
}
} catch (Exception $ex) {
}
}