%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.222.110.5
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/components/itserw/wishlist.list/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/components/itserw/wishlist.list/class.php
<?php

use \Bitrix\Main;
use \Bitrix\Main\Loader;
use \Bitrix\Main\Localization\Loc;
use \Itserw\Wishlist\Wishlist;
use \Itserw\Wishlist\Favorites;


class WishlistClass extends CBitrixComponent
{
    /**
     * Warnings list.
     * @var string[]
     */
    protected $warnings = array();

    /**
     *
     */
    protected function checkModules()
    {
        if (!Loader::includeModule('itserw.wishlist')) {
            ShowError(Loc::getMessage('ITSERW_WISHLIST_MODULE_NOT_INSTALLED'));
        }

        if (!Loader::includeModule('iblock')) {
            ShowError(Loc::getMessage('IBLOCK_MODULE_NOT_INSTALLED'));
            return;
        }

    }

    /**
     * @param $params
     * @return mixed
     */
    public function onPrepareComponentParams($params)
    {
        $params = parent::onPrepareComponentParams($params);

        $params["ITSERW_ELEMENT_ID"] = intval($params["ITSERW_ELEMENT_ID"]);
        $params["ITSERW_LINK"] = trim($params["ITSERW_LINK"]);
        $params["ITSERW_ACTION"] = trim($params["ITSERW_ACTION"]);
        $params["ITSERW_ID"] = trim($params["ITSERW_ID"]);
        $params["IBLOCKS"] = intval(trim($params["IBLOCKS"]));
        $params["WIDTH_IMAGE"] = intval(trim($params["WIDTH_IMAGE"])) > 0 ? intval($params["WIDTH_IMAGE"]) : 100;
        $params["HEIGHT_IMAGE"] = intval(trim($params["HEIGHT_IMAGE"])) > 0?  intval($params["HEIGHT_IMAGE"]) : 100;
        return $params;
    }

    /**
     * @param $id
     * @return array
     */
    public function getItems(array $ids)
    {
        if (empty($ids)) {
            return array();
        }

        $actualIds = array();

        $result = array();
        $arSelect = Array("ID", "NAME", "DATE_ACTIVE_FROM", "DETAIL_PAGE_URL", "PREVIEW_PICTURE", "DETAIL_PICTURE");
        $arFilter = Array("IBLOCK_ID" => $this->arParams["IBLOCKS"], "ID" => $ids, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y");
        $res = CIBlockElement::GetList(Array(), $arFilter, false, Array(), $arSelect);
        while ($ob = $res->GetNext()) {

            $actualIds[] = $ob["ID"];
            $file = '';

            if ($ob['PREVIEW_PICTURE']) {
                $file = CFile::ResizeImageGet($ob['PREVIEW_PICTURE'], Array("width" => $this->arParams["WIDTH_IMAGE"], "height" => $this->arParams["HEIGHT_IMAGE"]), BX_RESIZE_IMAGE_PROPORTIONAL, true, array());
            } elseif ($ob['DETAIL_PICTURE']) {
                $file = CFile::ResizeImageGet($ob['DETAIL_PICTURE'], Array("width" => $this->arParams["WIDTH_IMAGE"], "height" => $this->arParams["HEIGHT_IMAGE"]), BX_RESIZE_IMAGE_PROPORTIONAL, true, array());
            }

            $ob['IMG'] = $file;
            $result[$ob['ID']] = $ob;

        }


        return $result;
    }

    /**
     * @return bool
     */
    protected function isAjax()
    {
        return isset($_REQUEST['ajax_action_wishlist']) && $_REQUEST['ajax_action_wishlist'] == 'Y';
    }

    protected function processAddOrDeleteValue()
    {

        global $APPLICATION;
        $request = \Bitrix\Main\HttpApplication::getInstance()->getContext()->getRequest();
        $idParam = $this->arParams["ITSERW_ID"];
        $id = $request->get($idParam);
        $countIds = Favorites::getInstance()->getCountValuesFromFavorites();
        $values = Favorites::getInstance()->getStorageObject()->getStorageValue();
        $successfulAction = false;
        $action = '';
        $params = '';

        if ($id) {

            if (!empty(Favorites::getInstance()->getStorageObject()->isStorageValue(array($id)))) {

                $action = 'delete';

                foreach ($values as $key => $value) {
                    if($value === $id){
                        unset($values[$key]);
                    }
                }

            }else{
                $action = 'add';
                $values[] = $id;
            }

            $successfulAction = true;
        }


        if ($successfulAction) {

            $result['ID'] = $id;
            $result['ITEMS'] = $values ? $this->getItems($values) : array();
            $result['COUNT'] = count($result['ITEMS']);
            $addResult = array_merge(array('STATUS' => 'OK', 'MESSAGE' => Loc::GetMessage("ITSERW_WISHLIST_AJAX_STATUS_OK"), 'ACTION' => $action), $result);

            if($action === 'add'){
                Favorites::getInstance()->getStorageObject()->addStorageValue(array($id));
            }else if($action === 'delete'){
                Favorites::getInstance()->getStorageObject()->deleteStorageValue(array($id));
            }

        } else {
            $addResult = array('STATUS' => 'ERROR', 'MESSAGE' => Loc::GetMessage("ITSERW_WISHLIST_AJAX_STATUS_NO"), 'params' => $params);
        }

        return $addResult;

    }


    /**
     * Extract data from cache. No action by default.
     * @return bool
     */
    protected function extractDataFromCache()
    {
        return false;
    }

    protected function putDataToCache()
    {
    }

    protected function abortDataCache()
    {
    }

    /**
     * @return mixed
     */
    protected function formatResult()
    {
        $this->arResult['ITEMS'] = array();

        if (Favorites::getInstance()->getStorageObject()->isStorage()) {
            $this->arResult['ITEMS'] = $this->getItems(Favorites::getInstance()->getStorageObject()->getStorageValue());
        }

        return $this->arResult['ITEMS'];
    }


    public function executeComponent()
    {
        global $APPLICATION;

        $this->includeComponentLang('class.php');

        try {
            $this->checkModules();

            if ($this->isAjax()) {
                $APPLICATION->RestartBuffer();
                header('Content-Type: application/json');
                echo Main\Web\Json::encode($this->processAddOrDeleteValue());
                Main\Application::getInstance()->end();
                die();
            }else{

                if (!$this->extractDataFromCache()) {
                    $this->formatResult();
                    $this->setResultCacheKeys(array());
                    $this->includeComponentTemplate();
                    $this->putDataToCache();
                }
            }

        } catch (Main\SystemException $e) {
            $this->abortDataCache();

            if ($this->isAjax()) {
                $APPLICATION->restartBuffer();
                header('Content-Type: application/json');
                echo Main\Web\Json::encode(array('STATUS' => 'ERROR', 'MESSAGE' => $e->getMessage()));
                die();
            }

            ShowError($e->getMessage());
        }

    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit