function logXml($xmlMsg, $subject = null)
 {
     if ($this->_debugSecureLogging) {
         $xmlMsg = preg_replace("/<eBayAuthToken>.*<\\/eBayAuthToken>/", "<eBayAuthToken>...</eBayAuthToken>", $xmlMsg);
         $xmlMsg = preg_replace("/<AuthCert>.*<\\/AuthCert>/", "<AuthCert>...</AuthCert>", $xmlMsg);
     }
     if ($this->_debugXmlBeautify) {
         if (is_object($xmlMsg)) {
             $this->log($xmlMsg);
         } else {
             require_once 'XML/Beautifier.php';
             $xmlb = new XML_Beautifier();
             $this->log($xmlb->formatString($xmlMsg), $subject);
         }
         return;
     }
     $this->log($xmlMsg, $subject);
 }
Example #2
0
 /**
  * Display final results
  *
  * Display final results, when data source parsing is over.
  *
  * @access public
  * @return void
  * @since  version 1.8.0b2 (2008-06-03)
  */
 function display()
 {
     if ($this->parseData === false) {
         // invalid data source
         return;
     }
     $version = isset($this->conf['xml']['version']) ? $this->conf['xml']['version'] : '1.0';
     $encoding = isset($this->conf['xml']['encoding']) ? $this->conf['xml']['encoding'] : 'UTF-8';
     $standalone = isset($this->conf['xml']['standalone']) ? $this->conf['xml']['standalone'] : null;
     $msg = XML_Util::getXMLDeclaration($version, $encoding, $standalone);
     $msg .= PHP_EOL;
     $msg .= XML_Util::createStartElement('pci', array('version' => '1.9.0'));
     $o = $this->args['output-level'];
     $v = $this->args['verbose'];
     $dataSource = $this->_parser->dataSource['dataSource'];
     $dataType = $this->_parser->dataSource['dataType'];
     $options = $this->_parser->options;
     if ($dataType == 'directory' || $dataType == 'array' || $dataType == 'file') {
         // parsing a directory or a list of files, chunks of code
         if ($options['is_string'] == false) {
             if ($dataType == 'directory') {
                 // print <dir> tag
                 $tag = array('qname' => 'dir', 'content' => dirname($dataSource[0]));
             } else {
                 // print <file> tag
                 $tag = array('qname' => 'file', 'content' => $dataSource[0]);
             }
             $msg .= XML_Util::createTagFromArray($tag);
             $msg .= PHP_EOL;
         }
         // print global <version> tag
         if ($o & 16) {
             if (empty($this->parseData['max_version'])) {
                 $attr = array();
             } else {
                 $attr = array('max' => $this->parseData['max_version']);
             }
             $tag = array('qname' => 'version', 'attributes' => $attr, 'content' => $this->parseData['version']);
             $msg .= XML_Util::createTagFromArray($tag);
             $msg .= PHP_EOL;
         }
         // print global <conditions> tag group
         if ($o & 1) {
             $msg .= $this->_printTagList($this->parseData['cond_code'], 'condition');
         }
         // print global <extensions> tag group
         if ($o & 2) {
             $msg .= $this->_printTagList($this->parseData['extensions'], 'extension');
         }
         // print global <constants> tag group
         if ($o & 4) {
             $msg .= $this->_printTagList($this->parseData['constants'], 'constant');
         }
         // print global <tokens> tag group
         if ($o & 8) {
             $msg .= $this->_printTagList($this->parseData['tokens'], 'token');
         }
         // print global <ignored> tag group
         $msg .= XML_Util::createStartElement('ignored');
         $msg .= PHP_EOL;
         // with children groups <files>, <functions>, <extensions>, <constants>
         $ignored = array('file' => $this->parseData['ignored_files'], 'function' => $this->parseData['ignored_functions'], 'extension' => $this->parseData['ignored_extensions'], 'constant' => $this->parseData['ignored_constants']);
         foreach ($ignored as $tag => $data) {
             $msg .= $this->_printTagList($data, $tag);
         }
         $msg .= XML_Util::createEndElement('ignored');
         $msg .= PHP_EOL;
         // remove summary data
         unset($this->parseData['ignored_files']);
         unset($this->parseData['ignored_functions']);
         unset($this->parseData['ignored_extensions']);
         unset($this->parseData['ignored_constants']);
         unset($this->parseData['max_version']);
         unset($this->parseData['version']);
         unset($this->parseData['classes']);
         unset($this->parseData['functions']);
         unset($this->parseData['extensions']);
         unset($this->parseData['constants']);
         unset($this->parseData['tokens']);
         unset($this->parseData['cond_code']);
         if ($v & 4 || $options['debug'] == true) {
             // print local <functions> tag group
             $msg .= $this->_printTagList($this->parseData, 'function');
             $entries = array_keys($this->parseData);
             foreach ($entries as $k) {
                 if (is_numeric($k[0])) {
                     unset($this->parseData[$k]);
                 }
             }
         }
         if ($dataType == 'file') {
             // parsing a single file
             $files = array($dataSource[0] => $this->parseData);
         } else {
             $files = $this->parseData;
         }
     } else {
         // ... or a chunk of code (string)
         $files = array($this->parseData);
     }
     if ($this->args['summarize'] === false && count($files) > 1) {
         if ($options['is_string'] == false) {
             // print <files> tag group
             $msg .= XML_Util::createStartElement('files', array('count' => count($files)));
             $msg .= PHP_EOL;
         }
         foreach ($files as $file => $this->parseData) {
             if ($options['is_string'] == true) {
                 $msg .= XML_Util::createStartElement('string', array('name' => $file));
             } else {
                 // print local <file> tag
                 $msg .= XML_Util::createStartElement('file', array('name' => $file));
             }
             $msg .= PHP_EOL;
             // print local <version> tag
             if ($o & 16) {
                 if (empty($this->parseData['max_version'])) {
                     $attr = array();
                 } else {
                     $attr = array('max' => $this->parseData['max_version']);
                 }
                 $tag = array('qname' => 'version', 'attributes' => $attr, 'content' => $this->parseData['version']);
                 $msg .= XML_Util::createTagFromArray($tag);
                 $msg .= PHP_EOL;
             }
             // print local <conditions> tag group
             if ($o & 1) {
                 $msg .= $this->_printTagList($this->parseData['cond_code'], 'condition');
             }
             // print local <extensions> tag group
             if ($o & 2) {
                 $msg .= $this->_printTagList($this->parseData['extensions'], 'extension');
             }
             // print local <constants> tag group
             if ($o & 4) {
                 $msg .= $this->_printTagList($this->parseData['constants'], 'constant');
             }
             // print local <tokens> tag group
             if ($o & 8) {
                 $msg .= $this->_printTagList($this->parseData['tokens'], 'token');
             }
             // print local <ignored> tag group
             $msg .= XML_Util::createStartElement('ignored');
             $msg .= PHP_EOL;
             // with children groups <functions>, <extensions>, <constants>
             $ignored = array('function' => $this->parseData['ignored_functions'], 'extension' => $this->parseData['ignored_extensions'], 'constant' => $this->parseData['ignored_constants']);
             foreach ($ignored as $tag => $data) {
                 $msg .= $this->_printTagList($data, $tag);
             }
             $msg .= XML_Util::createEndElement('ignored');
             $msg .= PHP_EOL;
             // extra information only if verbose mode >= 4
             if ($v & 4 || $options['debug'] == true) {
                 unset($this->parseData['ignored_files']);
                 unset($this->parseData['ignored_functions']);
                 unset($this->parseData['ignored_extensions']);
                 unset($this->parseData['ignored_constants']);
                 unset($this->parseData['max_version']);
                 unset($this->parseData['version']);
                 unset($this->parseData['classes']);
                 unset($this->parseData['functions']);
                 unset($this->parseData['extensions']);
                 unset($this->parseData['constants']);
                 unset($this->parseData['tokens']);
                 unset($this->parseData['cond_code']);
                 // print local <functions> tag group
                 $msg .= $this->_printTagList($this->parseData, 'function');
             }
             if ($options['is_string'] == true) {
                 $msg .= XML_Util::createEndElement('string');
             } else {
                 $msg .= XML_Util::createEndElement('file');
             }
             $msg .= PHP_EOL;
         }
         if ($options['is_string'] == false) {
             $msg .= XML_Util::createEndElement('files');
             $msg .= PHP_EOL;
         }
     }
     $msg .= XML_Util::createEndElement('pci');
     $msg .= PHP_EOL;
     if (strtolower($this->conf['use-beautifier']) != 'no') {
         // try to see if we can improve XML render
         $beautifier = 'XML/Beautifier.php';
         if (PHP_CompatInfo_Renderer::isIncludable($beautifier)) {
             include_once $beautifier;
             $def = array();
             $opt = isset($this->conf['beautifier']) ? $this->conf['beautifier'] : $def;
             $fmt = new XML_Beautifier($opt);
             $msg = $fmt->formatString($msg);
         }
     }
     echo $msg;
 }
