-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
129 lines (123 loc) · 3.07 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
<?php
error_reporting(E_ALL);
ini_set('display_errors','1');
include_once "includes/global.php";
$path = ltrim(str_replace('//','/',$_SERVER['REQUEST_URI']), '/');
$elements = explode('/', $path);
//SERVER SIDE CODE TO DISPLAY DEMO
$className = '';
if($_SERVER['HTTP_HOST']=='dev.goaptitude.com'){
foreach($elements as $key => $element){
$className = strtolower($elements[0]);
if(strtolower($className)=='class'||strtolower($className)=='group'){
$className='Group';
if(isset($elements[$key+1])){
$groupid=$elements[$key+1];
}
break;
}
else if(strtolower($className)=='section'){
if(isset($elements[$key+1])){
$subjectName=$elements[$key+1];
if(isset($elements[$key+2])){
$chapterid=$elements[$key+2];
if(isset($elements[$key+3])){
$sectionid=$elements[$key+3];
}
else{
$sectionid = 1;
}
}
else{
$chapterName=1;
}
}
else{
$subjectName='math-1050';
}
break;
}
}
}
//LOCAL DEVELOPMENT CODE
else{
if(isset($_SESSION['userid'])){
if(count($elements) == 0 || (count($elements)==2 && !$elements[1])){
echo 'homepage';
$className='Homepage';
}
else {
array_shift($elements); // using localhost/aptitude
foreach($elements as $key => $element){
$className .= strtolower($element);
if(strtolower($className)=='class'||strtolower($className)=='group'){
$className='Group';
if(isset($elements[$key+1])){
$groupid=$elements[$key+1];
}
break;
} else if(strtolower($className)=='section'){
if(isset($elements[$key+1]) && !$elements[$key+1]==''){
$subjectName=$elements[$key+1];
if(isset($elements[$key+2]) && !$elements[$key+2]==''){
$chapterid=$elements[$key+2];
if(isset($elements[$key+3]) && !$elements[$key+3]==''){
$sectionid=$elements[$key+3];
} else{
$sectionid = 1;
}
} else{
$chapterid = 1;
$sectionid = 1;
}
} else{
$subjectName='math-1050';
}
break;
} else if(strtolower($className)=='profile'){
if(isset($elements[$key+1]) && !$elements[$key+1]==''){
$profileid=$elements[$key+1];
} else {
// go to my profile page
echo 'myprofile page';
//die;
break;
}
break;
} else if(strtolower($className)=='login'){
if(isset($elements[$key+1]) && !$elements[$key+1]==''){
$loginUserid=$elements[$key+1];
} else {
//die;
break;
}
break;
}
if($key<sizeof($elements)-1){
$className .= '_';
}
}
}
} else {
$className='login';
print_r($elements);
// Find where 'login' is in the $elements array
$loginPos=(array_search('login',array_map('strtolower',$elements)));
if(isset($elements[$loginPos+1]) && $elements[$loginPos+1]!=''){
$loginUserid=$elements[$loginPos+1];
}
}
}
if(isset($_SESSION['logged'])){
} else{
// saving this for later
//$user->name='Guest';
}
?>
<!DOCTYPE html>
<html lang="en">
<?php
//Load php file corresponding to page request
include_once 'includes/class.'.ucwords($className).'.php';
?>
</html>