2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
5 require_once ("inc/settings.php");
7 function unquote($gpc_str) {
8 if (!isset ($gpc_str)) {
11 if (get_magic_quotes_gpc ()) {
12 return stripslashes ($gpc_str);
18 function full_url_from_filename ($filename) {
19 if (defined ("IMGSDIRURL") && (strlen (IMGSDIRURL) != 0)) {
20 return rtrim (IMGSDIRURL, '/') . "/" . rawurlencode ($filename);
23 $rel_path = UPLOADDIR . "/" . rawurlencode ($filename);
25 while (substr($rel_path, 0, 2) == "./") { // strips ./
26 $rel_path = substr ($rel_path, 2);
29 if ($rel_path [0] == "/") {
32 $script_dir = dirname ($_SERVER ["SCRIPT_NAME"]);
33 while ((substr ($rel_path, 0, 3) == "../") &&
34 (strlen($script_dir) != 0)) {
35 $rel_path = substr ($rel_path, 3);
36 while (substr($rel_path, 0, 2) == "./") {
37 $rel_path = substr ($rel_path, 2);
39 $script_dir = substr ($script_dir, 0, strrpos ($script_dir, "/"));
41 if ((strlen ($script_dir) == 0) && (substr ($rel_path, 0, 3) == "../")) {
44 $path = "$script_dir/$rel_path";
47 $host = $_SERVER ["HTTP_HOST"];
48 $port = $_SERVER ["SERVER_PORT"];
49 if ($_SERVER ["HTTPS"] == "on") {
55 if (($port == "80" && $proto == "http") ||
56 ($port == "443" && $proto == "https")) {
62 return "$proto://$host$port$path";