2008-11-19 23:33:50 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.");
|
|
|
|
|
/**
|
|
|
|
|
* Gallery - a web based photo album viewer and editor
|
2013-01-21 01:22:01 -05:00
|
|
|
* Copyright (C) 2000-2013 Bharat Mediratta
|
2008-11-19 23:33:50 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
|
* your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
class url extends url_Core {
|
2009-01-29 03:22:02 +00:00
|
|
|
static function parse_url() {
|
|
|
|
|
if (Router::$controller) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-04 18:40:38 -07:00
|
|
|
// Work around problems with the CGI sapi by enforcing our default path
|
|
|
|
|
if ($_SERVER["SCRIPT_NAME"] && "/" . Router::$current_uri == $_SERVER["SCRIPT_NAME"]) {
|
|
|
|
|
Router::$controller_path = MODPATH . "gallery/controllers/albums.php";
|
|
|
|
|
Router::$controller = "albums";
|
|
|
|
|
Router::$method = 1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-21 20:47:14 -08:00
|
|
|
$item = item::find_by_relative_url(html_entity_decode(Router::$current_uri, ENT_QUOTES));
|
2009-11-25 13:22:24 -08:00
|
|
|
if ($item && $item->loaded()) {
|
2009-06-09 21:35:35 +08:00
|
|
|
Router::$controller = "{$item->type}s";
|
|
|
|
|
Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
|
2009-11-30 11:10:58 -08:00
|
|
|
Router::$method = "show";
|
|
|
|
|
Router::$arguments = array($item);
|
2009-06-09 21:35:35 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-19 23:33:50 +00:00
|
|
|
/**
|
|
|
|
|
* Just like url::file() except that it returns an absolute URI
|
|
|
|
|
*/
|
2009-01-14 04:12:02 +00:00
|
|
|
static function abs_file($path) {
|
2010-06-18 15:25:33 -07:00
|
|
|
return url::base(false, request::protocol()) . $path;
|
2008-11-19 23:33:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Just like url::site() except that it returns an absolute URI and
|
|
|
|
|
* doesn't take a protocol parameter.
|
|
|
|
|
*/
|
2009-01-14 04:12:02 +00:00
|
|
|
static function abs_site($path) {
|
2010-06-18 15:25:33 -07:00
|
|
|
return url::site($path, request::protocol());
|
2008-11-19 23:33:50 +00:00
|
|
|
}
|
2008-11-25 15:54:45 +00:00
|
|
|
|
2008-12-21 03:50:11 +00:00
|
|
|
/**
|
|
|
|
|
* Just like url::current except that it returns an absolute URI
|
|
|
|
|
*/
|
2009-01-14 04:12:02 +00:00
|
|
|
static function abs_current($qs=false) {
|
2008-12-21 03:50:11 +00:00
|
|
|
return self::abs_site(url::current($qs));
|
2008-11-25 15:54:45 +00:00
|
|
|
}
|
2010-01-18 11:10:37 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Just like url::merge except that it escapes any XSS in the path.
|
|
|
|
|
*/
|
2010-01-30 17:41:48 -08:00
|
|
|
static function merge(array $arguments) {
|
|
|
|
|
return htmlspecialchars(parent::merge($arguments));
|
2010-01-18 11:10:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Just like url::current except that it escapes any XSS in the path.
|
|
|
|
|
*/
|
|
|
|
|
static function current($qs=false, $suffix=false) {
|
|
|
|
|
return htmlspecialchars(parent::current($qs, $suffix));
|
|
|
|
|
}
|
2010-12-16 20:36:00 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Merge extra an query string onto a given url safely.
|
|
|
|
|
* @param string the original url
|
|
|
|
|
* @param array the query string data in key=value form
|
|
|
|
|
*/
|
|
|
|
|
static function merge_querystring($url, $query_params) {
|
|
|
|
|
$qs = implode("&", $query_params);
|
|
|
|
|
if (strpos($url, "?") === false) {
|
|
|
|
|
return $url . "?$qs";
|
|
|
|
|
} else {
|
|
|
|
|
return $url . "&$qs";
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-11-20 01:25:29 +00:00
|
|
|
}
|