-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathindex.php
executable file
·138 lines (113 loc) · 3.55 KB
/
index.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
require_once dirname(__FILE__).'/mc-files/mc-core.php';
$mc_post_per_page = 10;
$qs = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
if (preg_match('|^post/([a-z0-5]{6})$|', $qs, $matches)) {
$mc_get_type = 'post';
$mc_get_name = $matches[1];
}
else if (preg_match('|^tag/([^/]+)/(\?page=([0-9]+)){0,1}$|', $qs, $matches)) {
$mc_get_type = 'tag';
$mc_get_name = urldecode($matches[1]);
$mc_page_num = isset($matches[2]) ? $matches[3] : 1;
}
else if (preg_match('|^date/([0-9]{4}-[0-9]{2})/(\?page=([0-9]+)){0,1}$|', $qs, $matches)) {
$mc_get_type = 'date';
$mc_get_name = urldecode($matches[1]);
$mc_page_num = isset($matches[2]) ? $matches[3] : 1;
}
else if (preg_match('|^archive/$|', $qs, $matches)) {
$mc_get_type = 'archive';
}
else if ($qs == 'rss/') {
$mc_get_type = 'rss';
$mc_get_name = '';
$mc_page_num = isset($_GET['page']) ? $_GET['page'] : 1;
}
else if (preg_match('|^(([-a-zA-Z0-5]+/)+)$|', $qs, $matches)) {
$mc_get_type = 'page';
$mc_get_name = substr($matches[1], 0, -1);
} else {
$mc_get_type = 'index';
$mc_get_name = '';
$mc_page_num = isset($_GET['page']) ? $_GET['page'] : 1;
}
if ($mc_get_type == 'post') {
require 'mc-files/posts/index/publish.php';
if (array_key_exists($mc_get_name, $mc_posts)) {
$mc_post_id = $mc_get_name;
$mc_post = $mc_posts[$mc_post_id];
$mc_data = unserialize(file_get_contents('mc-files/posts/data/'.$mc_post_id.'.dat'));
}
else {
mc_404();
}
}
else if ($mc_get_type == 'tag') {
require 'mc-files/posts/index/publish.php';
$mc_post_ids = array_keys($mc_posts);
$mc_post_count = count($mc_post_ids);
$mc_tag_posts = array();
for ($i = 0; $i < $mc_post_count; $i ++) {
$id = $mc_post_ids[$i];
$post = $mc_posts[$id];
if (in_array($mc_get_name, $post['tags'])) {
$mc_tag_posts[$id] = $post;
}
}
$mc_posts = $mc_tag_posts;
$mc_post_ids = array_keys($mc_posts);
$mc_post_count = count($mc_post_ids);
}
else if ($mc_get_type == 'date') {
require 'mc-files/posts/index/publish.php';
$mc_post_ids = array_keys($mc_posts);
$mc_post_count = count($mc_post_ids);
$mc_date_posts = array();
for ($i = 0; $i < $mc_post_count; $i ++) {
$id = $mc_post_ids[$i];
$post = $mc_posts[$id];
if (strpos($post['date'], $mc_get_name) === 0) {
$mc_date_posts[$id] = $post;
}
}
$mc_posts = $mc_date_posts;
$mc_post_ids = array_keys($mc_posts);
$mc_post_count = count($mc_post_ids);
}
else if ($mc_get_type == 'archive') {
require 'mc-files/posts/index/publish.php';
$mc_post_ids = array_keys($mc_posts);
$mc_post_count = count($mc_post_ids);
$tags_array = array();
$date_array = array();
for ($i = 0; $i < $mc_post_count; $i ++) {
$post_id = $mc_post_ids[$i];
$post = $mc_posts[$post_id];
$date_array[] = substr($post['date'], 0, 7);
$tags_array = array_merge($tags_array, $post['tags']);
}
$mc_tags = array_values(array_unique($tags_array));
$mc_dates = array_values(array_unique($date_array));
}
else if ($mc_get_type == 'page') {
require 'mc-files/pages/index/publish.php';
if (array_key_exists($mc_get_name, $mc_pages)) {
$mc_post_id = $mc_get_name;
$mc_post = $mc_pages[$mc_post_id];
$mc_data = unserialize(file_get_contents('mc-files/pages/data/'.$mc_post['file'].'.dat'));
}
else {
mc_404();
}
}
else {
require 'mc-files/posts/index/publish.php';
$mc_post_ids = array_keys($mc_posts);
$mc_post_count = count($mc_post_ids);
}
if ($mc_get_type != 'rss')
require 'mc-files/theme/index.php';
else
require 'mc-files/mc-rss.php';
?>