Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/extmag/dhlshipping2/Plugin/Helper/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/extmag/dhlshipping2/Plugin/Helper/Connector.php
<?php
/**
 * Copyright © Extmag. All rights reserved.
 */

namespace Extmag\DhlShipping\Plugin\Helper;

use DOMDocument;
use Exception;

class Connector
{
    /**
     * @var string
     */
    public $dhlXml;

    /**
     * Before Plugin FormatNativeData
     *
     * @param \Extmag\Shiplab\Helper\Connector $subject
     * @param $data
     * @param $carrier
     * @param $requestType
     * @param $formattedData
     * @return array
     */
    public function beforeFormatNativeData(
        \Extmag\Shiplab\Helper\Connector $subject,
                                         $data,
                                         $carrier,
                                         $requestType = null,
                                         $formattedData = ''
    ) {
        try {
            if ('dhl' == strtolower($carrier)) {
                $this->dhlXml = new DOMDocument('1.0', 'UTF-8');
                switch ($requestType) {
                    case 'Rate':
                        $root = $this->dhlXml->createElementNS(
                            "http://www.dhl.com",
                            'p:DCTRequest'
                        );
                        $root->setAttributeNS(
                            'http://www.w3.org/2000/xmlns/',
                            'xmlns:p1',
                            'http://www.dhl.com/datatypes'
                        );
                        $root->setAttributeNS(
                            'http://www.w3.org/2000/xmlns/',
                            'xmlns:p2',
                            'http://www.dhl.com/DCTRequestdatatypes'
                        );
                        $root->setAttribute('schemaVersion', '3.0');
                        $root->setAttributeNS(
                            'http://www.w3.org/2001/XMLSchema-instance',
                            'xsi:schemaLocation',
                            'http://www.dhl.com DCT-req.xsd'
                        );
                        break;
                    case 'Ship':
                        $root = $this->dhlXml->createElementNS(
                            "http://www.dhl.com",
                            'req:ShipmentRequest'
                        );
                        $root->setAttributeNS(
                            'http://www.w3.org/2001/XMLSchema-instance',
                            'xsi:schemaLocation',
                            'http://www.dhl.com ship-val-global-req.xsd'
                        );
                        $root->setAttribute('schemaVersion', '10.0');
                        break;
                    case 'PickupCreation':
                        $root = $this->dhlXml->createElementNS(
                            "http://www.dhl.com",
                            'req:BookPURequest'
                        );
                        $root->setAttributeNS(
                            'http://www.w3.org/2001/XMLSchema-instance',
                            'xsi:schemaLocation',
                            'http://www.dhl.com pickup-global-req.xsd'
                        );
                        $root->setAttribute('schemaVersion', '3.0');
                        break;
                    case 'PickupCancel':
                        $root = $this->dhlXml->createElementNS(
                            "http://www.dhl.com",
                            'req:CancelPURequest'
                        );
                        $root->setAttributeNS(
                            'http://www.w3.org/2001/XMLSchema-instance',
                            'xsi:schemaLocation',
                            'http://www.dhl.com cancel-pickup-global-req.xsd'
                        );
                        $root->setAttribute('schemaVersion', '3.0');
                        break;
                    case 'Track':
                        $root = $this->dhlXml->createElementNS(
                            "http://www.dhl.com",
                            'req:KnownTrackingRequest'
                        );
                        $root->setAttributeNS(
                            'http://www.w3.org/2001/XMLSchema-instance',
                            'xsi:schemaLocation',
                            'http://www.dhl.com TrackingRequestKnown.xsd'
                        );
                        $root->setAttribute('schemaVersion', '1.0');
                        break;
                }

                $root = $this->dhlXml->appendChild($root);
                $this->dhlXml->formatOutput = true;
                foreach ($data as $rootKey => $value) {
                    if ($value !== null) {
                        $element = $subject::serializeXML($this->dhlXml, $rootKey, $value);
                        $root->appendChild($element);
                    }
                }

                $formattedData = mb_convert_encoding(
                    str_replace(
                        ["&amp;lt;", "&amp;gt;", "&amp;#39;", "&amp;quot;"],
                        ["&lt;", "&gt;", "&#39;", "&quot;"],
                        $this->dhlXml->saveXML()
                    ),
                    "UTF-8"
                );
            }
        } catch (Exception $e) {
            $subject->manager->debug($e->getMessage());
            $subject->manager->debug($e->getTraceAsString());
        }

        return [$data, $carrier, $requestType, $formattedData];
    }
}

Spamworldpro Mini