summaryrefslogtreecommitdiff
path: root/blaears.php
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2025-05-28 09:17:55 +0100
committerLuke Bratch <luke@bratch.co.uk>2025-05-28 09:17:55 +0100
commit43ccb33c9c49d6c47b9364c9c7b24e491ee24cab (patch)
treeae69407dce636fda1ff9b4b6f95a69b285a12ff0 /blaears.php
parentead39a0fd68f88c6c7387997d95261b229af2fc0 (diff)
Add remote IP and timestamp logging, stop relaying messages if no URL and channel were set.HEADmaster
Diffstat (limited to 'blaears.php')
-rw-r--r--blaears.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/blaears.php b/blaears.php
index 66d6b29..0e0c850 100644
--- a/blaears.php
+++ b/blaears.php
@@ -1,15 +1,22 @@
<?php
+$notset = 0;
+
if (isset($_POST['url']) && isset($_POST['channel'])) {
$url = $_POST['url'];
$channel = preg_replace("/[^a-zA-Z0-9:\/\.]/", "", $_POST['channel']);
$cmd = "echo -e \"" . $channel . "\nNew file uploaded: " . $url . "\" | /home/smsd/core/msgrelay.bash";
} else {
+ $notset = 1;
$cmd = "echo -e \"theblueroom\nblaears-php received something but it did not have a url and a channel set.\" | /home/smsd/core/msgrelay.bash";
}
+file_put_contents('post.txt', "Timestamp: " . date('Y/m/d H:i:s') . " " . date('T') . "\n", FILE_APPEND);
+file_put_contents('post.txt', "Remote IP: " . $_SERVER['REMOTE_ADDR'] . "\n", FILE_APPEND);
file_put_contents('post.txt', "Command: " . $cmd . "\n", FILE_APPEND);
-exec($cmd, $output, $retval);
+if (!$notset) {
+ exec($cmd, $output, $retval);
+}
file_put_contents('post.txt', "Output: " . print_r($output, true), FILE_APPEND);
file_put_contents('post.txt', "Retval: " . $retval . "\n", FILE_APPEND);
?>