Example #3
0
<?php

/**
* XML_Beautifier example 1
*
* This example displays the basic usage.
*
* @author	Stephan Schmidt <*****@*****.**>
*/
error_reporting(E_ALL);
require_once 'XML/Beautifier.php';
$fmt = new XML_Beautifier();
$result = $fmt->formatFile('test.xml', 'test2.xml');
if (PEAR::isError($result)) {
    echo $result->getMessage();
    exit;
}
echo "<h3>Original file</h3>";
echo "<pre>";
echo htmlspecialchars(implode("", file('test.xml')));
echo "</pre>";
echo "<br><br>";
echo "<h3>Beautified file</h3>";
echo "<pre>";
echo htmlspecialchars(implode("", file('test2.xml')));
echo "</pre>";
 function getFullWireLog($beautifyRequest = true)
 {
     if ($beautifyRequest === true) {
         require_once 'XML/Beautifier.php';
         $xmlb = new XML_Beautifier();
         $this->Request = $xmlb->formatString($this->Request);
     }
     return $this->_RequestUrl . ($this->debugHtml ? "<br>" : "\n") . ($this->debugHtml ? htmlentities($this->Request) : $this->Request) . ($this->debugHtml ? "<br>" : "\n") . ($this->debugHtml ? htmlentities($this->Response) : $this->Response);
 }
