forked from Westie/phpuush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
107 lines (93 loc) · 1.66 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
<?php
/**
* phpuush service for PHP
*
* @author Blake <blake@totalru.in>
* @author PwnFlakes <pwnflak.es>
* @author Westie <westie@typefish.co.uk>
*
* @version: 0.1
*/
/**
* Include our classes
*/
include "classes/functions.php";
include "classes/database.php";
include "classes/element.php";
include "classes/handlers.php";
include "classes/user.php";
include "classes/upload.php";
/**
* Include our configuration files
*/
include "configuration.php";
/**
* Attempt initialisation of the MySQL connection
*/
try
{
$pDatabase = Database::getInstance();
}
catch(Exception $pException)
{
echo "-1";
exit;
}
/**
* Do some defining stuff
*/
$pFunctions = Functions::getInstance();
$_SEO = $pFunctions->translateRequestURI();
/**
* Add a bit of branding - branding is always cool!
*/
header("X-Powered-By: phpuush");
/**
* Delegate to our controllers
*/
try
{
if(isset($_SEO[0]))
{
if($_SEO[0] == "api")
{
if(file_exists("controllers/api/{$_SEO[1]}.php"))
{
require "controllers/api/{$_SEO[1]}.php";
}
else
{
throw new Exception("API method does not exist.");
}
}
elseif($_SEO[0] == "dl")
{
return "85";
}
elseif($_SEO[0] == "page")
{
if(file_exists("controllers/page/{$_SEO[1]}.php"))
{
require "controllers/page/{$_SEO[1]}.php";
}
else
{
throw new Exception("API method does not exist.");
}
}
else
{
require "controllers/file-handler.php";
}
}
else
{
echo "This is a phpuush endpoint.";
}
}
catch(Exception $pException)
{
echo "-1";
}
$pDatabase->close();
exit;