= 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 error($message) { global $board; if(function_exists('sql_close')) sql_close(); die(Element('page.html', Array( 'index'=>ROOT, 'title'=>'Error', 'subtitle'=>'An error has occured.', 'body'=>"
" . "

$message

" . (isset($board) ? "

Go back.

" : ''). "
" ))); } function loginForm($error=false, $username=false) { if(function_exists('sql_close')) sql_close(); die(Element('page.html', Array( 'index'=>ROOT, 'title'=>'Login', 'body'=>Element('login.html', Array( 'index'=>ROOT, 'error'=>$error, 'username'=>$username ) ) ))); } function postControls($id, $thread=false) { global $mod; $built = ''; if($mod) { // Mod controls (on posts) if($thread) { $built .= ''; } else { $built .= ''; } // Delete if($mod['type'] >= MOD_DELETE) $built .= ' ' . MOD_LINK_DELETE . ''; // Delete all posts by IP if($mod['type'] >= MOD_DELETEBYIP) $built .= ' ' . MOD_LINK_DELETEBYIP . ''; // Ban if($mod['type'] >= MOD_BAN) $built .= ' ' . MOD_LINK_BAN . ''; // Ban & Delete if($mod['type'] >= MOD_BANDELETE) $built .= ' ' . MOD_LINK_BANDELETE . ''; // Delete file (keep post) if(!$thread && $mod['type'] >= MOD_DELETEFILE) $built .= ' ' . MOD_LINK_DELETEFILE . ''; if($thread) { // Delete file (keep post) if($mod['type'] >= MOD_STICKY) $built .= ' ' . MOD_LINK_STICKY . ''; } $built .= ''; } return $built; } class Post { public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $root=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; } public function build($index=false) { global $board, $mod; $built = '
' . '

'; // Subject if(!empty($this->subject)) $built .= '' . $this->subject . ' '; // Email if(!empty($this->email)) $built .= '' . $this->ip . ']'; } // End email if(!empty($this->email)) $built .= ''; // Date/time $built .= ' ' . date('m/d/y (D) H:i:s', $this->time); $built .= ' No.' . // JavaScript cite ''.$this->id.'' . '

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

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

' . // Thumbnail ''; } $built .= postControls($this->id); // Body $built .= '

' . $this->body . '


'; return $built; } }; 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, $root=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->posts = Array(); $this->ip = $ip; $this->sticky = $sticky; $this->root = $root; } public function add(Post $post) { $this->posts[] = $post; } public function build($index=false) { global $board, $mod; $built = '

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

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

'; // Subject if(!empty($this->subject)) $built .= '' . $this->subject . ' '; // Email if(!empty($this->email)) $built .= '' . $this->ip . ']'; } // End email if(!empty($this->email)) $built .= ''; // Date/time $built .= ' ' . date('m/d/y (D) H:i:s', $this->time); $built .= ' No.' . // JavaScript cite ''.$this->id.'' . // Sticky ($this->sticky ? '' : '') . // [Reply] ($index ? '[Reply]' : '') . // Mod controls postControls($this->id, true) . '

'; // Body $built .= $this->body . // Omitted posts ($this->omitted ? '' . $this->omitted . ' post' . ($this->omitted==1?'':'s') . ' omitted. Click reply to view.':'') . // End '
'; // Replies foreach($this->posts as &$post) { $built .= $post->build($index); } $built .= '

'; return $built; } }; ?>