', $contents)[0]), 'html') !== false) { $fn='/tmp/html_' . $rn . '.html'; } else if (strpos(strtolower(explode('>', $contents)[0]), 'xml') !== false) { $fn='/tmp/xml_' . $rn . '.xml'; } file_put_contents($fn, $contents); } else { $fn=str_replace('+',' ',urldecode($_GET['htmlfile'])); } if ($fn != '') { if (strpos($fn, 'localhost') !== false) { $rhs=explode('localhost' . explode('/', explode('localhost', $fn)[1])[0], $fn)[1]; $fn=$_SERVER['DOCUMENT_ROOT'] . $rhs; $pth='/usr/bin/'; } else if (strpos($fn, 'rjmprogramming.com.au') !== false) { $rhs=explode('rjmprogramming.com.au' . explode('/', explode('rjmprogramming.com.au', $fn)[1])[0], $fn)[1]; $fn=$_SERVER['DOCUMENT_ROOT'] . $rhs; } else if (strpos($_SERVER['SERVER_NAME'], 'localhost') !== false) { $pth='/usr/bin/'; } } if (file_exists($fn)) { if ($contents == '') { $contents=file_get_contents($fn); } $prefn=$fn; $fn=realpath($fn); if (strpos(strtolower($fn), '.xml') !== false) { $vsnone='block'; $results=shell_exec($pth . 'xmllint --valid --noout ' . $fn . ' 2> ' . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err')) { $results.="\n"; $results.=file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); unlink(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); } } else if (strpos(strtolower($fn), '.htm') !== false) { $vsnone='block'; $results=shell_exec($pth . 'xmllint --html --valid --noout ' . $fn . ' 2> ' . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err')) { $results.="\n"; $results.=file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); unlink(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); } } if (strpos($fn, '/tmp/') !== false) { unlink($fn); } } else { $contents=''; if (strpos($fn, '/tmp/') !== false) { unlink($fn); } } } else if (isset($_POST['htmlfile'])) { if (substr(trim(urldecode($_POST['htmlfile'])) . ' ', 0, 1) == '<') { $contents=trim(str_replace('+',' ',urldecode($_POST['htmlfile']))); if (strpos(strtolower(explode('>', $contents)[0]), 'html') !== false) { $fn='/tmp/html_' . $rn . '.html'; } else if (strpos(strtolower(explode('>', $contents)[0]), 'xml') !== false) { $fn='/tmp/xml_' . $rn . '.xml'; } file_put_contents($fn, $contents); } else { $fn=str_replace('+',' ',urldecode($_POST['htmlfile'])); } if ($fn != '') { if (strpos($fn, 'localhost') !== false) { $rhs=explode('localhost' . explode('/', explode('localhost', $fn)[1])[0], $fn)[1]; $fn=$_SERVER['DOCUMENT_ROOT'] . $rhs; $pth='/usr/bin/'; } else if (strpos($fn, 'rjmprogramming.com.au') !== false) { $rhs=explode('rjmprogramming.com.au' . explode('/', explode('rjmprogramming.com.au', $fn)[1])[0], $fn)[1]; $fn=$_SERVER['DOCUMENT_ROOT'] . $rhs; } else if (strpos($_SERVER['SERVER_NAME'], 'localhost') !== false) { $pth='/usr/bin/'; } } if (file_exists($fn)) { $prefn=$fn; if ($contents == '') { $contents=file_get_contents($fn); } $fn=realpath($fn); if (strpos(strtolower($fn), '.xml') !== false) { $vsnone='block'; $results=shell_exec($pth . 'xmllint --valid --noout ' . $fn . ' 2> ' . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err')) { $results.="\n"; $results.=file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); unlink(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); } } else if (strpos(strtolower($fn), '.htm') !== false) { $vsnone='block'; $results=shell_exec($pth . 'xmllint --html --valid --noout ' . $fn . ' 2> ' . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err')) { $results.="\n"; $results.=file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); //file_put_contents('xxx.xxx', $results); unlink(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err'); } } if (strpos($fn, '/tmp/') !== false) { unlink($fn); } } else { $contents=''; if (strpos($fn, '/tmp/') !== false) { unlink($fn); } } } if ($contents != '') { $lines=explode("\n", $contents); for ($ii=1; $ii<=sizeof($lines); $ii++) { $precontents.='' . $ii . "\n"; } } ?> XML Lint Usage - RJM Programming - June, 2024

XML Lint Validation

RJM Programming - June, 2024

XML Lint validation of
Data to validateXML Lint results
value=Validate>