Phalcon Framework 5.9.3

Error: Call to undefined function Site\Pic\Controller\mbereg_replace()

/var/www/fullrest-team/data/www/fullrest.net/Site/Pic/Controller/PicController.php (575)
#0Site\Pic\Controller\PicController->htmlGenerateRestrictedAccess
/var/www/fullrest-team/data/www/fullrest.net/Site/Pic/Controller/PicController.php (118)
<?php
//TODO: описание плана
/*
    1. eva-project.members - after insert : вставляем запись в fullres1_phalcon.scl_members
    2. eva-project.members - after update : правим таймеры, мейк группу и остальное
 
    3. eva-project.members_auth - after insert : ставляем запись в fullres1_phalcon.scl_members_auth
 
 
 
 
*/
 
namespace Site\Pic\Controller;
 
use Core\Lib\Calc;
use Core\Lib\Mustache;
use Core\Modules\Pic\Controller\ImageController;
use Core\Modules\Pic\Controller\StackController;
use Core\Extenders\ContentController;
use Phalcon\Db;
use Core\Lib;
 
class PicController extends ContentController
{
    private $pageStart = 1;
    private $pageEnd   = 1;
 
    private $idElizaPicRightBack       = 'elizaPicRightBack';
    private $idElizaPicRightPanel      = 'elizaPicRightPanel';
    private $idElizaPicRightPanelClose = 'elizaPicRightPanelClose';
 
    private $idElizaPicPluploadBtn  = 'elizaPicPluploadBtn';
    private $idElizaPicPluploadZone = 'elizaPicPluploadZone';
 
    private $idElizaPicFooter        = 'elizaPicFooter';
    private $idElizaPicFooterTitle   = 'elizaPicFooterTitle';
    private $idElizaPicFooterNext    = 'elizaPicFooterNext';
    private $idElizaPicFooterPrev    = 'elizaPicFooterPrev';
    private $idElizaPicFooterRoot    = 'elizaPicFooterRoot';
    private $idElizaPicFooterNumbers = 'elizaPicFooterNumbers';
    private $idElizaPicFooterAlbums  = 'elizaPicFooterAlbums';
    private $idElizaPicFooterContent = 'elizaPicFooterContent';
 
    private $idElizaPicTool         = 'elizaPicTool';
    private $idElizaPicToolStackExp = 'elizaPicToolExpand';
    private $idElizaPicToolAddImage = 'ElizaAppPic_addImage'; // К этому айдишнику привязан ЦСС; без надобности не менять.
    private $idElizaPicToolAddStack = 'elizaPicToolAddAlbum';
    private $idElizaPicToolTree     = 'elizaPicToolMoveToAlbum';
    private $idElizaPicToolTrash    = 'elizaPicToolDeleteItems';
    private $idElizaPicToolUnsel    = 'elizaPicToolRemoveSelect';
    
 
    public function initialize()
    {
        $this->overseer->setJSController('pic');
        $this->overseer->setJSAction('picInitialization');
 
        if ($this->request->get('page')) {
            $expl = explode('-', $this->request->get('page'));
 
            if (sizeof($expl) == 2) {
                $start = (int)$expl[0];
                $end   = (int)$expl[1];
 
                if($start <= 0) {
                    $start = 1;
                }
 
                if($end <= 0) {
                    $end = 1;
                }
 
                if($start > $end) {
                    $start = $end;
                }
            }
            else {
                $start = (int)$expl[0];
 
                if(!$start) {
                    $start = 1;
                }
 
                $end = $start;
            }
 
            $this->pageStart = $start;
            $this->pageEnd   = $end;
        }
    }
 
    public function indexAction() {
        if (!$this->user->getId())
            return;
 
        $this->generateHtmlForStack('', $this->user->getId(), 0);
    }
 
 
    public function stackAction($stackName) {
        $this->generateHtmlForStack($stackName, $this->user->getId(), 0);
    }
 
