|
| 1 | +<?php |
| 2 | + |
| 3 | +include "sbnr/config.php"; |
| 4 | +if($SBNR_CONTACT_ENABLED === false) { exit; } |
| 5 | + |
| 6 | +include "sbnr/security.php"; |
| 7 | +include "sbnr/utils.php"; |
| 8 | +include "sbnr/pre.php"; |
| 9 | + |
| 10 | +if(isset($_POST["CSRF_TOKEN"], $_POST["txtName"], $_POST["txtPhone"], $_POST["txtMessage"])) { |
| 11 | + if(noHTML($_POST["CSRF_TOKEN"]) == $_SESSION['SBNR_CSRF_TOKEN']) { |
| 12 | + $name = noHTML(base64_decode(urldecode($_POST["txtName"]))); |
| 13 | + $number = preg_replace("/[^0-9]/", '', noHTML(base64_decode(urldecode($_POST["txtPhone"])))); |
| 14 | + $message = noHTML(base64_decode(urldecode($_POST["txtMessage"]))); |
| 15 | + if(strlen($name) <= $SBNR_CONTACT_MAX_LENGTH_NAME |
| 16 | + && strlen($number) >= $SBNR_CONTACT_MIN_LENGTH_PHONE_NUMBER |
| 17 | + && strlen($number) <= $SBNR_CONTACT_MAX_LENGTH_PHONE_NUMBER |
| 18 | + && strlen($message) <= $SBNR_CONTACT_MAX_LENGTH_MESSAGE) { |
| 19 | + |
| 20 | + $msentinel = generateRandomString($SBNR_CONTACT_MESSAGE_PREFIX_LENGTH); |
| 21 | + |
| 22 | + if ($SBNR_CONTACT_GEOIP) { |
| 23 | + $geoIP = $_SERVER["MM_COUNTRY_CODE"]; |
| 24 | + if(strlen($_SERVER["MM_CITY_NAME"] . $_SERVER["MM_REGION_CODE"]) > 1) { |
| 25 | + $geoIP = $_SERVER["MM_CITY_NAME"] . ", " . $_SERVER["MM_REGION_CODE"] . " " . $_SERVER["MM_COUNTRY_CODE"]; |
| 26 | + } |
| 27 | + $location = "[" . $msentinel . "] Location: " . $geoIP . "\n"; |
| 28 | + } |
| 29 | + |
| 30 | + $message = "[" . $msentinel . "] MESSAGE START\n" . |
| 31 | + "[" . $msentinel . "] Name: " . $name . "\n" . |
| 32 | + "[" . $msentinel . "] Phone Number: " . $number . "\n" . |
| 33 | + $location . |
| 34 | + "[" . $msentinel . "] Message: \n" . $message . "\n" . |
| 35 | + "[" . $msentinel . "] MESSAGE END"; |
| 36 | + |
| 37 | + exec("echo " . escapeshellarg($message) . " | sendxmpp -f " . $SBNR_CONTACT_SENDXMPP_CONFIG . " -t " . $SBNR_CONTACT_SENDXMPP_RECEIPENT); |
| 38 | + print("Message Sent!"); |
| 39 | + } else { |
| 40 | + generateErrorPageBasic(406); |
| 41 | + } |
| 42 | + } else { |
| 43 | + generateErrorPageBasic(401); |
| 44 | + } |
| 45 | +} else { |
| 46 | + generateErrorPageBasic(400); |
| 47 | +} |
| 48 | + |
| 49 | +$_SESSION['SBNR_CSRF_TOKEN'] = bin2hex(random_bytes(32)); //Always renew the token to prevent brute forcing |
| 50 | + |
| 51 | +?> |
0 commit comments