summaryrefslogtreecommitdiff
path: root/inc/display.php
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2011-02-16 15:08:17 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2011-02-16 15:08:17 +1100
commitafbd0c6473f864736bacab28035dfd3702c5d231 (patch)
tree1f0b9781ce3b8baafc0f38eda11137d597147672 /inc/display.php
parent392ae5f6e400c23ba0cf1e2a16137e23fb8390ba (diff)
parent44d280e120a3c7e1912f101c6ce8f8dfaf963cc8 (diff)
merged mod branch
Diffstat (limited to 'inc/display.php')
-rw-r--r--inc/display.php199
1 files changed, 172 insertions, 27 deletions
diff --git a/inc/display.php b/inc/display.php
index f7e70290..acf77e39 100644
--- a/inc/display.php
+++ b/inc/display.php
@@ -20,27 +20,32 @@
}
function error($message) {
- global $board;
+ global $board, $mod, $config;
if(function_exists('sql_close')) sql_close();
die(Element('page.html', Array(
- 'index'=>ROOT,
+ 'index'=>$config['root'],
'title'=>'Error',
'subtitle'=>'An error has occured.',
'body'=>"<center>" .
"<h2>$message</h2>" .
- (isset($board) ? "<p><a href=\"" . ROOT . $board['dir'] . FILE_INDEX . "\">Go back</a>.</p>" : '').
+ (isset($board) ?
+ "<p><a href=\"" . $config['root'] .
+ ($mod ? $config['file_mod'] . '?/' : '') .
+ $board['dir'] . $config['file_index'] . "\">Go back</a>.</p>" : '').
"</center>"
)));
}
function loginForm($error=false, $username=false) {
+ global $config;
+
if(function_exists('sql_close')) sql_close();
die(Element('page.html', Array(
- 'index'=>ROOT,
+ 'index'=>$config['root'],
'title'=>'Login',
'body'=>Element('login.html', Array(
- 'index'=>ROOT,
+ 'index'=>$config['root'],
'error'=>$error,
'username'=>$username
)
@@ -49,7 +54,10 @@
}
class Post {
- public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename) {
+ public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $root=null, $mod=false) {
+ global $config;
+ if(!isset($root)) $root = $config['root'];
+
$this->id = $id;
$this->thread = $thread;
$this->subject = utf8tohtml($subject);
@@ -66,12 +74,59 @@
$this->filey = $filey;
$this->filesize = $filesize;
$this->filename = $filename;
+ $this->ip = $ip;
+ $this->root = $root;
+ $this->mod = $mod;
+
+ if($this->mod)
+ // Fix internal links
+ // Very complicated regex
+ $this->body = preg_replace(
+ '/<a(([a-zA-Z]+="[^"]+")|[a-zA-Z]+=[a-zA-Z]+|\s)*href="' . preg_quote($config['root'], '/') . '(' . sprintf(preg_quote($config['board_path'], '/'), '\w+') . ')/',
+ '<a href="?/$3',
+ $this->body
+ );
+ }
+ public function postControls() {
+ global $board, $config;
+
+ $built = '';
+ if($this->mod) {
+ // Mod controls (on posts)
+ $built .= '<span class="controls">';
+
+ // Delete
+ if($this->mod['type'] >= $config['mod']['delete'])
+ $built .= ' <a title="Delete" href="?/' . $board['uri'] . '/delete/' . $this->id . '">' . $config['mod']['link_delete'] . '</a>';
+
+ // Delete all posts by IP
+ if($this->mod['type'] >= $config['mod']['deletebyip'])
+ $built .= ' <a title="Delete all posts by IP" href="?/' . $board['uri'] . '/deletebyip/' . $this->id . '">' . $config['mod']['link_deletebyip'] . '</a>';
+
+ // Ban
+ if($this->mod['type'] >= $config['mod']['ban'])
+ $built .= ' <a title="Ban" href="?/' . $board['uri'] . '/ban/' . $this->id . '">' . $config['mod']['link_ban'] . '</a>';
+
+ // Ban & Delete
+ if($this->mod['type'] >= $config['mod']['bandelete'])
+ $built .= ' <a title="Ban & Delete" href="?/' . $board['uri'] . '/ban&amp;delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
+
+ // Delete file (keep post)
+ if(!empty($this->file) && $this->mod['type'] >= $config['mod']['deletefile'])
+ $built .= ' <a title="Remove file" href="?/' . $board['uri'] . '/deletefile/' . $this->id . '">' . $config['mod']['link_deletefile'] . '</a>';
+
+ $built .= '</span>';
+ }
+ return $built;
}
+
public function build($index=false) {
- global $board;
+ global $board, $config;
$built = '<div class="post reply"' . (!$index?' id="reply_' . $this->id . '"':'') . '>' .
- '<p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>';
+ '<p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>' .
+ // Delete
+ '<input type="checkbox" class="delete" name="delete_' . $this->id . '" id="delete_' . $this->id . '" /><label for="delete_' . $this->id . '">';
// Subject
if(!empty($this->subject))
@@ -84,39 +139,52 @@
// Trip
. (!empty($this->trip) ? ' <span class="trip">'.$this->trip.'</span>':'');
+ // IP Address
+ if($this->mod && $this->mod['type'] >= $config['mod']['show_ip']) {
+ $built .= ' [<a style="margin:0;" href="?/IP/' . $this->ip . '">' . $this->ip . '</a>]';
+ }
+
// End email
if(!empty($this->email))
$built .= '</a>';
// Date/time
- $built .= ' ' . date('m/d/y (D) H:i:s', $this->time);
+ $built .= ' ' . date($config['post_date'], $this->time);
+
+ // End delete
+ $built .= '</label>';
$built .= ' <a class="post_no"' .
// JavaScript highlight
($index?'':' onclick="highlightReply(' . $this->id . ');"') .
- ' href="' . ROOT . $board['dir'] . DIR_RES . $this->thread . '.html' . '#' . $this->id . '">No.</a>' .
+ ' href="' . $this->root . $board['dir'] . $config['dir']['res'] . $this->thread . '.html' . '#' . $this->id . '">No.</a>' .
// JavaScript cite
- '<a class="post_no"' . ($index?'':'onclick="citeReply(' . $this->id . ');"') . 'href="' . ($index?ROOT . $board['dir'] . DIR_RES . $this->thread . '.html' . '#q' . $this->id:'javascript:void(0);') . '">'.$this->id.'</a>' .
+ '<a class="post_no"' . ($index?'':' onclick="citeReply(' . $this->id . ');"') . ' href="' . ($index?$this->root . $board['dir'] . $config['dir']['res'] . $this->thread . '.html' . '#q' . $this->id:'javascript:void(0);') . '">'.$this->id.'</a>' .
'</p>';
// File info
- if(!empty($this->file)) {
- $built .= '<p class="fileinfo">File: <a href="' . ROOT . $board['dir'] . DIR_IMG . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' .
+ if(!empty($this->file) && $this->file != 'deleted') {
+ $built .= '<p class="fileinfo">File: <a href="' . $config['root'] . $board['dir'] . $config['dir']['img'] . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' .
// Filesize
format_bytes($this->filesize) . ', ' .
// File dimensions
$this->filex . 'x' . $this->filey;
// Aspect Ratio
- if(SHOW_RATIO) {
+ if($config['show_ratio']) {
$fraction = fraction($this->filex, $this->filey, ':');
$built .= ', ' . $fraction;
}
// Filename
- $built .= ', ' . $this->filename . ')</span></p>' .
+ $built .= ', ' . $this->filename . ')</span></p>' .
+
// Thumbnail
- '<a href="' . ROOT . $board['dir'] . DIR_IMG . $this->file.'"><img src="' . ROOT . $board['dir'] . DIR_THUMB . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
+ '<a href="' . $config['root'] . $board['dir'] . $config['dir']['img'] . $this->file.'"><img src="' . $config['root'] . $board['dir'] . $config['dir']['thumb'] . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
+ } elseif($this->file == 'deleted') {
+ $built .= '<img src="' . $config['image_deleted'] . '" />';
}
+ $built .= $this->postControls();
+
// Body
$built .= '<p class="body">' . $this->body . '</p></div><br class="clear"/>';
@@ -126,7 +194,10 @@
class Thread {
public $omitted = 0;
- public function __construct($id, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename) {
+ public function __construct($id, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $root=null, $mod=false) {
+ global $config;
+ if(!isset($root)) $root = $config['root'];
+
$this->id = $id;
$this->subject = utf8tohtml($subject);
$this->email = $email;
@@ -144,32 +215,91 @@
$this->filename = $filename;
$this->omitted = 0;
$this->posts = Array();
+ $this->ip = $ip;
+ $this->sticky = $sticky;
+ $this->locked = $locked;
+ $this->root = $root;
+ $this->mod = $mod;
+
+ if($this->mod)
+ // Fix internal links
+ // Very complicated regex
+ $this->body = preg_replace(
+ '/<a(([a-zA-Z]+="[^"]+")|[a-zA-Z]+=[a-zA-Z]+|\s)*href="' . preg_quote($config['root'], '/') . '(' . sprintf(preg_quote($config['board_path'], '/'), '\w+') . ')/',
+ '<a href="?/$3',
+ $this->body
+ );
}
public function add(Post $post) {
$this->posts[] = $post;
}
-
+ public function postControls() {
+ global $board, $config;
+
+ $built = '';
+ if($this->mod) {
+ // Mod controls (on posts)
+ $built .= '<span class="controls op">';
+
+ // Delete
+ if($this->mod['type'] >= $config['mod']['delete'])
+ $built .= ' <a title="Delete" href="?/' . $board['uri'] . '/delete/' . $this->id . '">' . $config['mod']['link_delete'] . '</a>';
+
+ // Delete all posts by IP
+ if($this->mod['type'] >= $config['mod']['deletebyip'])
+ $built .= ' <a title="Delete all posts by IP" href="?/' . $board['uri'] . '/deletebyip/' . $this->id . '">' . $config['mod']['link_deletebyip'] . '</a>';
+
+ // Ban
+ if($this->mod['type'] >= $config['mod']['ban'])
+ $built .= ' <a title="Ban" href="?/' . $board['uri'] . '/ban/' . $this->id . '">' . $config['mod']['link_ban'] . '</a>';
+
+ // Ban & Delete
+ if($this->mod['type'] >= $config['mod']['bandelete'])
+ $built .= ' <a title="Ban & Delete" href="?/' . $board['uri'] . '/ban&amp;delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
+
+ // Stickies
+ if($this->mod['type'] >= $config['mod']['sticky'])
+ if($this->sticky)
+ $built .= ' <a title="Make thread not sticky" href="?/' . $board['uri'] . '/unsticky/' . $this->id . '">' . $config['mod']['link_desticky'] . '</a>';
+ else
+ $built .= ' <a title="Make thread sticky" href="?/' . $board['uri'] . '/sticky/' . $this->id . '">' . $config['mod']['link_sticky'] . '</a>';
+
+ // Lock
+ if($this->mod['type'] >= $config['mod']['lock'])
+ if($this->locked)
+ $built .= ' <a title="Lock thread" href="?/' . $board['uri'] . '/unlock/' . $this->id . '">' . $config['mod']['link_unlock'] . '</a>';
+ else
+ $built .= ' <a title="Unlock thread" href="?/' . $board['uri'] . '/lock/' . $this->id . '">' . $config['mod']['link_lock'] . '</a>';
+
+
+ $built .= '</span>';
+ }
+ return $built;
+ }
public function build($index=false) {
- global $board;
+ global $board, $config;
- $built = '<p class="fileinfo">File: <a href="' . ROOT . $board['dir'] . DIR_IMG . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' .
+ $built = '<p class="fileinfo">File: <a href="' . $config['root'] . $board['dir'] . $config['dir']['img'] . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' .
// Filesize
format_bytes($this->filesize) . ', ' .
// File dimensions
$this->filex . 'x' . $this->filey;
// Aspect Ratio
- if(SHOW_RATIO) {
+ if($config['show_ratio']) {
$fraction = fraction($this->filex, $this->filey, ':');
$built .= ', ' . $fraction;
}
// Filename
$built .= ', ' . $this->filename . ')</span></p>' .
// Thumbnail
- '<a href="' . ROOT . $board['dir'] . DIR_IMG . $this->file.'"><img src="' . ROOT . $board['dir'] . DIR_THUMB . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
+ '<a href="' . $config['root'] . $board['dir'] . $config['dir']['img'] . $this->file.'"><img src="' . $config['root'] . $board['dir'] . $config['dir']['thumb'] . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
$built .= '<div class="post op"><p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>';
+ // Delete
+ $built .= '<input type="checkbox" class="delete" name="delete_' . $this->id . '" id="delete_' . $this->id . '" /><label for="delete_' . $this->id . '">';
+
// Subject
if(!empty($this->subject))
$built .= '<span class="subject">' . $this->subject . '</span> ';
@@ -181,23 +311,38 @@
// Trip
. (!empty($this->trip) ? ' <span class="trip">'.$this->trip.'</span>':'');
+ // IP Address
+ if($this->mod && $this->mod['type'] >= $config['mod']['show_ip']) {
+ $built .= ' [<a style="margin:0;" href="?/IP/' . $this->ip . '">' . $this->ip . '</a>]';
+ }
+
// End email
if(!empty($this->email))
$built .= '</a>';
// Date/time
- $built .= ' ' . date('m/d/y (D) H:i:s', $this->time);
+ $built .= ' ' . date($config['post_date'], $this->time);
+
+ // End delete
+ $built .= '</label>';
$built .= ' <a class="post_no"' .
// JavaScript highlight
($index?'':' onclick="highlightReply(' . $this->id . ');"') .
- ' href="' . ROOT . $board['dir'] . DIR_RES . $this->id . '.html' . '#' . $this->id . '">No.</a>' .
+ ' href="' . $this->root . $board['dir'] . $config['dir']['res'] . $this->id . '.html' . '#' . $this->id . '">No.</a>' .
// JavaScript cite
- '<a class="post_no"' . ($index?'':'onclick="citeReply(' . $this->id . ');"') . 'href="' . ($index?ROOT . $board['dir'] . DIR_RES . $this->id . '.html' . '#q' . $this->id:'javascript:void(0);') . '">'.$this->id.'</a>' .
+ '<a class="post_no"' . ($index?'':' onclick="citeReply(' . $this->id . ');"') . ' href="' . ($index?$this->root . $board['dir'] . $config['dir']['res'] . $this->id . '.html' . '#q' . $this->id:'javascript:void(0);') . '">'.$this->id.'</a>' .
+ // Sticky
+ ($this->sticky ? '<img class="icon" title="Sticky" src="' . $config['image_sticky'] . '" />' : '') .
+ // Locked
+ ($this->locked ? '<img class="icon" title="Locked" src="' . $config['image_locked'] . '" />' : '') .
// [Reply]
- ($index ? '<a href="' . ROOT . $board['dir'] . DIR_RES . $this->id . '.html">[Reply]</a>' : '') .
+ ($index ? '<a href="' . $this->root . $board['dir'] . $config['dir']['res'] . $this->id . '.html">[Reply]</a>' : '') .
+
+ // Mod controls
+ $this->postControls() .
'</p>';
-
+
// Body
$built .= $this->body .