summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain Boissat rboissat <rboissat@lv0.in>2014-08-05 10:08:45 +0200
committerRomain Boissat rboissat <rboissat@lv0.in>2014-08-05 10:08:45 +0200
commit592b22a06433ab3aa66f39f5c462af074ed6c992 (patch)
tree60a80223b49ecf3f3bfef9e47c40fc131f50c3d2
parent3a14c6984da5200d10e4c5a0dcd5e6445ea27025 (diff)
completing HTTP_X_FORWARDED_FOR support
-rw-r--r--execute.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/execute.php b/execute.php
index a6f0a15..12d819e 100644
--- a/execute.php
+++ b/execute.php
@@ -22,6 +22,13 @@
require_once 'config.php';
require_once 'routers/router.php';
+// From where the user *really* comes from.
+if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+ $requester = $_SERVER['HTTP_X_FORWARDED_FOR'];
+} else {
+ $requester = $_SERVER['REMOTE_ADDR'];
+}
+
function process_output($output) {
global $config;
@@ -57,7 +64,7 @@ function process_output($output) {
// Obvious spam
if (!isset($_POST['dontlook']) || !empty($_POST['dontlook'])) {
- log_to_file('Spam detected from '.$_SERVER['REMOTE_ADDR'].'.');
+ log_to_file('Spam detected from '.$requester.'.');
die('Spam detected');
}
@@ -69,7 +76,7 @@ if (isset($_POST['query']) && !empty($_POST['query']) &&
$parameters = htmlspecialchars($_POST['parameters']);
// Do the processing
- $router = Router::instance($hostname, $_SERVER['REMOTE_ADDR']);
+ $router = Router::instance($hostname, $requester);
try {
$output = $router->send_command($query, $parameters);