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