$valid = !$form->has_errors(); // protect against CSRF attacks if ($ps->conf['main']['security']['csrf_protection']) { $valid = ($valid and $form->key_is_valid($cms->session)); } $list = array(); $valid = !$form->has_errors(); // process the XML and make sure it has valid data in it if ($valid) { $str = trim($input['xml']); $str = preg_replace('/^<\\?xml.+\\?>\\s*/', '', $str); if (substr($str, 0, 6) != '<maps>') { $str = "<maps>\n" . $str . "\n</maps>"; } $xml = new simplexml(); $ary = $xml->xml_load_string($str, 'array'); if (is_array($ary)) { if ($ary['map']) { $list = $ary['map'][0] ? $ary['map'] : array($ary['map']); } else { $form->error('fatal', $cms->trans("No valid 'map' nodes found! Make sure all 'map' nodes are contained with a root 'maps' node.")); } } else { if (substr($ary, 0, 15) == 'XML parse error') { // ary is an error string $form->error('fatal', $ary); } else { $form->error('fatal', "Invalid XML syntax!"); } } }
function simplexml_load_string($file) { $sx = new simplexml(); return $sx->xml_load_string($file); }