forked from honestcode/cimsy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cimsy.php
50 lines (36 loc) · 1.1 KB
/
cimsy.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
47
48
49
50
<?php
// configure
$default_page_title = "Document Repository";
$content_folder_name = "files";
$home_page_content = "index.md";
// /////////////////////////////////////////////////////////////////// //
// initialize
require_once('markdown.php');
// page display
if (!isset($_GET['id'])) {
$shortened_id = $default_page_title;
$contents = file_get_contents($content_folder_name . '/' . $home_page_content);
} else {
$shortened_id = htmlspecialchars($_GET['id']);
$shortened_id = str_ireplace("/", "|", $shortened_id);
$contents = @file_get_contents($content_folder_name . '/' . $shortened_id . '.md');
}
if (!$contents) {
$shortened_id = "Not Found";
$contents = "#Not Found
Sorry, but we couldn't find what you're looking for.";
}
$GLOBALS['title'] = $shortened_id;
$GLOBALS['contents'] = $contents;
// utility functions
function get_title () {
$string = $GLOBALS['title'];
$output = str_ireplace("|", ": ", $string);
$output = str_ireplace("-", " ", $output);
$output = str_ireplace("_", " ", $output);
echo (ucwords($output));
}
function get_content() {
echo Markdown($GLOBALS['contents']);
}
?>