1<?php
2/*
3 * Gallery - a web based photo album viewer and editor
4 * Copyright (C) 2000-2008 Bharat Mediratta
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21GalleryCoreApi::requireOnce('modules/httpauth/classes/HttpAuthHelper.class');
22
23/**
24 * Try to clear the browser's authentication cache by as many tricks as possible and redirect to a
25 * view which checks that logout was successful.  https://bugzilla.mozilla.org/show_bug.cgi?id=55181
26 * @package HttpAuth
27 * @subpackage UserInterface
28 * @author Jack Bates <ms419@freezone.co.uk>
29 * @version $Revision: 17580 $
30 */
31class TryLogoutView extends GalleryView {
32
33    /**
34     * @see GalleryView::loadTemplate
35     */
36    function loadTemplate(&$template, &$form) {
37	global $gallery;
38	$urlGenerator =& $gallery->getUrlGenerator();
39
40	/* Ask browser to authenticate with bogus authtype */
41	GalleryUtilities::setResponseHeader('HTTP/1.0 401 Unauthorized', false);
42	GalleryUtilities::setResponseHeader('WWW-Authenticate: Bogus');
43
44	/* Redirect using random username and password */
45	$TryLogout = array();
46	foreach (array('scriptUrl', 'hrefUrl') as $key) {
47	    $url = $urlGenerator->generateUrl(array('view' => 'httpauth.FinishLogout'),
48					      array('forceFullUrl' => true,
49						    'htmlEntities' => $key == 'hrefUrl'));
50	    $TryLogout[$key] =
51		HttpAuthHelper::addHttpAuthToUrl($url, '__LOGOUT__' . rand(), rand());
52	}
53
54	/* Render HTML body */
55	$template->setVariable('TryLogout', $TryLogout);
56
57	return array(null, array('body' => 'modules/httpauth/templates/TryLogout.tpl'));
58    }
59}
60?>
61