403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/wbs24.ozonapinew/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/wbs24.ozonapinew/lib/OrdersStack.php
<?php
namespace Wbs24\Ozonapinew;

use Bitrix\Main\SystemException;

class OrdersStack {
    protected $Db;

    protected $accountIndex;

    public function __construct($accountIndex = 1, $objects = [])
    {
        $this->Db = $objects['Db'] ?? new Db();

        $this->accountIndex = $accountIndex;
    }

    public function addOrdersToStack($ordersFromTradingPlatform)
    {
        $data = [];
        foreach ($ordersFromTradingPlatform as $key => $resultOrder) {
            $externalId = $resultOrder['posting_number'];
            $order = $resultOrder;
            $serializedOrder = serialize(
                $this->clearDataFromInvalidCharacters($order)
            );
            $data['external_id'] = $externalId;
            $data['order'] = $serializedOrder;
            $data['account_index'] = $this->accountIndex;
            $this->Db->set('wbs24_ozonapinew_orders_stack', $data);
        }
    }

    protected function clearDataFromInvalidCharacters($order)
    {
        // Удаление Эмодзи из строки
        array_walk_recursive($order, function (&$value, $key) {
            if (gettype($value) == 'string') {
                $value = preg_replace('~[\x{10000}-\x{10FFFF}]~u', '', $value);
            }
        });

        return $order;
    }

    public function getOrders()
    {
        $serializedorders = $this->Db->get('wbs24_ozonapinew_orders_stack', [
            'account_index' => $this->accountIndex,
        ]);
        foreach ($serializedorders as $key => $resultOrder) {
            $unserializedOrder = $this->safeUnserialize($resultOrder['order']);
            $unserializedOrder['account_index'] = $this->accountIndex;
            $orders[] = $unserializedOrder;
        }

        return $orders;
    }

    public function safeUnserialize($s)
    {
        $u = unserialize($s);
        if (!$u) {
            $s = preg_replace_callback(
                '/s:(\d+):"(.*?)"([;}])/',
                function($m) {
                    return 's:'.strlen($m[2]).':"'.$m[2].'"'.$m[3];
                },
                $s
            );
            $u = unserialize($s);
        }

        if (!$u) {
            $s = preg_replace_callback(
                '/s:(\d+):"(.*?)"([;}])/',
                function($m) {
                    $f = iconv('windows-1251', 'UTF-8', $m[2]);
                    return 's:'.strlen($f).':"'.$m[2].'"'.$m[3];
                },
                $s
            );
            $u = unserialize($s);
        }

        return $u;
    }

    public function cleanStack($externalIds)
    {
        foreach ($externalIds as $externalId) {
            $this->Db->clear('wbs24_ozonapinew_orders_stack', $where = [
                'external_id' => $externalId,
                'account_index' => $this->accountIndex,
            ]);
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit