-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
94 lines (57 loc) · 1.64 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
<?php
header('Content-type: text/html; charset=utf-8');
require 'flight/globals.php';
require 'vendor/autoload.php';
use RedBean_Facade as R;
// do app setting and config
Flight::before('start', function(){
R::setup('sqlite:db/lanshare.db');
R::freeze(True);
require_once('models/User.php');
Flight::register('user', 'User');
});
// controller
Flight::route('/a', function(){
// $a = R::dispense('a');
// $a->name = 1;
// R::store($a);
// $a = R::findOne('a', 'name = ?', array('1') );
// $a->name1 = 2;
// R::store($a);
// R::trash($a);
// $d = R::findOne('directory');
// var_dump($d->ownObject);
// R::trash($a);
});
Flight::route('/', function(){
Flight::render('header', array(), 'header_content');
Flight::render('index', array(), 'body_content');
Flight::render('footer', array(), 'footer_content');
Flight::render('layout', array('title' => 'Home Page'));
});
Flight::route('/image/@path', function($path){
Flight::render('header', array(), 'header_content');
Flight::render('image/image', array('path'=>$path), 'body_content');
Flight::render('footer', array(), 'footer_content');
Flight::render('layout', array('title' => 'Home Page'));
});
$uriUpdate = '/update/';
Flight::route( $uriUpdate. '.*', function(){
global $uriUpdate;
$path = $_SERVER['REQUEST_URI'];
$path = str_replace($uriUpdate, '', $path);
require('models/updater.php');
Flight::register('updater', 'Updater');
$updater = Flight::updater();
try{
if( $updater->update( $path ) ){
echo 'success';
return;
}
echo 'fail, refresh to try!';
}catch( Exception $e ){
throw $e;
}
});
// start
Flight::start();