diff --git a/Dockerfile.php b/Dockerfile.php
index 3ea07b3..c6f028e 100644
--- a/Dockerfile.php
+++ b/Dockerfile.php
@@ -18,7 +18,8 @@
ca-certificates \
lsb-release \
apt-transport-https \
- curl
+ curl \
+ ffmpeg
# setup nodejs repo
RUN set -exu \
diff --git a/README.md b/README.md
index caaff53..f0d9568 100644
--- a/README.md
+++ b/README.md
@@ -3,12 +3,16 @@
See [https://github.com/wetfish/production-manifests](https://github.com/wetfish/production-manifests)
for production deployment and full stack dev env info.
+TODO: doesnt work with rootless docker/podman, need to build and launch as root.
+
For development, to run just this stack, do
```bash
cp mariadb.env.example mariadb.env
# -> edit, change passwords and other info as needed
cp php.env.example php.env
# -> edit, change db info to match mariadb, other passwords as needed
+# for the uploader & gallery features
+chmod 777 ./upload; mkdir ./upload/thumbs; chmod -R 777 ./upload/thumbs
# in dev env, run npm install manually
cd wwwroot/src && npm install
diff --git a/wwwroot/api/v1/api.php b/wwwroot/api/v1/api.php
old mode 100644
new mode 100755
diff --git a/wwwroot/api/v1/endpoints/authorized.php b/wwwroot/api/v1/endpoints/authorized.php
old mode 100644
new mode 100755
diff --git a/wwwroot/api/v1/endpoints/public.php b/wwwroot/api/v1/endpoints/public.php
old mode 100644
new mode 100755
diff --git a/wwwroot/api/v1/index.php b/wwwroot/api/v1/index.php
old mode 100644
new mode 100755
diff --git a/wwwroot/ban.php b/wwwroot/ban.php
old mode 100644
new mode 100755
diff --git a/wwwroot/cssparser.php b/wwwroot/cssparser.php
old mode 100644
new mode 100755
diff --git a/wwwroot/diff/inline_example.php b/wwwroot/diff/inline_example.php
old mode 100644
new mode 100755
diff --git a/wwwroot/diff/inline_function.php b/wwwroot/diff/inline_function.php
old mode 100644
new mode 100755
diff --git a/wwwroot/diff/inline_renderer.php b/wwwroot/diff/inline_renderer.php
old mode 100644
new mode 100755
diff --git a/wwwroot/exif.php b/wwwroot/exif.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fishlib.php b/wwwroot/fishlib.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fun/browse.php b/wwwroot/fun/browse.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fun/edits.php b/wwwroot/fun/edits.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fun/google.php b/wwwroot/fun/google.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fun/include.php b/wwwroot/fun/include.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fun/names.php b/wwwroot/fun/names.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fun/news.php b/wwwroot/fun/news.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fun/paginate.php b/wwwroot/fun/paginate.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fun/simple_html_dom.php b/wwwroot/fun/simple_html_dom.php
old mode 100644
new mode 100755
diff --git a/wwwroot/fun/time.php b/wwwroot/fun/time.php
old mode 100644
new mode 100755
diff --git a/wwwroot/functions.php b/wwwroot/functions.php
old mode 100644
new mode 100755
index a2bb808..9e5cd05
--- a/wwwroot/functions.php
+++ b/wwwroot/functions.php
@@ -131,6 +131,8 @@ function ResizeImage($Filename, $Thumbnail, $Size)
$Extension = $Path['extension'];
$ImageData = @GetImageSize($Filename);
+ if(!$ImageData)
+ return false;
$Width = $ImageData[0];
$Height = $ImageData[1];
@@ -156,8 +158,12 @@ function ResizeImage($Filename, $Thumbnail, $Size)
$Image = @ImageCreateFromGif($Filename);
elseif(preg_match('/^png$/i', $Extension))
$Image = @ImageCreateFromPng($Filename);
- else
+ elseif(preg_match('/^webp$/i', $Extension))
+ $Image = ImageCreateFromWebp($Filename);
+ elseif(preg_match('/^jpe?g$/i', $Extension))
$Image = @ImageCreateFromJpeg($Filename);
+ if(!$Image)
+ return false;
if($ImageData[2] == IMAGETYPE_GIF or $ImageData[2] == IMAGETYPE_PNG)
{
diff --git a/wwwroot/gallery.php b/wwwroot/gallery.php
old mode 100644
new mode 100755
index 7b01794..5f0ca4c
--- a/wwwroot/gallery.php
+++ b/wwwroot/gallery.php
@@ -52,6 +52,13 @@
# the current working directory would be wrong
# and likely to mess up relatave paths!
+ # Icons, placeholders for missing thumbnails
+$SVG_Icon_directory="";
+$SVG_Icon_image="";
+$SVG_Icon_text="";
+$SVG_Icon_video="";
+
+
if(the($Directory) == 'Empty')
$Directory = str_replace($Path, '', getcwd());
@@ -62,9 +69,9 @@
if($Pagination['is'] == 'On')
{
- if(is_numeric($_GET['page']))
- $Page = $_GET['page'];
-
+ $Page = $_GET['page'] ?? 1;
+ if(!is_numeric($Page))
+ $Page = 1;
if($Page < 2)
$Page = 1;
@@ -100,20 +107,37 @@
foreach($Files as $File)
{
- if(the($File) == 'Image')
+ $mimetype = mime_content_type("$Path/$Directory/$File");
+ $thumbnail_loc = "{$Thumbnail['Directory']}/{$Thumbnail['Size']}_{$File}";
+ if(preg_match("/^video/", $mimetype))
+ $thumbnail_loc = substr($thumbnail_loc, 0 , (strrpos($thumbnail_loc, "."))) . ".jpg";
+ if(preg_match("/^(image|video)/", $mimetype))
{
if($Generate == 'Thumbnails')
{
- if(!file_exists("$Path/{$Thumbnail['Directory']}/{$Thumbnail['Size']}_$File"))
- if(!ResizeImage("$Path/$Directory/$File", "$Path/{$Thumbnail['Directory']}/{$Thumbnail['Size']}_$File", $Thumbnail['Size']))
- continue;
+ if(!file_exists("$Path/$thumbnail_loc"))
+ {
+ if (preg_match("/^image/", $mimetype))
+ ResizeImage("$Path/$Directory/$File", "$Path/$thumbnail_loc", $Thumbnail['Size']);
+ elseif (preg_match("/^video/", $mimetype))
+ VideoThumbnail("$Path/$Directory/$File", "$Path/$thumbnail_loc", $Thumbnail['Size']);
+ }
}
-
- echo "
";
+ echo "";
}
}
diff --git a/wwwroot/glitchcity/missingno.php b/wwwroot/glitchcity/missingno.php
old mode 100644
new mode 100755
diff --git a/wwwroot/glitchcity/pokecompare.php b/wwwroot/glitchcity/pokecompare.php
old mode 100644
new mode 100755
diff --git a/wwwroot/glitchcity/poketiles.php b/wwwroot/glitchcity/poketiles.php
old mode 100644
new mode 100755
diff --git a/wwwroot/index.php b/wwwroot/index.php
old mode 100644
new mode 100755
diff --git a/wwwroot/ircdown.php b/wwwroot/ircdown.php
old mode 100644
new mode 100755
diff --git a/wwwroot/load.php b/wwwroot/load.php
old mode 100644
new mode 100755
diff --git a/wwwroot/lol.php b/wwwroot/lol.php
old mode 100644
new mode 100755
diff --git a/wwwroot/navigation.php b/wwwroot/navigation.php
old mode 100644
new mode 100755
diff --git a/wwwroot/notgallery.php b/wwwroot/notgallery.php
old mode 100644
new mode 100755
index c667a38..e60f3e7
--- a/wwwroot/notgallery.php
+++ b/wwwroot/notgallery.php
@@ -1,140 +1,181 @@
-= $Height and $Width > $Size)
- {
- $NewWidth = $Size;
- $NewHeight = ($Size / $Width) * $Height;
- }
- elseif($Height >= $Width and $Height > $Size)
- {
- $NewWidth = ($Size / $Height) * $Width;
- $NewHeight = $Size;
- }
- else
- {
- $NewWidth = $Width;
- $NewHeight = $Height;
- }
-
- $NewImage = @ImageCreateTrueColor($NewWidth, $NewHeight);
-
- $Mime = mime_content_type($Filename);
- switch ($Mime) {
- case "image/gif":
- $Image = @ImageCreateFromGif($Filename);
- break;
- case "image/png":
- $Image = @ImageCreateFromPng($Filename);
- break;
- case "image/jpeg":
- $Image = @ImageCreateFromJpeg($Filename);
- break;
- }
-
- if($ImageData[2] == IMAGETYPE_GIF or $ImageData[2] == IMAGETYPE_PNG)
- {
- $TransIndex = imagecolortransparent($Image);
-
- // If we have a specific transparent color
- if ($TransIndex >= 0)
- {
- // Get the original image's transparent color's RGB values
- $TransColor = imagecolorsforindex($Image, $TransIndex);
-
- // Allocate the same color in the new image resource
- $TransIndex = imagecolorallocate($NewImage, $TransColor['red'], $TransColor['green'], $TransColor['blue']);
-
- // Completely fill the background of the new image with allocated color.
- imagefill($NewImage, 0, 0, $TransIndex);
-
- // Set the background color for new image to transparent
- imagecolortransparent($NewImage, $TransIndex);
-
- }
- // Always make a transparent background color for PNGs that don't have one allocated already
- elseif ($ImageData[2] == IMAGETYPE_PNG)
- {
-
- // Turn off transparency blending (temporarily)
- imagealphablending($NewImage, false);
-
- // Create a new transparent color for image
- $color = imagecolorallocatealpha($NewImage, 0, 0, 0, 127);
-
- // Completely fill the background of the new image with allocated color.
- imagefill($NewImage, 0, 0, $color);
-
- // Restore transparency blending
- imagesavealpha($NewImage, true);
- }
- }
-
- @ImageCopyResampled($NewImage, $Image, 0, 0, 0, 0, $NewWidth, $NewHeight, $Width, $Height);
-
- switch ($Mime) {
- case "image/gif":
- @ImageGif($NewImage, $Thumbnail);
- break;
- case "image/png":
- @ImagePng($NewImage, $Thumbnail);
- break;
- case "image/jpeg":
- @ImageJpeg($NewImage, $Thumbnail);
- break;
- }
-
- @chmod($Thumbnail, 0644);
- return true;
-}
-
-function scandirByDate($dir)
-{
- $ignore = array('.', '..', '.svn', '.htaccess', '.git');
- $files = array();
-
- foreach (scandir($dir) as $file)
- {
- if(in_array($file, $ignore)) continue;
- $files[$file] = filemtime($dir . '/' . $file);
- }
-
- arsort($files);
- $files = array_keys($files);
-
- return ($files) ? $files : false;
-}
-
-?>
+= $Height and $Width > $Size)
+ {
+ $NewWidth = $Size;
+ $NewHeight = ($Size / $Width) * $Height;
+ }
+ elseif($Height >= $Width and $Height > $Size)
+ {
+ $NewWidth = ($Size / $Height) * $Width;
+ $NewHeight = $Size;
+ }
+ else
+ {
+ $NewWidth = $Width;
+ $NewHeight = $Height;
+ }
+
+ $NewImage = @ImageCreateTrueColor($NewWidth, $NewHeight);
+
+ $Mime = mime_content_type($Filename);
+ switch ($Mime) {
+ case "image/gif":
+ $Image = @ImageCreateFromGif($Filename);
+ break;
+ case "image/png":
+ $Image = @ImageCreateFromPng($Filename);
+ break;
+ case "image/jpeg":
+ case "image/jpg":
+ $Image = @ImageCreateFromJpeg($Filename);
+ break;
+ case "image/webp":
+ $WebpData = webpinfo($Filename);
+ if(isset($WebpData['Animation']) && $WebpData['Animation'] === true)
+ $Image = "";
+ else
+ $Image = ImageCreateFromWebp($Filename);
+ break;
+ }
+ if(!$Image)
+ return false;
+
+ if($ImageData[2] == IMAGETYPE_GIF or $ImageData[2] == IMAGETYPE_PNG)
+ {
+ $TransIndex = imagecolortransparent($Image);
+
+ // If we have a specific transparent color
+ if ($TransIndex >= 0)
+ {
+ // Get the original image's transparent color's RGB values
+ $TransColor = imagecolorsforindex($Image, $TransIndex);
+
+ // Allocate the same color in the new image resource
+ $TransIndex = imagecolorallocate($NewImage, $TransColor['red'], $TransColor['green'], $TransColor['blue']);
+
+ // Completely fill the background of the new image with allocated color.
+ imagefill($NewImage, 0, 0, $TransIndex);
+
+ // Set the background color for new image to transparent
+ imagecolortransparent($NewImage, $TransIndex);
+
+ }
+ // Always make a transparent background color for PNGs that don't have one allocated already
+ elseif ($ImageData[2] == IMAGETYPE_PNG)
+ {
+
+ // Turn off transparency blending (temporarily)
+ imagealphablending($NewImage, false);
+
+ // Create a new transparent color for image
+ $color = imagecolorallocatealpha($NewImage, 0, 0, 0, 127);
+
+ // Completely fill the background of the new image with allocated color.
+ imagefill($NewImage, 0, 0, $color);
+
+ // Restore transparency blending
+ imagesavealpha($NewImage, true);
+ }
+ }
+
+ @ImageCopyResampled($NewImage, $Image, 0, 0, 0, 0, $NewWidth, $NewHeight, $Width, $Height);
+
+ switch ($Mime) {
+ case "image/gif":
+ @ImageGif($NewImage, $Thumbnail);
+ break;
+ case "image/png":
+ @ImagePng($NewImage, $Thumbnail);
+ break;
+ case "image/jpeg":
+ case "image/webp":
+ @ImageJpeg($NewImage, $Thumbnail);
+ break;
+ }
+
+ @chmod($Thumbnail, 0644);
+ return true;
+}
+
+function VideoThumbnail($Filename, $Thumbnail, $Size)
+{
+ if(!file_exists("/usr/bin/ffprobe"))
+ return false;
+ $Mime = mime_content_type($Filename);
+ if(!preg_match("/^video/", $Mime))
+ return false;
+ $ffprobe_cmd = '/usr/bin/ffprobe -v quiet -select_streams "v:0" -show_entries "stream=duration" -of "default=nokey=1:noprint_wrappers=1" ' . $Filename;
+ exec($ffprobe_cmd, $exec_stdout, $status);
+ $duration = (int)$exec_stdout;
+ if($duration==0)
+ return false;
+ if(!file_exists("/usr/bin/ffmpeg"))
+ return false;
+ $ffmpeg_cmd = '/usr/bin/ffmpeg -v quiet -ss "' . $duration * 0.25 .
+ '" -i "' . $Filename .
+ '" -vf "scale=' . $Size . ':' . $Size . ':force_original_aspect_ratio=decrease" ' .
+ '-vframes 1 ' .
+ '"' . $Thumbnail . '"';
+ exec($ffmpeg_cmd, $exec_stdout, $status);
+ @chmod($Thumbnail, 0644);
+ return true;
+}
+
+function scandirByDate($dir)
+{
+ $ignore = array('.', '..', '.svn', '.htaccess', '.git');
+ $files = array();
+
+ foreach (scandir($dir) as $file)
+ {
+ if(in_array($file, $ignore)) continue;
+ $files[$file] = filemtime($dir . '/' . $file);
+ }
+
+ arsort($files);
+ $files = array_keys($files);
+
+ return ($files) ? $files : false;
+}
+
+?>
diff --git a/wwwroot/popular.php b/wwwroot/popular.php
old mode 100644
new mode 100755
diff --git a/wwwroot/recaptchalib.php b/wwwroot/recaptchalib.php
old mode 100644
new mode 100755
diff --git a/wwwroot/search.php b/wwwroot/search.php
old mode 100644
new mode 100755
diff --git a/wwwroot/simple_html_dom.php b/wwwroot/simple_html_dom.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/archive.php b/wwwroot/src/actions/archive.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/diff.php b/wwwroot/src/actions/diff.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/history.php b/wwwroot/src/actions/history.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/login.php b/wwwroot/src/actions/login.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/random.php b/wwwroot/src/actions/random.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/recent.php b/wwwroot/src/actions/recent.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/rename.php b/wwwroot/src/actions/rename.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/replace.php b/wwwroot/src/actions/replace.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/source.php b/wwwroot/src/actions/source.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/tag.php b/wwwroot/src/actions/tag.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/actions/view.php b/wwwroot/src/actions/view.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/ban.php b/wwwroot/src/ban.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/benchmark.php b/wwwroot/src/benchmark.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/captcha.php b/wwwroot/src/captcha.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/config.php b/wwwroot/src/config.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/connection.php b/wwwroot/src/connection.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/functions.php b/wwwroot/src/functions.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/libraries/Diff.php b/wwwroot/src/libraries/Diff.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/libraries/Diff/Renderer/Abstract.php b/wwwroot/src/libraries/Diff/Renderer/Abstract.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/libraries/Diff/Renderer/Html/Array.php b/wwwroot/src/libraries/Diff/Renderer/Html/Array.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/libraries/Diff/Renderer/Html/Inline.php b/wwwroot/src/libraries/Diff/Renderer/Html/Inline.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/libraries/Diff/Renderer/Html/SideBySide.php b/wwwroot/src/libraries/Diff/Renderer/Html/SideBySide.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/libraries/Diff/Renderer/Text/Context.php b/wwwroot/src/libraries/Diff/Renderer/Text/Context.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/libraries/Diff/Renderer/Text/Unified.php b/wwwroot/src/libraries/Diff/Renderer/Text/Unified.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/libraries/Diff/SequenceMatcher.php b/wwwroot/src/libraries/Diff/SequenceMatcher.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/libraries/simple_html_dom.php b/wwwroot/src/libraries/simple_html_dom.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/markup/comments.php b/wwwroot/src/markup/comments.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/markup/edit.php b/wwwroot/src/markup/edit.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/markup/embed.php b/wwwroot/src/markup/embed.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/markup/fishformat.php b/wwwroot/src/markup/fishformat.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/markup/parser2.php b/wwwroot/src/markup/parser2.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/markup/view.php b/wwwroot/src/markup/view.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/models/edits.php b/wwwroot/src/models/edits.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/models/model.php b/wwwroot/src/models/model.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/models/page.php b/wwwroot/src/models/page.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/models/tags.php b/wwwroot/src/models/tags.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/mysql.php b/wwwroot/src/mysql.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/pages/lonely.php b/wwwroot/src/pages/lonely.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/pages/tag-cloud.php b/wwwroot/src/pages/tag-cloud.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/pages/tags.php b/wwwroot/src/pages/tags.php
old mode 100644
new mode 100755
diff --git a/wwwroot/src/template.php b/wwwroot/src/template.php
old mode 100644
new mode 100755
diff --git a/wwwroot/stats/edits.php b/wwwroot/stats/edits.php
old mode 100644
new mode 100755
diff --git a/wwwroot/stats/phpgraphlib.php b/wwwroot/stats/phpgraphlib.php
old mode 100644
new mode 100755
diff --git a/wwwroot/stats/searches.php b/wwwroot/stats/searches.php
old mode 100644
new mode 100755
diff --git a/wwwroot/style.php b/wwwroot/style.php
old mode 100644
new mode 100755
diff --git a/wwwroot/superpopular.php b/wwwroot/superpopular.php
old mode 100644
new mode 100755
diff --git a/wwwroot/upload.php b/wwwroot/upload.php
old mode 100644
new mode 100755
index 7dde7fd..a327550
--- a/wwwroot/upload.php
+++ b/wwwroot/upload.php
@@ -25,17 +25,16 @@ function uuid($prefix = '')
}
else
{
+ $Extension = "";
$Mime = mime_content_type($Image['tmp_name']);
switch($Mime){
- case "image/jpg":
- $Extension = "jpg";
- break;
- case "image/jpeg":
- $Extension = "jpeg";
- break;
case "image/gif":
$Extension = "gif";
break;
+ case "image/jpeg":
+ case "image/jpg":
+ $Extension = "jpg";
+ break;
case "image/png":
$Extension = "png";
break;
@@ -47,6 +46,9 @@ function uuid($prefix = '')
case "video/webm":
$Extension = "webm";
break;
+ case "image/webp":
+ $Extension = "webp";
+ break;
case "video/mp4":
$Extension = "mp4";
break;
@@ -61,10 +63,12 @@ function uuid($prefix = '')
// Catch all for the various text types that may end up being parsed, accept them as text files
if(preg_match('/text\/.*/i', $Mime))
$Extension = "txt";
- else {
- echo "HACKER!!!!!!!!!!!!!";
- return;
- }
+ }
+ if($Extension=="")
+ {
+ # echo "HACKER!!!!!!!!!!!!!";
+ echo "We do not accept $Mime files at this time.";
+ return false;
}
$Filename = uuid();
diff --git a/wwwroot/whoami.php b/wwwroot/whoami.php
old mode 100644
new mode 100755
diff --git a/wwwroot/yousosilly.php b/wwwroot/yousosilly.php
old mode 100644
new mode 100755