mirror of
https://github.com/avecms/AVE.cms.git
synced 2025-10-09 05:00:21 +00:00
Last fixes
This commit is contained in:
.htaccess
admin
lang
templates
class
fields
functions
inc
index.phpinstall
lib/redactor
codemirror
elfinder
css
img
edit_aceeditor.pngedit_ckeditor.pngedit_codemirror.pngedit_creativecloud.pngedit_pixlreditor.pngedit_pixlrexpress.pngedit_simplemde.pngedit_tinymce.pngtitleBg.pngtoolbar.pngvolume_icon_trash.png
js
elfinder.full.jselfinder.min.js
extras
i18n
elfinder.LANG.jselfinder.cs.jselfinder.id.jselfinder.jp.jselfinder.pl.jselfinder.ru.jselfinder.sk.js
help
proxy
php
.tmp
MySQLStorage.sqlautoload.phpconnector.minimal.php-distconnector.phpconnector.php-distconnector_template.phpelFinder.class.phpelFinderConnector.class.phpelFinderFlysystemGoogleDriveNetmount.phpelFinderPlugin.phpelFinderSession.phpelFinderSessionInterface.phpelFinderVolumeBox.class.phpelFinderVolumeDriver.class.phpelFinderVolumeDropbox.class.phpelFinderVolumeDropbox2.class.phpelFinderVolumeFTP.class.phpelFinderVolumeGoogleDrive.class.phpelFinderVolumeGroup.class.phpelFinderVolumeLocalFileSystem.class.phpelFinderVolumeMySQL.class.phpelFinderVolumeOneDrive.class.phpelFinderVolumeTrash.class.phplibs
mime.typesplugins
AutoResize
AutoRotate
Normalizer
Sanitizer
Watermark
resources
modules
187
inc/thumb.php
187
inc/thumb.php
@@ -27,14 +27,14 @@
|
||||
$retval .= chr($length >> 8) . chr($length & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
$retval .= chr(0x80) .
|
||||
chr(0x04) .
|
||||
chr(($length >> 24) & 0xFF) .
|
||||
chr(($length >> 16) & 0xFF) .
|
||||
chr(($length >> 8) & 0xFF) .
|
||||
chr($length & 0xFF);
|
||||
}
|
||||
{
|
||||
$retval .= chr(0x80) .
|
||||
chr(0x04) .
|
||||
chr(($length >> 24) & 0xFF) .
|
||||
chr(($length >> 16) & 0xFF) .
|
||||
chr(($length >> 8) & 0xFF) .
|
||||
chr($length & 0xFF);
|
||||
}
|
||||
|
||||
return $retval . $value;
|
||||
}
|
||||
@@ -68,39 +68,66 @@
|
||||
return is_dir($path) || (mkdir(dirname($path), $mode) && _mkdir($path, $mode));
|
||||
}
|
||||
|
||||
require(dirname(__FILE__).'/config.php');
|
||||
//-- Подгружаем настройки системы
|
||||
require(dirname(__FILE__) . '/config.php');
|
||||
|
||||
//-- Разрешенные расширения файлов
|
||||
$allowedExt = array('jpg', 'jpeg', 'png', 'gif', 'JPG', 'JPEG', 'PNG', 'GIF');
|
||||
|
||||
//-- Разрешенные размеры миниатюр
|
||||
$allowedSize = THUMBNAIL_SIZES
|
||||
? explode(',', trim(THUMBNAIL_SIZES))
|
||||
: array();
|
||||
|
||||
//-- Разрешения для админпанели
|
||||
$allowedAdmin = array(
|
||||
't128x128',
|
||||
'f128x128',
|
||||
);
|
||||
|
||||
//-- Ссылка на файл
|
||||
$imagefile = urldecode($_SERVER['REQUEST_URI']);
|
||||
|
||||
if(! empty($_REQUEST['thumb']))
|
||||
//-- Вызов чере $_GET параметры
|
||||
//-- ToDo
|
||||
if (! empty($_REQUEST['thumb']))
|
||||
{
|
||||
$imagefile = '/'.
|
||||
rtrim(
|
||||
dirname($_REQUEST['thumb'])
|
||||
.'/'.THUMBNAIL_DIR.'/'
|
||||
.(str_replace(
|
||||
. '/' . THUMBNAIL_DIR . '/'
|
||||
. (str_replace(
|
||||
'.',
|
||||
(empty($_REQUEST['mode']) ? '-c' : '-'.$_REQUEST['mode']).((empty($_REQUEST['width'])&& empty($_REQUEST['height'])) ? '128' : intval(@$_REQUEST['width'])).'x'.((empty($_REQUEST['width'])&& empty($_REQUEST['height'])) ? '128' : intval(@$_REQUEST['height'])).'.',
|
||||
(empty($_REQUEST['mode'])
|
||||
? '-t'
|
||||
: '-' . $_REQUEST['mode']) . ((empty($_REQUEST['width']) && empty($_REQUEST['height']))
|
||||
? '128'
|
||||
: intval(@$_REQUEST['width'])) . 'x' . ((empty($_REQUEST['width']) && empty($_REQUEST['height']))
|
||||
? '128'
|
||||
: intval(@$_REQUEST['height'])) . '.',
|
||||
basename($_REQUEST['thumb'])
|
||||
)
|
||||
),
|
||||
'/');
|
||||
}
|
||||
|
||||
if($_SERVER['REQUEST_URI'] == '/inc/thumb.php')
|
||||
//-- Если пришел прямой вызов файла, то сразу отрубаем его
|
||||
if ($_SERVER['REQUEST_URI'] == '/inc/thumb.php')
|
||||
die('No image');
|
||||
|
||||
$baseDir = str_replace("\\", "/", dirname(dirname(__FILE__)));
|
||||
//-- Базовая папка
|
||||
$baseDir = str_replace('\\', '/', dirname(dirname(__FILE__)));
|
||||
|
||||
if(file_exists($baseDir . $imagefile))
|
||||
//-- Если файл существует, показываем его
|
||||
if (file_exists($baseDir . $imagefile))
|
||||
{
|
||||
$img_data = @getimagesize($baseDir . $imagefile);
|
||||
|
||||
header('Content-Type:' . $img_data['mime'], true);
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s".filemtime($baseDir . $imagefile))." GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s" . filemtime($baseDir . $imagefile)) . " GMT");
|
||||
header("Content-Length: " . (string) filesize($baseDir . $imagefile), true);
|
||||
readfile($baseDir . $imagefile);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -122,23 +149,40 @@
|
||||
exit(0);
|
||||
|
||||
$matches = array();
|
||||
preg_match('/-(r|c|f|t)(\d+)x(\d+)(r)*$/i', $nameParts[$countParts-2], $matches);
|
||||
|
||||
//-- Смотрим переданные параметры
|
||||
preg_match('/-(r|c|f|t|s)(\d+)x(\d+)(r)*$/i', $nameParts[$countParts-2], $matches);
|
||||
|
||||
if (!isset($matches[0]))
|
||||
//-- Если нет параметров, отдаем 404
|
||||
if (! isset($matches[0]))
|
||||
{
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$check = ltrim($matches[0], '-');
|
||||
|
||||
//-- Проверяем разрешен ли данный размер для миниатюры
|
||||
if (! empty($allowedSize) && ! in_array($check, $allowedSize))
|
||||
{
|
||||
if (! in_array($check, $allowedAdmin))
|
||||
{
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
//-- Если есть параметр rotate
|
||||
if (isset($matches[4]))
|
||||
{
|
||||
list($size, $method, $width, $height, $rotate) = $matches;
|
||||
list ($size, $method, $width, $height, $rotate) = $matches;
|
||||
}
|
||||
//-- Иначе
|
||||
else
|
||||
{
|
||||
list($size, $method, $width, $height) = $matches;
|
||||
$rotate = false;
|
||||
}
|
||||
{
|
||||
list ($size, $method, $width, $height) = $matches;
|
||||
$rotate = false;
|
||||
}
|
||||
|
||||
$nameParts[$countParts-2] = substr($nameParts[$countParts-2], 0, -strlen($size));
|
||||
$imageName = implode('.', $nameParts);
|
||||
@@ -149,27 +193,30 @@
|
||||
{
|
||||
$l= "$imagePath/$imageName";
|
||||
|
||||
if(file_exists($l.'.tmp'))
|
||||
if (file_exists($l . '.tmp'))
|
||||
{
|
||||
include_once(BASE_DIR.'/functions/func.common.php');
|
||||
|
||||
$abs_path = dirname((!strstr($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) && (@php_sapi_name() == 'cgi')) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
|
||||
$abs_path = dirname((!strstr($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) && (@php_sapi_name() == 'cgi'))
|
||||
? $_SERVER['PHP_SELF']
|
||||
: $_SERVER['SCRIPT_NAME']);
|
||||
|
||||
define('ABS_PATH', rtrim(str_replace("\\", "/", $abs_path), '/') . '/');
|
||||
|
||||
$url = trim(file_get_contents($l.'.tmp'),ABS_PATH);
|
||||
$url = trim(file_get_contents($l . '.tmp'), ABS_PATH);
|
||||
|
||||
$img=CURL_file_get_contents($url);
|
||||
$img = CURL_file_get_contents($url);
|
||||
|
||||
if($img)
|
||||
if ($img)
|
||||
{
|
||||
file_put_contents("$imagePath/$imageName",$img);
|
||||
|
||||
setEXIFF("$imagePath/$imageName");
|
||||
|
||||
$save = true;
|
||||
}
|
||||
|
||||
@unlink($l.'.tmp');
|
||||
@unlink($l . '.tmp');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -177,12 +224,16 @@
|
||||
if (! file_exists("$imagePath/$imageName"))
|
||||
{
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
|
||||
|
||||
$imageName = 'noimage.gif';
|
||||
|
||||
if (!file_exists("$imagePath/$imageName"))
|
||||
{
|
||||
$imagePath = $baseDir . '/' . UPLOAD_DIR . '/images';
|
||||
}
|
||||
if (!file_exists("$imagePath/$imageName")) exit(0);
|
||||
|
||||
if (!file_exists("$imagePath/$imageName"))
|
||||
exit(0);
|
||||
|
||||
$save = false;
|
||||
}
|
||||
@@ -191,6 +242,7 @@
|
||||
|
||||
$thumb = new Image_Toolbox("$imagePath/$imageName");
|
||||
|
||||
//-- Методы генерации миниатюр
|
||||
switch ($method)
|
||||
{
|
||||
case 'r':
|
||||
@@ -204,9 +256,14 @@
|
||||
case 'f':
|
||||
$thumb->newOutputSize((int)$width, (int)$height, 2, false, '#ffffff');
|
||||
break;
|
||||
|
||||
case 't':
|
||||
$thumb->newOutputSize((int)$width, (int)$height, 3, false);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
$thumb->newOutputSize((int)$width, (int)$height, 4, (boolean)$rotate);
|
||||
break;
|
||||
}
|
||||
|
||||
//Blend
|
||||
@@ -222,48 +279,58 @@
|
||||
|
||||
$thumb->output();
|
||||
|
||||
//-- Если можно сохранять миниатюру
|
||||
if ($save)
|
||||
{
|
||||
if (!file_exists($thumbPath) && !mkdir($thumbPath, 0777)) exit(0);
|
||||
if (! file_exists($thumbPath) && ! mkdir($thumbPath, 0777))
|
||||
exit(0);
|
||||
|
||||
if ($thumb->save("$thumbPath/$thumbName"))
|
||||
{
|
||||
$old = umask(0);
|
||||
chmod("$thumbPath/$thumbName", 0777);
|
||||
umask($old);
|
||||
}
|
||||
if($thumb->_img['main']['type']==2){
|
||||
|
||||
if ($thumb->_img['main']['type']==2)
|
||||
{
|
||||
$image = getimagesize("$thumbPath/$thumbName", $info);
|
||||
if(!isset($info['APP13']))
|
||||
|
||||
if (! isset($info['APP13']))
|
||||
{
|
||||
if(!isset($AVE_DB)){
|
||||
@require(BASE_DIR . '/class/class.database.php');
|
||||
$sitename=@$AVE_DB->Query("SELECT site_name FROM " . PREFIX . "_settings LIMIT 1")->GetCell();
|
||||
}
|
||||
|
||||
// установка IPTC тэгов
|
||||
$iptc = array(
|
||||
'2#120' => iconv("UTF-8","WINDOWS-1251",$sitename),
|
||||
'2#116' => "http://".$_SERVER['SERVER_NAME']
|
||||
);
|
||||
|
||||
// Преобразование IPTC тэгов в двоичный код
|
||||
$data = '';
|
||||
|
||||
foreach($iptc as $tag => $string)
|
||||
//-- Если в настройках разрешена генерация IPTC тегов для миниатюр
|
||||
if (THUMBNAIL_IPTC)
|
||||
{
|
||||
$tag = substr($tag, 2);
|
||||
$data .= iptc_make_tag(2, $tag, $string);
|
||||
if (! isset($AVE_DB))
|
||||
{
|
||||
@require(BASE_DIR . '/class/class.database.php');
|
||||
$sitename= @$AVE_DB->Query("SELECT site_name FROM " . PREFIX . "_settings LIMIT 1")->GetCell();
|
||||
}
|
||||
|
||||
// установка IPTC тэгов
|
||||
$iptc = array(
|
||||
'2#120' => iconv("UTF-8", "WINDOWS-1251", $sitename),
|
||||
'2#116' => "http://" . $_SERVER['SERVER_NAME']
|
||||
);
|
||||
|
||||
// Преобразование IPTC тэгов в двоичный код
|
||||
$data = '';
|
||||
|
||||
foreach($iptc as $tag => $string)
|
||||
{
|
||||
$tag = substr($tag, 2);
|
||||
$data .= iptc_make_tag(2, $tag, $string);
|
||||
}
|
||||
|
||||
// Встраивание IPTC данных
|
||||
$content = iptcembed($data, "$thumbPath/$thumbName");
|
||||
|
||||
// запись нового изображения в файл
|
||||
$fp = fopen("$thumbPath/$thumbName", "wb");
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// Встраивание IPTC данных
|
||||
$content = iptcembed($data, "$thumbPath/$thumbName");
|
||||
|
||||
// запись нового изображения в файл
|
||||
$fp = fopen("$thumbPath/$thumbName", "wb");
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user