aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_url.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/functions_url.inc.php')
-rw-r--r--include/functions_url.inc.php64
1 files changed, 52 insertions, 12 deletions
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index 787c06780..d8c49f372 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -51,9 +51,11 @@ function get_absolute_root_url($with_scheme=true)
$url = '';
if ($with_scheme)
{
+ $is_https = false;
if (isset($_SERVER['HTTPS']) &&
- ((strtolower($_SERVER['HTTPS']) == 'on') or ($_SERVER['HTTPS'] == 1)))
+ ((strtolower($_SERVER['HTTPS']) == 'on') or ($_SERVER['HTTPS'] == 1)))
{
+ $is_https = true;
$url .= 'https://';
}
else
@@ -61,7 +63,8 @@ function get_absolute_root_url($with_scheme=true)
$url .= 'http://';
}
$url .= $_SERVER['HTTP_HOST'];
- if ($_SERVER['SERVER_PORT'] != 80)
+ if ( (!$is_https && $_SERVER['SERVER_PORT'] != 80)
+ ||($is_https && $_SERVER['SERVER_PORT'] != 443))
{
$url_port = ':'.$_SERVER['SERVER_PORT'];
if (strrchr($url, ':') != $url_port)
@@ -231,7 +234,7 @@ function make_picture_url($params)
$url .= $params['image_id'];
if ( isset($params['image_file']) )
{
- $url .= '-'.get_filename_wo_extension($params['image_file']);
+ $url .= '-'.str2url(get_filename_wo_extension($params['image_file']));
}
break;
case 'file':
@@ -463,14 +466,13 @@ function parse_section_url( $tokens, &$next_token)
{
if (empty($maybe_permalinks))
{
- array_push($maybe_permalinks, $tokens[$current_token]);
+ $maybe_permalinks[] = $tokens[$current_token];
}
else
{
- array_push($maybe_permalinks,
+ $maybe_permalinks[] =
$maybe_permalinks[count($maybe_permalinks)-1]
- . '/' . $tokens[$current_token]
- );
+ . '/' . $tokens[$current_token];
}
$current_token++;
}
@@ -524,11 +526,11 @@ function parse_section_url( $tokens, &$next_token)
if ( $conf['tag_url_style'] != 'tag' and preg_match('/^(\d+)(?:-(.*)|)$/', $tokens[$i], $matches) )
{
- array_push($requested_tag_ids, $matches[1]);
+ $requested_tag_ids[] = $matches[1];
}
else
{
- array_push($requested_tag_url_names, $tokens[$i]);
+ $requested_tag_url_names[] = $tokens[$i];
}
$i++;
}
@@ -594,7 +596,7 @@ function parse_section_url( $tokens, &$next_token)
if (empty($tokens[$next_token]))
{
// Add dummy element list
- array_push($page['list'], -1);
+ $page['list'][] = -1;
}
// With pictures list
else
@@ -605,7 +607,7 @@ function parse_section_url( $tokens, &$next_token)
}
foreach (explode(',', $tokens[$next_token]) as $image_id)
{
- array_push($page['list'], $image_id);
+ $page['list'][] = $image_id;
}
}
$next_token++;
@@ -792,4 +794,42 @@ function get_gallery_home_url()
return make_index_url();
}
}
+
+/**
+ * returns $_SERVER['QUERY_STRING'] whithout keys given in parameters
+ *
+ * @param string[] $rejects
+ * @param boolean $escape escape *&* to *&*
+ * @returns string
+ */
+function get_query_string_diff($rejects=array(), $escape=true)
+{
+ if (empty($_SERVER['QUERY_STRING']))
+ {
+ return '';
+ }
+
+ parse_str($_SERVER['QUERY_STRING'], $vars);
+
+ $vars = array_diff_key($vars, array_flip($rejects));
+
+ return '?' . http_build_query($vars, '', $escape ? '&' : '&');
+}
+
+/**
+ * returns true if the url is absolute (begins with http)
+ *
+ * @param string $url
+ * @returns boolean
+ */
+function url_is_remote($url)
+{
+ if ( strncmp($url, 'http://', 7)==0
+ or strncmp($url, 'https://', 8)==0 )
+ {
+ return true;
+ }
+ return false;
+}
+
?> \ No newline at end of file