예제 #1
0
    header('HTTP/1.1 500 Internal Server Error');
    $log->error("[listener] The gateway include {$gatewayfile} could not be located - is this the correct gateway name?");
    $log->error_fatal("[listener] Sorry, there is no such destination device - please check your input.");
}
include $gatewayfile;
$gateway = new device_gateway();
/*
	Fetch the message details & input validate. Whilst there's no SQL DB to worry about, we do need
	to filter the phone number and body to ensure they're valid and that there's no sneaky XML
	injection taking place that could mess with the generated XMPP message.

	Format:
	$message_raw["phone"]	Source phone number
	$message_raw["body"]	Message string
*/
$message_raw = $gateway->message_listen();
if (!$message_raw) {
    header('HTTP/1.1 500 Internal Server Error');
    $log->error_fatal("[listener] An invalid message request was recieved, unable to process.");
}
$message = array();
if (preg_match("/^[+]*[0-9]{1}[0-9]*\$/", $message_raw["phone"])) {
    $message["phone"] = $message_raw["phone"];
} else {
    header('HTTP/1.1 500 Internal Server Error');
    $log->error_fatal("[listener] Invalid phone number recieved!");
}
if (preg_match("/^[\\S\\s]*\$/", $message_raw["body"])) {
    // quote out special XML characters to prevent
    // messing with the XML body of the XMPP message
    // that gets generated.