forked from highfidelity-worklist/worklist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
130 lines (109 loc) · 4.94 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
<?php
/**
* Copyright 2014 - High Fidelity, Inc.
*/
require_once("config.php");
class Dispatcher {
static public $url = '';
public function run() {
self::$url = isset($_GET['url']) ? $_GET['url'] : '';
$dispatcher = new Pux\Mux;
$dispatcher->any('/budget/:method(/:param)', array('Budget'), array(
'require' => array(
'method' => '[a-zA-Z0-9]+',
'param' => '.*'
),
'default' => array('method' => 'info')
));
$dispatcher->get('/confirmation', array('Confirmation'));
$dispatcher->post('/confirmation', array('Confirmation'));
$dispatcher->get('/feedlist', array('FeedList'));
$dispatcher->get('/feeds', array('Feeds'));
$dispatcher->get('/forgot', array('Forgot'));
$dispatcher->post('/forgot', array('Forgot'));
$dispatcher->any('/github(/:method)', array('Github'), array(
'require' => array('method' => '\w+'),
'default' => array('method' => 'index')
));
$dispatcher->get('/github/:method(/:param)', array('Github'), array(
'require' => array(
'method' => '\w+',
'param' => '.*'
),
'default' => array('method' => 'index')
));
$dispatcher->any('/file(/:method)', array('File'), array(
'require' => array('method' => '\w+'),
'default' => array('method' => 'index')
));
$dispatcher->any('/file/:method(/:param)', array('File'), array(
'require' => array(
'method' => '\w+',
'param' => '.*'
),
'default' => array('method' => 'index')
));
$dispatcher->get('/help', array('Help'));
$dispatcher->get('/jobs', array('Jobs'));
$dispatcher->get('/password', array('Password'));
$dispatcher->post('/password', array('Password'));
$dispatcher->get('/payments', array('Payments'));
$dispatcher->post('/payments', array('Payments'));
$dispatcher->get('/privacy', array('Privacy'));
$dispatcher->get('/projects', array('Projects'));
$dispatcher->get('/reports', array('Reports'));
$dispatcher->post('/reports', array('Reports'));
$dispatcher->get('/resend', array('Resend'));
$dispatcher->post('/resend', array('Resend'));
$dispatcher->get('/resetpass', array('ResetPass'));
$dispatcher->post('/resetpass', array('ResetPass'));
$dispatcher->get('/status', array('Status'));
$dispatcher->post('/status', array('Status', 'api'));
$dispatcher->get('/settings', array('Settings'));
$dispatcher->post('/settings', array('Settings'));
$dispatcher->get('/team', array('Team'));
$dispatcher->get('/timeline', array('Timeline'));
$dispatcher->get('/uploads/:filename', array('Upload'), array('require' => array('filename' => '.+')));
$dispatcher->get('/user/:method(/:param)', array('User'), array(
'require' => array(
'method' => '[a-zA-Z0-9]+',
'param' => '.*'
),
'default' => array('method' => 'index')
));
$dispatcher->post('/user/:id', array('User'));
$dispatcher->get('/welcome', array('Welcome'));
$dispatcher->get('/:id', array('Job', 'view'), array('require' => array('id' => '\d+')));
$dispatcher->post('/:id', array('Job', 'view'), array('require' => array('id' => '\d+')));
$dispatcher->any('/job/:method(/:param)', array('Job'), array(
'require' => array(
'method' => '[a-zA-Z0-9]+',
'param' => '.*'
),
'default' => array('method' => 'index')
));
$dispatcher->get('/:project', array('Project'));
$dispatcher->post('/:project', array('Project'));
$dispatcher->any('/login', array('Github', 'federated'));
$dispatcher->any('/signup', array('Github', 'federated'));
try {
$route = $dispatcher->dispatch('/' . self::$url);
$controller = isset($route[2][0]) ? $route[2][0] : DEFAULT_CONTROLLER_NAME;
if (strlen($controller) < 10 || substr($controller, -10) != 'Controller') {
$controller .= 'Controller';
}
$method = isset($route[2][1]) ? $route[2][1] : DEFAULT_CONTROLLER_METHOD;
$variables = isset($route[3]['variables']) ? $route[3]['variables'] : array();
$values = isset($route[3]['vars']) ? $route[3]['vars'] : array();
$params = array();
foreach($variables as $variable) {
if (isset($values[$variable])) {
$params[$variable] = $values[$variable];
}
}
$Controller = new $controller();
call_user_func_array(array($Controller, $method), $params);
} catch(Exception $e) {
}
}
}