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/lpost.delivery/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/lpost.delivery/options.php
<?php

use \Bitrix\Main\Localization\Loc,
    \Lpost\Delivery,
    \Bitrix\Main\Config\Option,
    \Bitrix\Main\Page\Asset,
    \Bitrix\Main\EventManager;
use Lpost\Delivery\Agents\AgentManager;
use Lpost\Delivery\Agents\Receiver;
use Lpost\Delivery\Service\ServiceUpdateAddressPoints;
use Lpost\Delivery\Settings;
use Lpost\Delivery\TabOptions\TabAutomation;
use Lpost\Delivery\TabOptions\TabIntegration;
use Lpost\Delivery\TabOptions\TabMain;
use Lpost\Delivery\TabOptions\TabPointReception;
use Lpost\Delivery\TabOptions\TabShippingCost;
use Lpost\Delivery\TabOptions\TabShippingCostFixed;
use Lpost\Delivery\TabOptions\TabTech;

\Bitrix\Main\UI\Extension::load("ui.hint");

Loc::loadMessages(__FILE__);
Loc::loadMessages($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . '/modules/main/options.php');


global $APPLICATION;

$module_id = 'lpost.delivery';



\Bitrix\Main\Loader::includeModule($module_id);
\Bitrix\Main\Loader::includeModule('sale');

\Bitrix\Main\UI\Extension::load("lpost.delivery.admin");


?>