    /**
     * @param $imageName
     */
    public function imageAction($imageName)
    {
        if ($imageName == 'trash') {
            $this->trashAction();
            return;
        }
 
        $image = (new ImageController())->getPageData($imageName);
 
        if (isset($image['restricted'])) {
            $this->htmlGenerateRestrictedAccess('image', $image['restricted']);
 
            return;
        }
 
 
        $this->og->setTitle('Изображение: '.$image['image']['meta']['title']);
 
        if ($image['image']['meta']['descr']) {
            $this->og->setDescr($image['image']['meta']['descr']);
        }
        else {
            $this->og->setDescr('Страница изображения, расположенного на сервисе picain.ru');
        }
 
        $this->og->setImageUrl('/upl/t/'.$image['image']['system']['name'].'_150x150.'.$image['image']['meta']['file']['type']);
        $this->og->setImageType($image['image']['meta']['file']['type']);
        $this->og->setImageSize(150, 150);
 
        $rightContent = '';
        $rightHead    = '';
 
        if ($this->cookies->get('rightMenuActive') == 'true') {
            $rightHead = Mustache::renderWithBinds(
                'app/pic/image_right_head',
                [
                    'texted' => [
                        'text' => 'Информация',
                        'icon' => ['svg' => ['main' => 'ic-info'], 'size' => 'small']
                    ],
                    'close' => [
                        'id'    => $this->idElizaPicRightPanelClose,
                        'title' => 'панель информации'
                    ],
                    'lang' => [
                        'close' => 'Закрыть'
                    ]
                ]
            );
            
            $hostName = $this->request->getHttpHost();
 
            $copyPage   = 'http://'.$hostName.'/'. $image['image']['system']['name'];
            $copyUrl    = 'http://'.$hostName.'/'.$image['image']['system']['name'].'.'.$image['image']['meta']['file']['type'];
            $copyThumb  = 'http://'.$hostName.'/upl/t/'. $image['image']['system']['name'].'_150x150.'.$image['image']['meta']['file']['type'];
            $copyHtml   = '<a title=\''.$image['image']['meta']['title'].'\' href=\''.$copyPage.'\' target=\'_blank\'><img alt=\''.$image['image']['meta']['title'].'\' src=\''.$copyThumb.'\' /></a>';
            $copyBBCode = '[url='.$copyPage.'][img]'.$copyThumb.'[/img][/url]';
            $resolution = $image['image']['meta']['file']['width'].'×'.$image['image']['meta']['file']['height'];
 
            $info = [
                ['tag' => 'time', 'title' => 'Добавлено:',    'value' => Lib\DateFuncs::dateFormatTextedMonthAndTime($image['image']['system']['date']),],
                ['tag' => 'span', 'title' => 'Разрешение:',   'value' => $resolution],
                ['tag' => 'span', 'title' => 'Просмотры:',    'value' => $image['image']['meta']['views']['count']],
                ['tag' => 'span', 'title' => 'Размер файла:', 'value' => Calc::fileSize($image['image']['meta']['file']['size'])]
            ];
 
            $links_html = '';
    
            $links = [
                ['title' => 'Ссылка', 'value' => $copyUrl   ],
                ['title' => 'HTML',   'value' => $copyHtml  ],
                ['title' => 'BBCode', 'value' => $copyBBCode]
            ];
 
            for($a = 0; $a <3; $a++) {
                $item = $links[$a];
 
                $links_html .= Mustache::renderWithBinds(
                    'forms/base_input',
                    [
                        'title' => $item['title'],
                        'input' => [
                            'tag'    => 'input',
                            'class'  => 'input code',
                            'value'  =>  $item['value'],
                            'type'   => 'text',
                            'style'  => 'default',
                            'size'   => 'medium',
                            'tone'   => 'dark',
                            'radius' => 'rad',
                            'bg'     => 'grey 200',
                            'short'  =>  1
                        ],
                        'icon_left' => [
                            'tag'      => 'span',
                            'position' => 'left',
                            'tone'     => 'dark',
                            'bg'       => 'grey 200',
                            'icon' => [
                                'svg'    => ['main' => 'ic-earth'],
                                'size'   => 'small',
                                'radius' => 'rad'
                            ]
                        ]
                    ]
                );
            }
 
 
 
            $rightContent = Mustache::renderWithBinds(
                'app/pic/image_right_content',
                [
                    'id_descr' => 'elizaPicImageDescr',
                    'isChild'  => $image['image']['system']['parent'] ? 1 : 0,
                    'parent' =>  ''/*imageParent*/,
                    'member' =>  $image['member'],
                    'stack' =>  'stack',
                    'restrict' =>  $image['restrict'],
                    'description' =>  $image['description'],
                    'meta' =>  [
                        'title' =>        $image['image']['meta']['title'],
                        'description' => ''
                    ],
                    'info' =>    $info,
                    'links_html' => $links_html
                ]
            );
 
        }
 
        $windowHtml = $this->htmlGenerateWindow("image", json_encode($image),
            Mustache::renderWithBinds(
                'eliza/toolbar_panel', ['floated' => 'floated', 'size' => 'contentLarge'],
                [
                    'TOOLBAR_MIDDLE' => $this->htmlGenerateUserPanel($type = 'image', $image),
                    'TOOLBAR_RIGHT'  => Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'tag'     => 'div',
                            'class'   => 'sep',
                            'default' => 0
                        ]
                    ).Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'     => $this->idElizaPicRightPanel,
                            'tag'    => 'div',
                            'title'  => 'Правая панель',
                            'class'  => 'rpanel'. ($this->cookies->get('rightMenuActive') == 'true' ? ' active' : '' ),
                            'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                            'icon'   => ['svg' => ['main' => 'ic-rpanel'], 'size' => 'small'],
                            'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                        ]
                    ).Mustache::renderWithBinds(
                            'eliza/toolbar_button',
                            [
                                'id'     => $this->idElizaPicRightBack,
                                'tag'    => 'div',
                                'title'  => 'Назад',
                                'class'  => 'back',
                                'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                                'icon'   => ['svg' => ['main' => 'ic-arrow-left2'], 'size' => 'small'],
                                'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                            ]
                    )
                ]
            ),
            Mustache::renderWithBinds(
                'app/pic/image',
                [
 
                    'vcont'   => 'elizaPicImageCont',
                    'viewer'  => 'elizaPicImageViewer',
                    'cropper' => 'elizaPicImageCropper',
                    'title'   => $image['image']['meta']['title'],
                    'name'    => $image['image']['system']['name'],
                    'type'    => $image['image']['meta']['file']['type'],
                    'width'   => $image['image']['meta']['file']['width'],
                    'height'  => $image['image']['meta']['file']['height']
                ]
            ),
            $this->htmlGenerateFooter($type = 'image', $image),
            $rightContent,
            $rightHead
        );
 
        $windowHtml = mbereg_replace(
            'data-layout="cnt_content_content"',
            'data-layout="cnt_content_content" data-elz-bg="grey 900"',
            $windowHtml
        );
 
        if ($this->cookies->get('rightMenuActive') == 'true') {
            $windowHtml = mbereg_replace(
                'elz tplCLSgrid cells',
                'elz tplCLSgrid cells showside',
                $windowHtml
            );
 
        }
 
        $this->view->setVar('picHtml', $windowHtml);
    }
 
    public function trashAction() {
        if (!$this->user->getId())
            return;
 
        $this->generateHtmlForStack('trash', $this->user->getId(), -1);
    }
 
 
    public function generateHtmlForStack($stackName, $memberId, $stackId)
    {
        if ($stackName == '' && $this->user->isNotActivated()) {
            $this->htmlGenerateRestrictedAccess('stack', ['code' => 'activation', 'data' => '']);
            return;
        }
 
        $stackController = (new StackController())->initialize();
 
        $metaData = $stackController->getName($stackName ? $stackName : 'root');
 
        if ($metaData['restricted']) {
            $this->htmlGenerateRestrictedAccess('stack', $metaData['restricted']);
            return;
        }
 
        //die($metaData['pages']);
 
        if ($this->pageStart > $metaData['pages']) {
            $this->pageStart = $metaData['pages'];
        }
 
        if ($this->pageEnd > $metaData['pages']) {
            $this->pageEnd = $metaData['pages'];
        }
 
        if ($stackName == '' || $stackName == 'trash') {
            $state = "list ".($stackName ? "trash" : "root");
 
            $itemList = $stackController->getItemsList($memberId, $stackId, ['start' => $this->pageStart, 'end' => $this->pageEnd]);
        }
        else {
            $itemList = $stackController->getItemsListByName($stackName,    ['start' => $this->pageStart, 'end' => $this->pageEnd]);
 
            $state = "list album";
        }
 
        $contentHtml = '';
 
        if (/*(!$stackId && !$stackName) ||*/ $stackName == 'trash' || $this->pageStart > 1 || $metaData['owner'] != $this->user->getId() /*|| ($stackName && sizeof($itemList))*/) {
            $uploadCls = ' hide';
        }
        else {
            $uploadCls = '';
        }
 
 
        $contentHtml = '<div class="elz picCLSupload'.(!sizeof($itemList) ? ' empty' : '').$uploadCls.'">'.Mustache::renderWithBinds(
            'common/upload_zone',
            [
                'id'    => $this->idElizaPicPluploadBtn,
                'parent_id'   => $this->idElizaPicPluploadZone,
                'description' => !sizeof($itemList) ?
                    ('<p class="bb p al-center"><span class="bb fn-12">В этом альбоме ещё нет изображений</span>'.
                     '<br>Выберите изображения для загрузки, нажав на эту область, или перетащите файлы сюда<br>'.
                     '<span class="bb fn-8">Ограничение на размер файла: <b class="bb bold">10 mb</b></span>'.
                     '</p>')
                    :
                    ('<p class="bb p al-center"><span class="bb fn-12">Выберите файлы</span>'.
                     '<br>Или перетащите в эту область<br>'.
                     'Вы можете сделать снимок экрана и нажать <b class="bb bold">[Ctrl + V]</b><br>'.
                     '<span class="bb fn-8">Ограничение на размер файла: <b class="bb bold">10 mb</b></span>'.
                     '</p>'),
                'icon' => [
                    'svg' => [
                        'main' => $stackName == 'root' || $stackName == '' ? 'ic-image' : 'ic-images',
                        'sub' =>  'ic-plus'
                    ],
                    'color' => ['subbg' => 'blue']],
                'circle' => ['size' => 'large ', 'radius' => '55', 'color' => 'blue']
            ]
        ).'</div>';
        //}
 
 
        $contentHtml .= Mustache::renderWithBinds(
            'app/pic/items_list',
            [
                'id'   => 'elizaPicContentStackList',
                'list' => $itemList, 'iconEnabled' => $stackName == '' || $stackName == 'trash' ? 0 : 1,
                'lang' => [
                    'title1'    => 'Размер изображения',
                    'title2'    => 'Вариаций изображения',
                    'title3'    => 'Формат изображения',
                    'title4p1'  => 'Является',
                    'title4p2'  => 'Сделать',
                    'title4p3'  => 'иконкой альбома',
                    'title5'    => 'Альбомов внутри',
                    'title6'    => 'Изображений в альбоме',
                    'title7'    => 'Альбом',
                    'title8'    => 'Дней до удаления',
                    'title9'    => 'Изображение',
                    'title10'   => 'Иконка альбома',
                    'title11'   => 'Доступ ограничен',
                    'title12p1' => 'Доступно только пользователям старше',
                    'title12p2' => 'лет',
                    'title13'   => 'Доступно только вам',
                    'title14'   => 'Доступно только автору',
                    'title15'   => 'Доступно только по прямой ссылке'
                ]
            ]
        );
 
 
        $this->view->setVar('picHtml',
            $this->htmlGenerateWindow($state, json_encode($metaData),
                Mustache::renderWithBinds(
                    'eliza/toolbar_panel', ['floated' => 'floated', 'size' => 'contentLarge'],
                    [
                        'TOOLBAR_MIDDLE' => $this->htmlGenerateUserPanel($type = 'stack', $metaData, $stackName),
                        'TOOLBAR_RIGHT'  =>  Mustache::renderWithBinds(
                            'eliza/toolbar_button',
                            [
                                'id'     => $this->idElizaPicRightPanel,
                                'tag'    => 'div',
                                'title'  => 'Правая панель',
                                'class'  => 'rpanel hide',
                                'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                                'icon'   => ['svg' => ['main' => 'ic-rpanel'], 'size' => 'small'],
                                'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                            ]
                        ).Mustache::renderWithBinds(
                                'eliza/toolbar_button',
                                [
                                    'id'     => $this->idElizaPicRightBack,
                                    'tag'    => 'div',
                                    'title'  => 'Назад',
                                    'class'  => 'back'.($stackName == '' ? ' hide' : ''),
                                    'setts'  => ['type' => 'default', 'link' => 1, 'tip_h' => 'dtr'],
                                    'icon'   => ['svg' => ['main' => 'ic-arrow-left2'], 'size' => 'small'],
                                    'border' => ['enable' => 1, 'lines' => 'bottom', 'color' => 'blue']
                                ]
                        )]
                ),
                Mustache::renderWithBinds(
                    'eliza/scroll_content',
                    ['id' => 'elizaPicContentScroll', 'abs' => 'abs'],
                    ['CONTENT' => $contentHtml]
                ),
                $this->htmlGenerateFooter($type = 'stack', $metaData)
            )
        );
    }
 
 
    private function htmlGenerateWindow($state, $data, $topHeader, $cntContent, $cntFooter, $rightContent = '', $rightHead = '') {
        return Mustache::renderWithBinds(
            'eliza/window',
            [
                'setts' => [
                    'id'     => 'ElizaAppPic',
                    'app'    => 'pic',
                    'state'  => $state,
                    'zindex' => 1,
                    'data'   => $data ? ' data-meta=\''.$data.'\' ' : '',
                    'isFullscreen' => 1
                ],
                'class'  => 'standalone',
                'enable' => [
                    'content' => ['cnt' => ['subfooter' => 1,'footer' => 1]],
                    'right'   => ['cnt' => [],'footer' => 1]
                ]
            ],
            [
                'TOP_HEADER' => $topHeader,
                'CNT_CONTENT_CONTENT'   => $cntContent,
                'CNT_CONTENT_FOOTER'    => $cntFooter,
                'CNT_CONTENT_SUBFOOTER' => Mustache::renderWithBinds(
                    'app/pic/image_slider',
                    [
                        'id' => [
                            'main'        => 'elizaPicImageSlider',
                            'list'        => 'elizaPicImageSliderList',
                            'crop'        => 'elizaPicImageSliderCrop',
                            'title'       => 'elizaPicImageSliderTitle',
                            'crop_create' => 'elizaPicThumbCreate',
                            'crop_form'   => 'elizaPicThumbForm'
                        ],
                        'lang' => [
                            'text' =>   'Изображения в альбоме',
                            'title1' => 'Закрыть',
                            'title2' => 'Создать новую миниатюру',
                            'item' =>   'Новая миниатюра'
                        ]
                    ]
                ),
                'RIGHT_CNT_CONTENT' => $rightContent,
                'RIGHT_HEADER'      => $rightHead
            ]
        );
    }
 
 
    private function htmlGenerateRestrictedAccess($type = 'stack', $meta) {
 
 
        $statuses = [
            'private' => [
                'icon' =>  ['name' => "ic-eye-blocked", 'bg' => "red 700", 'txt' => ""],
                'descr' => "Эта страница доступна только её автору."
            ],
            'age' => [
                'icon' =>  ['name' => "", 'bg' => "red 700", 'txt' => $meta['data'].'+'],
                'descr' => 'Эта страница запрещена для просмотра лицам, не достигшим возраста '.$meta['data'].' лет.'
            ],
            'missing' => [
                'icon' =>  ['name' => "", 'bg' => "red 700", 'txt' => "404"],
                'descr' => "Страница не найдена."
            ],
            'guest' => [
                'icon' =>  ['name' => "ic-user", 'bg' => "red 700", 'txt' => ""],
                'descr' => "Для доступа к функционалу требуется регистрация."
            ],
            'activation' => [
                'icon' =>  ['name' => "ic-key", 'bg' => "blue", 'txt' => ""],
                'descr' => "Для использования данного сервиса необходима активация."
            ]
        ];
 
        $data = $statuses[$meta['code']];
 
        $html = Mustache::renderWithBinds(
            'eliza/window',
            [
                'setts' => [
                    'id'    => 'ElizaAppPic',
                    'app'   =>   'pic',
                    'state' => 'default',
                    'isFullscreen' => 1,
                    'zindex' => 1
                ],
                'enable' => [
                    'content' => ['cnt' => ['subfooter' => 1,'footer' => 1]],
                    'right'   => ['cnt' => [],'footer' => 1]
                ]
            ],
            [
                'TOP_HEADER' => Mustache::renderWithBinds('eliza/toolbar_panel', ['floated' => 'floated', 'size' => 'contentLarge'], []),
                'CNT_CONTENT_CONTENT' => Mustache::renderWithBinds(
                    'eliza/forbidden',
                    [
                        'tone' => $type == 'image' ? 'light' : 'dark',
                        'icon' => [
                            'svg'   => ['main' => 'ic-lock', 'sub' =>  $data['icon']['name']],
                            'txt'   => ['sub' => $data['icon']['txt']],
                            'color' => ['subbg' => $data['icon']['bg']]
                        ],
                        'description' => $data['descr']
                    ]
                )
            ]
        );
 
        if ($type == 'image') {
            $html = mbereg_replace(
                'data-layout="cnt_content_content"',
                'data-layout="cnt_content_content" data-elz-bg="grey 900"',
                $html
            );
        }
        
        $this->view->setVar('picHtml', $html);
    }
 
 
 
 
    private function htmlGenerateUserPanel($type = 'stack', $metaData, $stackName ='') // stack, image, trash
    {
        $buttonsHtml = '';
        $buttonsTransformHtml = '';
        $buttons = [];
        $toolbarHtml = '';
 
        $editable = $type == 'stack' ? $metaData['editable'] : $metaData['image']['access']['editing'];
 
        if ($this->user->isNotActivated()) {
            return '';
        }
 
        if ($type == 'stack' && $editable) {
            $buttons = [];
 
            if ($stackName != "trash") {
                if ($stackName != '' && $stackName != 'root') {
                    $buttons[] = [
                        'id'    => 'elizaPicImagePageMeta',
                        'tag'   => 'div',
                        'title' => 'Редактировать описание',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-pencil'],
                            'size'  => 'small'
                        ]
                    ];
                }
 
                $buttons[] = [
                    'id'    => $this->idElizaPicToolAddImage,
                    'tag'   => 'label',
                    'title' => 'Загрузить изображения',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-image', 'sub' => 'ic-plus'],
                        'size'  => 'small',
                        'color' => ['subbg' => 'blue']]
                ];
 
                $buttons[] = [
                    'id'    => $this->idElizaPicToolAddStack,
                    'tag'   => 'div',
                    'title' => 'Добавить альбом',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-folder', 'sub' => 'ic-plus'],
                        'size'  => 'small',
                        'color' => ['subbg' => 'blue']]
                ];
 
                $buttons[] = [
                    'id'    => $this->idElizaPicToolTree,
                    'tag'   => 'div',
                    'title' => 'Проводник по альбомам',
                    'align' => 'right',
                    'icon'  => [
                        'svg'  => ['main' => 'ic-foldertree'],
                        'size' => 'small']
                ];
 
                /*$buttons = [
                    [
                        'id'    => 'ElizaAppPic_addImage',
                        'tag'   => 'label',
                        'title' => 'Загрузить изображения',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-image', 'sub' => 'ic-plus'],
                            'size'  => 'small',
                            'color' => ['subbg' => 'blue']]
                    ],
                    [
                        'id'    => 'ElizaAppPic_addAlbum',
                        'tag'   => 'div',
                        'title' => 'Добавить альбом',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-folder', 'sub' => 'ic-plus'],
                            'size'  => 'small',
                            'color' => ['subbg' => 'blue']]
                    ],
                    [
                        'id'    => 'ElizaAppPic_moveToAlbum',
                        'tag'   => 'div',
                        'title' => 'Проводник по альбомам',
                        'align' => 'right',
                        'icon'  => [
                            'svg'  => ['main' => 'ic-foldertree'],
                            'size' => 'small']
                    ],
                ];*/
            }
 
            $buttons[] = [
                'id'     => $this->idElizaPicToolTrash,
                'tag'    => 'a',
                'title'  => 'Показать удаленное',
                'align'  => 'right',
                'class'  => $stackName == 'trash' ? ' active' : '',
                'border' => [
                    'enable' => 1,
                    'lines'  => 'bottom',
                    'color'  => 'red 800'],
                'icon'  => [
                    'svg'  => ['main' => $stackName == 'trash' ? 'ic-loop' :'ic-trash'],
                    'size' => 'small'],
                'href' => '/trash'
            ];
 
            $length = sizeof($buttons);
 
            for($a = 0; $a < $length; $a++) {
                $item = $buttons[$a];
 
                $buttonsHtml .= Mustache::renderWithBinds(
                    'eliza/toolbar_button',
                    [
                        'id'    => $item['id'],
                        'tag'   => $item['tag'],
                        'title' => $item['title'],
                        'class' => isset($item['class']) ? $item['class'] : '',
                        'setts' => ['type' => 'default', 'align' => $item['align'], 'link' => 1],
                        'text'  => ['str' => $item['title'], 'align' => 'left'],
                        'icon'  => $item['icon'],
                        'href'  => isset($item['href']) ? $item['href'] : '',
                        'border'  => isset($item['border']) ? $item['border'] : ''
                    ]
                );
            }
 
            $toolbarHtml = Mustache::renderWithBinds(
                'eliza/toolbar_group',
                [
                    'active'   => '',
                    'position' => 'right',
                    'xsub'     => '320',
                    'v_pos'    => 'top',
                    'h_pos'    => 'right'
                ],
                [
                    'TOOL_TRIGGER' => Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'    => $this->idElizaPicToolStackExp,
                            'tag'   => 'div',
                            'title' => 'Показать правую панель',
                            'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1],
                            'icon'  => ['svg' => ['main' => 'ic-more1'], 'size' => 'small', 'radius' => 'rad']
                        ]),
                    'TOOL_LIST' => $buttonsHtml
                ]
            );
        }
        else if ($type == 'image'){
            $type = $metaData['image']['meta']['file']['type'];
            $name = $metaData['image']['system']['name'];
 
            $buttons[] = [
                'id'    => 'elizaPicImagePageDownload',
                'title' => 'Скачать изображение',
                'tag'   => 'a',
                'href' => '/'.$name.'.'.$type,
                'data' => ' download="'.$name.'.'.$type.'" ',
                'align' => 'right',
                'icon'  => ['svg' => ['main' => 'ic-download'], 'size' => 'small', 'radius' => 'rad']
            ];
 
            $buttonsTransform = [];
 
            if ($editable) {
                if (!$metaData['image']['system']['parent']) {
                    $buttons[] = [
                        'id'    => 'elizaPicImagePageTree',
                        'title' => 'Переместить изображение',
                        'tag'   => 'div',
                        'align' => 'right',
                        'icon'  => [
                            'svg'   => ['main' => 'ic-foldertree', 'sub' => 'ic-arrow-left'],
                            'size'  => 'small',
                            'color' => ['subbg' => 'blue']]
                    ];
                }
 
                $buttons[] = [
                    'id'    => 'elizaPicImagePageCrop',
                    'title' => 'Создать миниатюру',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-crop'],
                        'size'  => 'small'
                    ],
                    'border' => [
                        'enable' => 1,
                        'lines'  => 'bottom',
                        'color'  => 'green'
                    ]
                ];
 
                $buttons[] = [
                    'id'    => 'elizaPicImagePageEdit',
                    'title' => $metaData['image']['system']['parent'] ? 'Редактирование изображения' : 'Создать вариацию',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-wand', 'sub' => $metaData['image']['system']['parent'] ? 'ic-pencil' : 'ic-plus'],
                        'size'  => 'small',
                        'color' => ['subbg' => 'blue']],
                    'border' => [
                        'enable' => 1,
                        'lines'  => 'bottom',
                        'color'  => 'green'
                    ]
                ];
 
                $buttons[] = [
                    'id'    => 'elizaPicImagePageMeta',
                    'title' => 'Редактировать описание',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => [
                        'svg'   => ['main' => 'ic-pencil'],
                        'size'  => 'small']
                ];
 
                $buttons[] = [
                    'id'     => 'elizaPicImagePageDelete',
                    'title'  => 'Удалить',
                    'tag'    => 'div',
                    'align'  => 'right',
                    'icon'  => [
                        'svg'  => ['main' => 'ic-trash'],
                        'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformMirrorHorizontal',
                    'title' => 'Отразить по горизонтали',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-mirror-h'], 'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformMirrorVertical',
                    'title' => 'Отразить по вертикали',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-mirror-v'], 'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformRotateLeft',
                    'title' => 'Повернуть против часовой стрелки',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-rotateclockcw'], 'size' => 'small']
                ];
 
                $buttonsTransform[] = [
                    'id'    => 'elizaImageTransformRotateRight',
                    'title' => 'Повернуть по часовой стрелке',
                    'tag'   => 'div',
                    'align' => 'right',
                    'icon'  => ['svg' => ['main' => 'ic-rotateclockw'], 'size' => 'small']
                ];
 
                $length = sizeof($buttonsTransform);
 
                for($a = 0; $a < $length; $a++) {
                    $item = $buttonsTransform[$a];
 
                    $buttonsTransformHtml .= Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'     => $item['id'],
                            'tag'    => $item['tag'],
                            'title'  => $item['title'],
                            'setts'  => ['type' => 'default', 'align' => $item['align'], 'link' => 1],
                            'text'   => ['str' => $item['title'], 'align' => 'left'],
                            'icon'   => $item['icon'],
                            'border' => isset($item['border']) ? $item['border'] : []
                        ]
                    );
                }
 
                $buttonsTransformHtml .= Mustache::renderWithBinds(
                    'eliza/toolbar_button',
                    [
                        'tag'     => 'div',
                        'class'   => 'sep',
                        'default' => 0,
                        'setts'   => ['align' => 'right']
                    ]
                );
            }
 
            $length = sizeof($buttons);
 
            for($a = 0; $a < $length; $a++) {
                $item = $buttons[$a];
 
                $buttonsHtml .= Mustache::renderWithBinds(
                    'eliza/toolbar_button',
                    [
                        'id'     => $item['id'],
                        'tag'    => $item['tag'],
                        'title'  => $item['title'],
                        'href'   => isset($item['href']) ? $item['href'] : '',
                        'data'   => isset($item['data']) ? $item['data'] : '',
                        'setts'  => ['type' => 'default', 'align' => $item['align'], 'link' => 1],
                        'text'   => ['str' => $item['title'], 'align' => 'left'],
                        'icon'   => $item['icon'],
                        'border' => isset($item['border']) ? $item['border'] : []
                    ]
                );
            }
 
            $toolbarHtml = ($editable ? Mustache::renderWithBinds(
                'eliza/toolbar_group',
                [
                    'id'       => 'elizaImageToolGroupTransform',
                    'active'   => '',
                    'ordered'  => 'ordered',
                    'position' => 'right',
                    'xsub'     => '768',
                    'v_pos'    => 'top',
                    'h_pos'    => 'right'
                ],
                [
                    'TOOL_TRIGGER' => Mustache::renderWithBinds(
                        'eliza/toolbar_button',
                        [
                            'id'    => 'elizaImageTransformExpand',
                            'tag'   => 'div',
                            'title' => 'Трансформация изображения',
                            'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1],
                            'icon'  => ['svg' => ['main' => 'ic-fix'], 'size' => 'small', 'radius' => 'rad'],
                            'border' => [
                                'enable' => 1,
                                'lines'  => 'bottom',
                                'color'  => 'blue'
                            ]
                        ]),
                    'TOOL_LIST' => $buttonsTransformHtml
                ]
            ) : '').Mustache::renderWithBinds(
                    'eliza/toolbar_group',
                    [
                        'id'       => 'elizaImageToolGroupMain',
                        'active'   => '',
                        'ordered'  => 'ordered',
                        'position' => 'right',
                        'xsub'     => '540',
                        'v_pos'    => 'top',
                        'h_pos'    => 'right'
                    ],
                    [
                        'TOOL_TRIGGER' => Mustache::renderWithBinds(
                            'eliza/toolbar_button',
                            [
                                'id'    => 'elizaImageToolGroupExpand',
                                'tag'   => 'div',
                                'title' => 'Действия',
                                'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1],
                                'icon'  => ['svg' => ['main' => 'ic-more1'], 'size' => 'small', 'radius' => 'rad'],
                                'border' => [
                                    'enable' => 1,
                                    'lines'  => 'bottom',
                                    'color'  => 'blue'
                                ]
                            ]),
                        'TOOL_LIST' => $buttonsHtml
                    ]
                );
        }
 
 
 
 
        return $toolbarHtml;
    }
 
 
    private function htmlGenerateFooter($type = 'stack', $metaData)
    {
        $htmlLeft   = '';
        $htmlMiddle = '';
        $htmlRight  = '';
 
        if ($type == 'stack') {
            $midButtons = [
                'left'  => ['class' => '', 'tag' => 'a'],
                'right' => ['class' => '', 'tag' => 'a'],
                'root'  => ['class' => '', 'tag' => 'a']
            ];
 
            if ($metaData['name'] === "root") {
                $rooTitle = "Перейти на первую страницу";
 
                if ($this->pageEnd === 1) {
                    $midButtons['root']['class'] = "disabled";
                }
            }
            else {
                $rooTitle = !$metaData['parent'] ? ($this->user->getId() ? "Перейти в корень" : "Перейти на главную страницу") : "Наверх";
            }
 
            if ($this->pageStart <= 1) {
                $midButtons['left']  = ['class' => 'disabled', 'tag' => 'div'];
            }
 
            if ($this->pageEnd >= $metaData['pages']) {
                $midButtons['right'] = ['class' => 'disabled', 'tag' => 'div'];
            }
 
            if (!$this->user->isNotActivated() || ($this->user->isNotActivated() && $metaData['name'] != "root")) {
                $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                    [
                        'id'    => $this->idElizaPicFooterAlbums,
                        'tag'   => 'div',
                        'title' => 'Показать только альбомы',
                        'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                        'icon'  => ['svg' => ['main' => 'ic-foldertree'], 'size' => 'small']
                    ]
                );
 
 
                $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                    [
                        'id'    => $this->idElizaPicFooterContent,
                        'tag'   => 'div',
                        'title' => 'Показать только связанное с контентом',
                        'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                        'icon'  => ['svg' => ['main' => 'ic-sharedfile'], 'size' => 'small']
                    ]
                );
            }
 
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_title',
                [
                    'id'   => $this->idElizaPicFooterTitle,
                    'text' => $metaData['title']
                ]
            );
 
 
            $htmlMiddle .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterPrev,
                    'tag'   => $midButtons['left']['tag'],
                    'href'  => '/'.($metaData['name'] == "root" ? '' : $metaData['name']).'?page='.($this->pageStart - 1),
                    'title' => 'Предыдущая страница',
                    'class' => $midButtons['left']['class'],
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-left'], 'size' => 'small']
                ]
            );
 
 
            $htmlMiddle .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterRoot,
                    'tag'   => $midButtons['root']['tag'],
                    'href'  => '/'.($metaData['parent'] ? $metaData['parent'] : ''),
                    'title' => $rooTitle,
                    'class' => $midButtons['root']['class'],
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-gallery3'], 'size' => 'small']
                ]
            );
 
            $htmlMiddle .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterNext,
                    'tag'   => $midButtons['right']['tag'],
                    'href'  => '/'.($metaData['name'] == "root" ? '' : $metaData['name']).'?page='.($this->pageEnd + 1),
                    'title' => 'Следующая страница',
                    'class' => $midButtons['right']['class'],
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-right'], 'size' => 'small']
                ]
            );
 
            $number = $this->pageStart != $this->pageEnd ? $this->pageStart.'-'.$this->pageEnd : $this->pageStart;
 
            $htmlRight .= Mustache::renderWithBinds(
                'eliza/toolbar_num_of_num',[
                    'id'      => $this->idElizaPicFooterNumbers,
                    'current' => $number,
                    'total'   => $metaData['pages'] ? $metaData['pages'] : 1
                ]
            );
 
            $htmlRight .= Mustache::renderWithBinds(
                'eliza/toolbar_button',[
                    'id'      => $this->idElizaPicToolUnsel,
                    'tag'     => 'div',
                    'title'   => 'Сбросить выделение',
                    'class'   => 'hide',
                    'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtr'],
                    'icon'  => ['svg' => ['main' => 'ic-selectremove'], 'size' => 'small']
                ]
            );
        }
        else {
            if ($metaData['image']['system']['parent']) {
                $upButton = '/'.$metaData['image']['system']['prow']['name'];
                $upTitle  = 'Перейти к оригиналу';
            }
            else {
                $upButton = $metaData['page']['up'] !== 'root' ? '/'.$metaData['page']['up'] : '/';
                $upTitle  = $metaData['page']['up'] !== 'root' ? 'Перейти в альбом' : ($this->user->getId() ? 'Перейти в корень' : 'Перейти на главную страницу');
            }
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'     => 'elizaPicImageFooterVariations',
                    'title'  => 'Вариации изображения',
                    'tag'    => 'div',
                    'class'  => !$metaData['image']['meta']['numbs']['variations'] && !$metaData['image']['system']['parent'] ? 'hide' : '',
                    'setts'  => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                    'icon'   => ['svg' => ['main' => 'ic-wand'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'green']
                ]
            );
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'     => 'elizaPicImageFooterContent',
                    'tag'    => 'div',
                    'title'  => 'Связи с контентом',
                    'class'  => !$metaData['image']['flags']['isContent'] ? 'hide' : '',
                    'setts'  => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtl'],
                    'icon'   => ['svg' => ['main' => 'ic-sharedfile'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'orange']
                ]
            );
 
            $htmlLeft .=  Mustache::renderWithBinds('eliza/toolbar_title',
                [
                    'id'   => $this->idElizaPicFooterTitle,
                    'text' => $metaData['image']['meta']['title']
                ]
            );
 
 
            $htmlMiddle .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterPrev,
                    'tag'   => $metaData['page']['prev'] != "" ? 'a' : 'div',
                    'href'  => '/'.$metaData['page']['prev'],
                    'title' => 'Предыдущее изображение',
                    'class' => $metaData['page']['prev'] != "" && !$metaData['image']['system']['parent'] ? '' : 'disabled',
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => $metaData['page']['prev'] != "" ? 1 : 0, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-left'], 'size' => 'small']
                ]
            );
 
            $htmlMiddle .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterRoot,
                    'tag'   => 'a',
                    'href'  => $upButton,
                    'title' => $upTitle,
                    'class' => !$metaData['page']['up'] ? 'disabled' : '',
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => 1, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-gallery3'], 'size' => 'small']
                ]
            );
 
            $htmlMiddle .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => $this->idElizaPicFooterNext,
                    'tag'   => $metaData['page']['next'] != "" ? 'a' : 'div',
                    'href'  => '/'.$metaData['page']['next'],
                    'title' => 'Следующее изображение"',
                    'class' => $metaData['page']['next'] != "" && !$metaData['image']['system']['parent'] ? '' : 'disabled',
                    'setts' => ['type' => 'default', 'align' => 'left', 'link' => $metaData['page']['next'] != "" ? 1 : 0, 'tip_v' => 'dtb'],
                    'icon'  => ['svg' => ['main' => 'ic-move-right'], 'size' => 'small']
                ]
            );
 
 
 
            $htmlRight .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => 'elizaPicImageFooterThumbs',
                    'tag'   => 'div',
                    'title' => 'Доступные миниатюры',
                    'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtr'],
                    'icon'  => ['svg' => ['main' => 'ic-crop2'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'blue']
                ]
            );
 
            $htmlRight .= Mustache::renderWithBinds('eliza/toolbar_button',
                [
                    'id'    => 'elizaPicImageFooterSiblings',
                    'tag'   => 'div',
                    'class'  => ((!$metaData['page']['prev']   && !$metaData['page']['next']) ||
                                   $metaData['stack'] == 'root' || $metaData['image']['system']['parent']) ? 'hide' : '',
                    'title' => 'Изображения в альбоме',
                    'setts' => ['type' => 'default', 'align' => 'right', 'link' => 1, 'tip_v' => 'dtb', 'tip_h' => 'dtr'],
                    'icon'  => ['svg' => ['main' => 'ic-gallery1'], 'size' => 'small'],
                    'border' => ['enable' => 1, 'lines' => 'top', 'color' => 'blue']
                ]
            );
        }
 
 
        return Mustache::renderWithBinds(
            'eliza/footer_1',
            [
                'id' => $this->idElizaPicFooter
            ],
            [
                'FOOTER_LEFT'   => $htmlLeft,
                'FOOTER_MIDDLE' => $htmlMiddle,
                'FOOTER_RIGHT'  => $htmlRight
            ]
        );
    }
 
 
