2010-11-02 06:57:33 -04:00
|
|
|
<?php
|
|
|
|
/*
|
2010-11-04 01:58:43 -04:00
|
|
|
Stuff to help with the display.
|
2010-11-02 06:57:33 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
joaoptm78@gmail.com
|
|
|
|
http://www.php.net/manual/en/function.filesize.php#100097
|
|
|
|
*/
|
|
|
|
function format_bytes($size) {
|
|
|
|
$units = array(' B', ' KB', ' MB', ' GB', ' TB');
|
|
|
|
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
|
|
|
|
return round($size, 2).$units[$i];
|
|
|
|
}
|
|
|
|
|
|
|
|
function error($message) {
|
2010-11-04 07:30:23 -04:00
|
|
|
die(Element('page.html', Array('index' => ROOT, 'title'=>'Error', 'subtitle'=>'An error has occured.', 'body'=>"<center><h2>$message</h2></center><p style=\"text-align:center;\"><a href=\"" . ROOT . FILE_INDEX . "\">Go back</a>.</p>")));
|
2010-11-02 06:57:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
class Post {
|
|
|
|
public function __construct($id, $thread, $subject, $email, $name, $trip, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename) {
|
|
|
|
$this->id = $id;
|
|
|
|
$this->thread = $thread;
|
2010-11-03 08:02:15 -04:00
|
|
|
$this->subject = utf8tohtml($subject);
|
2010-11-02 06:57:33 -04:00
|
|
|
$this->email = $email;
|
2010-11-03 08:02:15 -04:00
|
|
|
$this->name = utf8tohtml($name);
|
2010-11-02 06:57:33 -04:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
public function build($index=false) {
|
2010-11-03 12:10:47 -04:00
|
|
|
$built = '<div class="post reply"' . (!$index?' id="reply_' . $this->id . '"':'') . '>' .
|
|
|
|
'<p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>';
|
|
|
|
|
|
|
|
// Subject
|
|
|
|
$built .= '<span class="subject">' . $this->subject . '</span>';
|
|
|
|
// Email
|
|
|
|
if(!empty($this->email))
|
|
|
|
$built .= '<a class="email" href="mailto:' . $this->email . '">';
|
|
|
|
// Name
|
|
|
|
$built .= '<span class="name">' . $this->name . '</span>'
|
|
|
|
// Trip
|
|
|
|
. (!empty($this->trip) ? ' <span class="trip">'.$this->trip.'</span>':'');
|
|
|
|
|
|
|
|
// End email
|
|
|
|
if(!empty($this->email))
|
|
|
|
$built .= '</a>';
|
|
|
|
|
|
|
|
// Date/time
|
|
|
|
$built .= ' ' . date('m/d/y (D) H:i:s', $this->time);
|
|
|
|
|
|
|
|
$built .= ' <a class="post_no"' .
|
|
|
|
// JavaScript highlight
|
|
|
|
($index?'':' onclick="highlightReply(' . $this->id . ');"') .
|
|
|
|
' href="' . ROOT . DIR_RES . $this->thread . '.html' . '#' . $this->id . '">No.</a>' .
|
|
|
|
// JavaScript cite
|
|
|
|
'<a class="post_no"' . ($index?'':'onclick="citeReply(' . $this->id . ');"') . 'href="' . ($index?ROOT . DIR_RES . $this->thread . '.html' . '#q' . $this->id:'javascript:void(0);') . '">'.$this->id.'</a>' .
|
|
|
|
'</p>';
|
|
|
|
|
|
|
|
// File info
|
|
|
|
if(!empty($this->file)) {
|
|
|
|
$built .= '<p class="fileinfo">File: <a href="' . ROOT . $this->file .'">' . basename($this->file) . '</a> <span class="unimportant">(' .
|
|
|
|
// 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 . ')</span></p>' .
|
|
|
|
// Thumbnail
|
|
|
|
'<a href="' . ROOT . $this->file.'"><img src="' . ROOT . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Body
|
|
|
|
$built .= '<p class="body">' . $this->body . '</p></div><br class="clear"/>';
|
|
|
|
|
2010-11-02 06:57:33 -04:00
|
|
|
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) {
|
|
|
|
$this->id = $id;
|
2010-11-03 08:02:15 -04:00
|
|
|
$this->subject = utf8tohtml($subject);
|
2010-11-02 06:57:33 -04:00
|
|
|
$this->email = $email;
|
2010-11-03 08:02:15 -04:00
|
|
|
$this->name = utf8tohtml($name);
|
2010-11-02 06:57:33 -04:00
|
|
|
$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();
|
|
|
|
}
|
|
|
|
public function add(Post $post) {
|
|
|
|
$this->posts[] = $post;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function build($index=false) {
|
2010-11-04 02:16:47 -04:00
|
|
|
$built = '<p class="fileinfo">File: <a href="' . ROOT . $this->file .'">' . basename($this->file) . '</a> <span class="unimportant">(' .
|
|
|
|
// 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 . ')</span></p>' .
|
|
|
|
// Thumbnail
|
|
|
|
'<a href="' . ROOT . $this->file.'"><img src="' . ROOT . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
|
|
|
|
|
|
|
|
$built .= '<div class="post op"><p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>';
|
|
|
|
|
|
|
|
// Subject
|
|
|
|
$built .= '<span class="subject">' . $this->subject . '</span>';
|
|
|
|
// Email
|
|
|
|
if(!empty($this->email))
|
|
|
|
$built .= '<a class="email" href="mailto:' . $this->email . '">';
|
|
|
|
// Name
|
|
|
|
$built .= '<span class="name">' . $this->name . '</span>'
|
|
|
|
// Trip
|
|
|
|
. (!empty($this->trip) ? ' <span class="trip">'.$this->trip.'</span>':'');
|
|
|
|
|
|
|
|
// End email
|
|
|
|
if(!empty($this->email))
|
|
|
|
$built .= '</a>';
|
|
|
|
|
|
|
|
// Date/time
|
|
|
|
$built .= ' ' . date('m/d/y (D) H:i:s', $this->time);
|
|
|
|
|
|
|
|
$built .= ' <a class="post_no"' .
|
|
|
|
// JavaScript highlight
|
|
|
|
($index?'':' onclick="highlightReply(' . $this->id . ');"') .
|
|
|
|
' href="' . ROOT . DIR_RES . $this->id . '.html' . '#' . $this->id . '">No.</a>' .
|
|
|
|
// JavaScript cite
|
|
|
|
'<a class="post_no"' . ($index?'':'onclick="citeReply(' . $this->id . ');"') . 'href="' . ($index?ROOT . DIR_RES . $this->id . '.html' . '#q' . $this->id:'javascript:void(0);') . '">'.$this->id.'</a>' .
|
|
|
|
// [Reply]
|
|
|
|
($index ? '<a href="' . ROOT . DIR_RES . $this->id . '.html">[Reply]</a>' : '') .
|
|
|
|
'</p>';
|
|
|
|
|
|
|
|
// Body
|
|
|
|
$built .= $this->body .
|
|
|
|
|
|
|
|
// Omitted posts
|
|
|
|
($this->omitted ? '<span class="omitted">' . $this->omitted . ' post' . ($this->omitted==1?'':'s') . ' omitted. Click reply to view.</span>':'') .
|
|
|
|
|
|
|
|
// End
|
|
|
|
'</div>';
|
|
|
|
|
|
|
|
// Replies
|
2010-11-02 06:57:33 -04:00
|
|
|
foreach($this->posts as &$post) {
|
|
|
|
$built .= $post->build($index);
|
|
|
|
}
|
2010-11-04 02:16:47 -04:00
|
|
|
|
2010-11-02 06:57:33 -04:00
|
|
|
$built .= '<br class="clear"/><hr/>';
|
|
|
|
return $built;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
?>
|