-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.php
94 lines (63 loc) · 2.24 KB
/
main.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
<?php
/*
* Author: Ian Innocent
* For: CourseMate
*/
/* Database connection variables ... and more! */
@session_start;
date_default_timezone_set("Africa/Nairobi");
//the complete site path
$this_site = "";
//database login credentials
$db = ''; $host = ''; $user = '';
$pass = '';
/*End of database connection variable declaration*/
if (@$jsoncallback == ""){$jsoncallback = $_REQUEST['callback'];}
//If the page resource identifier is provided
if(@$id != ''){
// WARNING ONLY ADD PAGES THAT ARE FULLY CLASSES OR PURELY FUNCTIONS TO THIS ARRAY Else Face the wrath of a broken connection
$ids = array('',
'mailer.php', //Primary
'obsfucate.php', //primary
'the_connection.php', //Primary
);
//find the position of the given page-id in the above array
$pos = array_search($id, $ids);
//if the given page-id is non existent in the array give it's position [currently 'NULL'] the value 'unknown'
if($ids[$pos]==''){$ids[$pos] = 'unknown';}
//Loop through the entire resource array
for($i = 0; $i <= (count($ids)-1); $i++){
//if the current position in the array is not the current one, include the given resource page
if($i <> $pos){
if($ids[$i] != ''){
include "$ids[$i]";
}
}
}
//Establish a database connection where required
if(@$connect){
//Establishing a database connection courtesy of the imported resource files
$connection = new connection($db, $host, $user, $pass, $jsoncallback);
}
//If the page resource identifier is not provided
}else{
$respArray = makeResponse("ERROR", "Critical Error: Failed to recognize application!", "");
echo $jsoncallback."(".json_encode($respArray).")";
die;
}
/*******************************************************
SIMPLE FUNCTIONS PLACED TO BE COPIED TO THE ACTUAL PAGES WHERE NEEDED
*/
function makeResponse($response, $message, $command){
return array( "response" => $response, "data" => array( "message" => $message, "command" => $command ) );
}
function sanitize($value){
return htmlspecialchars(str_replace("'","\'",$value));
}
function makeCookie($cname, $cval, $days){
$days = ($days * 24 * 60 * 60 * 1000);
@setcookie($cname,$cval,$days);
}
/******************************************************
*/
?>