From d3d5d1c385d245ae7023f5eadffe0619760e07cf Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 14 Sep 2023 10:42:35 +0200 Subject: [PATCH] =?UTF-8?q?Upgraded=20to=20php8.2=20=F0=9F=8E=89?= =?UTF-8?q?=F0=9F=8E=89=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 ++---- .../placeholder/placeholdergenerator.php | 6 +- docker/Dockerfile | 56 +++++++++---------- docker/rootfs/start.sh | 13 +++-- inc/core.php | 2 +- 5 files changed, 46 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 6960f09..3e48c90 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@
-![](https://img.shields.io/badge/php-7.1%2B-brightgreen.svg) +![](https://img.shields.io/badge/php-8.2%2B-brightgreen.svg) [![](https://img.shields.io/docker/pulls/hascheksolutions/pictshare?color=brightgreen)](https://hub.docker.com/r/hascheksolutions/pictshare) -[![](https://img.shields.io/docker/cloud/build/hascheksolutions/pictshare?color=brightgreen)](https://hub.docker.com/r/hascheksolutions/pictshare/builds) +![](https://github.com/hascheksolutions/pictshare/actions/workflows/build-docker.yml/badge.svg)] [![Apache License](https://img.shields.io/badge/license-Apache-brightgreen.svg?style=flat)](https://github.com/HaschekSolutions/pictshare/blob/master/LICENSE) -![HitCount](https://visitor-badge.glitch.me/badge?page_id=pictshare) +[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fhascheksolutions%2Fpictshare&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com) [![](https://img.shields.io/github/stars/HaschekSolutions/pictshare.svg?label=Stars&style=social)](https://github.com/HaschekSolutions/pictshare) #### Host your own `images` `gifs` `mp4s` `text bins` and stay in control @@ -29,10 +29,6 @@ PictShare demo

-# [INFO] March '23 -Since Docker Hub won't allow team Organizations anymore, we moved our images to GitHub Container Registry. -So if you want to use the latest version, please use the new image `ghcr.io/hascheksolutions/pictshare` instead of `hascheksolutions/pictshare` - Table of contents ================= * [Quick Start](#quickstart) @@ -62,7 +58,7 @@ Then open http://localhost:8080 in your browser - [Encryption of files in external storage](/rtfm/ENCRYPTION.md) - Added text hosting (like pastebin) - Added URL shortening -- Added WebP to images (and conversion from jpg,png to webp) +- Added WebP to images (and automatic conversion from jpg, png to webp if the requesting browser supports it) - Massive code rework. Actually we designed it from the ground up to be more modular and easier to debug # Features @@ -70,13 +66,13 @@ Then open http://localhost:8080 in your browser - Selfhostable - [Simple upload API](/rtfm/API.md) - 100% file based - no database needed -- [Scalable](/rtfm/SCALING.md) +- [Scalable hosting](/rtfm/SCALING.md) - Many [Filters](/rtfm/IMAGEFILTERS.md) for images - GIF to MP4 conversion - JPG, PNG to WEBP conversion - MP4 resizing - PictShare removes all exif data so you can upload photos from your phone and all GPS tags and camera model info get wiped -- Change and resize your uploads just by editing the URL +- Change and resize your images and videos just by editing the URL - Duplicates don't take up space. If the exact same file is uploaded twice, the second upload will link to the first - Many [configuration options](/rtfm/CONFIG.md) - Full control over your data. Delete images with individual and global delete codes diff --git a/content-controllers/placeholder/placeholdergenerator.php b/content-controllers/placeholder/placeholdergenerator.php index 1701ad0..8bc87d7 100644 --- a/content-controllers/placeholder/placeholdergenerator.php +++ b/content-controllers/placeholder/placeholdergenerator.php @@ -38,8 +38,8 @@ class PlaceholderGenerator { if($textwidth > imagesx($im) || $textheight > imagesy($im)) return $im; - $x = (imagesx($im) - $textwidth) / 2; - $y = (imagesy($im) - $textheight) / 2 + $textheight; + $x = intval((imagesx($im) - $textwidth) / 2); + $y = intval((imagesy($im) - $textheight) / 2 + $textheight); imagettftext($im, $fontsize, 0, $x, $y, $textcolor, $font, $text); return $im; @@ -63,7 +63,7 @@ class PlaceholderGenerator { for($x=0;$x<=$w;$x++) { // loop columns for($y=0;$y<=$h;$y++) { // loop rows // set pixel color - $col=imagecolorallocate($im,$rgb[0],$rgb[1],$rgb[2]); + $col=imagecolorallocate($im,intval($rgb[0]),intval($rgb[1]),intval($rgb[2])); imagesetpixel($im,$x-1,$y-1,$col); // calculate new color for($i=0;$i<=2;$i++) { diff --git a/docker/Dockerfile b/docker/Dockerfile index c15823d..23712a7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,9 +1,8 @@ -FROM alpine:3.14.2 +FROM alpine:3.18 -RUN apk add --no-cache bash socat wget curl nginx file ffmpeg unzip \ - php7-fileinfo \ - php7-session \ - zlib \ +RUN apk add --no-cache bash socat wget curl nginx file ffmpeg unzip zlib \ + php82-fileinfo \ + php82-session \ php \ php-curl \ php-openssl \ @@ -12,26 +11,27 @@ RUN apk add --no-cache bash socat wget curl nginx file ffmpeg unzip \ php-gd \ php-dom \ php-fpm \ - php7 \ - php7-pdo \ - php7-exif \ - php7-mcrypt \ - php7-curl \ - php7-gd \ - php7-json \ - php7-phar \ - php7-fpm \ - php7-openssl \ - php7-ctype \ - php7-opcache \ - php7-mbstring \ - php7-sodium \ - php7-xml \ - php7-ftp \ - php7-simplexml \ - php7-session \ - php7-fileinfo \ - php7-pcntl + php82 \ + php82-pdo \ + php82-exif \ + php82-curl \ + php82-gd \ + php82-json \ + php82-phar \ + php82-fpm \ + php82-openssl \ + php82-ctype \ + php82-opcache \ + php82-mbstring \ + php82-sodium \ + php82-xml \ + php82-ftp \ + php82-simplexml \ + php82-session \ + php82-fileinfo \ + php82-pcntl + +RUN ln -s /usr/bin/php82 /usr/bin/php RUN curl -sS https://getcomposer.org/installer | /usr/bin/php -- --install-dir=/usr/bin --filename=composer RUN mkdir -p /var/www @@ -51,11 +51,11 @@ WORKDIR /var/www ADD docker/rootfs/nginx.conf /etc/nginx/http.d/default.conf RUN mkdir -p /run/nginx RUN mkdir -p /var/log/nginx -RUN sed -i 's/nobody/nginx/g' /etc/php7/php-fpm.d/www.conf +RUN sed -i 's/nobody/nginx/g' /etc/php82/php-fpm.d/www.conf # Since requests can trigger conversion, let's give the server enough time to respond -RUN sed -i "/max_execution_time/c\max_execution_time=3600" /etc/php7/php.ini -RUN sed -i "/max_input_time/c\max_input_time=3600" /etc/php7/php.ini +RUN sed -i "/max_execution_time/c\max_execution_time=3600" /etc/php82/php.ini +RUN sed -i "/max_input_time/c\max_input_time=3600" /etc/php82/php.ini WORKDIR /var/www/ diff --git a/docker/rootfs/start.sh b/docker/rootfs/start.sh index a61b619..5dcc4eb 100644 --- a/docker/rootfs/start.sh +++ b/docker/rootfs/start.sh @@ -5,15 +5,18 @@ _maxUploadSize() { echo "[i] Setting uploadsize to ${MAX_UPLOAD_SIZE}M" - sed -i "/post_max_size/c\post_max_size=${MAX_UPLOAD_SIZE}M" /etc/php7/php.ini - sed -i "/upload_max_filesize/c\upload_max_filesize=${MAX_UPLOAD_SIZE}M" /etc/php7/php.ini + sed -i "/post_max_size/c\post_max_size=${MAX_UPLOAD_SIZE}M" /etc/php82/php.ini + sed -i "/upload_max_filesize/c\upload_max_filesize=${MAX_UPLOAD_SIZE}M" /etc/php82/php.ini + + # set error reporting no notices, no warnings + sed -i "/^error_reporting/c\error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING & ~E_NOTICE" /etc/php82/php.ini sed -i -e "s/50M/${MAX_UPLOAD_SIZE}M/g" /etc/nginx/http.d/default.conf MAX_RAM=$((MAX_UPLOAD_SIZE + 30)) # 30megs more than the upload size echo "[i] Also changing memory limit of PHP to ${MAX_RAM}M" - sed -i -e "s/128M/${MAX_RAM}M/g" /etc/php7/php.ini - sed -i "/memory_limit/c\memory_limit=${MAX_RAM}M" /etc/php7/php.ini + sed -i -e "s/128M/${MAX_RAM}M/g" /etc/php82/php.ini + sed -i "/memory_limit/c\memory_limit=${MAX_RAM}M" /etc/php82/php.ini } _filePermissions() { @@ -74,7 +77,7 @@ if [[ ${SKIP_FILEPERMISSIONS:=false} != true ]]; then fi echo ' [+] Starting php' -php-fpm7 +php-fpm82 echo ' [+] Creating config' diff --git a/inc/core.php b/inc/core.php index 5974e10..0e90c51 100644 --- a/inc/core.php +++ b/inc/core.php @@ -4,7 +4,7 @@ spl_autoload_register('autoload'); //disable output buffering if (ob_get_level()) ob_end_clean(); -error_reporting(E_ALL & ~E_NOTICE); +error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); if(!defined('FFMPEG_BINARY')) define('FFMPEG_BINARY',ROOT.DS.'bin'.DS.'ffmpeg');