= 1024 && $i < 4; $i++) $size /= 1024; 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) { global $config; $body = ''; foreach($list as $board) { if(is_array($board)) $body .= ' [' . doBoardListPart($board, $root) . '] '; else { if(($key = array_search($board, $list)) && gettype($key) == 'string') { $body .= ' ' . $key . ' /'; } else { $body .= ' ' . $board . ' /'; } } } $body = preg_replace('/\/$/', '', $body); return $body; } function createBoardlist($mod=false) { global $config; if(!isset($config['boards'])) return Array('top'=>'','bottom'=>''); $body = doBoardListPart($config['boards'], $mod?'?/':$config['root']); if(!preg_match('/\]$/', $body)) $body = '[' . $body . ']'; return Array( 'top' => '
' . $body . '
', 'bottom' => '
' . $body . '
' ); } function error($message) { global $board, $mod, $config; if(function_exists('sql_close')) sql_close(); die(Element('page.html', Array( 'index'=>$config['root'], 'title'=>'Error', 'subtitle'=>'An error has occured.', 'body'=>"
" . "

$message

" . (isset($board) ? "

Go back.

" : ''). "
" ))); } function loginForm($error=false, $username=false, $redirect=false) { global $config; if(function_exists('sql_close')) sql_close(); die(Element('page.html', Array( 'index'=>$config['root'], 'title'=>'Login', 'body'=>Element('login.html', Array( 'index'=>$config['root'], 'error'=>$error, 'username'=>$username, 'redirect'=>$redirect ) ) ))); } class Post { 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); $this->email = $email; $this->name = utf8tohtml($name); $this->trip = $trip; $this->body = $body; $this->time = $time; $this->thumb = $thumb; $this->thumbx = $thumbx; $this->thumby = $thumby; $this->file = $file; $this->filex = $filex; $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( '/'; // Delete if($this->mod['type'] >= $config['mod']['delete']) $built .= ' ' . $config['mod']['link_delete'] . ''; // Delete all posts by IP if($this->mod['type'] >= $config['mod']['deletebyip']) $built .= ' ' . $config['mod']['link_deletebyip'] . ''; // Ban if($this->mod['type'] >= $config['mod']['ban']) $built .= ' ' . $config['mod']['link_ban'] . ''; // Ban & Delete if($this->mod['type'] >= $config['mod']['bandelete']) $built .= ' ' . $config['mod']['link_bandelete'] . ''; // Delete file (keep post) if(!empty($this->file) && $this->mod['type'] >= $config['mod']['deletefile']) $built .= ' ' . $config['mod']['link_deletefile'] . ''; $built .= ''; } return $built; } public function build($index=false) { global $board, $config; $built = '
' . '

' . // Delete ''; $built .= ' No.' . // JavaScript cite ''.$this->id.'' . '

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

File: ' . $this->file . ' (' . // Filesize format_bytes($this->filesize) . ', ' . // File dimensions $this->filex . 'x' . $this->filey; // Aspect Ratio if($config['show_ratio']) { $fraction = fraction($this->filex, $this->filey, ':'); $built .= ', ' . $fraction; } // Filename $built .= ', ' . $this->filename . ')

' . // Thumbnail ''; } elseif($this->file == 'deleted') { $built .= ''; } $built .= $this->postControls(); // Body $built .= '

' . $this->body . '


'; return $built; } }; class Thread { 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, $hr=true) { global $config; if(!isset($root)) $root = $config['root']; $this->id = $id; $this->subject = utf8tohtml($subject); $this->email = $email; $this->name = utf8tohtml($name); $this->trip = $trip; $this->body = $body; $this->time = $time; $this->thumb = $thumb; $this->thumbx = $thumbx; $this->thumby = $thumby; $this->file = $file; $this->filex = $filex; $this->filey = $filey; $this->filesize = $filesize; $this->filename = $filename; $this->omitted = 0; $this->omitted_images = 0; $this->posts = Array(); $this->ip = $ip; $this->sticky = $sticky; $this->locked = $locked; $this->root = $root; $this->mod = $mod; $this->hr = $hr; if($this->mod) // Fix internal links // Very complicated regex $this->body = preg_replace( '/'; // Delete if($this->mod['type'] >= $config['mod']['delete']) $built .= ' ' . $config['mod']['link_delete'] . ''; // Delete all posts by IP if($this->mod['type'] >= $config['mod']['deletebyip']) $built .= ' ' . $config['mod']['link_deletebyip'] . ''; // Ban if($this->mod['type'] >= $config['mod']['ban']) $built .= ' ' . $config['mod']['link_ban'] . ''; // Ban & Delete if($this->mod['type'] >= $config['mod']['bandelete']) $built .= ' ' . $config['mod']['link_bandelete'] . ''; // Stickies if($this->mod['type'] >= $config['mod']['sticky']) if($this->sticky) $built .= ' ' . $config['mod']['link_desticky'] . ''; else $built .= ' ' . $config['mod']['link_sticky'] . ''; // Lock if($this->mod['type'] >= $config['mod']['lock']) if($this->locked) $built .= ' ' . $config['mod']['link_unlock'] . ''; else $built .= ' ' . $config['mod']['link_lock'] . ''; $built .= ''; } return $built; } public function build($index=false) { global $board, $config; $built = '

File: ' . $this->file . ' (' . // Filesize format_bytes($this->filesize) . ', ' . // File dimensions $this->filex . 'x' . $this->filey; // Aspect Ratio if($config['show_ratio']) { $fraction = fraction($this->filex, $this->filey, ':'); $built .= ', ' . $fraction; } // Filename $built .= ', ' . $this->filename . ')

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

'; // Delete $built .= ''; $built .= ' No.' . // JavaScript cite ''.$this->id.'' . // Sticky ($this->sticky ? '' : '') . // Locked ($this->locked ? '' : '') . // [Reply] ($index ? '[Reply]' : '') . // Mod controls $this->postControls() . '

'; // Body $built .= '

' . $this->body . '

' . // Omitted posts ($this->omitted || $this->omitted_images? '' . ($this->omitted ? $this->omitted . ' post' . ($this->omitted==1?'':'s') . ($this->omitted_images ? ' and ' : '') :'') . ($this->omitted_images ? $this->omitted_images . ' image repl' . ($this->omitted_images==1?'y':'ies') :'') . ' omitted. Click reply to view.':'') . // End '
'; // Replies foreach($this->posts as &$post) { $built .= $post->build($index); } $built .= '
' . ($this->hr ? '
' : ''); return $built; } }; ?>