-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr_main.php
115 lines (77 loc) · 3.08 KB
/
r_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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/*
* m4Labs Framework
*The main connector file.
*Allows the collective manipulation of a package
*
*
*
*
*/
/*
* m4Labs Framework Database connection variables ... and more! */
date_default_timezone_set("Africa/Nairobi");
$this_site = "eleanor/BitsaQuiz";
$db = 'quiz'; $host = 'localhost'; $user = 'root';
$pass = ''; //YOUR_DATABASE_PASSWORD_GOES_HERE
/*
* m4Labs FrameworkEnd 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('',
'r_mailer.php', //Framework Mailing Component
'r_obsfucate.php', //Framework Obsfucation Component
'r_connection.php', //Framework Database Manipulation Component
'r_minify.php', //Framework File Minifying component
'r_cleaner.php', //Framework File Deletion Component
'r_redirect.php' //Framework Page Redirect Cmponent
);
//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);
//$respArray = makeResponse("SUCCESS", "SUCCESSFULLY ESTABLISHED A DATABASE CONNECTION", "{alert, iara}");
//echo $jsoncallback."(".json_encode($respArray).")";
}
if(@$crypt[0] && @$crypt['key'] != "" && @$crypt['salt'] != ""){
$crypto = new obsfucate($crypt['key'], $crypt['salt']);
}
//If the page resource identifier is not provided
}else{
$respArray = makeResponse("ERROR", "Critical Error: Failed to recognize application!", "");
echo $jsoncallback."(".json_encode($respArray).")";
die;
}
/*
* m4Labs Framework******************************************************
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);
}
/*
* m4Labs Framework*****************************************************
*/
?>