Example #5
0
/**
 * Dump pretty XML
 *
 * @param mixed $xml
 */
function dxml($xml)
{
    $xml = null;
    if ($xml instanceof DOMElement) {
        $xml = $xml->ownerDocument->saveXML($xml);
    } else {
        if ($xml instanceof DOMDocument) {
            $xml = $xml->saveXML();
        } else {
            if ($xml instanceof SimpleXMLElement) {
                $xml = $xml->saveXML();
            } else {
                if (is_string($xml)) {
                    $xml = $xml;
                }
            }
        }
    }
    // make the XML readable by human eye!
    if (!is_null($xml)) {
        $er = error_reporting();
        error_reporting(0);
        // PEAR has lots of strict errors
        if (class_exists('XML_Beautifier')) {
            $fmt = new XML_Beautifier();
            $xml = PHP_EOL . $fmt->formatString($xml, "Plain");
        }
        error_reporting($er);
    }
    decorate('<div style="background:#f8f8f8;margin:5px;padding:5px;border: solid grey 1px;">' . PHP_EOL);
    $trace = dtrace();
    echo PHP_EOL . PHP_EOL . 'o----' . $trace . '----o' . PHP_EOL;
    decorate('<pre style="margin:0px;padding:0px;">' . PHP_EOL);
    var_dump($xml) . PHP_EOL;
    if (!is_null($xml)) {
        if (class_exists('Zend_Debug')) {
            // replaces < > with &lt; &gt;
            Zend_Debug::dump($xml) . PHP_EOL;
        } else {
            var_dump(htmlspecialchars($xml)) . PHP_EOL;
        }
    }
    decorate('</pre>' . PHP_EOL);
    decorate('</div>' . PHP_EOL);
    cli_decorate('o----' . str_repeat('-', strlen($trace)) . '----o' . PHP_EOL . PHP_EOL);
}
Example #6
0
 /**
  * Indent an XML text 
  *
  * @param string $xml   XML text to indent
  * 
  * @return string       The XML text indented
  * @acess public
  */
 function indentXML($xml)
 {
     require_once "XML/Beautifier.php";
     $fmt = new XML_Beautifier();
     $out =& $fmt->formatString($xml);
     return $out;
 }
