HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/SGL/Task/XmlToPhpUnserializer.php
<?php
require_once 'XML/Unserializer.php';

/**
 * Unserializes XML data into PHP objects.
 *
 * Used when the REST server receives an XML post
 *
 * @package Task
 * @author  Demian Turner <demian@phpkitchen.com>
 */
class SGL_Task_XmlToPhpUnserializer extends SGL_DecorateProcess
{
    public function process(&$input, &$output)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);

        if ($_SERVER['REQUEST_METHOD'] == 'POST') {

            $req = $input->getRequest();
            $entityName = SGL_Config::get('REST.entityName');
            $xml = $req->get($entityName, $allowTags = true);
            $unserializer = new XML_Unserializer();
            ///fix PHP 5.3
            $unserializer = &$unserializer;
            $unserializer->setOption('tagAsClass', true);
            $unserializer->setOption('ignoreKeys', $this->getKeysToIgnore());
            $unserializer->setOption('complexType', $this->getComplexTypes());

            $result = $unserializer->unserialize($xml);
            if (SGL::isError($result)) {
                return $result;
            }
            $data = $unserializer->getUnserializedData();
            $input->$entityName = $data;
        }
        $this->processRequest->process($input, $output);
    }

    /**
     * Builds an array of keys from the configuration to ignore.
     *
     * @return array
     */
    public function getKeysToIgnore()
    {
        $keys = SGL_Config::get('REST.keysToIgnore');
        $aKeys = explode(',', $keys);
        return $aKeys;
    }

    /**
     * Builds a hash  from the configuration of complex type names and their type.
     *
     * Type = 'object' by default
     *
     * @return array
     */
    public function getComplexTypes()
    {
        $keys = SGL_Config::get('REST.complexType');
        $aKeys = explode(',', $keys);
        $aRet = array();
        foreach ($aKeys as $key) {
            $aRet[$key] = 'object';
        }
        return $aRet;
    }
}
?>