-
Notifications
You must be signed in to change notification settings - Fork 12
/
functions.php
executable file
·46 lines (43 loc) · 1.04 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
if (function_exists('http_build_url'))
{
function formbuilder_create_url($parts)
{
$parts += array('path' => preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']));
return http_build_url($parts);
}
}
else
{
function formbuilder_create_url($parts)
{
static $prefixes = array('password' => ':', 'host' => '://', 'port' => ':',
'path' => '/', 'query' => '?', 'fragment' => '#');
$parts += array(
'scheme' => isset($_SERVER['HTTPS']) ? 'https' : 'http',
'host' => $_SERVER['HTTP_HOST'],
'port' => $_SERVER['SERVER_PORT'],
'path' => preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']),
);
switch ($parts['scheme'].$parts['port']) {
case 'http80':
case 'https443':
unset($parts['port']);
break;
}
if (isset($parts['username'])) {
$parts['host'] = '@' . $parts['host'];
}
$url = $parts['scheme'];
foreach ($prefixes as $key => $pre) {
if (! isset($parts[$key])) {
continue;
}
if ($parts[$key][0] !== $pre) {
$url .= $pre;
}
$url .= $parts[$key];
}
return $url;
}
}