From 8478ee430fa86edb971bb4b3546e49a64a964c81 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Thu, 7 Dec 2023 06:17:29 +0000 Subject: [PATCH] whitespaces --- inc/api.php | 5 ++++ inc/display.php | 9 +++++++ inc/filters.php | 7 +++++- inc/image.php | 66 +++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 73 insertions(+), 14 deletions(-) diff --git a/inc/api.php b/inc/api.php index a60d9b41..c097f82c 100644 --- a/inc/api.php +++ b/inc/api.php @@ -9,6 +9,11 @@ defined('TINYBOARD') or exit; * Class for generating json API compatible with 4chan API */ class Api { + public $config; + public $postFields; + public $threadsPageFields; + public $fileFields; + function __construct(){ global $config; /** diff --git a/inc/display.php b/inc/display.php index a82cfab1..2f246f6b 100644 --- a/inc/display.php +++ b/inc/display.php @@ -357,6 +357,11 @@ class PostProps { public $slug; public $delete_token; public $board; + public $thread_id; + public $link; + public $file; + public $pubdate; + public $board_name; public $mod; public $root; @@ -465,17 +470,21 @@ class Thread extends PostProps { $this->body ); } + public function link($pre = '', $page = false) { global $config, $board; return $this->root . $board['dir'] . $config['dir']['res'] . link_for((array)$this, $page == '50') . '#' . $pre . $this->id; } + public function add(Post $post) { $this->posts[] = $post; } + public function postCount() { return count($this->posts) + $this->omitted; } + public function build($index=false, $isnoko50=false) { global $board, $config, $debug; diff --git a/inc/filters.php b/inc/filters.php index 591b4f92..cf73b896 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -14,8 +14,9 @@ class Filter { private $post; public function __construct(array $arr) { - foreach ($arr as $key => $value) + foreach ($arr as $key => $value) { $this->$key = $value; + } } public function match($condition, $match) { @@ -146,6 +147,7 @@ class Filter { global $board; $this->add_note = isset($this->add_note) ? $this->add_note : false; + if ($this->add_note) { $query = prepare('INSERT INTO ``ip_notes`` VALUES (NULL, :ip, :mod, :time, :body)'); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); @@ -154,6 +156,7 @@ class Filter { $query->bindValue(':body', "Autoban message: ".$this->post['body']); $query->execute() or error(db_error($query)); } + if (isset ($this->action)) switch($this->action) { case 'reject': error(isset($this->message) ? $this->message : 'Posting blocked by filter.'); @@ -183,6 +186,7 @@ class Filter { public function check(array $post) { $this->post = $post; + foreach ($this->condition as $condition => $value) { if ($condition[0] == '!') { $NOT = true; @@ -263,6 +267,7 @@ function do_filters(array $post) { foreach ($config['filters'] as $filter_array) { $filter = new Filter($filter_array); $filter->flood_check = $flood_check; + if ($filter->check($post)) { $filter->action(); } diff --git a/inc/image.php b/inc/image.php index 20fcfdcb..f136273a 100644 --- a/inc/image.php +++ b/inc/image.php @@ -102,6 +102,13 @@ class Image { } class ImageGD { + public $image; + public $original; + public $width; + public $height; + public $original_width; + public $original_height; + public function GD_create() { $this->image = imagecreatetruecolor($this->width, $this->height); } @@ -116,10 +123,7 @@ class ImageGD { class ImageBase extends ImageGD { public $image, $src, $original, $original_width, $original_height, $width, $height; - public function valid() { - return (bool)$this->image; - } - + public function __construct($img, $size = false) { if (method_exists($this, 'init')) $this->init(); @@ -134,6 +138,10 @@ class ImageBase extends ImageGD { $this->from(); } } + + public function valid() { + return (bool)$this->image; + } public function _width() { if (method_exists($this, 'width')) @@ -141,18 +149,21 @@ class ImageBase extends ImageGD { // use default GD functions return imagesx($this->image); } + public function _height() { if (method_exists($this, 'height')) return $this->height(); // use default GD functions return imagesy($this->image); } + public function _destroy() { if (method_exists($this, 'destroy')) return $this->destroy(); // use default GD functions return imagedestroy($this->image); } + public function _resize($original, $width, $height) { $this->original = &$original; $this->width = $width; @@ -171,6 +182,7 @@ class ImageImagick extends ImageBase { $this->image = new Imagick(); $this->image->setBackgroundColor(new ImagickPixel('transparent')); } + public function from() { try { $this->image->readImage($this->src); @@ -179,25 +191,34 @@ class ImageImagick extends ImageBase { $this->image = false; } } + public function to($src) { global $config; + if ($config['strip_exif']) { $this->image->stripImage(); } - if (preg_match('/\.gif$/i', $src)) - $this->image->writeImages($src, true); - else - $this->image->writeImage($src); + + if (preg_match('/\.gif$/i', $src)) { + $this->image->writeImages($src, true); + } + else { + $this->image->writeImage($src); + } } + public function width() { return $this->image->getImageWidth(); } + public function height() { return $this->image->getImageHeight(); } + public function destroy() { return $this->image->destroy(); } + public function resize() { global $config; @@ -206,11 +227,14 @@ class ImageImagick extends ImageBase { $this->image->setFormat('gif'); $keep_frames = array(); - for ($i = 0; $i < $this->original->getNumberImages(); $i += floor($this->original->getNumberImages() / $config['thumb_keep_animation_frames'])) + + for ($i = 0; $i < $this->original->getNumberImages(); $i += floor($this->original->getNumberImages() / $config['thumb_keep_animation_frames'])) { $keep_frames[] = $i; + } $i = 0; $delay = 0; + foreach ($this->original as $frame) { $delay += $frame->getImageDelay(); @@ -246,6 +270,7 @@ class ImageConvert extends ImageBase { $this->temp = false; } + public function get_size($src, $try_gd_first = true) { if ($try_gd_first) { if ($size = @getimagesize($src)) @@ -256,12 +281,15 @@ class ImageConvert extends ImageBase { return array($m[1], $m[2]); return false; } + public function from() { if ($this->width > 0 && $this->height > 0) { $this->image = true; return; } + $size = $this->get_size($this->src, false); + if ($size) { $this->width = $size[0]; $this->height = $size[1]; @@ -272,6 +300,7 @@ class ImageConvert extends ImageBase { $this->image = false; } } + public function to($src) { global $config; @@ -294,16 +323,20 @@ class ImageConvert extends ImageBase { chmod($src, 0664); } } + public function width() { return $this->width; } + public function height() { return $this->height; } + public function destroy() { @unlink($this->temp); $this->temp = false; } + public function resize() { global $config; @@ -446,13 +479,16 @@ class ImageConvert extends ImageBase { } class ImagePNG extends ImageBase { + public function from() { $this->image = @imagecreatefrompng($this->src); } + public function to($src) { global $config; imagepng($this->image, $src); } + public function resize() { $this->GD_create(); imagecolortransparent($this->image, imagecolorallocatealpha($this->image, 0, 0, 0, 0)); @@ -463,12 +499,15 @@ class ImagePNG extends ImageBase { } class ImageGIF extends ImageBase { + public function from() { $this->image = @imagecreatefromgif($this->src); } + public function to($src) { imagegif ($this->image, $src); } + public function resize() { $this->GD_create(); imagecolortransparent($this->image, imagecolorallocatealpha($this->image, 0, 0, 0, 0)); @@ -478,25 +517,26 @@ class ImageGIF extends ImageBase { } class ImageJPG extends ImageBase { + public function from() { $this->image = @imagecreatefromjpeg($this->src); } + public function to($src) { imagejpeg($this->image, $src); } } + class ImageJPEG extends ImageJPG { } class ImageBMP extends ImageBase { + public function from() { $this->image = @imagecreatefrombmp($this->src); } + public function to($src) { imagebmp($this->image, $src); } } - - - -