PageRenderTime 202ms CodeModel.GetById 111ms app.highlight 2ms RepoModel.GetById 59ms app.codeStats 29ms

/silversupport/php/functions.php

https://bitbucket.org/ianb/silverlining/
PHP | 38 lines | 33 code | 3 blank | 2 comment | 8 complexity | 44d93facf5ad5d7f9ad91590ea72839e MD5 | raw file
 1<?
 2
 3function silver_next_path($default=NULL, $url_path=NULL) {
 4    global $silver_base, $silver_php_root;
 5    if (! $url_path) {
 6        $url_path = $_SERVER['SCRIPT_NAME'];
 7    }
 8    $path = "{$silver_base}/{$silver_php_root}/{$url_path}";
 9    if (is_dir($path) and file_exists(rtrim($path, '/') . '/index.php')) {
10        if (rtrim($path, '/') == $path) {
11            # We need a redirect
12            header("Status: 301 Moved Permanently");
13            header("Location: {$url_path}/");
14            exit();
15        }
16        $path = rtrim($path, '/') . '/index.php';
17    }
18    if (! file_exists($path)) {
19        if ($default) {
20            /*echo "Path '{$path}' (in '{$silver_php_root}') didn't exist<br>\n";*/
21            $path = $default;
22        } else {
23            return NULL;
24        }
25    }
26    return $path;
27}
28
29function silver_call_next($default=NULL, $url_path=NULL) {
30    $path = silver_next_path($default, $url_path);
31    if ($path) {
32        chdir(dirname($path));
33    }
34    $_SERVER['PHP_SELF'] = $path;
35    return $path;
36}
37
38?>