From 3737439338629890598abff0cc9e5c04528c66a9 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sat, 12 Feb 2011 17:25:15 +1100 Subject: Changed config to an array --- inc/display.php | 122 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 57 deletions(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index 8423da0f..acf77e39 100644 --- a/inc/display.php +++ b/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'=>"
" . "

$message

" . (isset($board) ? - "

Go back.

" : ''). + "

Go back.

" : ''). "
" ))); } 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( - '/'; // Delete - if($this->mod['type'] >= MOD_DELETE) - $built .= ' ' . MOD_LINK_DELETE . ''; + if($this->mod['type'] >= $config['mod']['delete']) + $built .= ' ' . $config['mod']['link_delete'] . ''; // Delete all posts by IP - if($this->mod['type'] >= MOD_DELETEBYIP) - $built .= ' ' . MOD_LINK_DELETEBYIP . ''; + if($this->mod['type'] >= $config['mod']['deletebyip']) + $built .= ' ' . $config['mod']['link_deletebyip'] . ''; // Ban - if($this->mod['type'] >= MOD_BAN) - $built .= ' ' . MOD_LINK_BAN . ''; + if($this->mod['type'] >= $config['mod']['ban']) + $built .= ' ' . $config['mod']['link_ban'] . ''; // Ban & Delete - if($this->mod['type'] >= MOD_BANDELETE) - $built .= ' ' . MOD_LINK_BANDELETE . ''; + if($this->mod['type'] >= $config['mod']['bandelete']) + $built .= ' ' . $config['mod']['link_bandelete'] . ''; // Delete file (keep post) - if(!empty($this->file) && $this->mod['type'] >= MOD_DELETEFILE) - $built .= ' ' . MOD_LINK_DELETEFILE . ''; + if(!empty($this->file) && $this->mod['type'] >= $config['mod']['deletefile']) + $built .= ' ' . $config['mod']['link_deletefile'] . ''; $built .= ''; } @@ -116,7 +121,7 @@ } public function build($index=false) { - global $board; + global $board, $config; $built = '
' . '

' . @@ -135,7 +140,7 @@ . (!empty($this->trip) ? ' '.$this->trip.'':''); // IP Address - if($this->mod && $this->mod['type'] >= MOD_SHOW_IP) { + if($this->mod && $this->mod['type'] >= $config['mod']['show_ip']) { $built .= ' [' . $this->ip . ']'; } @@ -144,7 +149,7 @@ $built .= ''; // Date/time - $built .= ' ' . date(POST_DATE, $this->time); + $built .= ' ' . date($config['post_date'], $this->time); // End delete $built .= ''; @@ -152,20 +157,20 @@ $built .= ' No.' . + ' href="' . $this->root . $board['dir'] . $config['dir']['res'] . $this->thread . '.html' . '#' . $this->id . '">No.' . // JavaScript cite - ''.$this->id.'' . + ''.$this->id.'' . '

'; // File info if(!empty($this->file) && $this->file != 'deleted') { - $built .= '

File: ' . $this->file . ' (' . + $built .= '

File: ' . $this->file . ' (' . // 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 . ')

' . // Thumbnail - ''; + ''; } elseif($this->file == 'deleted') { - $built .= ''; + $built .= ''; } $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( - '/'; // Delete - if($this->mod['type'] >= MOD_DELETE) - $built .= ' ' . MOD_LINK_DELETE . ''; + if($this->mod['type'] >= $config['mod']['delete']) + $built .= ' ' . $config['mod']['link_delete'] . ''; // Delete all posts by IP - if($this->mod['type'] >= MOD_DELETEBYIP) - $built .= ' ' . MOD_LINK_DELETEBYIP . ''; + if($this->mod['type'] >= $config['mod']['deletebyip']) + $built .= ' ' . $config['mod']['link_deletebyip'] . ''; // Ban - if($this->mod['type'] >= MOD_BAN) - $built .= ' ' . MOD_LINK_BAN . ''; + if($this->mod['type'] >= $config['mod']['ban']) + $built .= ' ' . $config['mod']['link_ban'] . ''; // Ban & Delete - if($this->mod['type'] >= MOD_BANDELETE) - $built .= ' ' . MOD_LINK_BANDELETE . ''; + if($this->mod['type'] >= $config['mod']['bandelete']) + $built .= ' ' . $config['mod']['link_bandelete'] . ''; // Stickies - if($this->mod['type'] >= MOD_STICKY) + if($this->mod['type'] >= $config['mod']['sticky']) if($this->sticky) - $built .= ' ' . MOD_LINK_DESTICKY . ''; + $built .= ' ' . $config['mod']['link_desticky'] . ''; else - $built .= ' ' . MOD_LINK_STICKY . ''; + $built .= ' ' . $config['mod']['link_sticky'] . ''; // Lock - if($this->mod['type'] >= MOD_LOCK) + if($this->mod['type'] >= $config['mod']['lock']) if($this->locked) - $built .= ' ' . MOD_LINK_UNLOCK . ''; + $built .= ' ' . $config['mod']['link_unlock'] . ''; else - $built .= ' ' . MOD_LINK_LOCK . ''; + $built .= ' ' . $config['mod']['link_lock'] . ''; $built .= ''; @@ -270,22 +278,22 @@ } public function build($index=false) { - global $board; + global $board, $config; - $built = '

File: ' . $this->file . ' (' . + $built = '

File: ' . $this->file . ' (' . // 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 . ')

' . // Thumbnail - ''; + ''; $built .= '

'; @@ -304,7 +312,7 @@ . (!empty($this->trip) ? ' '.$this->trip.'':''); // IP Address - if($this->mod && $this->mod['type'] >= MOD_SHOW_IP) { + if($this->mod && $this->mod['type'] >= $config['mod']['show_ip']) { $built .= ' [' . $this->ip . ']'; } @@ -313,7 +321,7 @@ $built .= ''; // Date/time - $built .= ' ' . date(POST_DATE, $this->time); + $built .= ' ' . date($config['post_date'], $this->time); // End delete $built .= ''; @@ -321,15 +329,15 @@ $built .= ' No.' . + ' href="' . $this->root . $board['dir'] . $config['dir']['res'] . $this->id . '.html' . '#' . $this->id . '">No.' . // JavaScript cite - ''.$this->id.'' . + ''.$this->id.'' . // Sticky - ($this->sticky ? '' : '') . + ($this->sticky ? '' : '') . // Locked - ($this->locked ? '' : '') . + ($this->locked ? '' : '') . // [Reply] - ($index ? '[Reply]' : '') . + ($index ? '[Reply]' : '') . // Mod controls $this->postControls() . -- cgit v1.3