-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
66 lines (49 loc) · 1.38 KB
/
index.php
File metadata and controls
66 lines (49 loc) · 1.38 KB
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
<?php
/*
Vendima Framework MD documentation parser
It uses the excellent PHP Markdown Extra from Michel Fortin
https://michelf.ca/projects/php-markdown/extra/
Files are inside the 'md/' directory, and uses the same structure as the
URI, except if it begins with a two-letter word, indicating a different
language.
Each file have the format "name.[language.]md". If omitted, the default
language is spanish.
*/
const MD_BASEPATH = 'md/';
require 'mdparser.php';
if (isset($_GET['q'])) {
$file = trim($_GET['q'], '/.\\');
}
else {
$file = 'index';
}
$parts = explode('/', $file);
// Usamos la 1ra parte sólo si tiene 2 caracteres
if (strlen($parts[0]) == 2) {
$language = array_shift($parts);
} else {
$language = '';
}
// Es un fichero o un directorio?
$test = MD_BASEPATH . join('/', $parts);
if (is_dir($test)) {
// Intentamos index
$basefile = ['index', $language, 'md'];
} else {
$basefile = [array_pop($parts), $language, 'md'];
}
$md_path = join('/', $parts) . '/';
$md_basename = join('.', array_filter($basefile));
$md_file = MD_BASEPATH . $md_path . $md_basename;
if (file_exists($md_file)) {
extract( MDparser::parse($md_file) );
// DEBUG
if (file_exists('/etc/DOROTHY')) {
$base = '/vendimia/docs/';
} else {
$base = '/';
}
include 'templates/default.php';
} else {
// TODO: 404!
}