//--//------------------------------------------------------------------------------------------------------------------
//--//  РАЗДЕЛ ГЕНЕРАЦИИ РОУТОВ
//--//------------------------------------------------------------------------------------------------------------------
 
    public function generateRoutes() {
        $this->routeGenDynamic();
    }
 
    private function routeGenDynamic() {
        $routeMap = [
            'indexPages' => [
                'pattern' => '/',     'controller' => 'Pic',
                'action'  => 'index', 'params'     => []
            ],
            'stack' => [
                'pattern' => '/([-_a-zA-Z0-9]{7})', 'controller' => 'Pic',
                'action'  => 'stack',             'params'     => ['stackName' => 1]
            ],
            'image' => [
                'pattern'    => '/([-_a-zA-Z0-9]{1,6}|[-_a-zA-Z0-9]{8}|[-_a-zA-Z0-9]{9,})',
                'controller' => 'Pic',
                'action'     => 'image',
                'params'     => ['imageName' => 1]
            ]
        ];
 
        $ch = new Lib\RouteCache($this->getSiteId(), $this->getModuleId());
        $ch->clearDynamicRoutes();
 
        foreach($routeMap as $i => $v) {
            $ch->insertDynamicRoute('picHandler', '', $v['pattern'], $v['controller'], $v['action'], $v['params']);
        }
    }
 
    private function calcSize($bytes)
    {
        if ($bytes >= 1073741824)
        {
            $bytes = number_format($bytes / 1073741824, 2) . ' GB';
        }
        elseif ($bytes >= 1048576)
        {
            $bytes = number_format($bytes / 1048576, 2) . ' MB';
        }
        elseif ($bytes >= 1024)
        {
            $bytes = number_format($bytes / 1024, 2) . ' KB';
        }
        elseif ($bytes > 1)
        {
            $bytes = $bytes . ' bytes';
        }
        elseif ($bytes == 1)
        {
            $bytes = $bytes . ' byte';
        }
        else
        {
            $bytes = '0 bytes';
        }
 
        return $bytes;
    }
}
#1Site\Pic\Controller\PicController->imageAction
#2Phalcon\Dispatcher\AbstractDispatcher->callActionMethod
#3Phalcon\Dispatcher\AbstractDispatcher->dispatch
#4Phalcon\Mvc\Application->handle
/var/www/fullrest-team/data/www/fullrest.net/public/index.php (299)
<?
use Core\Modules\Utils\Controller\MinController;
use Phalcon\Di\Di;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Dispatcher as MvcDispatcher;
use \Phalcon\Mvc\Dispatcher as PhDispatcher;
 
