Japanese English

PHP deobfuscation, decryption, reconstruction tool

De-obfuscate PHP malware/viruses and tampering code on Wordpress to original readable code.

*Please note that not all obfuscation codes can be decoded.

Decoded the code below.

<?php declare(strict_types=1); namespace OneTeamSoftware\WC\Shipping; use OneTeamSoftware\Logger\LoggerInterface; use OneTeamSoftware\WC\Orders\Query; class OrderShipments { private $id; private $logger; private $key; private $completedStatuses; public function __construct(string $hsNwz, LoggerIn...



Obfuscated php code

<?php
declare(strict_types=1);
namespace OneTeamSoftware\WC\Shipping;
use OneTeamSoftware\Logger\LoggerInterface;
use OneTeamSoftware\WC\Orders\Query;
class OrderShipments
{
    private $id;
    private $logger;
    private $key;
    private $completedStatuses;
    public function __construct(string $hsNwz, LoggerInterface $w8Mi0)
    {
        $this->id = $hsNwz;
        $this->logger = $w8Mi0;
        $this->key = $hsNwz . "\137\x73\150\x69\160\155\145\x6e\164\x73";
        $this->completedStatuses = array();
    }
    public function setCompletedStatuses(array $uOcBI): void
    {
        $this->completedStatuses = $uOcBI;
    }
    public function has(int $iKfxj, string $FCwSX): bool
    {
        $uUHNN = $this->get($iKfxj);
        return isset($uUHNN[$FCwSX]);
    }
    public function get(int $iKfxj, string $FCwSX = '', int $txXCS = 0): array
    {
        if ($iKfxj <= 0 && false === empty($FCwSX)) {
            $iKfxj = $this->getOrderIdByShipmentId($FCwSX);
        }
        if ($iKfxj <= 0) {
            return array();
        }
        $this->logger->debug(__FILE__, 100, "\147\145\x74\54\40\x6f\x72\144\145\162\x49\x64\x3a\40\x25\144\54\40\163\x68\x69\160\x6d\x65\x6e\164\x49\144\x3a\x20\x25\x73\54\40\x76\145\x6e\x64\157\162\111\144\72\x20\x25\144", $iKfxj, $FCwSX, $txXCS);
        $uUHNN = get_post_meta($iKfxj, $this->key, true);
        if (empty($uUHNN)) {
            $uUHNN = array();
        }
        $uUHNN = $this->getVendorShipments($uUHNN, $txXCS);
        $uUHNN = apply_filters($this->key, $uUHNN, $txXCS);
        if (false === empty($FCwSX)) {
            $JFCNv = $this->getShipmentId($FCwSX);
            if (isset($uUHNN[$JFCNv])) {
                $uUHNN = array($FCwSX => $uUHNN[$JFCNv]);
            } else {
                $uUHNN = array();
            }
        }
        $this->logger->debug(__FILE__, 121, "\x66\157\x75\156\144\x20\163\x68\x69\160\155\x65\x6e\164\163\x3a\x20\45\x73", print_r($uUHNN, true));
        return $uUHNN;
    }
    public function put(int $iKfxj, array $uT9iq, int $txXCS = 0): array
    {
        if (empty($iKfxj) || empty($uT9iq["\x69\x64"])) {
            return array();
        }
        $this->logger->debug(__FILE__, 141, "\160\x75\x74\54\40\157\x72\x64\x65\x72\x49\x64\x3a\40\x25\144\54\40\x73\150\x69\x70\x6d\x65\156\x74\x3a\x20\x25\163\54\x20\x76\145\156\144\x6f\162\111\144\x3a\x20\x25\x64", $iKfxj, print_r($uT9iq, true), $txXCS);
        $uT9iq = apply_filters($this->id . "\x5f\163\x68\x69\x70\x6d\x65\156\x74", $uT9iq, $iKfxj, $txXCS);
        $FCwSX = $this->getShipmentId((string) $uT9iq["\x69\144"]);
        $uUHNN = $this->get($iKfxj);
        $NT6aX = false;
        if (false === empty($uT9iq["\163\x74\141\164\165\x73"])) {
            if (empty($uUHNN[$FCwSX]["\x73\x74\x61\164\165\163"])) {
                $this->logger->debug(__FILE__, 151, "\160\x72\x65\x76\x69\x6f\x75\163\40\163\x74\141\x74\x75\x73\40\167\141\x73\x20\x6e\x6f\164\x20\163\x65\164\54\40\163\x6f\x20\x6d\141\x72\153\x20\151\x74\40\x73\164\141\164\165\x73\x20\x61\x73\x20\x63\x68\141\x6e\x67\145\x64");
                $NT6aX = true;
            } elseif ($uUHNN[$FCwSX]["\163\x74\141\164\x75\163"] !== $uT9iq["\x73\x74\141\164\165\x73"]) {
                $this->logger->debug(__FILE__, 155, "\x73\164\141\164\165\163\x20\150\x61\163\x20\143\150\141\x6e\x67\145\x64");
                $NT6aX = true;
            }
        }
        if (empty($txXCS)) {
            if (false === empty($uUHNN[$FCwSX]["\166\145\156\x64\157\x72\x5f\x69\x64"])) {
                $txXCS = $uUHNN[$FCwSX]["\x76\x65\156\x64\x6f\162\x5f\151\x64"];
            } elseif (false === empty($uT9iq["\x76\145\x6e\144\x6f\162\x5f\151\x64"])) {
                $txXCS = $uT9iq["\166\145\156\144\x6f\162\x5f\151\144"];
            }
        }
        $uT9iq["\157\162\x64\x65\162\137\x69\x64"] = $iKfxj;
        $uT9iq["\166\145\x6e\144\x6f\x72\x5f\151\144"] = $txXCS;
        $uT9iq = array_merge($uUHNN[$FCwSX] ?? [], $uT9iq);
        $uUHNN[$FCwSX] = $uT9iq;
        $hWJKz = $this->set($iKfxj, $uUHNN);
        if ($hWJKz) {
            $this->logger->debug(__FILE__, 178, "\x73\x61\x76\145\144\40\x73\165\x63\x63\145\x73\163\x66\165\x6c\x79");
            if ($NT6aX) {
                $this->logger->debug(__FILE__, 181, "\x6e\x6f\x74\151\x66\171\40\141\x62\157\165\164\x20\163\164\141\164\x75\163\x20\143\150\x61\x6e\147\145");
                do_action($this->id . "\x5f\163\150\151\x70\155\145\156\x74\137\163\164\141\x74\x75\163\137\x63\x68\141\x6e\147\145\144", $iKfxj, $uT9iq);
                $this->setStatusChanged($iKfxj);
            }
        }
        $this->setUpdated($iKfxj, $uUHNN);
        return $uT9iq;
    }
    public function delete(int $iKfxj, string $FCwSX, int $txXCS = 0): bool
    {
        $this->logger->debug(__FILE__, 203, "\x64\x65\x6c\x65\164\x65\x2c\40\157\162\144\145\162\x49\x64\72\x20\45\144\54\40\163\x68\x69\160\x6d\145\156\164\111\x64\x3a\40\45\x73\x2c\x20\166\x65\156\x64\157\x72\x49\144\72\x20\45\x64", $iKfxj, $FCwSX, $txXCS);
        $uUHNN = $this->get($iKfxj);
        $JFCNv = $this->getShipmentId($FCwSX);
        if (!isset($uUHNN[$JFCNv])) {
            $this->logger->debug(__FILE__, 208, "\163\150\151\x70\x6d\x65\156\164\x20\144\x6f\145\x73\40\156\x6f\x74\40\145\x78\151\x73\164");
            return false;
        }
        if (false === empty($txXCS) && (empty($uUHNN[$JFCNv]["\x76\145\156\x64\x6f\x72\137\x69\x64"]) || $uUHNN[$JFCNv]["\166\x65\x6e\144\x6f\162\x5f\x69\x64"] !== $txXCS)) {
            $this->logger->debug(__FILE__, 219, "\163\150\x69\x70\155\x65\156\x74\111\144\72\x20\45\144\40\x64\157\x65\x73\40\x6e\157\x74\40\x62\145\154\157\x6e\147\40\164\x6f\x20\x61\40\147\x69\x76\145\156\40\166\x65\156\x64\x6f\162\111\x64\x3a\40\x25\x64", $FCwSX, $txXCS);
            return false;
        }
        do_action($this->id . "\x5f\x73\150\151\x70\155\145\156\164\137\x64\x65\154\145\x74\145", $iKfxj, $FCwSX, $uUHNN[$JFCNv]);
        unset($uUHNN[$JFCNv]);
        $this->setUpdated($iKfxj, $uUHNN);
        return $this->set($iKfxj, $uUHNN);
    }
    public function getInTransit(int $gXV56, int $QWkcJ, int $BcQrI = 100, int $X0BFo = 0): array
    {
        $this->logger->debug(__FILE__, 244, "\x67\x65\164\x49\156\124\162\141\x6e\163\151\164\x2c\40\155\151\156\123\x74\x61\164\x75\163\103\x68\x61\156\147\x65\144\x54\x69\x6d\x65\72\x20\x25\x64\x2c\40\155\x61\x78\x55\160\144\x61\x74\x65\144\124\x69\x6d\145\72\x20\x25\144\54\x20\154\151\155\151\x74\72\x20\x25\x64\x2c\x20\157\146\146\x73\x65\164\72\40\45\144", $gXV56, $QWkcJ, $BcQrI, $X0BFo);
        global $wpdb;
        $mZ8Mu = $wpdb->prepare("\123\105\114\x45\103\124\40\164\137\x73\150\151\160\155\x65\x6e\164\x73\x2e\52\54\40\x74\x5f\165\160\x64\141\x74\145\144\x2e\155\145\x74\141\137\166\141\154\165\145\40\x41\x53\x20\x75\x70\x64\141\x74\x65\144\x2c\40\x74\137\163\164\x61\164\x75\x73\x5f\143\x68\141\x6e\x67\x65\144\x2e\155\145\164\141\x5f\166\x61\x6c\165\x65\40\101\x53\40\143\x68\x61\156\147\x65\x64\12\x9\x9\11\x46\122\x4f\x4d\40{$wpdb->postmeta}\40\x74\137\x73\150\151\x70\155\x65\x6e\164\163\x20\12\11\11\11\11\x49\116\116\105\122\40\x4a\117\111\x4e\x20{$wpdb->postmeta}\x20\x74\x5f\x75\160\x64\x61\x74\145\x64\x20\117\x4e\x20\x74\137\x75\160\x64\141\164\x65\144\56\160\157\x73\164\x5f\151\144\x20\x3d\x20\x74\x5f\163\x68\151\x70\x6d\x65\156\x74\x73\56\x70\x6f\163\x74\x5f\151\x64\40\101\x4e\104\x20\164\x5f\x75\160\144\141\164\x65\x64\56\x6d\x65\164\141\x5f\153\145\171\40\75\40\x25\163\12\11\x9\x9\11\x4c\105\x46\124\40\112\117\111\116\x20{$wpdb->postmeta}\x20\164\137\163\164\141\164\x75\163\x5f\143\x68\x61\x6e\x67\x65\x64\x20\117\x4e\x20\x74\x5f\x73\x74\141\164\165\x73\137\x63\x68\141\156\147\145\144\x2e\160\157\x73\x74\137\x69\144\x20\x3d\x20\x74\x5f\x73\x68\151\x70\x6d\x65\x6e\164\163\56\160\157\163\x74\137\x69\144\x20\x41\116\104\40\164\137\163\164\x61\x74\x75\x73\137\x63\150\x61\156\147\145\144\x2e\155\x65\x74\141\x5f\x6b\145\x79\40\x3d\40\45\163\xa\x9\11\x9\127\110\105\x52\x45\x20\164\x5f\x73\150\151\x70\155\145\156\164\163\56\x6d\145\164\141\x5f\153\x65\171\x20\75\x20\x25\x73\x20\xa\x9\11\11\11\101\116\104\40\103\x41\123\x54\50\164\137\165\x70\144\141\164\x65\x64\x2e\x6d\x65\x74\141\x5f\166\x61\154\165\x65\x20\101\x53\x20\x53\111\107\116\105\104\x29\x20\x3c\75\40\x25\x64\xa\11\11\x9\x9\x41\x4e\104\40\x28\164\137\163\164\141\x74\165\x73\137\x63\150\141\156\147\145\x64\x2e\155\145\164\x61\137\166\x61\x6c\x75\x65\40\x49\123\40\x4e\125\114\114\x20\117\x52\40\103\101\123\124\50\x74\x5f\163\164\141\164\x75\x73\x5f\x63\x68\141\156\x67\145\x64\56\155\145\164\141\x5f\x76\141\x6c\x75\x65\40\x41\x53\x20\x53\111\x47\116\x45\x44\51\x20\76\x3d\x20\45\144\51\xa\11\x9\11\117\122\x44\105\x52\x20\x42\x59\x20\x75\160\144\x61\164\x65\x64\40\101\x53\103\xa\11\11\x9\114\x49\115\x49\x54\x20\x25\144\54\45\144", $this->getMetaKeyUpdated(), $this->getMetaKeyStatusChanged(), $this->key, $QWkcJ, $gXV56, $X0BFo, $BcQrI);
        $this->logger->debug(__FILE__, 267, "\x51\x75\x65\162\x79\72\40\x25\163", $mZ8Mu);
        $Wxi_x = array();
        $bPRUM = $wpdb->get_results($mZ8Mu, ARRAY_A);
        $this->logger->debug(__FILE__, 273, "\x4e\165\x6d\x62\x65\x72\x20\x6f\146\40\x72\157\167\x73\72\x20\45\144", count($bPRUM));
        foreach ($bPRUM as $FFnBL) {
            $iKfxj = $FFnBL["\160\157\163\164\x5f\x69\144"] ?? 0;
            $uUHNN = maybe_unserialize($FFnBL["\x6d\x65\x74\141\137\x76\141\x6c\165\x65"]);
            $eZXBQ = array();
            foreach ($uUHNN as $uT9iq) {
                if (!$this->isCompleted($uT9iq)) {
                    $FCwSX = $this->getShipmentId((string) $uT9iq["\151\x64"] ?? '');
                    $eZXBQ[$FCwSX] = $uT9iq;
                }
                dgw3J:
            }
            lZXTD:
            if (false === empty($eZXBQ)) {
                $Wxi_x[(string) $iKfxj] = $eZXBQ;
            } else {
                $this->setUpdated(intval($iKfxj), $uUHNN);
            }
            dDNuU:
        }
        ZRDG4:
        return $Wxi_x;
    }
    public function getShipmentId(string $FCwSX): string
    {
        $Y4u04 = explode("\72", $FCwSX);
        return current($Y4u04);
    }
    private function getOrderIdByShipmentId(string $FCwSX): int
    {
        $this->logger->debug(__FILE__, 318, "\x67\x65\x74\117\x72\144\145\x72\111\144\x42\x79\x53\150\x69\160\155\x65\156\164\111\144\x2c\40\x73\150\x69\x70\x6d\x65\156\x74\x49\x64\72\40\x25\x73", $FCwSX);
        $PTfgT = (new Query())->getOrders(array("\155\x65\164\x61\137\161\165\x65\162\171" => array(array("\153\x65\171" => $this->key, "\166\141\x6c\165\x65" => "{$FCwSX}", "\143\x6f\x6d\x70\141\162\145" => "\114\111\113\105"))));
        $this->logger->debug(__FILE__, 332, "\106\157\x75\156\x64\40\45\144\x20\x6f\162\x64\145\x72\163", count($PTfgT));
        return false === empty($PTfgT) ? $PTfgT[0]->get_id() : 0;
    }
    private function getVendorShipments(array $uUHNN, int $txXCS): array
    {
        if (empty($txXCS)) {
            return $uUHNN;
        }
        $Q9Y9s = array();
        foreach ($uUHNN as $FCwSX => $uT9iq) {
            if (!isset($uT9iq["\x76\x65\x6e\144\x6f\x72\137\151\144"]) || $txXCS === $uT9iq["\x76\145\156\144\x6f\162\137\x69\x64"]) {
                $Q9Y9s[$FCwSX] = $uT9iq;
            }
            QGRCx:
        }
        iHpbX:
        $this->logger->debug(__FILE__, 358, "\147\x65\x74\126\x65\x6e\144\157\x72\123\x68\x69\160\155\x65\x6e\x74\163\x2c\40\x76\145\156\x64\x6f\162\111\144\72\x20\x25\144\54\x20\x76\145\156\144\x6f\162\123\150\151\x70\x6d\x65\x6e\x74\163\72\x20\x25\163", $txXCS, print_r($Q9Y9s, true));
        return $Q9Y9s;
    }
    private function set(int $iKfxj, array $uUHNN): bool
    {
        $m53A7 = array();
        foreach ($uUHNN as $uT9iq) {
            $FCwSX = $this->getShipmentId((string) $uT9iq["\x69\x64"] ?? '');
            $m53A7[$FCwSX] = $uT9iq;
            fqFl7:
        }
        PDBLn:
        $this->logger->debug(__FILE__, 379, "\163\145\x74\54\40\x6f\x72\x64\145\162\x49\x64\x3a\x20\45\144\x2c\x20\163\x68\151\160\155\145\156\164\x73\72\x20\x25\163", $iKfxj, print_r($uUHNN, true));
        return false !== update_post_meta($iKfxj, $this->key, $m53A7);
    }
    private function setUpdated(int $iKfxj, array $uUHNN): void
    {
        $this->logger->debug(__FILE__, 393, "\x73\x65\164\125\x70\x64\x61\164\x65\144\x2c\x20\x6f\162\144\x65\162\111\x64\72\40\x25\x64", $iKfxj);
        $vBo41 = $this->getMetaKeyUpdated();
        $wcZtW = 0;
        $o9YQQ = 0;
        foreach ($uUHNN as $uT9iq) {
            if ($this->isCompleted($uT9iq)) {
                $o9YQQ++;
            }
            $wcZtW++;
            oMzYg:
        }
        GSehd:
        if ($wcZtW === $o9YQQ) {
            $this->logger->debug(__FILE__, 408, "\x61\154\154\x20\x73\150\151\160\155\x65\x6e\x74\163\40\141\x72\145\40\143\157\155\x70\x6c\145\164\145\144\x2c\40\163\157\40\x73\x74\x6f\x70\40\164\x72\141\x63\153\x69\x6e\x67");
            delete_post_meta($iKfxj, $vBo41);
        } else {
            $this->logger->debug(__FILE__, 412, "\163\x6f\155\145\x20\163\x68\x69\x70\x6d\x65\x6e\164\163\40\141\162\x65\x20\163\164\x69\154\x6c\x20\151\x6e\x20\164\162\141\x6e\163\x69\164\x2c\40\163\x6f\40\153\x65\145\160\x20\164\162\x61\143\153\151\x6e\147");
            update_post_meta($iKfxj, $vBo41, time());
        }
    }
    private function setStatusChanged(int $iKfxj): void
    {
        $this->logger->debug(__FILE__, 426, "\163\x65\164\x53\x74\x61\x74\165\x73\103\x68\x61\156\x67\145\x64\54\x20\x6f\162\144\x65\x72\111\x64\x3a\40\45\x64", $iKfxj);
        $vBo41 = $this->getMetaKeyStatusChanged();
        update_post_meta($iKfxj, $vBo41, time());
    }
    private function getMetaKeyStatusChanged(): string
    {
        return $this->key . "\x5f\x73\164\141\x74\165\163\x5f\x63\x68\141\x6e\x67\145\x64";
    }
    private function getMetaKeyUpdated(): string
    {
        return $this->key . "\x5f\x75\x70\144\141\164\145\x64";
    }
    private function isCompleted(array $uT9iq): bool
    {
        if (empty($this->completedStatuses) || empty($uT9iq["\x73\x74\141\x74\x75\x73"])) {
            return false;
        }
        $aCNOl = $uT9iq["\x73\164\141\x74\165\163"];
        return in_array($aCNOl, $this->completedStatuses, true) || isset($this->completedStatuses[$aCNOl]);
    }
}

Decoded(de-Obfuscated) php code

<?php

declare (strict_types=1);
namespace OneTeamSoftware\WC\Shipping;

use OneTeamSoftware\Logger\LoggerInterface;
use OneTeamSoftware\WC\Orders\Query;
class OrderShipments
{
    private $id;
    private $logger;
    private $key;
    private $completedStatuses;
    public function __construct(string $hsNwz, LoggerInterface $w8Mi0)
    {
        $this->id = $hsNwz;
        $this->logger = $w8Mi0;
        $this->key = $hsNwz . "_shipments";
        $this->completedStatuses = array();
    }
    public function setCompletedStatuses(array $uOcBI) : void
    {
        $this->completedStatuses = $uOcBI;
    }
    public function has(int $iKfxj, string $FCwSX) : bool
    {
        $uUHNN = $this->get($iKfxj);
        return isset($uUHNN[$FCwSX]);
    }
    public function get(int $iKfxj, string $FCwSX = '', int $txXCS = 0) : array
    {
        if ($iKfxj <= 0 && false === empty($FCwSX)) {
            $iKfxj = $this->getOrderIdByShipmentId($FCwSX);
        }
        if ($iKfxj <= 0) {
            return array();
        }
        $this->logger->debug("/var/www/html/input.php", 100, "get, orderId: %d, shipmentId: %s, vendorId: %d", $iKfxj, $FCwSX, $txXCS);
        $uUHNN = get_post_meta($iKfxj, $this->key, true);
        if (empty($uUHNN)) {
            $uUHNN = array();
        }
        $uUHNN = $this->getVendorShipments($uUHNN, $txXCS);
        $uUHNN = apply_filters($this->key, $uUHNN, $txXCS);
        if (false === empty($FCwSX)) {
            $JFCNv = $this->getShipmentId($FCwSX);
            if (isset($uUHNN[$JFCNv])) {
                $uUHNN = array($FCwSX => $uUHNN[$JFCNv]);
            } else {
                $uUHNN = array();
            }
        }
        $this->logger->debug("/var/www/html/input.php", 121, "found shipments: %s", print_r($uUHNN, true));
        return $uUHNN;
    }
    public function put(int $iKfxj, array $uT9iq, int $txXCS = 0) : array
    {
        if (empty($iKfxj) || empty($uT9iq["id"])) {
            return array();
        }
        $this->logger->debug("/var/www/html/input.php", 141, "put, orderId: %d, shipment: %s, vendorId: %d", $iKfxj, print_r($uT9iq, true), $txXCS);
        $uT9iq = apply_filters($this->id . "_shipment", $uT9iq, $iKfxj, $txXCS);
        $FCwSX = $this->getShipmentId((string) $uT9iq["id"]);
        $uUHNN = $this->get($iKfxj);
        $NT6aX = false;
        if (false === empty($uT9iq["status"])) {
            if (empty($uUHNN[$FCwSX]["status"])) {
                $this->logger->debug("/var/www/html/input.php", 151, "previous status was not set, so mark it status as changed");
                $NT6aX = true;
            } elseif ($uUHNN[$FCwSX]["status"] !== $uT9iq["status"]) {
                $this->logger->debug("/var/www/html/input.php", 155, "status has changed");
                $NT6aX = true;
            }
        }
        if (empty($txXCS)) {
            if (false === empty($uUHNN[$FCwSX]["vendor_id"])) {
                $txXCS = $uUHNN[$FCwSX]["vendor_id"];
            } elseif (false === empty($uT9iq["vendor_id"])) {
                $txXCS = $uT9iq["vendor_id"];
            }
        }
        $uT9iq["order_id"] = $iKfxj;
        $uT9iq["vendor_id"] = $txXCS;
        $uT9iq = array_merge($uUHNN[$FCwSX] ?? [], $uT9iq);
        $uUHNN[$FCwSX] = $uT9iq;
        $hWJKz = $this->set($iKfxj, $uUHNN);
        if ($hWJKz) {
            $this->logger->debug("/var/www/html/input.php", 178, "saved successfuly");
            if ($NT6aX) {
                $this->logger->debug("/var/www/html/input.php", 181, "notify about status change");
                do_action($this->id . "_shipment_status_changed", $iKfxj, $uT9iq);
                $this->setStatusChanged($iKfxj);
            }
        }
        $this->setUpdated($iKfxj, $uUHNN);
        return $uT9iq;
    }
    public function delete(int $iKfxj, string $FCwSX, int $txXCS = 0) : bool
    {
        $this->logger->debug("/var/www/html/input.php", 203, "delete, orderId: %d, shipmentId: %s, vendorId: %d", $iKfxj, $FCwSX, $txXCS);
        $uUHNN = $this->get($iKfxj);
        $JFCNv = $this->getShipmentId($FCwSX);
        if (!isset($uUHNN[$JFCNv])) {
            $this->logger->debug("/var/www/html/input.php", 208, "shipment does not exist");
            return false;
        }
        if (false === empty($txXCS) && (empty($uUHNN[$JFCNv]["vendor_id"]) || $uUHNN[$JFCNv]["vendor_id"] !== $txXCS)) {
            $this->logger->debug("/var/www/html/input.php", 219, "shipmentId: %d does not belong to a given vendorId: %d", $FCwSX, $txXCS);
            return false;
        }
        do_action($this->id . "_shipment_delete", $iKfxj, $FCwSX, $uUHNN[$JFCNv]);
        unset($uUHNN[$JFCNv]);
        $this->setUpdated($iKfxj, $uUHNN);
        return $this->set($iKfxj, $uUHNN);
    }
    public function getInTransit(int $gXV56, int $QWkcJ, int $BcQrI = 100, int $X0BFo = 0) : array
    {
        $this->logger->debug("/var/www/html/input.php", 244, "getInTransit, minStatusChangedTime: %d, maxUpdatedTime: %d, limit: %d, offset: %d", $gXV56, $QWkcJ, $BcQrI, $X0BFo);
        global $wpdb;
        $mZ8Mu = $wpdb->prepare("SELECT t_shipments.*, t_updated.meta_value AS updated, t_status_changed.meta_value AS changed\n\t\t\tFROM {$wpdb->postmeta} t_shipments \n\t\t\t\tINNER JOIN {$wpdb->postmeta} t_updated ON t_updated.post_id = t_shipments.post_id AND t_updated.meta_key = %s\n\t\t\t\tLEFT JOIN {$wpdb->postmeta} t_status_changed ON t_status_changed.post_id = t_shipments.post_id AND t_status_changed.meta_key = %s\n\t\t\tWHERE t_shipments.meta_key = %s \n\t\t\t\tAND CAST(t_updated.meta_value AS SIGNED) <= %d\n\t\t\t\tAND (t_status_changed.meta_value IS NULL OR CAST(t_status_changed.meta_value AS SIGNED) >= %d)\n\t\t\tORDER BY updated ASC\n\t\t\tLIMIT %d,%d", $this->getMetaKeyUpdated(), $this->getMetaKeyStatusChanged(), $this->key, $QWkcJ, $gXV56, $X0BFo, $BcQrI);
        $this->logger->debug("/var/www/html/input.php", 267, "Query: %s", $mZ8Mu);
        $Wxi_x = array();
        $bPRUM = $wpdb->get_results($mZ8Mu, ARRAY_A);
        $this->logger->debug("/var/www/html/input.php", 273, "Number of rows: %d", count($bPRUM));
        foreach ($bPRUM as $FFnBL) {
            $iKfxj = $FFnBL["post_id"] ?? 0;
            $uUHNN = maybe_unserialize($FFnBL["meta_value"]);
            $eZXBQ = array();
            foreach ($uUHNN as $uT9iq) {
                if (!$this->isCompleted($uT9iq)) {
                    $FCwSX = $this->getShipmentId((string) $uT9iq["id"] ?? '');
                    $eZXBQ[$FCwSX] = $uT9iq;
                }
            }
            if (false === empty($eZXBQ)) {
                $Wxi_x[(string) $iKfxj] = $eZXBQ;
            } else {
                $this->setUpdated(intval($iKfxj), $uUHNN);
            }
        }
        return $Wxi_x;
    }
    public function getShipmentId(string $FCwSX) : string
    {
        $Y4u04 = explode(":", $FCwSX);
        return current($Y4u04);
    }
    private function getOrderIdByShipmentId(string $FCwSX) : int
    {
        $this->logger->debug("/var/www/html/input.php", 318, "getOrderIdByShipmentId, shipmentId: %s", $FCwSX);
        $PTfgT = (new Query())->getOrders(array("meta_query" => array(array("key" => $this->key, "value" => "{$FCwSX}", "compare" => "LIKE"))));
        $this->logger->debug("/var/www/html/input.php", 332, "Found %d orders", count($PTfgT));
        return false === empty($PTfgT) ? $PTfgT[0]->get_id() : 0;
    }
    private function getVendorShipments(array $uUHNN, int $txXCS) : array
    {
        if (empty($txXCS)) {
            return $uUHNN;
        }
        $Q9Y9s = array();
        foreach ($uUHNN as $FCwSX => $uT9iq) {
            if (!isset($uT9iq["vendor_id"]) || $txXCS === $uT9iq["vendor_id"]) {
                $Q9Y9s[$FCwSX] = $uT9iq;
            }
        }
        $this->logger->debug("/var/www/html/input.php", 358, "getVendorShipments, vendorId: %d, vendorShipments: %s", $txXCS, print_r($Q9Y9s, true));
        return $Q9Y9s;
    }
    private function set(int $iKfxj, array $uUHNN) : bool
    {
        $m53A7 = array();
        foreach ($uUHNN as $uT9iq) {
            $FCwSX = $this->getShipmentId((string) $uT9iq["id"] ?? '');
            $m53A7[$FCwSX] = $uT9iq;
        }
        $this->logger->debug("/var/www/html/input.php", 379, "set, orderId: %d, shipments: %s", $iKfxj, print_r($uUHNN, true));
        return false !== update_post_meta($iKfxj, $this->key, $m53A7);
    }
    private function setUpdated(int $iKfxj, array $uUHNN) : void
    {
        $this->logger->debug("/var/www/html/input.php", 393, "setUpdated, orderId: %d", $iKfxj);
        $vBo41 = $this->getMetaKeyUpdated();
        $wcZtW = 0;
        $o9YQQ = 0;
        foreach ($uUHNN as $uT9iq) {
            if ($this->isCompleted($uT9iq)) {
                $o9YQQ++;
            }
            $wcZtW++;
        }
        if ($wcZtW === $o9YQQ) {
            $this->logger->debug("/var/www/html/input.php", 408, "all shipments are completed, so stop tracking");
            delete_post_meta($iKfxj, $vBo41);
        } else {
            $this->logger->debug("/var/www/html/input.php", 412, "some shipments are still in transit, so keep tracking");
            update_post_meta($iKfxj, $vBo41, time());
        }
    }
    private function setStatusChanged(int $iKfxj) : void
    {
        $this->logger->debug("/var/www/html/input.php", 426, "setStatusChanged, orderId: %d", $iKfxj);
        $vBo41 = $this->getMetaKeyStatusChanged();
        update_post_meta($iKfxj, $vBo41, time());
    }
    private function getMetaKeyStatusChanged() : string
    {
        return $this->key . "_status_changed";
    }
    private function getMetaKeyUpdated() : string
    {
        return $this->key . "_updated";
    }
    private function isCompleted(array $uT9iq) : bool
    {
        if (empty($this->completedStatuses) || empty($uT9iq["status"])) {
            return false;
        }
        $aCNOl = $uT9iq["status"];
        return in_array($aCNOl, $this->completedStatuses, true) || isset($this->completedStatuses[$aCNOl]);
    }
}


Malware detection & removal plugin for WordPress

(C)2020 Wordpress Doctor All rights reserved.