forked from mariodev/verge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
66 lines (52 loc) · 1.51 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
<?php
include 'lib/bones.php';
define('ADMIN_USER', 'serveradmin');
define('ADMIN_PASSWORD', 'pass');
get('/signup', function($app) {
// echo curl_version();
// var_dump(function_exists("curl_init"));
$app->render('user/signup');
});
post('/signup', function($app) {
$user = new User();
$user->full_name = $app->form('full_name');
$user->email = $app->form('email');
$user->signup($app->form('username'), $app->form('password'));
$app->set('success', 'Thanks for Signing Up ' . $user->full_name . '!');
$app->render('home');
});
get('/login', function($app) {
$app->render('user/login');
});
post('/login', function($app) {
$user = new User();
$user->name = $app->form('username');
$user->login($app->form('password'));
$app->set('success', 'You are now logged in!');
$app->render('home');
});
get('/logout', function($app) {
User::logout();
$app->redirect('/');
});
get('/user/:username', function($app) {
$app->set('user', User::get_by_username($app->request('username')));
$app->set('is_current_user', ($app->request('username')== User::current_user() ? true: false));
$app->render('user/profile');
});
post('/post', function($app) {
if(User::is_authenticated()) {
$post = new Post();
$post->content = $app->form('content');
$post->create();
$app->redirect('/user/' . User::current_user());
} else {
$app->set('error', 'You must be logged in to do that.');
$app->render('user/login');
}
});
get('/', function($app) {
$app->set('message', 'Welcome Back!');
$app->render('home');
});
resolve();