<? if (in_array('curl', get_loaded_extensions())): ?>

    <?
    function listRP()
    {
        $list = Settings::getInstance()->getReceivePoints();
        $listHtml = '';
        foreach ($list as $nextOption) {
            $listHtml .= '<option value="' . $nextOption['id_sklad'] . '">' . $nextOption['city_name'] . ' - ' . $nextOption['address'] . '[' . $nextOption['id_sklad'] . ']</option>';
        }
        return $listHtml;
    }

    echo '<div class="adm-info-message-wrap" >
                <div class="adm-info-message">
                    ' . Loc::getMessage("lpost.option_SETTING_INFO_TEXT") . '
                </div>
        </div>';

    $aTabs = [
        [
            'DIV'       => 'lpost_general_setting_tech',
            'TAB'       => Loc::getMessage("lpost.option_SETTING_TECH"),
            'TITLE'     => Loc::getMessage("lpost.option_SETTING_TECH_TITLE"),
            'OPTIONS'   => TabTech::getListOptions()
        ],
        [
            'DIV'       => 'lpost_general_setting_intf',
            'TAB'       => Loc::getMessage("lpost.option_SETTING_INTF"),
            'TITLE'     => Loc::getMessage("lpost.option_SETTING_INTF_TITLE"),
            'OPTIONS'   => TabIntegration::getListOptions()
        ],
        [
            'DIV'       => 'lpost_general_setting_rp',
            'TAB'       => Loc::getMessage("lpost.option_SETTING_RP"),
            'TITLE'     => Loc::getMessage("lpost.option_SETTING_RP_TITLE"),
            'OPTIONS'   => TabPointReception::getListOptions()
        ],
        [
            'DIV'       => 'lpost_general_setting_automation',
            'TAB'       => Loc::getMessage("LPOST_OPTION_SETTING_TAB_AUTOMATION"),
            'TITLE'     => Loc::getMessage("LPOST_OPTION_SETTING_TITLE_AUTOMATION"),
            'OPTIONS'   => TabAutomation::getListOptions()
        ],
        [
            'DIV'       => 'lpost_general_setting_shipping_cost',
            'TAB'       => Loc::getMessage("LPOST_OPTION_SETTING_TAB_SHIPPING_COST"),
            'TITLE'     => Loc::getMessage("LPOST_OPTION_SETTING_TITLE_SHIPPING_COST"),
            'OPTIONS'   => TabShippingCost::getListOptions()
        ],
        [
            'DIV'       => 'lpost_general_setting_shipping_cost_fixed',
            'TAB'       => Loc::getMessage("LPOST_OPTION_SETTING_TAB_SHIPPING_COST_FIXED"),
            'TITLE'     => Loc::getMessage("LPOST_OPTION_SETTING_TITLE_SHIPPING_COST_FIXED"),
            'OPTIONS'   => TabShippingCostFixed::getListOptions()
        ]
    ];

    $request = \Bitrix\Main\HttpApplication::getInstance()->getContext()->getRequest();

    try {
        if ($request->isPost() && $request['Update'] && check_bitrix_sessid()) {

            TabMain::isPostValidFields();
            TabTech::isPostValidFields();
            TabShippingCost::isPostValidFields();
            AgentManager::addCheckDeliveryStatus();
            
            $arCostFreeParams = TabShippingCostFixed::getParams();
            foreach($arCostFreeParams as $name){
                
                if(isset($_REQUEST[$name]))
                {

                    $val = $_REQUEST[$name];
                    if(is_array($val))
                        $val = serialize($val);

                    $res = COption::SetOptionString($module_id, $name, $val /*, $arOption[1]*/);
                }
            }
            
            $arCostParams = TabShippingCost::getParams();
            foreach($arCostParams as $name){
                
                if(isset($_REQUEST[$name]))
                {

                    $val = $_REQUEST[$name];
                    if(is_array($val))
                        $val = serialize($val);

                    $res = COption::SetOptionString($module_id, $name, $val /*, $arOption[1]*/);
                }
            }

            foreach ($aTabs as &$aTab) {
                
                if($aTab['DIV'] == 'lpost_general_setting_shipping_cost_fixed')
                    $aTab['OPTIONS'] = TabShippingCostFixed::getListOptions();
                if($aTab['DIV'] == 'lpost_general_setting_shipping_cost')
                    $aTab['OPTIONS'] = TabShippingCost::getListOptions();
                
                if (!empty($aTab['OPTIONS'])) {
                    
                    __AdmSettingsSaveOptions($module_id, $aTab['OPTIONS']);
                }
            }

            CAdminMessage::ShowMessage(["MESSAGE" => Loc::getMessage("lpost.option_SETTING_SUCCESS_SAVE"), "TYPE" => "OK"]);
        }
        else if ($request->isPost() && $request['ajax'] && $request['ajax'] == 'y' && check_bitrix_sessid()) {
            $GLOBALS['APPLICATION']->RestartBuffer();
            $options = Settings::getInstance()->getOptions();
            if (!empty($request['command'])) {
                if ($request['command'] == 'check_connection') {

                    Settings::getInstance()->setOption("test_mode", $request['test_mode']);

                    $auth = new Delivery\Auth;
                    
                    if($request['secret_key'] != $options['secret_key'])
                        $resToken = $auth->isAuthorizeSystem($request['secret_key']);
                    else{
                        $resToken = $auth->isAuthorize($request['secret_key']);
                        if(!$resToken)
                            $resToken = $auth->isAuthorizeSystem($request['secret_key']);
                    }

                    if (!$resToken) {
                        $errors = $auth->getErrors();
                        if (count($errors) == 0) {
                            $errors[] = 'Unknown error';
                        }
                        echo Delivery\Logger::getHTMLErrors($errors);
                    } else {
                        echo CAdminMessage::ShowMessage([
                            "MESSAGE" => Loc::getMessage("lpost.option_SETTING_SUCCESS_CHECK"),
                            "TYPE"    => "OK"
                        ]);
                        if ($request['secret_key'] == $options['secret_key']) {
                            Settings::getInstance()->setOption('lpost_token', $resToken);
                        }

                    }
                }
                if ($request['command'] == 'check_yandex_key') {
                    
                    $arErrors = [];
                    if (Settings::getInstance()->checkYandexKey($request->get("yandex_key"))) {
                        echo CAdminMessage::ShowMessage([
                            "MESSAGE" => Loc::getMessage("lpost.option_SETTING_SUCCES_YANDEX_KEY"),
                            "TYPE"    => "OK"
                        ]);
                    } else {
                        $arErrors[] = Loc::getMessage("lpost.option_SETTING_ERROR_YANDEX_KEY");
                    }
                    
                    if (Settings::getInstance()->checkYandexKeySuggest($request->get("yandex_key_suggest"))) {
                        echo CAdminMessage::ShowMessage([
                            "MESSAGE" => Loc::getMessage("lpost.option_SETTING_SUCCES_YANDEX_KEY_SUGGEST"),
                            "TYPE"    => "OK"
                        ]);
                    } else {
                        $arErrors[] = Loc::getMessage("lpost.option_SETTING_ERROR_YANDEX_KEY_SUGGEST");
                    }
                    
                    if(!empty($arErrors))
                        echo Delivery\Logger::getHTMLErrors($arErrors);
                }
                else if ($request['command'] == 'update_rp_list') {
                    (new ServiceUpdateAddressPoints())->make();
                    (new Receiver())->getReceivePoints();
                    echo listRP();
                }
                else if ($request['command'] == 'get_location') {
                   
                    ob_start();
                    global $APPLICATION;
                    $APPLICATION->RestartBuffer();
                    ?>
                    <?$APPLICATION->IncludeComponent(
                        "bitrix:sale.location.selector.search",
                        "",
                        Array(
                            "COMPONENT_TEMPLATE" => ".default",
                            "ID" => '',
                            "CODE" => "",
                            "INPUT_NAME" => "SHIPPING_COST_FIXED_LOCATION[]",
                            "PROVIDE_LINK_BY" => "id",
                            "JSCONTROL_GLOBAL_ID" => "",
                            "JS_CALLBACK" => "",
                            "FILTER_BY_SITE" => "Y",
                            "SHOW_DEFAULT_LOCATIONS" => "Y",
                            "CACHE_TYPE" => "A",
                            "CACHE_TIME" => "36000000",
                            "FILTER_SITE_ID" => "s1",
                            "INITIALIZE_BY_GLOBAL_EVENT" => '',
                            "SUPPRESS_ERRORS" => "N"	
                        )
                    );?>
                    <?
                    $locationOutput = ob_get_contents();
                    ob_end_clean();
                    
                    echo $locationOutput;
                }
            }
            die();
        }

    } catch (\ErrorException $e) {
        CAdminMessage::ShowMessage([
            "MESSAGE" => $e->getMessage(),
            "TYPE"    => "ERROR"
        ]);
    }

    $tabControl = new CAdminTabControl("tabControl_lpost", $aTabs);
    $tabControl->Begin();
    ?>

    <form class="lpost_settings" method="post"
          action="<? echo $APPLICATION->GetCurPage() ?>?mid=<?= urlencode($module_id) ?>&amp;lang=<?= LANGUAGE_ID ?>">
        <?
        $tabControl->BeginNextTab();
        foreach ($aTabs as $nextTab) {
            /*__AdmSettingsDrawList(
                Settings::getInstance()->getModuleId(),
                $nextTab['OPTIONS']
            );*/
            foreach($nextTab['OPTIONS'] as $arOption)
            {
                if($arOption[0] == 'select_conditions' || $arOption[0] == 'select_conditions_fixed'){
                    ?>
                    <tr>
                        <td width="100%" class="adm-detail-content-cell-center" colspan="2">
                            <?=$arOption[2]?>
                        </td>
                    </tr>
                <?
                }
                else{
                    __AdmSettingsDrawRow($module_id, $arOption);;
                }
            }
            $tabControl->BeginNextTab();
        }
        $tabControl->Buttons(); ?>
        <input type="submit" name="Update" class="adm-btn-save" value="<?= Loc::getMessage("MAIN_SAVE") ?>">
        <input type="reset" name="reset" value="<?= Loc::getMessage("MAIN_RESET") ?>">
        <?= bitrix_sessid_post(); ?>
    </form>
    <?php $tabControl->End(); ?>

    <script>
        BX.ready(function () {

            BX.UI.Hint.init(BX('tabControl_lpost_layout'));

            BX.bindDelegate(document.querySelector('.lpost_settings'), 'click', {
                tagName: 'input',
                className: 'check_connection'
            }, function (e) {
                e.preventDefault();
                var self = this,
                    keyInput = document.querySelector('.lpost_settings input[name=secret_key]');
                BX.ajax({
                    url: location.href,
                    data: {
                        'command': 'check_connection',
                        'sessid': BX('sessid').value,
                        'secret_key': keyInput.value,
                        'ajax': 'y',
                        "test_mode": BX("test_mode").checked ? "Y" : "N"
                    },
                    method: 'POST',
                    dataType: 'html',
                    timeout: 300,
                    async: true,
                    onsuccess: function (data) {
                        self.nextElementSibling.innerHTML = data;
                    },
                    onfailure: function (data) {
                        console.log(data);
                    }
                });
            });

            BX.bindDelegate(
                document.querySelector('.lpost_settings'),
                'click',
                {
                    tagName: 'input',
                    className: 'check_yandex_key'
                },
                function (e) {

                e.preventDefault();

                let self = this;
                let keyInput = document.querySelector('.lpost_settings input[name=yandex_map_api_key]')
                    keySuggestInput = document.querySelector('.lpost_settings input[name=yandex_geo_suggest_api_key]');

                BX.ajax({
                    url: location.href,
                    data: {
                        'ajax': 'y',
                        'command': 'check_yandex_key',
                        'sessid': BX('sessid').value,
                        'yandex_key': keyInput.value,
                        'yandex_key_suggest': keySuggestInput.value,
                    },
                    method: 'POST',
                    dataType: 'html',
                    timeout: 300,
                    async: true,
                    onsuccess: function (data) {
                        self.nextElementSibling.innerHTML = data;
                    },
                    onfailure: function (data) {
                        console.log(data);
                    }
                });
            });

            BX.bindDelegate(document.querySelector('.lpost_settings'), 'click', {
                tagName: 'input',
                className: 'update_rp_list'
            }, function () {
                this.classList.add("disabled", "adm-btn-load");
                var self = this;
                self.disabled = true;
                BX.ajax({
                    url: location.href,
                    data: {
                        'command': 'update_rp_list',
                        'sessid': BX('sessid').value,
                        'ajax': 'y'
                    },
                    method: 'POST',
                    dataType: 'html',
                    timeout: 300,
                    async: true,
                    onsuccess: function (data) {
                        document.querySelector('.lpost_settings select[name=rplist]').innerHTML = data;
                        self.disabled = false;
                        self.classList.remove("disabled", "adm-btn-load");
                    },
                    onfailure: function (data) {
                        console.log(data);
                        self.disabled = false;
                    }
                });
            })

        })
    </script>

<? else: ?>
    <? CAdminMessage::ShowMessage([
        "MESSAGE" => loc::getMessage("LPOST_OPTION_SETTING_ERROR_NOT_CURL"),
        "TYPE"    => "ERROR"
    ]); ?>
<? endif; ?>


Youez - 2016 - github.com/yon3zu
LinuXploit