-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.php
More file actions
43 lines (36 loc) · 1.18 KB
/
Copy pathrouter.php
File metadata and controls
43 lines (36 loc) · 1.18 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
<?php
session_start();
$request = $_SERVER['REQUEST_URI']; // if your url look like this : http://localhost/application_name
//$request = $_SERVER['REQUEST_URI']; // if your url look like this : http://localhost/
switch ($request) {
case '/':
case '':
require __DIR__ . '/views/index.php';
break;
case '/post':
if (isset($_POST['submitUsername'])) {
$_SESSION['username'] = $_POST['username'];
header('Location: /');
} else if (isset($_POST['submitMessage'])) {
require __DIR__ . '/pusher.php';
$instance = new PusherClass();
$instance->trigger();
/* $ret = call_user_func(array($instance, 'trigger'));
var_dump($ret);
if (empty($ret)) {
throw new Exception("empty $ret.");
} */
}
break;
case '/pusher/auth':
require __DIR__ . '/pusher.php';
$instance = new PusherClass();
$ret = call_user_func(array($instance, 'auth'));
if (empty($ret)) {
throw new Exception("empty $ret.");
}
break;
default:
http_response_code(404);
break;
}