function Keys2Lower($a) { if (!is_array($a)) { return $a; } unset($res); reset($a); while (list($key, $value) = each($a)) { if (is_array($value)) { $res[strtolower($key)] = Keys2Lower($value); } else { $res[strtolower($key)] = $value; } } // while loop return $res; }
// strip out the header while ($buffer = fgets($fd, 4096)) { $xmldata .= $buffer; } fclose($fd); } else { throw new Exception('Unable to connect to ' . SAM_HOST . ':' . SAM_PORT . ". Station might be offline.<br>The error returned was {$errstr} ({$errno})."); } if (empty($xmldata)) { throw new Exception('Invalid data returned!'); } //################################# // Initialize data //################################# $tree = XML2Array($xmldata); $request = Keys2Lower($tree["REQUEST"]); $code = $request["status"]["code"]; $message = $request["status"]["message"]; $requestID = $request["status"]["requestid"]; if (empty($code)) { throw new Exception('Invalid data returned!'); } if ($code != 200) { throw new Exception($message); } } else { //If a request was already made, allow dedication to the request $data = array(); $data['msg'] = strip_tags(Def('rmessage')); $data['name'] = strip_tags(Def('rname')); $db = Database::getInstance();