-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathucvs_listener.php
60 lines (50 loc) · 1.66 KB
/
ucvs_listener.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
<?php
/***************************************/
/* UCVS - Unified Callback Vote Script */
/* Written by LemoniscooL */
/* released under GPLv3 license */
/***************************************/
/*=================================================================================*/
/* Debug settings */
/* These settings are solely for debug purposes, dont change anything here! */
/*=================================================================================*/
//Uncomment to show all errors
error_reporting(E_ALL);
//in case no errors are shown uncomment this
ini_set("display_errors", 1);
require_once("autoload.php");
$ucvs = new ucvsCore();
//Check wich request method was used and create a reference
switch($_SERVER['REQUEST_METHOD'])
{
case 'GET':
$the_request = &$_GET;
break;
case 'POST':
$the_request = &$_POST;
break;
}
//store requesting IP in a variable | compatibility with CloudFlare
$reqIP = isset($_SERVER['HTTP_CF_CONNECTING_IP']) ? $_SERVER['HTTP_CF_CONNECTING_IP'] : $_SERVER['REMOTE_ADDR'];
//Check if requesting IP is whitelisted
$check = $ucvs->checkIP($reqIP);
if($check != true)
{
cLog::Log("Wrong IP requested UCVS! - IP: " . $reqIP);
die('Wrong IP!');
}
else
{
$result = $ucvs->procData($the_request, $reqIP);
if($result !== true)
{
cLog::Log("Error while processing data: " . $result . " - User ID: " . $ucvs->getUser($the_request) . " Site: " . $ucvs->getSite($reqIP));
echo $result;
}
else
{
cLog::Log("Valid UCVS request finished successfull" . " - User ID: " . $ucvs->getUser($the_request) . " Site: " . $ucvs->getSite($reqIP));
echo 'OK';
}
}
?>