Michael Save
12 years ago
15 changed files with 6754 additions and 6668 deletions
@ -1,31 +1,25 @@ |
|||||
<?php |
<?php |
||||
if($_SERVER['SCRIPT_FILENAME'] == str_replace('\\', '/', __FILE__)) { |
|
||||
// You cannot request this file directly. |
|
||||
header('Location: ../', true, 302); |
|
||||
exit; |
|
||||
} |
|
||||
|
|
||||
/* |
/* |
||||
Stuff to help with the display. |
* Copyright (c) 2010-2012 Tinyboard Development Group |
||||
*/ |
*/ |
||||
|
|
||||
|
if(realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { |
||||
|
// You cannot request this file directly. |
||||
|
exit; |
||||
|
} |
||||
|
|
||||
/* |
/* |
||||
[email protected] |
[email protected] |
||||
http://www.php.net/manual/en/function.filesize.php#100097 |
http://www.php.net/manual/en/function.filesize.php#100097 |
||||
*/ |
*/ |
||||
function format_bytes($size) { |
function format_bytes($size) { |
||||
$units = array(' B', ' KB', ' MB', ' GB', ' TB'); |
$units = array(' B', ' KB', ' MB', ' GB', ' TB'); |
||||
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024; |
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024; |
||||
return round($size, 2).$units[$i]; |
return round($size, 2).$units[$i]; |
||||
} |
} |
||||
|
|
||||
function commaize($n) { |
|
||||
$n = strval($n); |
|
||||
return (intval($n) < 1000) ? $n : commaize(substr($n, 0, -3)) . ',' . substr($n, -3); |
|
||||
} |
|
||||
|
|
||||
function doBoardListPart($list, $root) { |
function doBoardListPart($list, $root) { |
||||
global $config; |
global $config; |
||||
|
|
||||
$body = ''; |
$body = ''; |
||||
@ -43,9 +37,9 @@ |
|||||
$body = preg_replace('/\/$/', '', $body); |
$body = preg_replace('/\/$/', '', $body); |
||||
|
|
||||
return $body; |
return $body; |
||||
} |
} |
||||
|
|
||||
function createBoardlist($mod=false) { |
function createBoardlist($mod=false) { |
||||
global $config; |
global $config; |
||||
|
|
||||
if(!isset($config['boards'])) return Array('top'=>'','bottom'=>''); |
if(!isset($config['boards'])) return Array('top'=>'','bottom'=>''); |
||||
@ -60,9 +54,9 @@ |
|||||
'top' => '<div class="boardlist">' . $body . '</div>', |
'top' => '<div class="boardlist">' . $body . '</div>', |
||||
'bottom' => '<div class="boardlist bottom">' . $body . '</div>' |
'bottom' => '<div class="boardlist bottom">' . $body . '</div>' |
||||
); |
); |
||||
} |
} |
||||
|
|
||||
function error($message, $priority = true) { |
function error($message, $priority = true) { |
||||
global $board, $mod, $config; |
global $board, $mod, $config; |
||||
|
|
||||
if($config['syslog'] && $priority !== false) { |
if($config['syslog'] && $priority !== false) { |
||||
@ -87,9 +81,9 @@ |
|||||
$board['dir'] . $config['file_index'] . "\">Go back</a>.</p>" : '') . |
$board['dir'] . $config['file_index'] . "\">Go back</a>.</p>" : '') . |
||||
'</center>' |
'</center>' |
||||
))); |
))); |
||||
} |
} |
||||
|
|
||||
function loginForm($error=false, $username=false, $redirect=false) { |
function loginForm($error=false, $username=false, $redirect=false) { |
||||
global $config; |
global $config; |
||||
|
|
||||
die(Element('page.html', Array( |
die(Element('page.html', Array( |
||||
@ -104,9 +98,9 @@ |
|||||
) |
) |
||||
) |
) |
||||
))); |
))); |
||||
} |
} |
||||
|
|
||||
function pm_snippet($body, $len=null) { |
function pm_snippet($body, $len=null) { |
||||
global $config; |
global $config; |
||||
|
|
||||
if(!isset($len)) |
if(!isset($len)) |
||||
@ -128,9 +122,9 @@ |
|||||
|
|
||||
// Re-escape the characters. |
// Re-escape the characters. |
||||
return '<em>' . utf8tohtml($body) . ($strlen > $len ? '…' : '') . '</em>'; |
return '<em>' . utf8tohtml($body) . ($strlen > $len ? '…' : '') . '</em>'; |
||||
} |
} |
||||
|
|
||||
function capcode($cap) { |
function capcode($cap) { |
||||
global $config; |
global $config; |
||||
|
|
||||
if(!$cap) |
if(!$cap) |
||||
@ -152,9 +146,9 @@ |
|||||
} |
} |
||||
|
|
||||
return $capcode; |
return $capcode; |
||||
} |
} |
||||
|
|
||||
function truncate($body, $url, $max_lines = false, $max_chars = false) { |
function truncate($body, $url, $max_lines = false, $max_chars = false) { |
||||
global $config; |
global $config; |
||||
|
|
||||
if($max_lines === false) |
if($max_lines === false) |
||||
@ -209,20 +203,21 @@ |
|||||
} |
} |
||||
|
|
||||
return $body; |
return $body; |
||||
} |
} |
||||
|
|
||||
function confirmLink($text, $title, $confirm, $href) { |
function confirmLink($text, $title, $confirm, $href) { |
||||
global $config, $mod; |
global $config, $mod; |
||||
if($config['mod']['server-side_confirm']) |
if($config['mod']['server-side_confirm']) |
||||
return '<a onclick="if(confirm(\'' . htmlentities(addslashes($confirm)) . '\')) document.location=\'?/' . htmlentities(addslashes($href)) . '\';return false;" title="' . htmlentities($title) . '" href="?/confirm/' . $href . '">' . $text . '</a>'; |
return '<a onclick="if(confirm(\'' . htmlentities(addslashes($confirm)) . '\')) document.location=\'?/' . htmlentities(addslashes($href)) . '\';return false;" title="' . htmlentities($title) . '" href="?/confirm/' . $href . '">' . $text . '</a>'; |
||||
else |
else |
||||
return '<a onclick="return confirm(\'' . htmlentities(addslashes($confirm)) . '\')" title="' . htmlentities($title) . '" href="?/' . $href . '">' . $text . '</a>'; |
return '<a onclick="return confirm(\'' . htmlentities(addslashes($confirm)) . '\')" title="' . htmlentities($title) . '" href="?/' . $href . '">' . $text . '</a>'; |
||||
} |
} |
||||
|
|
||||
class Post { |
class Post { |
||||
public function __construct($id, $thread, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $embed, $root=null, $mod=false) { |
public function __construct($id, $thread, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $embed, $root=null, $mod=false) { |
||||
global $config; |
global $config; |
||||
if(!isset($root)) $root = &$config['root']; |
if(!isset($root)) |
||||
|
$root = &$config['root']; |
||||
|
|
||||
$this->id = $id; |
$this->id = $id; |
||||
$this->thread = $thread; |
$this->thread = $thread; |
||||
@ -306,12 +301,13 @@ |
|||||
|
|
||||
return Element('post_reply.html', Array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index)); |
return Element('post_reply.html', Array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index)); |
||||
} |
} |
||||
}; |
}; |
||||
|
|
||||
class Thread { |
class Thread { |
||||
public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $bumplocked, $embed, $root=null, $mod=false, $hr=true) { |
public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $bumplocked, $embed, $root=null, $mod=false, $hr=true) { |
||||
global $config; |
global $config; |
||||
if(!isset($root)) $root = &$config['root']; |
if(!isset($root)) |
||||
|
$root = &$config['root']; |
||||
|
|
||||
$this->id = $id; |
$this->id = $id; |
||||
$this->subject = utf8tohtml($subject); |
$this->subject = utf8tohtml($subject); |
||||
@ -441,5 +437,5 @@ |
|||||
|
|
||||
return 'thread_' . ($index ? 'index_' : '') . $board['uri'] . '_' . $this->id; |
return 'thread_' . ($index ? 'index_' : '') . $board['uri'] . '_' . $this->id; |
||||
} |
} |
||||
}; |
}; |
||||
?> |
|
||||
|
File diff suppressed because it is too large
@ -1,11 +1,15 @@ |
|||||
<?php |
<?php |
||||
if($_SERVER['SCRIPT_FILENAME'] == str_replace('\\', '/', __FILE__)) { |
|
||||
|
/* |
||||
|
* Copyright (c) 2010-2012 Tinyboard Development Group |
||||
|
*/ |
||||
|
|
||||
|
if(realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { |
||||
// You cannot request this file directly. |
// You cannot request this file directly. |
||||
header('Location: ../', true, 302); |
|
||||
exit; |
exit; |
||||
} |
} |
||||
|
|
||||
class Image { |
class Image { |
||||
public $src, $format, $image, $size; |
public $src, $format, $image, $size; |
||||
public function __construct($src, $format = false) { |
public function __construct($src, $format = false) { |
||||
global $config; |
global $config; |
||||
@ -84,9 +88,9 @@ |
|||||
public function destroy() { |
public function destroy() { |
||||
$this->image->_destroy(); |
$this->image->_destroy(); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
class ImageGD { |
class ImageGD { |
||||
public function GD_create() { |
public function GD_create() { |
||||
$this->image = imagecreatetruecolor($this->width, $this->height); |
$this->image = imagecreatetruecolor($this->width, $this->height); |
||||
} |
} |
||||
@ -97,9 +101,9 @@ |
|||||
$this->GD_create(); |
$this->GD_create(); |
||||
$this->GD_copyresampled(); |
$this->GD_copyresampled(); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
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() { |
public function valid() { |
||||
return (bool)$this->image; |
return (bool)$this->image; |
||||
@ -144,9 +148,9 @@ |
|||||
// use default GD functions |
// use default GD functions |
||||
$this->GD_resize(); |
$this->GD_resize(); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
class ImageImagick extends ImageBase { |
class ImageImagick extends ImageBase { |
||||
public function init() { |
public function init() { |
||||
$this->image = new Imagick(); |
$this->image = new Imagick(); |
||||
$this->image->setBackgroundColor(new ImagickPixel('transparent')); |
$this->image->setBackgroundColor(new ImagickPixel('transparent')); |
||||
@ -207,10 +211,10 @@ |
|||||
$this->image->scaleImage($this->width, $this->height, false); |
$this->image->scaleImage($this->width, $this->height, false); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
|
|
||||
class ImageConvert extends ImageBase { |
class ImageConvert extends ImageBase { |
||||
public $width, $height, $temp; |
public $width, $height, $temp; |
||||
|
|
||||
public function init() { |
public function init() { |
||||
@ -264,9 +268,9 @@ |
|||||
if(shell_exec("convert -flatten -filter Point -scale {$this->width}x{$this->height} +antialias -quality {$quality} " . escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp)) |
if(shell_exec("convert -flatten -filter Point -scale {$this->width}x{$this->height} +antialias -quality {$quality} " . escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp)) |
||||
error('Failed to resize image!'); |
error('Failed to resize image!'); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
class ImagePNG extends ImageBase { |
class ImagePNG extends ImageBase { |
||||
public function from() { |
public function from() { |
||||
$this->image = @imagecreatefrompng($this->src); |
$this->image = @imagecreatefrompng($this->src); |
||||
} |
} |
||||
@ -281,9 +285,9 @@ |
|||||
imagealphablending($this->image, false); |
imagealphablending($this->image, false); |
||||
$this->GD_copyresampled(); |
$this->GD_copyresampled(); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
class ImageGIF extends ImageBase { |
class ImageGIF extends ImageBase { |
||||
public function from() { |
public function from() { |
||||
$this->image = @imagecreatefromgif($this->src); |
$this->image = @imagecreatefromgif($this->src); |
||||
} |
} |
||||
@ -296,38 +300,38 @@ |
|||||
imagesavealpha($this->image, true); |
imagesavealpha($this->image, true); |
||||
$this->GD_copyresampled(); |
$this->GD_copyresampled(); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
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); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
|
|
||||
/*********************************************/ |
/*********************************************/ |
||||
/* Fonction: imagecreatefrombmp */ |
/* Fonction: imagecreatefrombmp */ |
||||
/* Author: DHKold */ |
/* Author: DHKold */ |
||||
/* Contact: [email protected] */ |
/* Contact: [email protected] */ |
||||
/* Date: The 15th of June 2005 */ |
/* Date: The 15th of June 2005 */ |
||||
/* Version: 2.0B */ |
/* Version: 2.0B */ |
||||
/*********************************************/ |
/*********************************************/ |
||||
|
|
||||
function imagecreatefrombmp($filename) { |
function imagecreatefrombmp($filename) { |
||||
if (! $f1 = fopen($filename,"rb")) return FALSE; |
if (! $f1 = fopen($filename,"rb")) return FALSE; |
||||
$FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); |
$FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); |
||||
if ($FILE['file_type'] != 19778) return FALSE; |
if ($FILE['file_type'] != 19778) return FALSE; |
||||
@ -403,9 +407,9 @@ |
|||||
fclose($f1); |
fclose($f1); |
||||
|
|
||||
return $res; |
return $res; |
||||
} |
} |
||||
|
|
||||
function imagebmp(&$img, $filename='') { |
function imagebmp(&$img, $filename='') { |
||||
$widthOrig = imagesx($img); |
$widthOrig = imagesx($img); |
||||
$widthFloor = ((floor($widthOrig/16))*16); |
$widthFloor = ((floor($widthOrig/16))*16); |
||||
$widthCeil = ((ceil($widthOrig/16))*16); |
$widthCeil = ((ceil($widthOrig/16))*16); |
||||
@ -476,13 +480,12 @@ |
|||||
fwrite($file, $result); |
fwrite($file, $result); |
||||
fclose($file); |
fclose($file); |
||||
} |
} |
||||
} |
} |
||||
// imagebmp helpers |
// imagebmp helpers |
||||
function int_to_dword($n) { |
function int_to_dword($n) { |
||||
return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255).chr(($n >> 24) & 255); |
return chr($n & 255).chr(($n >> 8) & 255).chr(($n >> 16) & 255).chr(($n >> 24) & 255); |
||||
} |
} |
||||
function int_to_word($n) { |
function int_to_word($n) { |
||||
return chr($n & 255).chr(($n >> 8) & 255); |
return chr($n & 255).chr(($n >> 8) & 255); |
||||
} |
} |
||||
|
|
||||
?> |
|
||||
|
@ -1,10 +0,0 @@ |
|||||
<?php |
|
||||
if($_SERVER['SCRIPT_FILENAME'] == str_replace('\\', '/', __FILE__)) { |
|
||||
// You cannot request this file directly. |
|
||||
header('Location: ../', true, 302); |
|
||||
exit; |
|
||||
} |
|
||||
|
|
||||
// 'false' means that the user is not logged in as a moderator |
|
||||
$mod = false; |
|
||||
|
|
Loading…
Reference in new issue