some fixes

This commit is contained in:
themohooks 2024-10-10 18:38:14 +03:00
parent beaf493cb6
commit 12de4999a9
3 changed files with 14 additions and 4 deletions

View file

@ -14,7 +14,6 @@ class Compress {
$height = $info[1]; $height = $info[1];
$aspect_ratio = $width / $height; $aspect_ratio = $width / $height;
// Вычисляем новые размеры, сохраняя соотношение сторон
if ($width > $height) { if ($width > $height) {
$new_width = $max_width; $new_width = $max_width;
$new_height = $max_width / $aspect_ratio; $new_height = $max_width / $aspect_ratio;
@ -64,10 +63,22 @@ class Compress {
$quality = 40; $quality = 40;
$max_width = 400; $max_width = 400;
$max_height = 400; $max_height = 400;
if (!file_exists($_SERVER['DOCUMENT_ROOT'].'/cdn/imgcache')) { if (!file_exists($_SERVER['DOCUMENT_ROOT'].'/cdn/imgcache')) {
mkdir($_SERVER['DOCUMENT_ROOT'].'/cdn/imgcache', 0777, true); mkdir($_SERVER['DOCUMENT_ROOT'].'/cdn/imgcache', 0777, true);
} }
$parsed_url = parse_url($source_url);
if (!isset($parsed_url['scheme'])) {
$local_file_path = $_SERVER['DOCUMENT_ROOT'] . '/' . ltrim($source_url, '/');
if (file_exists($local_file_path)) {
$source_url = $local_file_path;
} else {
header("HTTP/1.0 404 Not Found");
exit;
}
}
$cache_filename = self::generateCacheFilename($source_url, $quality, $max_width, $max_height); $cache_filename = self::generateCacheFilename($source_url, $quality, $max_width, $max_height);
if (file_exists($cache_filename)) { if (file_exists($cache_filename)) {
@ -78,7 +89,7 @@ class Compress {
if ($compressed_image_data) { if ($compressed_image_data) {
file_put_contents($cache_filename, $compressed_image_data); file_put_contents($cache_filename, $compressed_image_data);
} else { } else {
$imageData = file_get_contents($_GET['url']); $imageData = file_get_contents($source_url);
$finfo = new \finfo(FILEINFO_MIME_TYPE); $finfo = new \finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->buffer($imageData); $mimeType = $finfo->buffer($imageData);

View file

@ -46,7 +46,6 @@ class Upload
if (filesize($_SERVER['DOCUMENT_ROOT'].'/'.$location.$filecdn) >= 94371840) { if (filesize($_SERVER['DOCUMENT_ROOT'].'/'.$location.$filecdn) >= 94371840) {
mkdir("{$_SERVER['DOCUMENT_ROOT']}/uploads/{$location}", 0777, true); mkdir("{$_SERVER['DOCUMENT_ROOT']}/uploads/{$location}", 0777, true);
move_uploaded_file ($tmpname, "{$_SERVER['DOCUMENT_ROOT']}/uploads/{$folder}"); move_uploaded_file ($tmpname, "{$_SERVER['DOCUMENT_ROOT']}/uploads/{$folder}");
$this->type = $type; $this->type = $type;
$this->src = "/uploads/{$folder}"; $this->src = "/uploads/{$folder}";
$this->size = self::human_filesize(filesize($tmpname)); $this->size = self::human_filesize(filesize($tmpname));

View file

@ -9,7 +9,7 @@ function createModal(id, type, value, modalid) {
<textarea style=" width: 100%; <textarea style=" width: 100%;
height: 200px;" name="wtext" id="bodypost__commedit`+id+`">`+value+`</textarea><br> height: 200px;" name="wtext" id="bodypost__commedit`+id+`">`+value+`</textarea><br>
<div class="cmt-submit"> <div class="cmt-submit">
<button type="submit" onclick="editComment('` + id + `', document.getElementById('bodypost__commedit` + id + `').value, , '`+modalid+`')" id="sbmt">Отредактировать</button>&ensp;&emsp;Ctrl + Enter <button type="submit" onclick="editComment('` + id + `', document.getElementById('bodypost__commedit` + id + `').value, '`+modalid+`')" id="sbmt">Отредактировать</button>&ensp;&emsp;Ctrl + Enter
</div> </div>
</div> </div>
</div> </div>