// SET GLOBAL sql_mode = "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES"
Model::setup(
    array(
        'notNullValidations' => false
    )
);
 
mb_internal_encoding("UTF-8");
 
set_time_limit (0);
ini_set('display_errors', 1);
error_reporting(E_ALL /*^ 'E_DEPRECATED'*/ );
date_default_timezone_set( 'Europe/Moscow' );
 
(new Phalcon\Support\Debug())->listen(true, true);
 
require_once('../Core/Lib/Vendor/autoload.php');
 
try {
  $Loader = new Phalcon\Autoload\Loader();
 
  $Loader->setNamespaces(
    [
      'Core\Lib'        => '../Core/Lib/',
            'Core\Lib\Navigation' => '../Core/Lib/Navigation/',
      'Core\Controller' => '../Core/Controller/',
            'Core\Extenders'  => '../Core/Extenders/',
            'Core\Model'      => '../Core/Model/'
    ],
    true
  )->register();
 
  $DI = new Phalcon\Di\FactoryDefault();
 
 
    $DI->get('dispatcher')->setEventsManager($DI->get('eventsManager'));
 
    $DI->set('url', function() {
        $url = new \Phalcon\Url();
        $url->setBaseUri('/');
 
        return $url;
    }, true);
 
  $DI->setShared('debug', 'Core\Lib\Debug')->resolve();
 
 
  $App = new Phalcon\Mvc\Application($DI);
 
  $DI->setShared('loader', $Loader);
 
    $DI->setShared('overseer', function () {
        return Core\Lib\Overseer::getInstance();
    });
 
    $DI->setShared('og', function () {
        return Core\Lib\OpenGraph::getInstance();
    });
 
    $DI->setShared('resconf', function () {
        return Core\Lib\ResourcesConfigurator::getInstance();
    });
 
  $DI->setShared('hostname', function () {
    $Hostname = new Core\Lib\Hostname();
        $Hostname->setHostnameConfigDir('../Cache/Sites/');
    $Hostname->initialize();
 
    return $Hostname;
  })->resolve();
 
  $DI->getShared('debug')->resolve($DI['hostname']->config->debug);
 
    $DI->set('db', function() use ($DI) {
        $config = require_once('../Config/mysql.php');
 
        $db = new Phalcon\Db\Adapter\Pdo\Mysql(array(
            "host"     => $config['host'],
            "username" => $config['username'],
            "password" => $config['password'],
            "dbname"   => $config['name'],
            'charset'   =>'UTF8',
            'options' =>[
                PDO::ATTR_DEFAULT_FETCH_MODE  =>  PDO::FETCH_ASSOC,
                PDO::MYSQL_ATTR_INIT_COMMAND  => 'SET NAMES UTF8'
            ]
        ));
 
        $db->query(
            '
                SET 
                    character_set_results = \'utf8\', 
                    character_set_client = \'utf8\', 
                    character_set_connection = \'utf8\', 
                    character_set_database = \'utf8\', 
                    character_set_server = \'utf8\'
            '
        );
 
        return $db;
    });
 
 
 
    //echo '<pre>';
    //print_r($mysqli->get_charset ());
 
 
 
  $DI->set('modelsMetadata', function () {
    return new \Phalcon\Mvc\Model\MetaData\Stream(
      [
        'metaDataDir' => '../Cache/Metadata/'
      ]
    );
  });
 
    $DI->set('cookies', function() {
        $Cookies = new Phalcon\Http\Response\Cookies();
        $Cookies->useEncryption(false);
        return $Cookies;
    });
 
    /*$DI->set('crypt', function() {
        $Crypt = new Phalcon\Crypt();
        $Crypt->setKey('KTr]t[S&gt;ATN');
        return $Crypt;
    });*/
 
 
    $DI->setShared('session', function () {
        $session = new Phalcon\Session\Manager();
        $files = new Phalcon\Session\Adapter\Stream();
        $session->setAdapter($files)->start();
 
        return $session;
    });
 
 
    $DI->setShared('user', function () {
    return Core\Lib\UserHandler::getInstance();
  });
 
  $DI->set('security', function () {
    $Security = new Core\Lib\Security();
 
    return $Security;
  });
 
  $DI->set('assets', function () use ($DI) {
    $Assets = new Phalcon\Assets\Manager(new Phalcon\Html\TagFactory(new Phalcon\Html\Escaper()));
 
        $js  = $Assets->collection('js');
        $css = $Assets->collection('css');
 
        $user = $DI['user'];
 
        if ($user->getSetting('tools', 'dev_compress_css')) {
            $css->addCss('/min/common_'.$DI['overseer']->getSiteName().'_css_ver'.$DI['resconf']->getVerCss().'.css');
        }
        else {
            $sysCss = (new MinController())->minCssSystemApp(true);
 
            foreach($sysCss as $i => $v) {
                $len = sizeof($v);
 
                for($a = 0; $a < $len; $a++) {
                    $css->addCss($i.$v[$a]);
                }
            }
 
            $configCss = $DI['hostname']->config['system']['css'];
 
            $name   = $DI['hostname']->config['system']['package']['name'];
            $path      = 'design/'.mb_strtolower($name).'/';
 
            if (sizeof($configCss)) {
                foreach($configCss as $i => $v) {
                    $css->addCss($path.$v);
                }
            }
        }
 
        if (false && $user->getSetting('tools', 'dev_compress_js') && $DI['hostname']->config['meta']['site_id'] != 0) {
            $js->addJs('/min/common_'.$DI['overseer']->getSiteName().'_js_ver'.$DI['resconf']->getVerJS().'_ru.js', false, false, array('async' => 'async'));
        }
        else {
            $sysJs = $DI['db']->query(
                '
                    SELECT
                        `srjg`.`group_folder`,
                        `srj`.`js_name`,
                        `srj`.`js_lang`
                    FROM `sys_resources_js` AS `srj`, `sys_resources_js_groups` AS `srjg`
                    WHERE `srjg`.`group_id`=`srj`.`group_id` AND `srj`.`js_type`=\'system\' AND `srj`.`js_skip`=0
                    ORDER BY `srjg`.`group_order` ASC, `srj`.`js_order` ASC
                '
            );
 
            while($row = $sysJs->fetch()) {
                if ($row['js_lang']) {
                    $js->addJs('/api/utils/builder/buildLangForJSByDirFile?file='.$row['group_folder'].$row['js_name'].'&trans='.$row['js_lang']);
                }
                else {
                    $js->addJs($row['group_folder'].$row['js_name']);
                }
            }
 
 
            $modules   = $DI['hostname']->config['system']['package']['modules'];
            $name      = $DI['hostname']->config['system']['package']['name'];
            $siteId    = $DI['hostname']->config['meta']['site_id'];
            $packageId = $DI['hostname']->config['system']['package']['id'];
 
            if($packageId) {
                $packageJs = $DI['db']->query('SELECT * FROM `sys_resources_js` WHERE `package_id`='.$packageId.' AND `js_type`=\'package\' ORDER BY `js_order` ASC');
 
                while($row = $packageJs->fetch()) {
                    if ($row['js_lang']) {
                        $js->addJs('/api/utils/builder/buildLangForJSByDirFile?file='.'js/'.$row['js_name'].'&trans='.$row['js_lang']);
                    }
                    else {
                        $js->addJs('js/'.$row['js_name']);
                    }
                }
            }
 
 
 
            $siteJs = $DI['db']->query('SELECT * FROM `sys_resources_js` WHERE `site_id`='.$siteId.' AND `js_type`=\'site\' ORDER BY `js_order` ASC');
 
 
            while($row = $siteJs->fetch()) {
                if ($row['js_lang']) {
                    $js->addJs('/api/utils/builder/buildLangForJSByDirFile?file='.'js/'.$row['js_name'].'&trans='.$row['js_lang']);
                }
                else {
                    $js->addJs('js/'.$row['js_name']);
                }
            }
 
            $js->addJs('js/packages/'.$name.'.js');
 
            if (sizeof($modules)) {
                foreach($modules as $i => $v) {
                    $addr = 'js/controllers/'.$name.'/'.$i.'.js';
 
                    if (!is_readable($addr))
                        continue;
 
                    $js->addJs($addr);
                }
            }
 
            $js->addJs('js/main.js');
        }
 
    return $Assets;
  });
 
  $DI->set('view', function () use ($DI) {
    $EventManager = new \Phalcon\Events\Manager();
 
//    Пример обработки события в \Core\Lib\Mustache (line 42)
//    $EventManager->attach('mustache:testEvent', function () {
//      die('WOO WOOOOOOOOOOOOOOOOOOO!!!!11');
//    });
 
    //$View = new Phalcon\Mvc\View();
 
        $View = new \Core\Extenders\MvcView();
 
    $View->setEventsManager($EventManager);
 
    $View->setViewsDir($DI['hostname']->config->view->path);
    $View->setLayoutsDir('layouts/');
    $View->setPartialsDir('partials/');
    $View->setMainView('main');
 
    $Engine = new Core\Lib\Mustache($View, $DI);
 
    $NativeEngine = new Phalcon\Mvc\View\Engine\Php($View, $DI);
 
    $View->registerEngines([
      '.hbs' => $Engine,
      '.phtml' => $NativeEngine
    ]);
 
    return $View;
  });
 
    $html = $App->handle($_SERVER["REQUEST_URI"])->getContent();
 
    if ($DI['request']->isAjax()) {
 
        (new \Core\Lib\JSONResponse(\Core\Lib\JSONResponse::SUCCESS))->send(
            [
                'status' => 'success',
                'hapi' => [
                    'title'      => $DI['overseer']->getMetaTitle(),
                    'container'  => $DI['overseer']->getJSContainer(),
                    'package'    => $DI['overseer']->getJSPackage(),
                    'controller' => $DI['overseer']->getJSController(),
                    'action'     => $DI['overseer']->getJSAction()
                ],
                'html' => $html
            ]
        );
    }
    else
        echo $html;
 
 
    
 
 
} catch (Core\Lib\ApiException $apiException) {
 
  if ($DI['hostname']->config->debug->enableApi) {
    $DI['debug']->onUncaughtException($apiException);
  }
 
  (new Core\Lib\JSONResponse(\Core\Lib\JSONResponse::ERROR))->send($apiException);
 
  //$DI['response']->setHeader('Content-type', 'application/json')
  //  ->setJsonContent(["status" => false, "error" => ["message" => $apiException->getMessage()]])->send();
} catch (Phalcon\Exception $e) {
  if ($DI['hostname']->config->debug->enable && !$DI['hostname']->checkMode(Core\Lib\Hostname::API_MODE)) {
    $DI['debug']->onUncaughtException($e);
  }
 
  echo "Error: {$e->getMessage()}<br>{$e->getFile()}:{$e->getLine()}";
}
KeyValue
_url/6jI29pfY
KeyValue
REDIRECT_REDIRECT_HTTPSon
REDIRECT_REDIRECT_STATUS200
REDIRECT_HTTPSon
REDIRECT_STATUS200
HTTPSon
HTTP_HOSTpic.fullrest.ru
HTTP_X_FORWARDED_PROTOhttps
HTTP_X_FORWARDED_PORT443
HTTP_CONNECTIONclose
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HTTP_ACCEPT_ENCODINGgzip, br, zstd, deflate
HTTP_COOKIEPHPSESSID=adghqcnnv2cvnd09r5nh08ovl2
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SERVER_SIGNATURE<address>Apache/2.4.62 (Debian) Server at pic.fullrest.ru Port 80</address>\n
SERVER_SOFTWAREApache/2.4.62 (Debian)
SERVER_NAMEpic.fullrest.ru
SERVER_ADDR127.0.0.1
SERVER_PORT80
REMOTE_ADDR216.73.216.75
DOCUMENT_ROOT/var/www/fullrest-team/data/www/fullrest.net
REQUEST_SCHEMEhttp
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT/var/www/fullrest-team/data/www/fullrest.net
SERVER_ADMINwebmaster@fullrest.net
SCRIPT_FILENAME/var/www/fullrest-team/data/www/fullrest.net/public/index.php
REMOTE_PORT60482
REDIRECT_URL/public/6jI29pfY
REDIRECT_QUERY_STRING_url=/6jI29pfY
GATEWAY_INTERFACECGI/1.1
SERVER_PROTOCOLHTTP/1.0
REQUEST_METHODGET
QUERY_STRING_url=/6jI29pfY
REQUEST_URI/6jI29pfY
SCRIPT_NAME/public/index.php
PHP_SELF/public/index.php
REQUEST_TIME_FLOAT1751212964.8932
REQUEST_TIME1751212964
#Path
0/var/www/fullrest-team/data/www/fullrest.net/public/index.php
1/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/autoload.php
2/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/composer/autoload_real.php
3/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/composer/platform_check.php
4/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/composer/ClassLoader.php
5/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/composer/autoload_static.php
6/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Debug.php
7/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Hostname.php
8/var/www/fullrest-team/data/www/fullrest.net/Cache/Sites/hostnames.php
9/var/www/fullrest-team/data/www/fullrest.net/Cache/Sites/Configs/config_sid_2.php
10/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Overseer.php
11/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/OpenGraph.php
12/var/www/fullrest-team/data/www/fullrest.net/Config/global.loader.php
13/var/www/fullrest-team/data/www/fullrest.net/Config/global.router.php
14/var/www/fullrest-team/data/www/fullrest.net/Config/global.modules.php
15/var/www/fullrest-team/data/www/fullrest.net/Cache/Sites/Routes/routes_sid_2.php
16/var/www/fullrest-team/data/www/fullrest.net/Core/Extenders/MvcView.php
17/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Mustache.php
18/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/compat.php
19/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Cache.php
20/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Cache/AbstractCache.php
21/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Cache/FilesystemCache.php
22/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Cache/NoopCache.php
23/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Compiler.php
24/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Context.php
25/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Engine.php
26/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception.php
27/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/InvalidArgumentException.php
28/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/LogicException.php
29/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/RuntimeException.php
30/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/SyntaxException.php
31/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/UnknownFilterException.php
32/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/UnknownHelperException.php
33/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Exception/UnknownTemplateException.php
34/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/HelperCollection.php
35/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/LambdaHelper.php
36/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader.php
37/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/ArrayLoader.php
38/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/MutableLoader.php
39/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/CascadingLoader.php
40/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/FilesystemLoader.php
41/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/InlineLoader.php
42/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/ProductionFilesystemLoader.php
43/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Loader/StringLoader.php
44/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Logger.php
45/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Logger/AbstractLogger.php
46/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Logger/StreamLogger.php
47/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Parser.php
48/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Source.php
49/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Source/FilesystemSource.php
50/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Template.php
51/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Vendor/mustache/mustache/src/Tokenizer.php
52/var/www/fullrest-team/data/www/fullrest.net/Core/Extenders/MustacheLoaderWithMinifier.php
53/var/www/fullrest-team/data/www/fullrest.net/Site/Pic/Controller/PicController.php
54/var/www/fullrest-team/data/www/fullrest.net/Core/Extenders/ContentController.php
55/var/www/fullrest-team/data/www/fullrest.net/Core/Modules/Pic/Controller/ImageController.php
56/var/www/fullrest-team/data/www/fullrest.net/Config/mysql.php
57/var/www/fullrest-team/data/www/fullrest.net/Cache/Templates/Mustache/__Mustache_1d001a510369b49d1a933ffc60bd8491.php
58/var/www/fullrest-team/data/www/fullrest.net/Cache/Templates/Mustache/__Mustache_0e4062d0754cc66f179b00868557c779.php
59/var/www/fullrest-team/data/www/fullrest.net/Core/Lib/Minify/HTML.php
60/var/www/fullrest-team/data/www/fullrest.net/Cache/Templates/Mustache/__Mustache_c108477bd1b88e556ae8738a5b41eb41.php
61/var/www/fullrest-team/data/www/fullrest.net/Cache/Templates/Mustache/__Mustache_b547b608e299c5c67f165888d625f8a0.php
Memory
Usage2097152