How to Parse via PHP
How to Parse via PHP

How to Parse via PHP

The following example shows how to parse the POST message.
It does not, however, show how to use this information on other pages, store the results in a database, report this to another device on the domain, etc. The response in this example will be sent back to the printer, but it will be ignored by the printer. If you wish to see the response you can use a packet sniffing tool such as Wireshark.
<?php $alertMsg = urldecode($_POST["alertMsg"]); if (preg_match("/(\w+(\s+\w+)?):\s+(((SGD SET)\s+([\w\d\.\_]+)\s+\->\s+(.+))|([\w|\s]+))/", $alertMsg, $matches)== 1) { $alertType = $matches[1]; if ($matches[5] === "SGD SET") { $alertCondition = $matches[5]; $alertSgdName = htmlspecialchars($matches[6]); $alertSgdData = htmlspecialchars($matches[7]); } else { $alertCondition = $matches[3]; } } echo "<H1>Alert Received</H1><br/>\r\n"; echo "<h2>Original Message = $alertMsg</h2><br/>\r\n"; echo "<h2>Alert Type = $alertType</h2><br/>\r\n"; echo "<h2>Alert Condition = $alertCondition</h2><br/>\r\n"; echo "<h2>SGD Name = $alertSgdName</h2><br/>\r\n"; echo"<h2>SGD Value = $alertSgdData</h2><br/>\r\n"; ?>