Example #7
0
// Para ver en la Pantalla el XML recibido  (sin addenda)
/*
 * Paquetes para ver bonito el codigo en la pantalla
 * No son necesarios 'para validar'
 * solo son para 'ver bonito' lo que se valida
 *
 * Son gratuitos se obtienen de pear.php.net
 * http://pear.php.net/package/XML_Beautifier/
 * http://pear.php.net/package/Text_Highlighter/
 *
 * Alguna dependencia de pear se baja del mismo pear
 * http://pear.php.net/package/XML_Parser
 * */
require_once 'XML/Beautifier.php';
require_once 'Text/Highlighter.php';
$fmt = new XML_Beautifier();
$fmt->setOption("multilineTags", TRUE);
$paso = $fmt->formatString($texto);
if (substr($paso, 0, 10) != "XML_Parser") {
    $texto = $paso;
}
// XML correctamente formado
$hl =& Text_Highlighter::factory('XML', array('numbers' => HL_NUMBERS_TABLE));
echo "<div style='height:300px; overflow:auto';";
echo $hl->highlight($texto);
echo "</div>";
/////////////////////////////////////////////////////////////////////////////
libxml_use_internal_errors(true);
// Gracias a Salim Giacoman
$xml = new DOMDocument();
$ok = $xml->loadXML($texto);
Example #8
0
<?php

/**
* XML_Beautifier example 2
*
* This example displays the formatString()
* method which can be used to beautify an XML string instead
* of a file.
*
* @author	Stephan Schmidt <*****@*****.**>
*/
error_reporting(E_ALL);
$xmlString = '<xml><foo bar="tomato &amp; Cheese"/><argh>foobar</argh></xml>';
require_once 'XML/Beautifier.php';
$fmt = new XML_Beautifier();
$result = $fmt->formatString($xmlString);
echo "<h3>Original string</h3>";
echo "<pre>";
echo htmlspecialchars($xmlString);
echo "</pre>";
echo "<br><br>";
echo "<h3>Beautified string</h3>";
echo "<pre>";
echo htmlspecialchars($result);
echo "</pre>";
Example #9
0
if (!isset($_GET['desc']) || $_GET['desc'] != 'show') {
    $description_link = '<a href="admin.php?page=wplister&action=display_log_entry&desc=show&log_id=' . $id . '">show description</a>';
    $req = preg_replace("/<Description>.*<\\/Description>/uUsm", "<Description> ... ___desc___ ... </Description>", $req);
}
// force WP default error reporting level - hide php strict notices for PEAR XML formatter
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
// try to include PEAR and hide php warnings on fail
@(include_once 'PEAR.php');
if (class_exists('PEAR') && !is_numeric($req) && 'custom' != get_option('wplister_xml_formatter', 'default')) {
    // add XML dir to include path
    $incPath = WPLISTER_PATH . '/includes';
    set_include_path(get_include_path() . ':' . $incPath);
    // use XML_Beautifier.php to format XML
    define('XML_BEAUTIFIER_INCLUDE_PATH', WPLISTER_PATH . '/includes/XML/Beautifier');
    include_once WPLISTER_PATH . '/includes/XML/Beautifier.php';
    $fmt = new XML_Beautifier();
    $formatted_req = $fmt->formatString($req);
    // check if XML_Beautifier returned an error
    if (PEAR::isError($formatted_req)) {
        // fall back to build in formatter
        $req = wpl_formatXmlString($req);
        $req .= '<!-- wpl_formatXmlString() -->';
    } else {
        $req = $formatted_req . '<!-- XML_Beautifier -->';
    }
} else {
    // use build in function to format XML
    $req = wpl_formatXmlString($req);
    $req .= '<!-- wpl_formatXmlString() -->';
}
// remove <![CDATA[ * ]]> tags for readibily
Example #10
0
<?php

/**
 * XML_Beautifier example 7
 *
 * This example shows to to change the treatment
 * of data section
 *
 * @author	Stephan Schmidt <*****@*****.**>
 */
error_reporting(E_ALL);
require_once 'XML/Beautifier.php';
$fmt = new XML_Beautifier(array('removeLineBreaks' => false));
$result = $fmt->formatFile('test3.xml');
echo "<h3>Original file</h3>";
echo "<pre>";
echo htmlspecialchars(implode("", file('test3.xml')));
echo "</pre>";
echo "<br><br>";
echo "<h3>Beautified output</h3>";
echo "<pre>";
echo htmlspecialchars($result);
echo "</pre>";