= 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, $mod; 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 ) ) ))); } 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) { $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; } public function postControls() { $built = ''; if($this->mod) { // Mod controls (on posts) $built .= ''; // Delete if($this->mod['type'] >= MOD_DELETE) $built .= ' ' . MOD_LINK_DELETE . ''; // Delete all posts by IP if($this->mod['type'] >= MOD_DELETEBYIP) $built .= ' ' . MOD_LINK_DELETEBYIP . ''; // Ban if($this->mod['type'] >= MOD_BAN) $built .= ' ' . MOD_LINK_BAN . ''; // Ban & Delete if($this->mod['type'] >= MOD_BANDELETE) $built .= ' ' . MOD_LINK_BANDELETE . ''; // Delete file (keep post) if(!empty($this->file) && $this->mod['type'] >= MOD_DELETEFILE) $built .= ' ' . MOD_LINK_DELETEFILE . ''; $built .= ''; } return $built; } public function build($index=false) { global $board; $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(POST_DATE, $this->time); $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(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 $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) { $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->locked = $locked; $this->root = $root; $this->mod = $mod; } public function add(Post $post) { $this->posts[] = $post; } public function postControls() { $built = ''; if($this->mod) { // Mod controls (on posts) $built .= ''; // Delete if($this->mod['type'] >= MOD_DELETE) $built .= ' ' . MOD_LINK_DELETE . ''; // Delete all posts by IP if($this->mod['type'] >= MOD_DELETEBYIP) $built .= ' ' . MOD_LINK_DELETEBYIP . ''; // Ban if($this->mod['type'] >= MOD_BAN) $built .= ' ' . MOD_LINK_BAN . ''; // Ban & Delete if($this->mod['type'] >= MOD_BANDELETE) $built .= ' ' . MOD_LINK_BANDELETE . ''; // Stickies if($this->mod['type'] >= MOD_STICKY) if($this->sticky) $built .= ' ' . MOD_LINK_DESTICKY . ''; else $built .= ' ' . MOD_LINK_STICKY . ''; // Lock if($this->mod['type'] >= MOD_LOCK) if($this->locked) $built .= ' ' . MOD_LINK_UNLOCK . ''; else $built .= ' ' . MOD_LINK_LOCK . ''; $built .= ''; } return $built; } public function build($index=false) { global $board; $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(POST_DATE, $this->time); $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 . ' post' . ($this->omitted==1?'':'s') . ' omitted. Click reply to view.':'') . // End '
'; // Replies foreach($this->posts as &$post) { $built .= $post->build($index); } $built .= '

'; return $built; } }; ?>