2009-09-20 02:53:15 +00:00
< ? php
2014-06-24 19:51:22 +00:00
if ( ! defined ( 'TINYIB_BOARD' )) {
die ( '' );
}
2009-09-20 02:53:15 +00:00
2009-09-22 21:29:27 +00:00
function pageHeader () {
2010-12-03 10:11:14 +00:00
$return = <<< EOF
2009-09-22 21:29:27 +00:00
<! DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.01 Transitional//EN " " http://www.w3.org/TR/html4/loose.dtd " >
< html >
< head >
< title >
2010-12-03 10:11:14 +00:00
EOF ;
$return .= TINYIB_BOARDDESC . <<< EOF
2009-09-22 21:29:27 +00:00
</ title >
< link rel = " shortcut icon " href = " favicon.ico " >
< link rel = " stylesheet " type = " text/css " href = " css/global.css " >
< link rel = " stylesheet " type = " text/css " href = " css/futaba.css " title = " Futaba " >
< link rel = " alternate stylesheet " type = " text/css " href = " css/burichan.css " title = " Burichan " >
< meta http - equiv = " content-type " content = " text/html;charset=UTF-8 " >
< meta http - equiv = " pragma " content = " no-cache " >
< meta http - equiv = " expires " content = " -1 " >
</ head >
EOF ;
2010-12-03 10:11:14 +00:00
return $return ;
2009-09-22 21:29:27 +00:00
}
function pageFooter () {
2012-12-28 07:14:41 +00:00
/* If the footer is removed from the page, please link to TinyIB somewhere on the site. */
2009-09-22 21:29:27 +00:00
return <<< EOF
< div class = " footer " >
2010-11-30 01:11:01 +00:00
- < a href = " http://www.2chan.net " target = " _top " > futaba </ a > + < a href = " http://www.1chan.net " target = " _top " > futallaby </ a > + < a href = " https://github.com/tslocum/TinyIB " target = " _top " > tinyib </ a > -
2009-09-22 21:29:27 +00:00
</ div >
</ body >
</ html >
EOF ;
}
2014-07-05 19:27:18 +00:00
function supportedFileTypes () {
$types_allowed = array ();
if ( TINYIB_PIC ) {
array_push ( $types_allowed , " GIF " , " JPG " , " PNG " );
}
if ( TINYIB_SWF ) {
array_push ( $types_allowed , " SWF " );
}
if ( TINYIB_WEBM ) {
array_push ( $types_allowed , " WebM " );
}
$i = 0 ;
$types_count = count ( $types_allowed );
$types_formatted = " " ;
foreach ( $types_allowed as $type ) {
if ( ++ $i >= $types_count - 1 ) {
$types_formatted .= $type . ( $i == $types_count - 1 && $types_count > 1 ? " and " : " " );
} else {
$types_formatted .= $type . " , " ;
}
}
if ( $types_formatted != " " ) {
return " Supported file type " . ( $types_count != 1 ? " s are " : " is " ) . $types_formatted . " . " ;
}
return $types_formatted ;
}
2011-08-07 07:24:39 +00:00
function buildPost ( $post , $res ) {
2009-09-20 02:53:15 +00:00
$return = " " ;
2011-08-07 07:24:39 +00:00
$threadid = ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) ? $post [ 'id' ] : $post [ 'parent' ];
$postlink = ( $res == TINYIB_RESPAGE ) ? ( $threadid . '.html#' . $post [ 'id' ]) : ( 'res/' . $threadid . '.html#' . $post [ 'id' ]);
2014-06-24 19:51:22 +00:00
if ( ! isset ( $post [ " omitted " ])) {
$post [ " omitted " ] = 0 ;
}
2011-08-07 07:24:39 +00:00
if ( $post [ " parent " ] != TINYIB_NEWTHREAD ) {
2009-09-20 02:53:15 +00:00
$return .= <<< EOF
< table >
< tbody >
< tr >
< td class = " doubledash " >
& #0168;
</ td >
< td class = " reply " id = " reply ${ post["id"] } " >
EOF ;
} elseif ( $post [ " file " ] != " " ) {
$return .= <<< EOF
< span class = " filesize " > File : < a href = " src/ ${ post["file"]}">${post["file"]}</a>–(${post["file_size_formatted"] } , ${ post["image_width"]}x${post["image_height"] } , ${ post["file_original"] } )</span>
< br >
< a target = " _blank " href = " src/ ${ post["file"] } " >
< span id = " thumb ${ post['id'] } " >< img src = " thumb/ ${ post["thumb"] } " alt = " ${ post["id"] } " class = " thumb " width = " ${ post["thumb_width"] } " height = " ${ post["thumb_height"] } " ></ span >
</ a >
EOF ;
}
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
$return .= <<< EOF
< a name = " ${ post['id'] } " ></ a >
< label >
< input type = " checkbox " name = " delete " value = " ${ post['id'] } " >
EOF ;
2011-09-06 06:53:37 +00:00
if ( $post [ 'subject' ] != '' ) {
2011-09-08 01:47:10 +00:00
$return .= ' <span class="filetitle">' . $post [ 'subject' ] . '</span> ' ;
2009-09-20 02:53:15 +00:00
}
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
$return .= <<< EOF
$ { post [ " nameblock " ]}
</ label >
< span class = " reflink " >
< a href = " $postlink " > No . $ { post [ " id " ]} </ a >
</ span >
EOF ;
2014-06-24 19:51:22 +00:00
2011-08-07 07:24:39 +00:00
if ( $post [ 'parent' ] != TINYIB_NEWTHREAD && $post [ " file " ] != " " ) {
2009-09-20 02:53:15 +00:00
$return .= <<< EOF
< br >
< span class = " filesize " >< a href = " src/ ${ post["file"]}">${post["file"]}</a>–(${post["file_size_formatted"] } , ${ post["image_width"]}x${post["image_height"] } , ${ post["file_original"] } )</span>
< br >
< a target = " _blank " href = " src/ ${ post["file"] } " >
< span id = " thumb ${ post["id"] } " >< img src = " thumb/ ${ post["thumb"] } " alt = " ${ post["id"] } " class = " thumb " width = " ${ post["thumb_width"] } " height = " ${ post["thumb_height"] } " ></ span >
</ a >
EOF ;
}
2014-06-24 19:51:22 +00:00
2011-08-07 07:24:39 +00:00
if ( $post [ 'parent' ] == TINYIB_NEWTHREAD && $res == TINYIB_INDEXPAGE ) {
2009-09-20 02:53:15 +00:00
$return .= " [<a href= \" res/ ${ post["id"] } .html \" >Reply</a>] " ;
}
2014-06-24 19:51:22 +00:00
2011-09-06 06:53:37 +00:00
if ( TINYIB_TRUNCATE > 0 && ! $res && substr_count ( $post [ 'message' ], '<br>' ) > TINYIB_TRUNCATE ) { // Truncate messages on board index pages for readability
$br_offsets = strallpos ( $post [ 'message' ], '<br>' );
2011-08-07 07:24:39 +00:00
$post [ 'message' ] = substr ( $post [ 'message' ], 0 , $br_offsets [ TINYIB_TRUNCATE - 1 ]);
$post [ 'message' ] .= '<br><span class="omittedposts">Post truncated. Click Reply to view.</span><br>' ;
}
2009-09-20 02:53:15 +00:00
$return .= <<< EOF
2013-06-07 05:39:36 +00:00
< div class = " message " >
2009-09-20 02:53:15 +00:00
$ { post [ " message " ]}
2013-06-07 05:39:36 +00:00
</ div >
2009-09-20 02:53:15 +00:00
EOF ;
2011-08-07 07:24:39 +00:00
if ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) {
2011-09-06 06:53:37 +00:00
if ( $res == TINYIB_INDEXPAGE && $post [ 'omitted' ] > 0 ) {
$return .= '<span class="omittedposts">' . $post [ 'omitted' ] . ' ' . plural ( 'post' , $post [ 'omitted' ]) . ' omitted. Click Reply to view.</span>' ;
2009-09-20 02:53:15 +00:00
}
} else {
$return .= <<< EOF
</ td >
</ tr >
</ tbody >
</ table >
EOF ;
}
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
return $return ;
}
2014-06-24 19:51:22 +00:00
function buildPage ( $htmlposts , $parent , $pages = 0 , $thispage = 0 ) {
2009-09-20 02:53:15 +00:00
$managelink = basename ( $_SERVER [ 'PHP_SELF' ]) . " ?manage " ;
2013-05-15 03:42:56 +00:00
$maxdimensions = TINYIB_MAXWOP . 'x' . TINYIB_MAXHOP ;
if ( TINYIB_MAXW != TINYIB_MAXWOP || TINYIB_MAXH != TINYIB_MAXHOP ) {
$maxdimensions .= ' (new thread) or ' . TINYIB_MAXW . 'x' . TINYIB_MAXH . ' (reply)' ;
}
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
$postingmode = " " ;
$pagenavigator = " " ;
2011-08-07 07:24:39 +00:00
if ( $parent == TINYIB_NEWTHREAD ) {
2009-09-20 04:57:57 +00:00
$pages = max ( $pages , 0 );
2009-09-20 02:53:15 +00:00
$previous = ( $thispage == 1 ) ? " index " : $thispage - 1 ;
$next = $thispage + 1 ;
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
$pagelinks = ( $thispage == 0 ) ? " <td>Previous</td> " : '<td><form method="get" action="' . $previous . '.html"><input value="Previous" type="submit"></form></td>' ;
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
$pagelinks .= " <td> " ;
2014-06-24 19:51:22 +00:00
for ( $i = 0 ; $i <= $pages ; $i ++ ) {
2009-09-20 02:53:15 +00:00
if ( $thispage == $i ) {
$pagelinks .= '[' . $i . '] ' ;
} else {
$href = ( $i == 0 ) ? " index " : $i ;
$pagelinks .= '[<a href="' . $href . '.html">' . $i . '</a>] ' ;
}
}
$pagelinks .= " </td> " ;
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
$pagelinks .= ( $pages <= $thispage ) ? " <td>Next</td> " : '<td><form method="get" action="' . $next . '.html"><input value="Next" type="submit"></form></td>' ;
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
$pagenavigator = <<< EOF
< table border = " 1 " >
< tbody >
< tr >
$pagelinks
</ tr >
</ tbody >
</ table >
EOF ;
} else {
$postingmode = '[<a href="../">Return</a>]<div class="replymode">Posting mode: Reply</div> ' ;
}
2014-06-24 19:51:22 +00:00
2014-07-05 19:27:18 +00:00
$max_file_size_input_html = '' ;
$max_file_size_rules_html = '' ;
$filetypes_html = '' ;
$file_input_html = '' ;
2009-09-20 02:53:15 +00:00
$unique_posts_html = '' ;
2014-07-05 19:27:18 +00:00
if ( TINYIB_PIC || TINYIB_WEBM || TINYIB_SWF ) {
if ( TINYIB_MAXKB > 0 ) {
$max_file_size_input_html = '<input type="hidden" name="MAX_FILE_SIZE" value="' . strval ( TINYIB_MAXKB * 1024 ) . '">' ;
$max_file_size_rules_html = '<li>Maximum file size allowed is ' . TINYIB_MAXKBDESC . '.</li>' ;
}
$filetypes_html = '<li>' . supportedFileTypes () . '</li>' ;
$file_input_html = <<< EOF
< tr >
< td class = " postblock " >
File
</ td >
< td >
< input type = " file " name = " file " size = " 35 " accesskey = " f " >
</ td >
</ tr >
EOF ;
}
$thumbnails_html = '' ;
if ( TINYIB_PIC ) {
$thumbnails_html = " <li>Images greater than $maxdimensions will be thumbnailed.</li> " ;
}
2009-09-20 02:53:15 +00:00
$unique_posts = uniquePosts ();
if ( $unique_posts > 0 ) {
2011-08-07 07:24:39 +00:00
$unique_posts_html = " <li>Currently $unique_posts unique user posts.</li> \n " ;
}
2014-06-24 19:51:22 +00:00
2009-09-22 21:29:27 +00:00
$body = <<< EOF
2009-09-20 02:53:15 +00:00
< body >
< div class = " adminbar " >
2011-08-07 07:24:39 +00:00
[ < a href = " $managelink " style = " text-decoration: underline; " > Manage </ a > ]
2009-09-20 02:53:15 +00:00
</ div >
< div class = " logo " >
2010-12-03 10:11:14 +00:00
EOF ;
2014-06-24 19:51:22 +00:00
$body .= TINYIB_LOGO . TINYIB_BOARDDESC . <<< EOF
2009-09-20 02:53:15 +00:00
</ div >
< hr width = " 90% " size = " 1 " >
$postingmode
< div class = " postarea " >
< form name = " postform " id = " postform " action = " imgboard.php " method = " post " enctype = " multipart/form-data " >
2014-07-05 19:27:18 +00:00
$max_file_size_input_html
2009-09-20 02:53:15 +00:00
< input type = " hidden " name = " parent " value = " $parent " >
< table class = " postform " >
< tbody >
< tr >
< td class = " postblock " >
Name
</ td >
< td >
< input type = " text " name = " name " size = " 28 " maxlength = " 75 " accesskey = " n " >
</ td >
</ tr >
< tr >
< td class = " postblock " >
E - mail
</ td >
< td >
< input type = " text " name = " email " size = " 28 " maxlength = " 75 " accesskey = " e " >
</ td >
</ tr >
< tr >
< td class = " postblock " >
Subject
</ td >
< td >
< input type = " text " name = " subject " size = " 40 " maxlength = " 75 " accesskey = " s " >
< input type = " submit " value = " Submit " accesskey = " z " >
</ td >
</ tr >
< tr >
< td class = " postblock " >
Message
</ td >
< td >
< textarea name = " message " cols = " 48 " rows = " 4 " accesskey = " m " ></ textarea >
</ td >
</ tr >
2014-07-05 19:27:18 +00:00
$file_input_html
2009-09-20 02:53:15 +00:00
< tr >
< td class = " postblock " >
Password
</ td >
< td >
< input type = " password " name = " password " size = " 8 " accesskey = " p " >& nbsp ;( for post and file deletion )
</ td >
</ tr >
< tr >
< td colspan = " 2 " class = " rules " >
2009-09-22 21:29:27 +00:00
< ul >
2014-07-05 19:27:18 +00:00
$filetypes_html
2013-07-31 04:32:55 +00:00
$max_file_size_rules_html
2014-07-05 19:27:18 +00:00
$thumbnails_html
2009-09-20 02:53:15 +00:00
$unique_posts_html
</ ul >
</ td >
</ tr >
</ tbody >
</ table >
</ form >
</ div >
< hr >
< form id = " delform " action = " imgboard.php?delete " method = " post " >
2010-12-03 10:11:14 +00:00
< input type = " hidden " name = " board "
EOF ;
2014-06-24 19:51:22 +00:00
$body .= 'value="' . TINYIB_BOARD . '">' . <<< EOF
2009-09-20 02:53:15 +00:00
$htmlposts
< table class = " userdelete " >
< tbody >
< tr >
< td >
2010-11-30 00:39:46 +00:00
Delete Post < input type = " password " name = " password " size = " 8 " placeholder = " Password " >& nbsp ; < input name = " deletepost " value = " Delete " type = " submit " >
2009-09-20 02:53:15 +00:00
</ td >
</ tr >
</ tbody >
</ table >
</ form >
$pagenavigator
< br >
EOF ;
2009-09-22 21:29:27 +00:00
return pageHeader () . $body . pageFooter ();
2009-09-20 02:53:15 +00:00
}
2014-06-24 19:51:22 +00:00
function rebuildIndexes () {
$page = 0 ;
$i = 0 ;
$htmlposts = '' ;
$threads = allThreads ();
2013-01-13 13:40:34 +00:00
$pages = ceil ( count ( $threads ) / TINYIB_THREADSPERPAGE ) - 1 ;
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
foreach ( $threads as $thread ) {
2013-01-13 10:47:36 +00:00
$replies = postsInThreadByID ( $thread [ 'id' ]);
2013-01-13 13:40:34 +00:00
$thread [ 'omitted' ] = max ( 0 , count ( $replies ) - TINYIB_PREVIEWREPLIES - 1 );
2014-06-24 19:51:22 +00:00
2013-01-17 01:39:45 +00:00
// Build replies for preview
$htmlreplies = array ();
2013-01-13 13:40:34 +00:00
for ( $j = count ( $replies ) - 1 ; $j > $thread [ 'omitted' ]; $j -- ) {
2013-01-17 01:39:45 +00:00
$htmlreplies [] = buildPost ( $replies [ $j ], TINYIB_INDEXPAGE );
2009-09-20 02:53:15 +00:00
}
2014-06-24 19:51:22 +00:00
2013-01-17 01:39:45 +00:00
$htmlposts .= buildPost ( $thread , TINYIB_INDEXPAGE ) . implode ( '' , array_reverse ( $htmlreplies )) . " <br clear= \" left \" > \n <hr> " ;
2014-06-24 19:51:22 +00:00
2013-01-13 13:40:34 +00:00
if ( ++ $i >= TINYIB_THREADSPERPAGE ) {
2011-09-06 06:53:37 +00:00
$file = ( $page == 0 ) ? 'index.html' : $page . '.html' ;
2009-09-20 02:53:15 +00:00
writePage ( $file , buildPage ( $htmlposts , 0 , $pages , $page ));
2014-06-24 19:51:22 +00:00
$page ++ ;
$i = 0 ;
$htmlposts = '' ;
2009-09-20 02:53:15 +00:00
}
}
2014-06-24 19:51:22 +00:00
2011-09-06 06:53:37 +00:00
if ( $page == 0 || $htmlposts != '' ) {
$file = ( $page == 0 ) ? 'index.html' : $page . '.html' ;
2009-09-20 02:53:15 +00:00
writePage ( $file , buildPage ( $htmlposts , 0 , $pages , $page ));
}
}
function rebuildThread ( $id ) {
$htmlposts = " " ;
$posts = postsInThreadByID ( $id );
foreach ( $posts as $post ) {
2011-08-07 07:24:39 +00:00
$htmlposts .= buildPost ( $post , TINYIB_RESPAGE );
2009-09-20 02:53:15 +00:00
}
2014-06-24 19:51:22 +00:00
2011-08-07 07:24:39 +00:00
$htmlposts .= " <br clear= \" left \" > \n <hr> \n " ;
2014-06-24 19:51:22 +00:00
2011-09-06 06:53:37 +00:00
writePage ( 'res/' . $id . '.html' , fixLinksInRes ( buildPage ( $htmlposts , $id )));
2009-09-20 02:53:15 +00:00
}
2009-09-22 21:29:27 +00:00
function adminBar () {
global $loggedin , $isadmin , $returnlink ;
2011-08-07 07:24:39 +00:00
$return = '[<a href="' . $returnlink . '" style="text-decoration: underline;">Return</a>]' ;
2014-06-24 19:51:22 +00:00
if ( ! $loggedin ) {
return $return ;
}
2011-09-06 06:53:37 +00:00
return '[<a href="?manage">Status</a>] [' . (( $isadmin ) ? '<a href="?manage&bans">Bans</a>] [' : '' ) . '<a href="?manage&moderate">Moderate Post</a>] [<a href="?manage&rawpost">Raw Post</a>] [' . (( $isadmin ) ? '<a href="?manage&rebuildall">Rebuild All</a>] [' : '' ) . '<a href="?manage&logout">Log Out</a>] · ' . $return ;
2009-09-20 02:53:15 +00:00
}
2014-06-24 19:51:22 +00:00
function managePage ( $text , $onload = '' ) {
2009-09-22 21:29:27 +00:00
$adminbar = adminBar ();
$body = <<< EOF
2009-09-20 02:53:15 +00:00
< body $onload >
< div class = " adminbar " >
2009-09-22 21:29:27 +00:00
$adminbar
2009-09-20 02:53:15 +00:00
</ div >
< div class = " logo " >
2010-12-03 10:11:14 +00:00
EOF ;
$body .= TINYIB_LOGO . TINYIB_BOARDDESC . <<< EOF
2009-09-20 02:53:15 +00:00
</ div >
< hr width = " 90% " size = " 1 " >
< div class = " replymode " > Manage mode </ div >
$text
< hr >
EOF ;
2009-09-22 21:29:27 +00:00
return pageHeader () . $body . pageFooter ();
2009-09-20 02:53:15 +00:00
}
function manageOnLoad ( $page ) {
switch ( $page ) {
case 'login' :
return ' onload="document.tinyib.password.focus();"' ;
case 'moderate' :
return ' onload="document.tinyib.moderate.focus();"' ;
2011-08-07 07:24:39 +00:00
case 'rawpost' :
2010-06-22 09:26:45 +00:00
return ' onload="document.tinyib.message.focus();"' ;
2009-09-20 02:53:15 +00:00
case 'bans' :
return ' onload="document.tinyib.ip.focus();"' ;
}
}
function manageLogInForm () {
return <<< EOF
< form id = " tinyib " name = " tinyib " method = " post " action = " ?manage " >
< fieldset >
2011-08-07 07:24:39 +00:00
< legend align = " center " > Enter an administrator or moderator password </ legend >
2009-09-22 21:29:27 +00:00
< div class = " login " >
2009-09-20 02:53:15 +00:00
< input type = " password " id = " password " name = " password " >< br >
2011-08-07 07:24:39 +00:00
< input type = " submit " value = " Log In " class = " managebutton " >
2009-09-20 02:53:15 +00:00
</ div >
</ fieldset >
</ form >
< br >
EOF ;
}
function manageBanForm () {
return <<< EOF
< form id = " tinyib " name = " tinyib " method = " post " action = " ?manage&bans " >
< fieldset >
2011-08-07 07:24:39 +00:00
< legend > Ban an IP address </ legend >
2009-09-20 02:53:15 +00:00
< label for = " ip " > IP Address :</ label > < input type = " text " name = " ip " id = " ip " value = " ${ _GET['bans'] } " > < input type = " submit " value = " Submit " class = " managebutton " >< br >
< label for = " expire " > Expire ( sec ) :</ label > < input type = " text " name = " expire " id = " expire " value = " 0 " >& nbsp ; & nbsp ; < small >< a href = " # " onclick = " document.tinyib.expire.value='3600';return false; " > 1 hr </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='86400';return false; " > 1 d </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='172800';return false; " > 2 d </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='604800';return false; " > 1 w </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='1209600';return false; " > 2 w </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='2592000';return false; " > 30 d </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='0';return false; " > never </ a ></ small >< br >
2011-08-07 07:24:39 +00:00
< label for = " reason " > Reason :& nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; </ label > < input type = " text " name = " reason " id = " reason " >& nbsp ; & nbsp ; < small > optional </ small >
2009-09-20 02:53:15 +00:00
< legend >
</ fieldset >
</ form >< br >
EOF ;
}
function manageBansTable () {
$text = '' ;
$allbans = allBans ();
if ( count ( $allbans ) > 0 ) {
$text .= '<table border="1"><tr><th>IP Address</th><th>Set At</th><th>Expires</th><th>Reason Provided</th><th> </th></tr>' ;
foreach ( $allbans as $ban ) {
2011-08-07 07:24:39 +00:00
$expire = ( $ban [ 'expire' ] > 0 ) ? date ( 'y/m/d(D)H:i:s' , $ban [ 'expire' ]) : 'Does not expire' ;
2009-09-20 02:53:15 +00:00
$reason = ( $ban [ 'reason' ] == '' ) ? ' ' : htmlentities ( $ban [ 'reason' ]);
$text .= '<tr><td>' . $ban [ 'ip' ] . '</td><td>' . date ( 'y/m/d(D)H:i:s' , $ban [ 'timestamp' ]) . '</td><td>' . $expire . '</td><td>' . $reason . '</td><td><a href="?manage&bans&lift=' . $ban [ 'id' ] . '">lift</a></td></tr>' ;
}
$text .= '</table>' ;
}
return $text ;
}
function manageModeratePostForm () {
return <<< EOF
< form id = " tinyib " name = " tinyib " method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
< fieldset >
< legend > Moderate a post </ legend >
2011-08-07 07:24:39 +00:00
< div valign = " top " >< label for = " moderate " > Post ID :</ label > < input type = " text " name = " moderate " id = " moderate " > < input type = " submit " value = " Submit " class = " managebutton " ></ div >< br >
2012-12-28 07:14:41 +00:00
< small >< b > Tip :</ b > While browsing the image board , you can easily moderate a post if you are logged in :< br >
Tick the box next to a post and click " Delete " at the bottom of the page with a blank password .</ small >< br >
2009-09-20 02:53:15 +00:00
</ fieldset >
</ form >< br >
EOF ;
}
2011-08-07 07:24:39 +00:00
function manageRawPostForm () {
2013-07-31 04:32:55 +00:00
$max_file_size_input_html = '' ;
if ( TINYIB_MAXKB > 0 ) {
$max_file_size_input_html = '<input type="hidden" name="MAX_FILE_SIZE" value="' . strval ( TINYIB_MAXKB * 1024 ) . '">' ;
}
2014-06-24 19:51:22 +00:00
2010-06-22 09:26:45 +00:00
return <<< EOF
< div class = " postarea " >
< form id = " tinyib " name = " tinyib " method = " post " action = " ? " enctype = " multipart/form-data " >
2011-08-07 07:24:39 +00:00
< input type = " hidden " name = " rawpost " value = " 1 " >
2013-07-31 04:32:55 +00:00
$max_file_size_input_html
2010-06-22 09:26:45 +00:00
< table class = " postform " >
< tbody >
< tr >
< td class = " postblock " >
2012-12-28 07:14:41 +00:00
Reply to
2010-06-22 09:26:45 +00:00
</ td >
< td >
2012-12-28 07:14:41 +00:00
< input type = " text " name = " parent " size = " 28 " maxlength = " 75 " value = " 0 " accesskey = " t " >& nbsp ; 0 to start a new thread
2010-06-22 09:26:45 +00:00
</ td >
</ tr >
< tr >
< td class = " postblock " >
Name
</ td >
< td >
< input type = " text " name = " name " size = " 28 " maxlength = " 75 " accesskey = " n " >
</ td >
</ tr >
< tr >
< td class = " postblock " >
E - mail
</ td >
< td >
< input type = " text " name = " email " size = " 28 " maxlength = " 75 " accesskey = " e " >
</ td >
</ tr >
< tr >
< td class = " postblock " >
Subject
</ td >
< td >
< input type = " text " name = " subject " size = " 40 " maxlength = " 75 " accesskey = " s " >
< input type = " submit " value = " Submit " accesskey = " z " >
</ td >
</ tr >
< tr >
< td class = " postblock " >
Message
</ td >
< td >
< textarea name = " message " cols = " 48 " rows = " 4 " accesskey = " m " ></ textarea >
</ td >
</ tr >
< tr >
< td class = " postblock " >
File
</ td >
< td >
< input type = " file " name = " file " size = " 35 " accesskey = " f " >
</ td >
</ tr >
< tr >
< td class = " postblock " >
Password
</ td >
< td >
< input type = " password " name = " password " size = " 8 " accesskey = " p " >& nbsp ;( for post and file deletion )
</ td >
</ tr >
2011-01-08 01:54:03 +00:00
< tr >
< td colspan = " 2 " class = " rules " >
< ul >
2012-12-28 07:14:41 +00:00
< li > Text entered in the Message field will be posted as is with no formatting applied .</ li >
< li > Line - breaks must be specified with " <br> " .</ li >
2011-01-08 01:54:03 +00:00
</ ul >
</ td >
</ tr >
2010-06-22 09:26:45 +00:00
</ tbody >
</ table >
</ form >
</ div >
EOF ;
}
2009-09-20 02:53:15 +00:00
function manageModeratePost ( $post ) {
global $isadmin ;
$ban = banByIP ( $post [ 'ip' ]);
$ban_disabled = ( ! $ban && $isadmin ) ? '' : ' disabled' ;
2011-08-07 07:24:39 +00:00
$ban_info = ( ! $ban ) ? (( ! $isadmin ) ? 'Only an administrator may ban an IP address.' : ( 'IP address: ' . $post [ " ip " ])) : ( ' A ban record already exists for ' . $post [ 'ip' ]);
$delete_info = ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) ? 'This will delete the entire thread below.' : 'This will delete the post below.' ;
$post_or_thread = ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) ? 'Thread' : 'Post' ;
2014-06-24 19:51:22 +00:00
2011-08-07 07:24:39 +00:00
if ( $post [ " parent " ] == TINYIB_NEWTHREAD ) {
$post_html = " " ;
$posts = postsInThreadByID ( $post [ " id " ]);
foreach ( $posts as $post_temp ) {
$post_html .= buildPost ( $post_temp , TINYIB_INDEXPAGE );
}
} else {
$post_html = buildPost ( $post , TINYIB_INDEXPAGE );
}
2014-06-24 19:51:22 +00:00
2009-09-20 02:53:15 +00:00
return <<< EOF
< fieldset >
2011-08-07 07:24:39 +00:00
< legend > Moderating No . $ { post [ 'id' ]} </ legend >
2009-09-20 02:53:15 +00:00
< fieldset >
2011-08-07 07:24:39 +00:00
< legend > Action </ legend >
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tr >< td align = " right " width = " 50%; " >
2009-09-20 02:53:15 +00:00
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
< input type = " hidden " name = " delete " value = " ${ post['id'] } " >
2011-08-07 07:24:39 +00:00
< input type = " submit " value = " Delete $post_or_thread " class = " managebutton " style = " width: 50%; " >
2009-09-20 02:53:15 +00:00
</ form >
2011-08-07 07:24:39 +00:00
</ td >< td >< small > $delete_info </ small ></ td ></ tr >
< tr >< td align = " right " width = " 50%; " >
2009-09-20 02:53:15 +00:00
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
< input type = " hidden " name = " bans " value = " ${ post['ip'] } " >
2011-08-07 07:24:39 +00:00
< input type = " submit " value = " Ban Poster " class = " managebutton " style = " width: 50%; " $ban_disabled >
2009-09-20 02:53:15 +00:00
</ form >
2011-08-07 07:24:39 +00:00
</ td >< td >< small > $ban_info </ small ></ td ></ tr >
</ table >
</ fieldset >
< fieldset >
< legend > $post_or_thread </ legend >
$post_html
2009-09-20 02:53:15 +00:00
</ fieldset >
</ fieldset >
< br >
EOF ;
}
2011-08-07 07:24:39 +00:00
function manageStatus () {
2013-04-16 02:03:37 +00:00
global $isadmin ;
2011-08-07 07:24:39 +00:00
$threads = countThreads ();
$bans = count ( allBans ());
$info = $threads . ' ' . plural ( 'thread' , $threads ) . ', ' . $bans . ' ' . plural ( 'ban' , $bans );
2014-06-28 08:45:56 +00:00
$output = '' ;
if ( $isadmin && TINYIB_DBMODE == 'mysql' && function_exists ( 'mysqli_connect' )) { // Recommend MySQLi
$output .= <<< EOF
< fieldset >
< legend > Notice </ legend >
< p >< b > TINYIB_DBMODE </ b > is currently < b > mysql </ b > in < b > settings . php </ b > , but < a href = " http://www.php.net/manual/en/book.mysqli.php " > MySQLi </ a > is installed . Please change it to < b > mysqli </ b >. This will not affect your data .</ p >
</ fieldset >
EOF ;
}
2014-06-24 19:51:22 +00:00
2011-08-07 07:24:39 +00:00
$post_html = '' ;
$posts = latestPosts ();
$i = 0 ;
foreach ( $posts as $post ) {
2014-06-24 19:51:22 +00:00
if ( $post_html != '' ) {
$post_html .= '<tr><td colspan="2"><hr></td></tr>' ;
}
2013-04-16 01:53:16 +00:00
$post_html .= '<tr><td>' . buildPost ( $post , TINYIB_INDEXPAGE ) . '</td><td valign="top" align="right"><form method="get" action="?"><input type="hidden" name="manage" value=""><input type="hidden" name="moderate" value="' . $post [ 'id' ] . '"><input type="submit" value="Moderate" class="managebutton"></form></td></tr>' ;
2011-08-07 07:24:39 +00:00
}
2014-06-24 19:51:22 +00:00
2014-06-28 08:45:56 +00:00
$output .= <<< EOF
2011-08-07 07:24:39 +00:00
< fieldset >
< legend > Status </ legend >
< fieldset >
< legend > Info </ legend >
2013-04-16 01:53:16 +00:00
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tbody >
< tr >< td >
$info
</ td >
EOF ;
if ( $isadmin ) {
$output .= <<< EOF
< td valign = " top " align = " right " >
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " >
< input type = " hidden " name = " update " >
< input type = " submit " value = " Update TinyIB " class = " managebutton " >
</ form >
</ td >
EOF ;
}
$output .= <<< EOF
</ tr >
</ tbody >
</ table >
2011-08-07 07:24:39 +00:00
</ fieldset >
< fieldset >
2012-12-28 07:14:41 +00:00
< legend > Recent posts </ legend >
2011-08-07 07:24:39 +00:00
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
$post_html
</ table >
</ fieldset >
</ fieldset >
< br >
EOF ;
2014-06-24 19:51:22 +00:00
2013-04-16 02:55:35 +00:00
return $output ;
2011-08-07 07:24:39 +00:00
}
function manageInfo ( $text ) {
return '<div class="manageinfo">' . $text . '</div>' ;
}