forked from leftypol/leftypol
Changed config to an array
This commit is contained in:
parent
b57d600c36
commit
3737439338
9 changed files with 523 additions and 606 deletions
122
inc/display.php
122
inc/display.php
|
@ -20,30 +20,32 @@
|
|||
}
|
||||
|
||||
function error($message) {
|
||||
global $board, $mod;
|
||||
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 .
|
||||
($mod ? FILE_MOD . '?/' : '') .
|
||||
$board['dir'] . FILE_INDEX . "\">Go back</a>.</p>" : '').
|
||||
"<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
|
||||
)
|
||||
|
@ -52,7 +54,10 @@
|
|||
}
|
||||
|
||||
class Post {
|
||||
public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $root=ROOT, $mod=false) {
|
||||
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);
|
||||
|
@ -77,13 +82,13 @@
|
|||
// Fix internal links
|
||||
// Very complicated regex
|
||||
$this->body = preg_replace(
|
||||
'/<a(([a-zA-Z]+="[^"]+")|[a-zA-Z]+=[a-zA-Z]+|\s)*href="' . preg_quote(ROOT, '/') . '(' . sprintf(preg_quote(BOARD_PATH, '/'), '\w+') . ')/',
|
||||
'/<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;
|
||||
global $board, $config;
|
||||
|
||||
$built = '';
|
||||
if($this->mod) {
|
||||
|
@ -91,24 +96,24 @@
|
|||
$built .= '<span class="controls">';
|
||||
|
||||
// Delete
|
||||
if($this->mod['type'] >= MOD_DELETE)
|
||||
$built .= ' <a title="Delete" href="?/' . $board['uri'] . '/delete/' . $this->id . '">' . MOD_LINK_DELETE . '</a>';
|
||||
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'] >= MOD_DELETEBYIP)
|
||||
$built .= ' <a title="Delete all posts by IP" href="?/' . $board['uri'] . '/deletebyip/' . $this->id . '">' . MOD_LINK_DELETEBYIP . '</a>';
|
||||
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'] >= MOD_BAN)
|
||||
$built .= ' <a title="Ban" href="?/' . $board['uri'] . '/ban/' . $this->id . '">' . MOD_LINK_BAN . '</a>';
|
||||
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'] >= MOD_BANDELETE)
|
||||
$built .= ' <a title="Ban & Delete" href="?/' . $board['uri'] . '/ban&delete/' . $this->id . '">' . MOD_LINK_BANDELETE . '</a>';
|
||||
if($this->mod['type'] >= $config['mod']['bandelete'])
|
||||
$built .= ' <a title="Ban & Delete" href="?/' . $board['uri'] . '/ban&delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
|
||||
|
||||
// Delete file (keep post)
|
||||
if(!empty($this->file) && $this->mod['type'] >= MOD_DELETEFILE)
|
||||
$built .= ' <a title="Remove file" href="?/' . $board['uri'] . '/deletefile/' . $this->id . '">' . MOD_LINK_DELETEFILE . '</a>';
|
||||
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>';
|
||||
}
|
||||
|
@ -116,7 +121,7 @@
|
|||
}
|
||||
|
||||
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 . '"':'') . '>' .
|
||||
|
@ -135,7 +140,7 @@
|
|||
. (!empty($this->trip) ? ' <span class="trip">'.$this->trip.'</span>':'');
|
||||
|
||||
// IP Address
|
||||
if($this->mod && $this->mod['type'] >= MOD_SHOW_IP) {
|
||||
if($this->mod && $this->mod['type'] >= $config['mod']['show_ip']) {
|
||||
$built .= ' [<a style="margin:0;" href="?/IP/' . $this->ip . '">' . $this->ip . '</a>]';
|
||||
}
|
||||
|
||||
|
@ -144,7 +149,7 @@
|
|||
$built .= '</a>';
|
||||
|
||||
// Date/time
|
||||
$built .= ' ' . date(POST_DATE, $this->time);
|
||||
$built .= ' ' . date($config['post_date'], $this->time);
|
||||
|
||||
// End delete
|
||||
$built .= '</label>';
|
||||
|
@ -152,20 +157,20 @@
|
|||
$built .= ' <a class="post_no"' .
|
||||
// JavaScript highlight
|
||||
($index?'':' onclick="highlightReply(' . $this->id . ');"') .
|
||||
' href="' . $this->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?$this->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) && $this->file != 'deleted') {
|
||||
$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;
|
||||
}
|
||||
|
@ -173,9 +178,9 @@
|
|||
$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="' . DELETED_IMAGE . '" />';
|
||||
$built .= '<img src="' . $config['image_deleted'] . '" />';
|
||||
}
|
||||
|
||||
$built .= $this->postControls();
|
||||
|
@ -189,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, $ip, $sticky, $locked, $root=ROOT, $mod=false) {
|
||||
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;
|
||||
|
@ -217,7 +225,7 @@
|
|||
// Fix internal links
|
||||
// Very complicated regex
|
||||
$this->body = preg_replace(
|
||||
'/<a(([a-zA-Z]+="[^"]+")|[a-zA-Z]+=[a-zA-Z]+|\s)*href="' . preg_quote(ROOT, '/') . '(' . sprintf(preg_quote(BOARD_PATH, '/'), '\w+') . ')/',
|
||||
'/<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
|
||||
);
|
||||
|
@ -226,7 +234,7 @@
|
|||
$this->posts[] = $post;
|
||||
}
|
||||
public function postControls() {
|
||||
global $board;
|
||||
global $board, $config;
|
||||
|
||||
$built = '';
|
||||
if($this->mod) {
|
||||
|
@ -234,34 +242,34 @@
|
|||
$built .= '<span class="controls op">';
|
||||
|
||||
// Delete
|
||||
if($this->mod['type'] >= MOD_DELETE)
|
||||
$built .= ' <a title="Delete" href="?/' . $board['uri'] . '/delete/' . $this->id . '">' . MOD_LINK_DELETE . '</a>';
|
||||
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'] >= MOD_DELETEBYIP)
|
||||
$built .= ' <a title="Delete all posts by IP" href="?/' . $board['uri'] . '/deletebyip/' . $this->id . '">' . MOD_LINK_DELETEBYIP . '</a>';
|
||||
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'] >= MOD_BAN)
|
||||
$built .= ' <a title="Ban" href="?/' . $board['uri'] . '/ban/' . $this->id . '">' . MOD_LINK_BAN . '</a>';
|
||||
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'] >= MOD_BANDELETE)
|
||||
$built .= ' <a title="Ban & Delete" href="?/' . $board['uri'] . '/ban&delete/' . $this->id . '">' . MOD_LINK_BANDELETE . '</a>';
|
||||
if($this->mod['type'] >= $config['mod']['bandelete'])
|
||||
$built .= ' <a title="Ban & Delete" href="?/' . $board['uri'] . '/ban&delete/' . $this->id . '">' . $config['mod']['link_bandelete'] . '</a>';
|
||||
|
||||
// Stickies
|
||||
if($this->mod['type'] >= MOD_STICKY)
|
||||
if($this->mod['type'] >= $config['mod']['sticky'])
|
||||
if($this->sticky)
|
||||
$built .= ' <a title="Make thread not sticky" href="?/' . $board['uri'] . '/unsticky/' . $this->id . '">' . MOD_LINK_DESTICKY . '</a>';
|
||||
$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 . '">' . MOD_LINK_STICKY . '</a>';
|
||||
$built .= ' <a title="Make thread sticky" href="?/' . $board['uri'] . '/sticky/' . $this->id . '">' . $config['mod']['link_sticky'] . '</a>';
|
||||
|
||||
// Lock
|
||||
if($this->mod['type'] >= MOD_LOCK)
|
||||
if($this->mod['type'] >= $config['mod']['lock'])
|
||||
if($this->locked)
|
||||
$built .= ' <a title="Lock thread" href="?/' . $board['uri'] . '/unlock/' . $this->id . '">' . MOD_LINK_UNLOCK . '</a>';
|
||||
$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 . '">' . MOD_LINK_LOCK . '</a>';
|
||||
$built .= ' <a title="Unlock thread" href="?/' . $board['uri'] . '/lock/' . $this->id . '">' . $config['mod']['link_lock'] . '</a>';
|
||||
|
||||
|
||||
$built .= '</span>';
|
||||
|
@ -270,22 +278,22 @@
|
|||
}
|
||||
|
||||
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 . '"':'') . '>';
|
||||
|
||||
|
@ -304,7 +312,7 @@
|
|||
. (!empty($this->trip) ? ' <span class="trip">'.$this->trip.'</span>':'');
|
||||
|
||||
// IP Address
|
||||
if($this->mod && $this->mod['type'] >= MOD_SHOW_IP) {
|
||||
if($this->mod && $this->mod['type'] >= $config['mod']['show_ip']) {
|
||||
$built .= ' [<a style="margin:0;" href="?/IP/' . $this->ip . '">' . $this->ip . '</a>]';
|
||||
}
|
||||
|
||||
|
@ -313,7 +321,7 @@
|
|||
$built .= '</a>';
|
||||
|
||||
// Date/time
|
||||
$built .= ' ' . date(POST_DATE, $this->time);
|
||||
$built .= ' ' . date($config['post_date'], $this->time);
|
||||
|
||||
// End delete
|
||||
$built .= '</label>';
|
||||
|
@ -321,15 +329,15 @@
|
|||
$built .= ' <a class="post_no"' .
|
||||
// JavaScript highlight
|
||||
($index?'':' onclick="highlightReply(' . $this->id . ');"') .
|
||||
' href="' . $this->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?$this->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="' . IMAGE_STICKY . '" />' : '') .
|
||||
($this->sticky ? '<img class="icon" title="Sticky" src="' . $config['image_sticky'] . '" />' : '') .
|
||||
// Locked
|
||||
($this->locked ? '<img class="icon" title="Locked" src="' . IMAGE_LOCKED . '" />' : '') .
|
||||
($this->locked ? '<img class="icon" title="Locked" src="' . $config['image_locked'] . '" />' : '') .
|
||||
// [Reply]
|
||||
($index ? '<a href="' . $this->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() .
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue