File: router.php

package info (click to toggle)
node-nouislider 15.8.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,936 kB
  • sloc: javascript: 5,234; php: 474; sh: 32; python: 28; makefile: 11
file content (68 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download | duplicates (3)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php

chdir(__DIR__ . '/..');

if ($argv[1] == 'index') {
    $relpath = '';
} else {
    $relpath = '../';
}

$is_server = isset($_SERVER['REQUEST_URI']);
$request_url = $is_server ? $_SERVER['REQUEST_URI'] : ('/nouislider/' . $argv[1]);

$url = strtolower($request_url);

// mjs mime type is not built-in
if (strpos($url, '.mjs')) {
    header('Content-Type: text/javascript');
    readfile($_SERVER["SCRIPT_FILENAME"]);

    return;
}

if (strpos($url, '.js') || strpos($url, '.css') || strpos($url, '.html')) {
    return false;
}

$request = parse_url($url);
$page = rtrim(substr($request['path'], strlen('/nouislider/')), '/');

if (!$page) {
    $page = 'index';
}

$file = $page . '.php';
$file_menu = '_run/menu.php';

require '_run/helpers.php';

if (!file_exists($file)) {
    header('HTTP/1.0 404 Not Found');
    $file = '_run/404.php';
}

// Defaults
$title = "";
$description = "";
$canonical = "";

$package = json_decode(file_get_contents('./../package.json'));
$version = $package->version;
$plain_version = str_replace('.', '', $version);

ob_start();

include $file;

$content = ob_get_contents();

ob_end_clean();

$distribute = $relpath . 'dist';

if ($canonical) {
    $canonical = 'https://refreshless.com/' . $canonical;
}

include '_run/index.php';