Менеджер изображений Opencart2.0 несовместим с некоторыми серверамиPhp

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Менеджер изображений Opencart2.0 несовместим с некоторыми серверами

Сообщение Anonymous »

ЕСЛИ НЕ РАБОТАЕТ, ИЗМЕНИТЕ КОД СЛЕДУЮЩИМ:
Admin /controller/common/filemanager.php

или измените код в строке нет GLOBAL_BRACE
ПОСТОЯННО эта константа не работает с некоторыми серверами.
class ControllerCommonFileManager extends Controller {
public function index() {
$this->load->language('common/filemanager');

if (isset($this->request->get['filter_name'])) {
$filter_name = rtrim(str_replace(array('../', '..\\', '..', '*'), '', $this->request->get['filter_name']), '/');
} else {
$filter_name = null;
}

// Make sure we have the correct directory
if (isset($this->request->get['directory'])) {
$directory = rtrim(DIR_IMAGE . 'catalog/' . str_replace(array('../', '..\\', '..'), '', $this->request->get['directory']), '/');
} else {
$directory = DIR_IMAGE . 'catalog';
}

if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}

$data['images'] = array();

$this->load->model('tool/image');

// Get directories
$directories = glob($directory . '/' . $filter_name . '*', GLOB_ONLYDIR);

if (!$directories) {
$directories = array();
}

// Get files
$files1 = glob($directory . '/' . $filter_name . '*.jpg');
if (!$files1) {
$files1 = array();
}

$files2 = glob($directory . '/' . $filter_name . '*.jpeg');
if (!$files2) {
$files2 = array();
}

$files3 = glob($directory . '/' . $filter_name . '*.JPG');
if (!$files3) {
$files3 = array();
}

$files4 = glob($directory . '/' . $filter_name . '*.png');
if (!$files4) {
$files4 = array();
}

$files5 = glob($directory . '/' . $filter_name . '*.JPEG');
if (!$files5) {
$files5 = array();
}

$files6 = glob($directory . '/' . $filter_name . '*.PNG');
if (!$files6) {
$files6 = array();
}

$files7 = glob($directory . '/' . $filter_name . '*.GIF');
if (!$files7) {
$files7 = array();
}

$files8 = glob($directory . '/' . $filter_name . '*.gif');
if (!$files8) {
$files8 = array();
}

$files = array_merge($files1, $files2, $files3, $files4, $files5, $files6, $files7, $files8);

// Merge directories and files
$images = array_merge($directories, $files);

// Get total number of files and directories
$image_total = count($images);

// Split the array based on current page number and max number of items per page of 10
$images = array_splice($images, ($page - 1) * 16, 16);

foreach ($images as $image) {
$name = str_split(basename($image), 14);

if (is_dir($image)) {
$url = '';

if (isset($this->request->get['target'])) {
$url .= '&target=' . $this->request->get['target'];
}

if (isset($this->request->get['thumb'])) {
$url .= '&thumb=' . $this->request->get['thumb'];
}

$data['images'][] = array(
'thumb' => '',
'name' => implode(' ', $name),
'type' => 'directory',
'path' => utf8_substr($image, utf8_strlen(DIR_IMAGE)),
'href' => $this->url->link('common/filemanager', 'token=' . $this->session->data['token'] . '&directory=' . urlencode(utf8_substr($image, utf8_strlen(DIR_IMAGE . 'catalog/'))) . $url, true)
);
} elseif (is_file($image)) {
// Find which protocol to use to pass the full image link back
if ($this->request->server['HTTPS']) {
$server = HTTPS_CATALOG;
} else {
$server = HTTP_CATALOG;
}

$data['images'][] = array(
'thumb' => $this->model_tool_image->resize(utf8_substr($image, utf8_strlen(DIR_IMAGE)), 100, 100),
'name' => implode(' ', $name),
'type' => 'image',
'path' => utf8_substr($image, utf8_strlen(DIR_IMAGE)),
'href' => $server . 'image/' . utf8_substr($image, utf8_strlen(DIR_IMAGE))
);
}
}

$data['heading_title'] = $this->language->get('heading_title');

$data['text_no_results'] = $this->language->get('text_no_results');
$data['text_confirm'] = $this->language->get('text_confirm');

$data['entry_search'] = $this->language->get('entry_search');
$data['entry_folder'] = $this->language->get('entry_folder');

$data['button_parent'] = $this->language->get('button_parent');
$data['button_refresh'] = $this->language->get('button_refresh');
$data['button_upload'] = $this->language->get('button_upload');
$data['button_folder'] = $this->language->get('button_folder');
$data['button_delete'] = $this->language->get('button_delete');
$data['button_search'] = $this->language->get('button_search');

$data['token'] = $this->session->data['token'];

if (isset($this->request->get['directory'])) {
$data['directory'] = urlencode($this->request->get['directory']);
} else {
$data['directory'] = '';
}

if (isset($this->request->get['filter_name'])) {
$data['filter_name'] = $this->request->get['filter_name'];
} else {
$data['filter_name'] = '';
}

// Return the target ID for the file manager to set the value
if (isset($this->request->get['target'])) {
$data['target'] = $this->request->get['target'];
} else {
$data['target'] = '';
}

// Return the thumbnail for the file manager to show a thumbnail
if (isset($this->request->get['thumb'])) {
$data['thumb'] = $this->request->get['thumb'];
} else {
$data['thumb'] = '';
}

// Parent
$url = '';

if (isset($this->request->get['directory'])) {
$pos = strrpos($this->request->get['directory'], '/');

if ($pos) {
$url .= '&directory=' . urlencode(substr($this->request->get['directory'], 0, $pos));
}
}

if (isset($this->request->get['target'])) {
$url .= '&target=' . $this->request->get['target'];
}

if (isset($this->request->get['thumb'])) {
$url .= '&thumb=' . $this->request->get['thumb'];
}

$data['parent'] = $this->url->link('common/filemanager', 'token=' . $this->session->data['token'] . $url, true);

// Refresh
$url = '';

if (isset($this->request->get['directory'])) {
$url .= '&directory=' . urlencode($this->request->get['directory']);
}

if (isset($this->request->get['target'])) {
$url .= '&target=' . $this->request->get['target'];
}

if (isset($this->request->get['thumb'])) {
$url .= '&thumb=' . $this->request->get['thumb'];
}

$data['refresh'] = $this->url->link('common/filemanager', 'token=' . $this->session->data['token'] . $url, true);

$url = '';

if (isset($this->request->get['directory'])) {
$url .= '&directory=' . urlencode(html_entity_decode($this->request->get['directory'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
}

if (isset($this->request->get['target'])) {
$url .= '&target=' . $this->request->get['target'];
}

if (isset($this->request->get['thumb'])) {
$url .= '&thumb=' . $this->request->get['thumb'];
}

$pagination = new Pagination();
$pagination->total = $image_total;
$pagination->page = $page;
$pagination->limit = 16;
$pagination->url = $this->url->link('common/filemanager', 'token=' . $this->session->data['token'] . $url . '&page={page}', true);

$data['pagination'] = $pagination->render();

$this->response->setOutput($this->load->view('common/filemanager', $data));
}

public function upload() {
$this->load->language('common/filemanager');

$json = array();

// Check user has permission
if (!$this->user->hasPermission('modify', 'common/filemanager')) {
$json['error'] = $this->language->get('error_permission');
}

if (isset($this->request->get['directory'])) {
$directory = rtrim(DIR_IMAGE . 'catalog/' . str_replace(array('../', '..\\', '..'), '', $this->request->get['directory']), '/');
} else {
$directory = DIR_IMAGE . 'catalog';
}

// Check its a directory
if (!is_dir($directory)) {
$json['error'] = $this->language->get('error_directory');
}

if (!$json) {
if (!empty($this->request->files['file']['name']) && is_file($this->request->files['file']['tmp_name'])) {
// Sanitize the filename
$filename = basename(html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8'));

// Validate the filename length
if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 255)) {
$json['error'] = $this->language->get('error_filename');
}

// Allowed file extension types
$allowed = array(
'jpg',
'jpeg',
'png',
'gif'
);

if (!in_array(utf8_strtolower(utf8_substr(strrchr($filename, '.'), 1)), $allowed)) {
$json['error'] = $this->language->get('error_filetype');
}

// Allowed file mime types
$allowed = array(
'image/jpeg',
'image/pjpeg',
'image/png',
'image/x-png',
'image/gif'
);

if (!in_array($this->request->files['file']['type'], $allowed)) {
$json['error'] = $this->language->get('error_filetype');
}

// Check to see if any PHP files are trying to be uploaded
$content = file_get_contents($this->request->files['file']['tmp_name']);

if (preg_match('/\

Подробнее здесь: https://stackoverflow.com/questions/369 ... me-servers
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Медиа-менеджер не отображает файловый менеджер в меню администратора
    Anonymous » » в форуме Php
    0 Ответы
    39 Просмотры
    Последнее сообщение Anonymous
  • Выпуск xcode с несколькими серверами
    Anonymous » » в форуме IOS
    0 Ответы
    50 Просмотры
    Последнее сообщение Anonymous
  • ASP.NET Core API 6.0 — невозможно обновить базу данных при использовании отложенной загрузки ядра EF с прокси-серверами.
    Anonymous » » в форуме C#
    0 Ответы
    488 Просмотры
    Последнее сообщение Anonymous
  • Невозможно сделать запрос API между двумя серверами
    Anonymous » » в форуме Apache
    0 Ответы
    52 Просмотры
    Последнее сообщение Anonymous
  • Один и тот же пакет Python для использования с двумя серверами в одном проекте.
    Anonymous » » в форуме Python
    0 Ответы
    61 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Php»