#0 | sizeof /var/www/fullrest-team/data/www/fullrest.net/Core/Model/PicItem.php (171) <?php namespace Core\Model; use Core\Dict\ContentType; use Core\Lib\Pic; use Imagick; use Phalcon\Mvc\Model; use Phalcon\Di\Di; class PicItem extends Model { private $item = [ 'flags' => [ 'isIcon' => 0, 'isImage' => 0, 'isStack' => 0, 'isContent' => 0 ], 'setts' => [], 'thumb' => [ 'name' => '', 'type' => '' ], 'meta' => [ 'title' => '', 'numbs' => ['stacks' => '', 'images' => '', 'variations' => ''], 'url' => '', 'file' => [ 'width' => 0, 'height' => 0, 'type' => '' ] ], 'system' => [ 'type' => '', // image|album 'name' => '', 'id' => 0, // Айди картинки или стэка 'order' => 0 ], 'access' => [ 'enabled' => 0, 'age' => 0, 'private' => 0, 'direct' => 0, 'editing' => 0 ] ]; public static function initById($id, $type, $access = [], $isApp = false) { $db = DI::getDefault()['db']; if($type == 'stack') { $result = $db->query(' SELECT `pis`.*, `pi`.`pic_file_name`, `pi`.`pic_file_format` FROM `src_pic_images_stacks` AS `pis` LEFT JOIN `src_pic_images` AS `pi` ON `pi`.`stack_id`=`pis`.`stack_id` AND `pi`.`pic_is_icon` = 1 WHERE `pis`.`stack_id` = '.$id); return PicItem::initBySqlArray($result->fetch(), $access, $isApp); } else { $result = $db->query( ' SELECT `spi`.*, `svs`.`stat_views` AS `views_count`, `svs`.`stat_unics` AS `views_unic` FROM `src_pic_images` AS `spi`, `stc_view_stat` AS `svs` WHERE `spi`.`pic_id` = '.$id.' AND `svs`.type_id='.ContentType::PIC.' AND `svs`.`content_id`=`spi`.`pic_id` ' ); return PicItem::initBySqlArray($result->fetch(), $access, $isApp); } } public static function initBySqlArray($sqlRowArray, $access = [], $isApp = false) { $item = new PicItem(); if ($isApp) $urlPref = '#pic/'; else $urlPref = '/'; if(!isset($sqlRowArray['stack_order'])) { $item->configAsImage($sqlRowArray, $access, $urlPref); } else { $item->configAsStack($sqlRowArray, $access, $urlPref); } return $item; } public function onConstruct() { $user = DI::getDefault()['user']; $this->item['setts'] = [ 'isDem' => (int)$user->getSetting('pic', 'show_img_dem'), 'isType' => (int)$user->getSetting('pic', 'show_img_type'), 'isStat' => (int)$user->getSetting('pic', 'show_alb_stat') ]; } public function getData() { return $this->item; } public function configAsImage($sqlRowArray, $access = [], $urlPref = '/') { $parentId = (int)$sqlRowArray['parent_id']; $variations = !$sqlRowArray['pic_variations'] ? '' : (int)$sqlRowArray['pic_variations']; $this->item['flags']['isImage'] = 1; $this->item['flags']['isIcon'] = (int)$sqlRowArray['pic_is_icon']; $this->item['flags']['isContent'] = $sqlRowArray['pic_in_content'] ? 1 : 0; $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150'; $this->item['thumb']['type'] = $sqlRowArray['pic_file_format']; $this->item['meta']['title'] = $sqlRowArray['pic_file_title']; $this->item['meta']['descr'] = $sqlRowArray['pic_description']; $this->item['meta']['numbs']['variations'] = (int)$variations; $this->item['meta']['file']['width'] = $sqlRowArray['pic_file_width']; $this->item['meta']['file']['height'] = $sqlRowArray['pic_file_height']; $this->item['meta']['file']['type'] = $sqlRowArray['pic_file_format']; $this->item['meta']['file']['size'] = $sqlRowArray['pic_file_size']; if (isset($sqlRowArray['views_count'])) { $this->item['meta']['views']['count'] = $sqlRowArray['views_count']; $this->item['meta']['views']['unic'] = $sqlRowArray['views_unic']; } $this->item['system']['url'] = $urlPref.$sqlRowArray['pic_file_name']; $this->item['system']['type'] = 'image'; $this->item['system']['name'] = $sqlRowArray['pic_file_name']; $this->item['system']['parent'] = $parentId; $this->item['system']['id'] = (int)$sqlRowArray['pic_id']; $this->item['system']['order'] = (int)$sqlRowArray['pic_order']; $this->item['system']['date'] = $sqlRowArray['pic_date_add']; $this->item['system']['owner'] = (int)$sqlRowArray['member_id']; if ($parentId) { $db = DI::getDefault()['db']; $row = $db->query('SELECT `pic_file_width`, `pic_file_height`, `pic_file_name`, `pic_file_title` FROM `src_pic_images` WHERE `pic_id`='.$parentId)->fetch(); $this->item['system']['prow'] = [ 'name' => $row['pic_file_name'], 'title' => $row['pic_file_title'], 'width' => (int)$row['pic_file_width'], 'height' => (int)$row['pic_file_height'] ]; } if (sizeof($access) == 5) $this->item['access'] = $access; else if ($access == 'self') $this->item['access'] = $this->getAccess('image'); } public function configAsStack($sqlRowArray, $access = [], $urlPref = '/') { $title = $sqlRowArray['stack_title'] ? $sqlRowArray['stack_title'] : "Альбом ID: ".$sqlRowArray['stack_id']; $this->item['flags']['isStack'] = 1; $this->item['flags']['isContent'] = $sqlRowArray['stack_in_content'] ? 1 : 0; $this->item['meta']['title'] = $title; $this->item['meta']['numbs']['stacks'] = !$sqlRowArray['stack_stacks'] ? '' : (int)$sqlRowArray['stack_stacks']; $this->item['meta']['numbs']['images'] = !$sqlRowArray['stack_images'] ? '' : (int)$sqlRowArray['stack_images']; $this->item['system']['url'] = $urlPref.$sqlRowArray['stack_url']; $this->item['system']['type'] = 'album'; $this->item['system']['name'] = $sqlRowArray['stack_url']; $this->item['system']['id'] = $sqlRowArray['stack_id']; $this->item['system']['order'] = $sqlRowArray['stack_order']; $this->item['system']['date'] = $sqlRowArray['stack_date_add']; $this->item['system']['owner'] = (int)$sqlRowArray['member_id']; if(!empty($sqlRowArray['pic_file_name'])) { $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150'; $this->item['thumb']['type'] = $sqlRowArray['pic_file_format']; } if (sizeof($access) == 5) $this->item['access'] = $access; else if ($access == 'self') $this->item['access'] = $this->getAccess('stack'); } private function getAccess($type) { $user = DI::getDefault()['user']; $db = DI::getDefault()['db']; $type = $type == 'image' ? 'image' : 'stack'; $id = $this->item['system']['id']; $memberId = $this->item['system']['owner']; $memberAge = $user->getAge(); $isRoot = $user->isRoot() || $user->hasRight('pic_root_access'); $item = $db->query('SELECT * FROM `src_pic` WHERE `type`=\''.$type.'\' AND `id`='.$id)->fetch(); $accesses = [ 'enabled' => 0, 'age' => 0, 'private' => 0, 'direct' => 0, 'editing' => 0 ]; if ($memberId && ($memberId == $user->getId() || $isRoot)) { // Либо хозяин, либо рут/модератор $accesses['editing'] = 1; if ($item['access_type'] == 'direct') $accesses['direct'] = 1; else if ($item['access_type'] == 'private') $accesses['private'] = 1; $accesses['age'] = (int)$item['access_age']; } else { if ($item['access_type'] == 'direct') { $accesses['enabled'] = 1; $accesses['direct'] = 1; } else if ($item['access_type'] == 'private') { $accesses['enabled'] = 1; $accesses['private'] = 1; } if ($memberAge < $item['access_age']) { $accesses['enabled'] = 1; $accesses['age'] = $item['access_age']; } } return $accesses; } } |
#1 | Core\Model\PicItem->configAsImage /var/www/fullrest-team/data/www/fullrest.net/Core/Model/PicItem.php (93) <?php namespace Core\Model; use Core\Dict\ContentType; use Core\Lib\Pic; use Imagick; use Phalcon\Mvc\Model; use Phalcon\Di\Di; class PicItem extends Model { private $item = [ 'flags' => [ 'isIcon' => 0, 'isImage' => 0, 'isStack' => 0, 'isContent' => 0 ], 'setts' => [], 'thumb' => [ 'name' => '', 'type' => '' ], 'meta' => [ 'title' => '', 'numbs' => ['stacks' => '', 'images' => '', 'variations' => ''], 'url' => '', 'file' => [ 'width' => 0, 'height' => 0, 'type' => '' ] ], 'system' => [ 'type' => '', // image|album 'name' => '', 'id' => 0, // Айди картинки или стэка 'order' => 0 ], 'access' => [ 'enabled' => 0, 'age' => 0, 'private' => 0, 'direct' => 0, 'editing' => 0 ] ]; public static function initById($id, $type, $access = [], $isApp = false) { $db = DI::getDefault()['db']; if($type == 'stack') { $result = $db->query(' SELECT `pis`.*, `pi`.`pic_file_name`, `pi`.`pic_file_format` FROM `src_pic_images_stacks` AS `pis` LEFT JOIN `src_pic_images` AS `pi` ON `pi`.`stack_id`=`pis`.`stack_id` AND `pi`.`pic_is_icon` = 1 WHERE `pis`.`stack_id` = '.$id); return PicItem::initBySqlArray($result->fetch(), $access, $isApp); } else { $result = $db->query( ' SELECT `spi`.*, `svs`.`stat_views` AS `views_count`, `svs`.`stat_unics` AS `views_unic` FROM `src_pic_images` AS `spi`, `stc_view_stat` AS `svs` WHERE `spi`.`pic_id` = '.$id.' AND `svs`.type_id='.ContentType::PIC.' AND `svs`.`content_id`=`spi`.`pic_id` ' ); return PicItem::initBySqlArray($result->fetch(), $access, $isApp); } } public static function initBySqlArray($sqlRowArray, $access = [], $isApp = false) { $item = new PicItem(); if ($isApp) $urlPref = '#pic/'; else $urlPref = '/'; if(!isset($sqlRowArray['stack_order'])) { $item->configAsImage($sqlRowArray, $access, $urlPref); } else { $item->configAsStack($sqlRowArray, $access, $urlPref); } return $item; } public function onConstruct() { $user = DI::getDefault()['user']; $this->item['setts'] = [ 'isDem' => (int)$user->getSetting('pic', 'show_img_dem'), 'isType' => (int)$user->getSetting('pic', 'show_img_type'), 'isStat' => (int)$user->getSetting('pic', 'show_alb_stat') ]; } public function getData() { return $this->item; } public function configAsImage($sqlRowArray, $access = [], $urlPref = '/') { $parentId = (int)$sqlRowArray['parent_id']; $variations = !$sqlRowArray['pic_variations'] ? '' : (int)$sqlRowArray['pic_variations']; $this->item['flags']['isImage'] = 1; $this->item['flags']['isIcon'] = (int)$sqlRowArray['pic_is_icon']; $this->item['flags']['isContent'] = $sqlRowArray['pic_in_content'] ? 1 : 0; $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150'; $this->item['thumb']['type'] = $sqlRowArray['pic_file_format']; $this->item['meta']['title'] = $sqlRowArray['pic_file_title']; $this->item['meta']['descr'] = $sqlRowArray['pic_description']; $this->item['meta']['numbs']['variations'] = (int)$variations; $this->item['meta']['file']['width'] = $sqlRowArray['pic_file_width']; $this->item['meta']['file']['height'] = $sqlRowArray['pic_file_height']; $this->item['meta']['file']['type'] = $sqlRowArray['pic_file_format']; $this->item['meta']['file']['size'] = $sqlRowArray['pic_file_size']; if (isset($sqlRowArray['views_count'])) { $this->item['meta']['views']['count'] = $sqlRowArray['views_count']; $this->item['meta']['views']['unic'] = $sqlRowArray['views_unic']; } $this->item['system']['url'] = $urlPref.$sqlRowArray['pic_file_name']; $this->item['system']['type'] = 'image'; $this->item['system']['name'] = $sqlRowArray['pic_file_name']; $this->item['system']['parent'] = $parentId; $this->item['system']['id'] = (int)$sqlRowArray['pic_id']; $this->item['system']['order'] = (int)$sqlRowArray['pic_order']; $this->item['system']['date'] = $sqlRowArray['pic_date_add']; $this->item['system']['owner'] = (int)$sqlRowArray['member_id']; if ($parentId) { $db = DI::getDefault()['db']; $row = $db->query('SELECT `pic_file_width`, `pic_file_height`, `pic_file_name`, `pic_file_title` FROM `src_pic_images` WHERE `pic_id`='.$parentId)->fetch(); $this->item['system']['prow'] = [ 'name' => $row['pic_file_name'], 'title' => $row['pic_file_title'], 'width' => (int)$row['pic_file_width'], 'height' => (int)$row['pic_file_height'] ]; } if (sizeof($access) == 5) $this->item['access'] = $access; else if ($access == 'self') $this->item['access'] = $this->getAccess('image'); } public function configAsStack($sqlRowArray, $access = [], $urlPref = '/') { $title = $sqlRowArray['stack_title'] ? $sqlRowArray['stack_title'] : "Альбом ID: ".$sqlRowArray['stack_id']; $this->item['flags']['isStack'] = 1; $this->item['flags']['isContent'] = $sqlRowArray['stack_in_content'] ? 1 : 0; $this->item['meta']['title'] = $title; $this->item['meta']['numbs']['stacks'] = !$sqlRowArray['stack_stacks'] ? '' : (int)$sqlRowArray['stack_stacks']; $this->item['meta']['numbs']['images'] = !$sqlRowArray['stack_images'] ? '' : (int)$sqlRowArray['stack_images']; $this->item['system']['url'] = $urlPref.$sqlRowArray['stack_url']; $this->item['system']['type'] = 'album'; $this->item['system']['name'] = $sqlRowArray['stack_url']; $this->item['system']['id'] = $sqlRowArray['stack_id']; $this->item['system']['order'] = $sqlRowArray['stack_order']; $this->item['system']['date'] = $sqlRowArray['stack_date_add']; $this->item['system']['owner'] = (int)$sqlRowArray['member_id']; if(!empty($sqlRowArray['pic_file_name'])) { $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150'; $this->item['thumb']['type'] = $sqlRowArray['pic_file_format']; } if (sizeof($access) == 5) $this->item['access'] = $access; else if ($access == 'self') $this->item['access'] = $this->getAccess('stack'); } private function getAccess($type) { $user = DI::getDefault()['user']; $db = DI::getDefault()['db']; $type = $type == 'image' ? 'image' : 'stack'; $id = $this->item['system']['id']; $memberId = $this->item['system']['owner']; $memberAge = $user->getAge(); $isRoot = $user->isRoot() || $user->hasRight('pic_root_access'); $item = $db->query('SELECT * FROM `src_pic` WHERE `type`=\''.$type.'\' AND `id`='.$id)->fetch(); $accesses = [ 'enabled' => 0, 'age' => 0, 'private' => 0, 'direct' => 0, 'editing' => 0 ]; if ($memberId && ($memberId == $user->getId() || $isRoot)) { // Либо хозяин, либо рут/модератор $accesses['editing'] = 1; if ($item['access_type'] == 'direct') $accesses['direct'] = 1; else if ($item['access_type'] == 'private') $accesses['private'] = 1; $accesses['age'] = (int)$item['access_age']; } else { if ($item['access_type'] == 'direct') { $accesses['enabled'] = 1; $accesses['direct'] = 1; } else if ($item['access_type'] == 'private') { $accesses['enabled'] = 1; $accesses['private'] = 1; } if ($memberAge < $item['access_age']) { $accesses['enabled'] = 1; $accesses['age'] = $item['access_age']; } } return $accesses; } } |
#2 | Core\Model\PicItem::initBySqlArray /var/www/fullrest-team/data/www/fullrest.net/Core/Model/PicItem.php (78) <?php namespace Core\Model; use Core\Dict\ContentType; use Core\Lib\Pic; use Imagick; use Phalcon\Mvc\Model; use Phalcon\Di\Di; class PicItem extends Model { private $item = [ 'flags' => [ 'isIcon' => 0, 'isImage' => 0, 'isStack' => 0, 'isContent' => 0 ], 'setts' => [], 'thumb' => [ 'name' => '', 'type' => '' ], 'meta' => [ 'title' => '', 'numbs' => ['stacks' => '', 'images' => '', 'variations' => ''], 'url' => '', 'file' => [ 'width' => 0, 'height' => 0, 'type' => '' ] ], 'system' => [ 'type' => '', // image|album 'name' => '', 'id' => 0, // Айди картинки или стэка 'order' => 0 ], 'access' => [ 'enabled' => 0, 'age' => 0, 'private' => 0, 'direct' => 0, 'editing' => 0 ] ]; public static function initById($id, $type, $access = [], $isApp = false) { $db = DI::getDefault()['db']; if($type == 'stack') { $result = $db->query(' SELECT `pis`.*, `pi`.`pic_file_name`, `pi`.`pic_file_format` FROM `src_pic_images_stacks` AS `pis` LEFT JOIN `src_pic_images` AS `pi` ON `pi`.`stack_id`=`pis`.`stack_id` AND `pi`.`pic_is_icon` = 1 WHERE `pis`.`stack_id` = '.$id); return PicItem::initBySqlArray($result->fetch(), $access, $isApp); } else { $result = $db->query( ' SELECT `spi`.*, `svs`.`stat_views` AS `views_count`, `svs`.`stat_unics` AS `views_unic` FROM `src_pic_images` AS `spi`, `stc_view_stat` AS `svs` WHERE `spi`.`pic_id` = '.$id.' AND `svs`.type_id='.ContentType::PIC.' AND `svs`.`content_id`=`spi`.`pic_id` ' ); return PicItem::initBySqlArray($result->fetch(), $access, $isApp); } } public static function initBySqlArray($sqlRowArray, $access = [], $isApp = false) { $item = new PicItem(); if ($isApp) $urlPref = '#pic/'; else $urlPref = '/'; if(!isset($sqlRowArray['stack_order'])) { $item->configAsImage($sqlRowArray, $access, $urlPref); } else { $item->configAsStack($sqlRowArray, $access, $urlPref); } return $item; } public function onConstruct() { $user = DI::getDefault()['user']; $this->item['setts'] = [ 'isDem' => (int)$user->getSetting('pic', 'show_img_dem'), 'isType' => (int)$user->getSetting('pic', 'show_img_type'), 'isStat' => (int)$user->getSetting('pic', 'show_alb_stat') ]; } public function getData() { return $this->item; } public function configAsImage($sqlRowArray, $access = [], $urlPref = '/') { $parentId = (int)$sqlRowArray['parent_id']; $variations = !$sqlRowArray['pic_variations'] ? '' : (int)$sqlRowArray['pic_variations']; $this->item['flags']['isImage'] = 1; $this->item['flags']['isIcon'] = (int)$sqlRowArray['pic_is_icon']; $this->item['flags']['isContent'] = $sqlRowArray['pic_in_content'] ? 1 : 0; $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150'; $this->item['thumb']['type'] = $sqlRowArray['pic_file_format']; $this->item['meta']['title'] = $sqlRowArray['pic_file_title']; $this->item['meta']['descr'] = $sqlRowArray['pic_description']; $this->item['meta']['numbs']['variations'] = (int)$variations; $this->item['meta']['file']['width'] = $sqlRowArray['pic_file_width']; $this->item['meta']['file']['height'] = $sqlRowArray['pic_file_height']; $this->item['meta']['file']['type'] = $sqlRowArray['pic_file_format']; $this->item['meta']['file']['size'] = $sqlRowArray['pic_file_size']; if (isset($sqlRowArray['views_count'])) { $this->item['meta']['views']['count'] = $sqlRowArray['views_count']; $this->item['meta']['views']['unic'] = $sqlRowArray['views_unic']; } $this->item['system']['url'] = $urlPref.$sqlRowArray['pic_file_name']; $this->item['system']['type'] = 'image'; $this->item['system']['name'] = $sqlRowArray['pic_file_name']; $this->item['system']['parent'] = $parentId; $this->item['system']['id'] = (int)$sqlRowArray['pic_id']; $this->item['system']['order'] = (int)$sqlRowArray['pic_order']; $this->item['system']['date'] = $sqlRowArray['pic_date_add']; $this->item['system']['owner'] = (int)$sqlRowArray['member_id']; if ($parentId) { $db = DI::getDefault()['db']; $row = $db->query('SELECT `pic_file_width`, `pic_file_height`, `pic_file_name`, `pic_file_title` FROM `src_pic_images` WHERE `pic_id`='.$parentId)->fetch(); $this->item['system']['prow'] = [ 'name' => $row['pic_file_name'], 'title' => $row['pic_file_title'], 'width' => (int)$row['pic_file_width'], 'height' => (int)$row['pic_file_height'] ]; } if (sizeof($access) == 5) $this->item['access'] = $access; else if ($access == 'self') $this->item['access'] = $this->getAccess('image'); } public function configAsStack($sqlRowArray, $access = [], $urlPref = '/') { $title = $sqlRowArray['stack_title'] ? $sqlRowArray['stack_title'] : "Альбом ID: ".$sqlRowArray['stack_id']; $this->item['flags']['isStack'] = 1; $this->item['flags']['isContent'] = $sqlRowArray['stack_in_content'] ? 1 : 0; $this->item['meta']['title'] = $title; $this->item['meta']['numbs']['stacks'] = !$sqlRowArray['stack_stacks'] ? '' : (int)$sqlRowArray['stack_stacks']; $this->item['meta']['numbs']['images'] = !$sqlRowArray['stack_images'] ? '' : (int)$sqlRowArray['stack_images']; $this->item['system']['url'] = $urlPref.$sqlRowArray['stack_url']; $this->item['system']['type'] = 'album'; $this->item['system']['name'] = $sqlRowArray['stack_url']; $this->item['system']['id'] = $sqlRowArray['stack_id']; $this->item['system']['order'] = $sqlRowArray['stack_order']; $this->item['system']['date'] = $sqlRowArray['stack_date_add']; $this->item['system']['owner'] = (int)$sqlRowArray['member_id']; if(!empty($sqlRowArray['pic_file_name'])) { $this->item['thumb']['name'] = $sqlRowArray['pic_file_name'].'_150x150'; $this->item['thumb']['type'] = $sqlRowArray['pic_file_format']; } if (sizeof($access) == 5) $this->item['access'] = $access; else if ($access == 'self') $this->item['access'] = $this->getAccess('stack'); } private function getAccess($type) { $user = DI::getDefault()['user']; $db = DI::getDefault()['db']; $type = $type == 'image' ? 'image' : 'stack'; $id = $this->item['system']['id']; $memberId = $this->item['system']['owner']; $memberAge = $user->getAge(); $isRoot = $user->isRoot() || $user->hasRight('pic_root_access'); $item = $db->query('SELECT * FROM `src_pic` WHERE `type`=\''.$type.'\' AND `id`='.$id)->fetch(); $accesses = [ 'enabled' => 0, 'age' => 0, 'private' => 0, 'direct' => 0, 'editing' => 0 ]; if ($memberId && ($memberId == $user->getId() || $isRoot)) { // Либо хозяин, либо рут/модератор $accesses['editing'] = 1; if ($item['access_type'] == 'direct') $accesses['direct'] = 1; else if ($item['access_type'] == 'private') $accesses['private'] = 1; $accesses['age'] = (int)$item['access_age']; } else { if ($item['access_type'] == 'direct') { $accesses['enabled'] = 1; $accesses['direct'] = 1; } else if ($item['access_type'] == 'private') { $accesses['enabled'] = 1; $accesses['private'] = 1; } if ($memberAge < $item['access_age']) { $accesses['enabled'] = 1; $accesses['age'] = $item['access_age']; } } return $accesses; } } |
#3 | Core\Model\PicItem::initById /var/www/fullrest-team/data/www/fullrest.net/Core/Modules/Pic/Controller/ImageController.php (405) <? namespace Core\Modules\Pic\Controller; use Core\Dict\PicConf; use Core\Lib\ApiException; use Core\Lib\Hostname; use Core\Lib\ImageEdit; use Core\Lib\JSONResponse; use Core\Lib\TemplateDataFormatter; use Core\Lib\UserHandler; use Core\Model\Image; use Core\Model\PicItem; use Core\Model\Stack; use Core\Model\User; use Phalcon\Mvc\Controller; /** * * * @property \Phalcon\Db\Adapter\Pdo\Mysql db * @property UserHandler user * @property Hostname hostname */ class ImageController extends Controller { private $isApp = true; public function initialize() { $siteId = $this->hostname->getSiteId(); if ($siteId == 2) $this->isApp = false; else $this->isApp = true; } public function addAction($stackName) { if (!$this->user->getId()) throw new ApiException('Bad request'); //TODO: проверка на права юзеров $userId = $this->user->getId(); $stackMId = $userId; $stackId = 0; $imageFile = $_FILES['file']; if ($stackName != 'root') { $result = $this->db->query('SELECT * FROM `src_pic_images_stacks` WHERE stack_url = \''.$stackName.'\''); if ($row = $result->fetch()) { $stackMId = $row['member_id']; $stackId = $row['stack_id']; } } // Если не является хозяином альбома, то идет вхуй if ($stackMId != $userId) throw new ApiException('Bad request'); $returned = Image::add($this->user->getId(), $stackMId, $stackId, 0, $imageFile); if ($stackId) { $stack = Stack::intById($stackId); $stack->setDefaultIcon(true); } (new JSONResponse(JSONResponse::SUCCESS))->send(PicItem::initById($returned->pic_id, 'image')->getData()); } public function addFromClipBoardAction($stackId = 0) { //TODO: проверка на права юзеров $stackId = (int)$stackId; $data = $this->request->getPost("image"); list($type, $data) = explode(';', $data); list($type, $data) = explode(',', $data); $data = base64_decode($data); $memberId = $this->user->getid(); file_put_contents(PicConf::REL_PATH.'upl/temp/temporary_clipboard_member_'.$memberId.'.png', $data); $image = Image::add($memberId, $memberId, $stackId, 0, [ 'tmp_name' => PicConf::REL_PATH.'upl/temp/temporary_clipboard_member_'.$memberId.'.png', 'name' => 'Изображение из буфера '.(string)date("Y-m-d H:i:s"), 'exists' => 1 ]); (new JSONResponse(JSONResponse::SUCCESS))->send($image->pic_file_name); } public function addTempClipBoardAction() { //TODO: проверка на права юзеров $data = $this->request->getPost("image"); list($type, $data) = explode(';', $data); list($type, $data) = explode(',', $data); $data = base64_decode($data); $memberId = $this->user->getid(); file_put_contents(PicConf::REL_PATH.'upl/temp/temporary_clipboard_member_'.$memberId.'.png', $data); $image = new \Imagick(); $image->readImage(PicConf::REL_PATH.'upl/temp/temporary_clipboard_member_'.$memberId.'.png'); (new JSONResponse(JSONResponse::SUCCESS))->send([ 'width' => $image->getImageWidth(), 'height' => $image->getImageHeight(), 'type' => 'png' ]); } public function addTempClipBoardCropAction($stackId = 0) { //TODO: проверка на права юзеров $stackId = (int)$stackId; $crop = json_decode($this->request->getPost('crop'), true); $point = json_decode($this->request->getPost('point'), true); $resize = json_decode($this->request->getPost('resize'), true); $memberId = $this->user->getid(); $edit = new ImageEdit(PicConf::REL_PATH.'upl/temp/temporary_clipboard_member_'.$memberId.'.png'); $width = (int)$crop['width']; $height = (int)$crop['height']; $pointX = (int)$point['x']; $pointY = (int)$point['y']; $edit->editResize((int)$resize['width'], (int)$resize['height'])->editCrop($width, $height, $pointX, $pointY); $edit->saveImageToFile(PicConf::REL_PATH.'upl/temp/temporary_clipboard_member_'.$memberId.'.png'); $image = Image::add($memberId, $memberId, $stackId, 0, [ 'tmp_name' => PicConf::REL_PATH.'upl/temp/temporary_clipboard_member_'.$memberId.'.png', 'name' => 'Изображение из буфера '.date("Y-m-d H:i:s"), 'exists' => 1 ]); (new JSONResponse(JSONResponse::SUCCESS))->send($image->pic_file_name); } public function addVariationAction($imageId) { //TODO: проверка на права юзеров $imageId = (int)$imageId; $imageRow = $this->db->query('SELECT * FROM `src_pic_images` WHERE `pic_id` = '.$imageId)->fetch(); $input = json_decode($this->request->getPost('input'), true); $data = $this->request->getPost("image"); list($type, $data) = explode(';', $data); list($type, $data) = explode(',', $data); $data = base64_decode($data); file_put_contents(PicConf::REL_PATH.'upl/temp/temporary_for_save_id'.$imageId.'.'.$imageRow['pic_file_format'], $data); $imagickCheck = new \Imagick(); $imagickCheck->readImage(PicConf::REL_PATH.'upl/temp/temporary_for_save_id'.$imageId.'.'.$imageRow['pic_file_format']); $imagickCheck->setImageFormat($imageRow['pic_file_format']); $imagickCheck->writeImage(); $memberId = $this->user->getid(); $image = Image::add($memberId, $memberId, 0, $imageId, [ 'tmp_name' => PicConf::REL_PATH.'upl/temp/temporary_for_save_id'.$imageId.'.'.$imageRow['pic_file_format'], 'name' => 'Вариация изображения '.$imageId, 'exists' => 1 ], ['pic_mirror_flip' => (int)$imageRow['pic_mirror_flip'], 'pic_mirror_flop' => (int)$imageRow['pic_mirror_flop'], 'preset' => $this->request->getPost('preset') ]); $this->db->query(' INSERT INTO `src_pic_images_editing` SET `pic_id` = :pic_id, `svg_filters` = :filters, `svg_corrections` = :corrections, `original_rotation` = :rotation, `original_flip` = :flip, `original_flop` = :flop', [ 'pic_id' => $image->getId(), 'rotation' => $imageRow['pic_rotated'], 'filters' => json_encode($input['filters']), 'corrections' => json_encode($input['corrections']), 'flip' => (int)$imageRow['pic_mirror_flip'], 'flop' => (int)$imageRow['pic_mirror_flop'] ] ); $this->db->query('UPDATE `src_pic_images` SET `pic_variations`=`pic_variations`+1 WHERE `pic_id` = '.$imageId); (new JSONResponse(JSONResponse::SUCCESS))->send(['name' => $image->getName()]); } public function saveVariationAction($imageId) { //TODO: проверка на права юзеров $imageId = (int)$imageId; $imageRow = $this->db->query('SELECT * FROM `src_pic_images` WHERE `pic_id` = '.$imageId)->fetch(); $input = json_decode($this->request->getPost('input'), true); $crop = $this->request->getPost('crop'); $data = $this->request->getPost("image"); list($type, $data) = explode(';', $data); list($type, $data) = explode(',', $data); $data = base64_decode($data); $node = mb_substr($imageRow['pic_file_name'], 0, 2); file_put_contents(PicConf::REL_PATH.'upl/'.$node.'/'.$imageRow['pic_file_name'].'.'.$imageRow['pic_file_format'], $data); $imagickCheck = new \Imagick(); $imagickCheck->readImage(PicConf::REL_PATH.'upl/'.$node.'/'.$imageRow['pic_file_name'].'.'.$imageRow['pic_file_format']); $imagickCheck->setImageFormat($imageRow['pic_file_format']); $imagickCheck->writeImage(); $image = Image::initById($imageId); $image->preset_id = (int)$this->request->getPost('preset'); $image->save(); $this->db->query(' UPDATE `src_pic_images_editing` SET `crop_data` = :crop_data, `crop_box` = :crop_box, `crop_canvas` = :crop_canvas, `crop_image` = :crop_image, `svg_filters` = :filters, `svg_corrections` = :corrections WHERE `pic_id`='.$imageId, [ 'filters' => json_encode($input['filters']), 'corrections' => json_encode($input['corrections']), 'crop_data' => $crop['crop_data'], 'crop_box' => $crop['crop_box'], 'crop_canvas' => $crop['crop_canvas'], 'crop_image' => $crop['crop_image'] ] ); $this->reassembleAllThumbnails($imageId); (new JSONResponse(JSONResponse::SUCCESS))->send(); } public function getVariationOriginalAction($variationId, $parentId, $dimensions = "") { $variationId = (int)$variationId; $parentId = (int)$parentId; $varRow = $this->db->query( 'SELECT `original_rotation`,`original_flip`, `original_flop` FROM `src_pic_images_editing` WHERE `pic_id` = '.$variationId)->fetch(); $rotating = $varRow['original_rotation']; $varImgRow = $this->db->query('SELECT * FROM `src_pic_images` WHERE `pic_id` = '.$variationId)->fetch(); $imgRow = $this->db->query('SELECT * FROM `src_pic_images` WHERE `pic_id` = '.$parentId)->fetch(); $node = mb_substr($imgRow['pic_file_name'], 0, 2); $fileName = PicConf::REL_PATH.'upl/'.$node.'/'.$imgRow['pic_file_name'].'.'.$imgRow['pic_file_format']; $image = new \Imagick(); $image->readImage($fileName); $image->setImageCompressionQuality(100); $image->rotateImage(new \ImagickPixel('none'), -(int)$imgRow['pic_rotated']); $image->rotateImage(new \ImagickPixel('none'), $rotating); $image->rotateImage(new \ImagickPixel('none'), (int)$varImgRow['pic_rotated']); if ((int)$varRow['original_flip']) { $image->flipImage(); } if ((int)$varRow['original_flop']) { $image->flopImage(); } if ((int)$varImgRow['pic_mirror_flip']) { $image->flipImage(); } if ((int)$varImgRow['pic_mirror_flop']) { $image->flopImage(); } if ($dimensions !== '') { $expl = explode('x', $dimensions); $edit = new ImageEdit("", $image); $edit->createThumbnail($expl[0], $expl[1], true); $image = $edit->getImage(); } header("Content-Type: image/".$imgRow['pic_file_format']); echo $image; } public function getVariationMetaAction($imageId) { $imageId = (int)$imageId; $row = $this->db->query('SELECT * FROM `src_pic_images_editing` WHERE `pic_id`='.$imageId)->fetch(); if (!$row) (new JSONResponse(JSONResponse::SUCCESS))->send(['status' => 'fail']); (new JSONResponse(JSONResponse::SUCCESS))->send(['status' => 'success', 'settings' => $row]); } public function setTitleAction($imageId) { //TODO: проверка на права юзеров $image = Image::initById($imageId); $image->setTitle($this->request->getPost('title')); $image->save(); (new JSONResponse(JSONResponse::SUCCESS))->send(); } public function setSettingsAction($imageId) { //TODO: проверка на права юзеров $image = Image::initById($imageId); $image->setAccess($this->request->getPost('access')); $image->setAge($this->request->getPost('age')); $image->setTitle($this->request->getPost('title')); $image->setDescription($this->request->getPost('description')); $image->save(); } public function createTempCanvasAction($imageId) { //TODO: проверка на права юзеров $imageId = (int)$imageId; $data = $this->request->getPost("image"); list($type, $data) = explode(';', $data); list(, $data) = explode(',', $data); $data = base64_decode($data); file_put_contents(PicConf::REL_PATH.'upl/temp/temporary_id'.$imageId.'.png', $data); (new JSONResponse(JSONResponse::SUCCESS))->send(['state' => 'ready']); } public function getPageDataAction($name) { (new JSONResponse(JSONResponse::SUCCESS))->send($this->getPageData($name)); } public function getPageData($name) { $db = $this->db; $picRow = $db->query(' SELECT * FROM `src_pic_images` AS `spi`, `src_pic` AS `sp` WHERE `spi`.`pic_file_name` = \''.$name.'\' AND `sp`.`type`=\'image\' AND (`sp`.`id`=`spi`.`pic_id` OR `sp`.`id`=`spi`.`parent_id`) AND `sp`.`deleted` = 0 ')->fetch(); if (!$picRow) { return ['restricted' => ['code' => 'missing', 'data' => '']]; } $image = PicItem::initById($picRow['pic_id'], 'image', 'self', $this->isApp)->getData(); if (!$image['access']['editing'] && $image['access']['enabled']) { if ($image['access']['private']) { return ['restricted' => ['code' => 'private', 'data' => '']]; } else if ($image['access']['age']) { return ['restricted' => ['code' => 'age', 'data' => $image['access']['age']]]; } } if ($picRow['stack_id']) $stack = PicItem::initById($picRow['stack_id'], 'stack', 'self', $this->isApp)->getData(); else $stack = 'root'; $owner = User::findFirstById($picRow['member_id']); $idForStrict = $picRow['pic_id']; if ($picRow['parent_id']) { $idForStrict = $picRow['parent_id']; } $stricts = $db->query(' SELECT `dat`.`access_title` AS `access_title`, `dat`.`access_description` AS `access_description`, `daa`.* FROM `src_pic` AS `sp`, `dict_access_types` AS `dat`, `dict_access_ages` AS `daa` WHERE `sp`.`id`='.$idForStrict.' AND `sp`.`type`=\'image\' AND `dat`.`access_name` = `sp`.`access_type` AND `daa`.`age_num`=`sp`.`access_age`' )->fetch(); if ($picRow['stack_id'] || ($stack == 'root' && $picRow['member_id'] == $this->user->getId())) { $sqlPart = $stack == 'root' ? ' AND `sp`.`member_id`='.$this->user->getId().' ' : ''; $prev = $db->query(' SELECT `spi`.`pic_file_name` FROM `src_pic` AS `sp`, `src_pic_images` AS `spi` WHERE `sp`.`stack_id`='.$picRow['stack_id'].$sqlPart.' AND `sp`.`sort` > '.$picRow['sort'].' AND `sp`.`type`=\'image\' AND `sp`.`deleted`=0 AND `sp`.`id`=`spi`.`pic_id` ORDER BY `sp`.`sort` ASC LIMIT 0, 1 ')->fetch(); $next = $db->query(' SELECT `spi`.`pic_file_name` FROM `src_pic` AS `sp`, `src_pic_images` AS `spi` WHERE `sp`.`stack_id`='.$picRow['stack_id'].$sqlPart.' AND `sp`.`sort` < '.$picRow['sort'].' AND `sp`.`type`=\'image\' AND `sp`.`deleted`=0 AND `sp`.`id`=`spi`.`pic_id` ORDER BY `sp`.`sort` DESC LIMIT 0, 1 ')->fetch(); $prev = $prev ? $prev['pic_file_name'] : ''; $next = $next ? $next['pic_file_name'] : ''; $up = $stack == 'root' ? 'root' : $stack['system']['name']; } else { $prev = ''; $next = ''; $up = 'root'; } $unixDate = date('U'); $return = [ 'image' => $image, 'stack' => $stack, 'member' => TemplateDataFormatter::dataAvatar( $owner->member_id, $owner->member_gender, $owner->member_nick_original, $owner->member_avatar_type, $owner->member_avatar_num, $owner->member_date_activity_unix, $owner->member_play_game_date, $owner->member_play_game_title, 48 ), 'restrict' => [ 'access' => [ 'title' => $stricts['access_title'], 'text' => $stricts['access_description'] ], 'age' => [ 'num' => $stricts['age_num'], 'title' => $stricts['age_description'] ] ], 'description' => nl2br($picRow['pic_description']), 'page' => [ 'prev' => $prev, 'next' => $next, 'up' => $up ] ]; return $return; } public function getImageThumbsAction($imageId) { $imageId = (int)$imageId; $image = $this->db->query('SELECT * FROM`src_pic_images` As `spi` WHERE `spi`.`pic_id`='.$imageId)->fetch(); $itemsList = []; $res = $this->db->query('SELECT * FROM `src_pic_images_thumbs` WHERE `pic_id`='.$imageId.' ORDER BY `thumb_width` ASC, `thumb_height` ASC'); while($row = $res->fetch()) { $itemsList[] = [ 'href' => '/upl/t/'.$image['pic_file_name'].'_'.$row['thumb_width'].'x'.$row['thumb_height'].'.'.$image['pic_file_format'], 'title' => 'Миниатюра: '.$row['thumb_width'].'×'.$row['thumb_height'], 'name' => $image['pic_file_name'], 'type' => $image['pic_file_format'], 'width' => $row['thumb_width'], 'height' => $row['thumb_height'], 'target' => '_blank', 'thumb' => [ 'width' => $row['thumb_width'], 'height' => $row['thumb_height'] ] ]; } (new JSONResponse(JSONResponse::SUCCESS))->send($itemsList); } public function getImageVariationsAction($imageId) { $imageId = (int)$imageId; if (!$imageId) die('blea'); $image = Image::initById($imageId); $isOwner = $this->user->checkRightOwner('pic_root_access', $image->member_id); $res = $this->db->query(' SELECT * FROM `src_pic_images` As `spi` WHERE `spi`.`parent_id`='.$imageId.' ORDER BY `spi`.`pic_id` ASC' ); $itemsList = []; $itemsList[] = [ 'href' => (!$this->isApp ? '' : '#pic').'/'.$image->pic_file_name, 'title' => $image->pic_file_title, 'name' => $image->pic_file_name, 'type' => $image->pic_file_format, 'width' => $image->pic_file_width, 'height' => $image->pic_file_height, 'text' => 'Оригинал', 'thumb' => [ 'width' => '150', 'height' => '150' ] ]; while($row = $res->fetch()) { $itemsList[] = [ 'href' => (!$this->isApp ? '' : '#pic').'/'.$row['pic_file_name'], 'title' => $row['pic_file_title'], 'name' => $row['pic_file_name'], 'type' => $row['pic_file_format'], 'width' => $row['pic_file_width'], 'height' => $row['pic_file_height'], 'item_type' => 'variation', 'deletable' => $isOwner ? 1 : 0, 'thumb' => [ 'width' => '150', 'height' => '150' ] ]; } (new JSONResponse(JSONResponse::SUCCESS))->send($itemsList); } public function getImageSiblingsAction($stackId, $imageId = 0) { $stackId = (int)$stackId; if (!$stackId) die('blea'); $res = $this->db->query(' SELECT * FROM `src_pic` AS `sp`, `src_pic_images` As `spi` WHERE `sp`.`stack_id`='.$stackId.' and `sp`.`type`=\'image\' and `sp`.`deleted`=0 AND `spi`.`pic_id`=`sp`.`id` ORDER BY `sp`.`sort` DESC' ); $itemsList = []; while($row = $res->fetch()) { $itemsList[] = [ 'href' => (!$this->isApp ? '' : '#pic') . '/'.$row['pic_file_name'], 'title' => $row['pic_file_title'], 'name' => $row['pic_file_name'], 'type' => $row['pic_file_format'], 'width' => $row['pic_file_width'], 'height' => $row['pic_file_height'], 'item_type' => 'image', 'thumb' => [ 'width' => '150', 'height' => '150' ] ]; } (new JSONResponse(JSONResponse::SUCCESS))->send($itemsList); } public function editAction($imageId) { //TODO: проверка на права юзеров $image = Image::initById($imageId); $editor = new ImageEdit(PicConf::REL_PATH.'upl/'.$image->getName().'.'.$image->getType()); header("Content-Type: image/".$image->getType()); echo $editor->getImage(); } public function createThumbnailAction($id, $mode) { //TODO: проверка на права юзеров $image = Image::initById((int)$id); $mode = $mode == 'simple' ? 'simple' : 'complex'; $crop = json_decode($this->request->getPost('crop'), true); $point = json_decode($this->request->getPost('point'), true); $resize = json_decode($this->request->getPost('resize'), true); $cropWidth = (int)$crop['width']; $cropHeight = (int)$crop['height']; if ($mode === 'simple') { $image->createThumbnail($cropWidth, $cropHeight, 'default', true); } else if ($mode === 'complex') { $image->createThumbnailComplex($crop, $point, $resize); } (new JSONResponse(JSONResponse::SUCCESS))->send('done'); } private $nginxThumbsAllowed = [ '48x48' => true, '150x150' => true, ]; public function nginxThumbnailAction($filename, $width, $height, $mode = '') { if ($mode != 'skipAllPreChecks') { } $image = Image::initByName(explode('.',$filename)[0]); $node = mb_substr($image->getName(), 0, 2); $thumbName = PicConf::REL_PATH.'upl/'.$node.'/t/'.$image->getName().'_'.$width.'x'.$height.'.'.$image->getType(); $image->createThumbnail($width, $height, 'noAdapt', true); header("Content-Type: image/".$image->getType()); readfile($thumbName); } public function transformMirroringAction($imageId, $type) { //TODO: проверка на права юзеров $imageId = (int)$imageId; $type = $type == 'horizontal' ? 'x' : 'y'; $image = Image::initById($imageId); $edit = $image->getImageEdit(); $edit->editRotateMirror($type); $edit->saveImage(); if ($type == 'x') { $image->pic_mirror_flop = (int)$image->pic_mirror_flop ? 0 : 1; } else { $image->pic_mirror_flip = (int)$image->pic_mirror_flip ? 0 : 1; } $image->pic_signature = $edit->getImage()->getImageSignature(); $image->save(); $this->reassembleAllThumbnails($imageId); (new JSONResponse(JSONResponse::SUCCESS))->send('done'); } public function transformRotationAction($imageId, $type) { //TODO: проверка на права юзеров $imageId = (int)$imageId; $degree = $type == 'left' ? -90 : 90; $image = Image::initById($imageId); $edit = $image->getImageEdit(); $edit->editRotateDegree($degree); $edit->saveImage(); $image->pic_rotated = (int)$image->pic_rotated + $degree; $image->pic_file_width = $edit->getImage()->getImageWidth(); $image->pic_file_height = $edit->getImage()->getImageHeight(); $image->pic_signature = $edit->getImage()->getImageSignature(); $image->save(); $this->reassembleAllThumbnails($imageId); (new JSONResponse(JSONResponse::SUCCESS))->send('done'); } public function deleteThumbByNameAction($imageName, $width, $height) { //TODO: проверка на права юзеров $image = $this->db->query('SELECT * FROM `src_pic_images` WHERE `pic_file_name`=\''.$imageName.'\''); $row = $image->fetch(); if($row) { if($row['pic_in_content']) { (new JSONResponse(JSONResponse::ERROR))->send(); } $node = mb_substr($imageName, 0, 2); unlink(PicConf::REL_PATH.'upl/'.$node.'/t/'.$imageName.'_'.$width.'x'.$height.'.'.$row['pic_file_format']); $this->db->query( 'DELETE FROM `src_pic_images_thumbs` WHERE `pic_id`='.$row['pic_id'].' AND `thumb_width`='.$width.' AND `thumb_height`='.$height ); (new JSONResponse(JSONResponse::SUCCESS))->send(2); } else { (new JSONResponse(JSONResponse::ERROR))->send(1); } } public function deleteVariationAction($imageName) { $image = Image::initByName($imageName); $isOwner = $this->user->checkRightOwner('pic_root_access', $image->member_id); if (!$isOwner || !$image->parent_id) { (new JSONResponse(JSONResponse::ERROR))->send(1); } $node = mb_substr($imageName, 0, 2); $thumbs = $this->db->query('SELECT * FROM `src_pic_images_thumbs` WHERE `pic_id`='.$image->pic_id); while($row = $thumbs->fetch()) { @unlink(PicConf::REL_PATH.'upl/'.$node.'/t/'.$imageName.'_'.$row['thumb_width'].'x'.$row['thumb_height'].'.'.$image->pic_file_format); } $this->db->query('DELETE FROM `src_pic_images_thumbs` WHERE `pic_id`='.$image->pic_id); @unlink(PicConf::REL_PATH.'upl/'.$node.'/'.$imageName.'.'.$image->pic_file_format); $this->db->query('DELETE FROM `src_pic_images` WHERE `pic_file_name`=\''.$imageName.'\''); //TODO: разобраться с этой хуйней - не удаляется чот $image->delete(); (new JSONResponse(JSONResponse::SUCCESS))->send(2); } private function reassembleAllThumbnails($imageId) { $thumbs = $this->db->query('SELECT * FROM `src_pic_images_thumbs` WHERE `pic_id`='.$imageId); while($row = $thumbs->fetch()) { $image = Image::initById($imageId); if ($row['thumb_settings'] == '') { $image->createThumbnail($row['thumb_width'], $row['thumb_height'], 'default', true); } else { $cropData = json_decode($row['thumb_settings'], true); $image->createThumbnailComplex($cropData['crop'], $cropData['point'], $cropData['resize']); } } } } |
#4 | Core\Modules\Pic\Controller\ImageController->getPageData /var/www/fullrest-team/data/www/fullrest.net/Site/Pic/Controller/PicController.php (115) <?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; } } |
#5 | Site\Pic\Controller\PicController->imageAction |
#6 | Phalcon\Dispatcher\AbstractDispatcher->callActionMethod |
#7 | Phalcon\Dispatcher\AbstractDispatcher->dispatch |
#8 | Phalcon\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>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()}"; } |
Key | Value |
---|---|
_url | /O0H4owcw |
Key | Value |
---|---|
REDIRECT_REDIRECT_HTTPS | on |
REDIRECT_REDIRECT_STATUS | 200 |
REDIRECT_HTTPS | on |
REDIRECT_STATUS | 200 |
HTTPS | on |
HTTP_HOST | pic.fullrest.ru |
HTTP_X_FORWARDED_PROTO | https |
HTTP_X_FORWARDED_PORT | 443 |
HTTP_CONNECTION | close |
HTTP_ACCEPT | */* |
HTTP_USER_AGENT | Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) |
HTTP_ACCEPT_ENCODING | gzip, br, zstd, deflate |
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_SOFTWARE | Apache/2.4.62 (Debian) |
SERVER_NAME | pic.fullrest.ru |
SERVER_ADDR | 127.0.0.1 |
SERVER_PORT | 80 |
REMOTE_ADDR | 216.73.216.75 |
DOCUMENT_ROOT | /var/www/fullrest-team/data/www/fullrest.net |
REQUEST_SCHEME | http |
CONTEXT_PREFIX | |
CONTEXT_DOCUMENT_ROOT | /var/www/fullrest-team/data/www/fullrest.net |
SERVER_ADMIN | webmaster@fullrest.net |
SCRIPT_FILENAME | /var/www/fullrest-team/data/www/fullrest.net/public/index.php |
REMOTE_PORT | 34420 |
REDIRECT_URL | /public/O0H4owcw |
REDIRECT_QUERY_STRING | _url=/O0H4owcw |
GATEWAY_INTERFACE | CGI/1.1 |
SERVER_PROTOCOL | HTTP/1.0 |
REQUEST_METHOD | GET |
QUERY_STRING | _url=/O0H4owcw |
REQUEST_URI | /O0H4owcw |
SCRIPT_NAME | /public/index.php |
PHP_SELF | /public/index.php |
REQUEST_TIME_FLOAT | 1751322185.9773 |
REQUEST_TIME | 1751322185 |
# | 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/Core/Model/PicItem.php |
58 | /var/www/fullrest-team/data/www/fullrest.net/Core/Dict/ContentType.php |
59 | /var/www/fullrest-team/data/www/fullrest.net/Core/Lib/UserHandler.php |
Memory | |
---|---|
Usage | 2097152 |