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/**
21 * This script will just redirect to main.php
22 * The Location header requires an absolute url to conform with HTTP/1.1
23 * @package Gallery
24 * @author Bharat Mediratta <bharat@menalto.com>
25 * @version $Revision: 17580 $
26 */
27
28/* Include bootstrap.inc in case config.php overrides GALLERY_MAIN_PHP */
29require_once(dirname(__FILE__) . '/bootstrap.inc');
30require_once(dirname(__FILE__) . '/modules/core/classes/GalleryUrlGenerator.class');
31require_once(dirname(__FILE__) . '/modules/core/classes/GalleryCoreApi.class');
32
33/* The REQUEST_URI can either be /path/index.php or just /path/. Get rid of index.php.* */
34$path = GalleryUrlGenerator::getCurrentRequestUri();
35if (preg_match('|^(/(?:[^?#/]+/)*)(.*)|', $path, $matches)) {
36    $path = $matches[1] . GALLERY_MAIN_PHP;
37    if (!empty($matches[2]) && ($pos = strpos($matches[2], '?')) !== false) {
38	$path .= substr($matches[2], $pos);
39    }
40}
41
42$configBaseUri = @$gallery->getConfig('baseUri');
43
44$urlGenerator = new GalleryUrlGenerator();
45$urlGenerator->init(!empty($configBaseUri) ? $configBaseUri : null);
46
47$phpVm = $gallery->getPhpVm();
48$phpVm->header('Location: ' . $urlGenerator->makeUrl($path));
49?>
50