-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmain.php
61 lines (48 loc) · 1.24 KB
/
main.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
<?php
/**
* Created by PhpStorm.
* User: Youi
* Date: 2015-12-08
* Time: 21:20
*/
$isHashHost = false;
$hostNumber = 4;
$packImages = false;
spl_autoload_register(function ($class) {
$class = strtolower($class);
include_once("$class.php");
});
main($isHashHost, $hostNumber, $packImages);
/**
* @param $isHashHost Boolean Is this host a router
* @param $hostNumber Number How many host there
* @param $packImages Boolean make a zip pack for images?
*/
function main($isHashHost, $hostNumber, $packImages) {
$url = isset($_GET['url']) ? $_GET['url'] : '';
# URL given
if ($url) {
# it's an image url
if (Input::isImageUrl($url))
Output::redirect($url);
# this host is a hash host(redirecting instead of dealing request)
elseif ($isHashHost)
Router::route($url, $hostNumber);
# handling
else {
$mc = new mc();
Input::loadMemcached($mc);
Output::loadMemcached($mc);
Handler::loadMemcached($mc);
Handler::handle($url, $packImages);
}
}
# not URL given
else exit_script('Hello Tumblr!');
}
/**
* @param null $message
*/
function exit_script($message = null) {
exit($message);
}