forked from pedro3005/whube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.php
71 lines (57 loc) · 1.86 KB
/
controller.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
<?php
/*
* License: AGPLv3
* Author: Paul Tagliamonte <paultag@whube.com>
* Description:
* This controlls _everything_ in whube
*/
session_start();
if ( ! isset ( $_SESSION['id'] ) ) {
$_SESSION['id'] = -1;
/*
* This sets the id to -1 if the user
* is not logged in
*/
}
$app_root = dirname( __FILE__ ) . "/";
$controller = basename( __FILE__ );
include( $app_root . "conf/site.php" );
include( $app_root . "conf/vcs.php" );
include( $app_root . "libs/php/globals.php" );
include( $app_root . "libs/php/easter.php" );
include( $app_root . "libs/php/core.php" );
if ($handle = opendir( $app_root . "model/" )) { // open up the model directory
while (false !== ($file = readdir($handle))) { // for each file
if ( $file != "." && $file != ".." ) { // ignore . / ..
$ftest = $file; // "backup" file
if (preg_match("/.*\.php$/i", $ftest)) {
include( $app_root . "model/" . $file ); // include all .php files
}
}
}
}
header( "Wisdom-Turd: " . getQuip() ); // wisdom turds!
if ( file_exists( $app_root . "install/install.php" ) ) {
include( $app_root . "install/install.php" ); // Disable access
include( $app_root . "view/view.php" ); // if we're not set up.
exit(0); // stop executing the controller code
}
$p = htmlentities( $_GET['p'], ENT_QUOTES);
$toks = explode( "/", $p );
$argv = $toks;
$argc = sizeof( $toks ); // these get passed to the view
if (
isset ( $toks[0] ) &&
$toks[0] != ""
) { // if there's a directive, use it.
$idz = $app_root . "content/" . basename( $toks[0] ) . ".php";
if ( file_exists( $idz ) ) {
include( $idz ); // all good :)
} else {
include( $app_root . "content/default.php" ); // fake the err.
}
} else {
header("Location: $SITE_PREFIX"); // redirect to the app root
}
include( $app_root . "view/view.php" ); // include the head/foot
?>