Example #1
0
//$response->loadXML(file_get_contents(__DIR__ . '/response.standard.xml'));
$response->loadXML(file_get_contents(__DIR__ . '/response.preferred.xml'));
//$response->loadXML(file_get_contents(__DIR__ . '/response.decline.xml'));
//$response->loadXML(file_get_contents(__DIR__ . '/response.refer.xml'));
$response->parse();
//If you want to have your response persist to the filesystem
//$response->save('./mvr2.xml');
//Our Response is received and parsed.  Lets print out the XML so you can look it over.
print PHP_EOL . PHP_EOL . "Simulated response from ADR:" . PHP_EOL;
print $response->getXML();
print PHP_EOL . PHP_EOL . "Begin custom processing of response XML:" . PHP_EOL;
//At this point, the communication with ADR is done, and you can do whatever you need with the response data.  This
//example involves scoring the data, based on our Codes, Rules and RuleSets (in the SQL).  This does little more than
//give an idea of what you might want to do with the data.
//History nodes have violations, violations have AVD Codes which we will score.
$historyNodes = $response->getHistoryNodes();
$pointTotal = 0;
$decisions = array();
$rulesHits = array();
if (count($historyNodes)) {
    /** @var \Adr\Response\HistoryNode $history */
    foreach ($historyNodes as $history) {
        if ($history->hasViolations()) {
            $violations = $history->getViolations();
            /** @var \Adr\Response\Violation $violation */
            foreach ($violations as $violation) {
                $avdCode = $violation->getIncident()->getAvdcode();
                $timeSince = $violation->getTimeSinceIncident();
                $q = "SELECT * FROM `MVR_AVDCodes` WHERE `productID` = 1 AND `avdcode`='" . $avdCode . "'";
                $res = $db->query($q);
                while ($row = $res->fetch_assoc()) {