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 () {
2021-03-15 00:16:17 +00:00
if ( TINYIB_BOARDTITLE != '' ) {
$title = TINYIB_BOARDTITLE ;
} else if ( TINYIB_BOARDDESC != '' ) {
$title = TINYIB_BOARDDESC ;
} else {
$title = 'TinyIB' ;
}
2021-03-10 18:45:54 +00:00
$js_captcha = '' ;
2021-07-09 07:22:02 +00:00
if ( TINYIB_CAPTCHA === 'hcaptcha' || TINYIB_REPLYCAPTCHA === 'hcaptcha' || TINYIB_MANAGECAPTCHA === 'hcaptcha' ) {
2021-03-10 18:45:54 +00:00
$js_captcha .= '<script src="https://www.hcaptcha.com/1/api.js" async defer></script>' ;
}
2021-07-09 07:22:02 +00:00
if ( TINYIB_CAPTCHA === 'recaptcha' || TINYIB_REPLYCAPTCHA === 'recaptcha' || TINYIB_MANAGECAPTCHA === 'recaptcha' ) {
2021-03-10 18:45:54 +00:00
$js_captcha .= '<script src="https://www.google.com/recaptcha/api.js" async defer></script>' ;
}
2016-07-19 21:14:54 +00:00
2021-06-03 00:07:31 +00:00
$stylesheets = pageStylesheets ();
2021-03-15 00:16:17 +00:00
return <<< EOF
2015-10-27 04:31:52 +00:00
<! DOCTYPE html >
2009-09-22 21:29:27 +00:00
< html >
< head >
2014-10-17 01:12:52 +00:00
< meta http - equiv = " content-type " content = " text/html;charset=UTF-8 " >
< meta http - equiv = " cache-control " content = " max-age=0 " >
< meta http - equiv = " cache-control " content = " no-cache " >
< meta http - equiv = " expires " content = " 0 " >
< meta http - equiv = " expires " content = " Tue, 01 Jan 1980 1:00:00 GMT " >
< meta http - equiv = " pragma " content = " no-cache " >
2016-06-24 19:53:33 +00:00
< meta name = " viewport " content = " width=device-width,initial-scale=1 " >
2021-03-15 00:16:17 +00:00
< title > $title </ title >
2009-09-22 21:29:27 +00:00
< link rel = " shortcut icon " href = " favicon.ico " >
2021-06-03 00:07:31 +00:00
$stylesheets
2015-08-07 07:01:18 +00:00
< script src = " js/jquery.js " ></ script >
2014-08-23 06:10:10 +00:00
< script src = " js/tinyib.js " ></ script >
2016-07-19 21:14:54 +00:00
$js_captcha
2009-09-22 21:29:27 +00:00
</ head >
EOF ;
}
2021-06-03 00:07:31 +00:00
function pageStylesheets () {
global $tinyib_stylesheets ;
// Global stylesheet
$return = '<link rel="stylesheet" type="text/css" href="css/global.css">' ;
// Default stylesheet
2021-06-03 00:17:06 +00:00
$return .= '<link rel="stylesheet" type="text/css" href="css/' . htmlentities ( TINYIB_DEFAULTSTYLE , ENT_QUOTES ) . '.css" title="' . htmlentities ( $tinyib_stylesheets [ TINYIB_DEFAULTSTYLE ], ENT_QUOTES ) . '" id="mainStylesheet">' ;
2021-06-03 00:07:31 +00:00
// Additional stylesheets
2021-06-03 00:17:06 +00:00
foreach ( $tinyib_stylesheets as $filename => $title ) {
if ( $filename === TINYIB_DEFAULTSTYLE ) {
2021-06-03 00:07:31 +00:00
continue ;
}
2021-06-03 00:17:06 +00:00
$return .= '<link rel="alternate stylesheet" type="text/css" href="css/' . htmlentities ( $filename , ENT_QUOTES ) . '.css" title="' . htmlentities ( $title , ENT_QUOTES ) . '">' ;
2021-06-03 00:07:31 +00:00
}
return $return ;
}
2009-09-22 21:29:27 +00:00
function pageFooter () {
2014-10-27 23:55:58 +00:00
// If the footer link is removed from the page, please link to TinyIB somewhere on the site.
// This is all I ask in return for the free software you are using.
2009-09-22 21:29:27 +00:00
return <<< EOF
< div class = " footer " >
2023-09-24 23:29:34 +00:00
- < a href = " http://www.2chan.net " target = " _blank " > futaba </ a > + < a href = " http://www.1chan.net " target = " _blank " > futallaby </ a > + < a href = " https://code.rocket9labs.com/tslocum/tinyib " target = " _blank " > tinyib </ a > -
2009-09-22 21:29:27 +00:00
</ div >
</ body >
</ html >
EOF ;
}
2014-07-05 19:27:18 +00:00
function supportedFileTypes () {
2016-09-30 07:17:24 +00:00
global $tinyib_uploads ;
if ( empty ( $tinyib_uploads )) {
return " " ;
2014-07-05 19:27:18 +00:00
}
2016-09-30 07:17:24 +00:00
$types_allowed = array_map ( 'strtoupper' , array_unique ( array_column ( $tinyib_uploads , 0 )));
2020-10-22 15:24:11 +00:00
if ( count ( $types_allowed ) == 1 ) {
return sprintf ( __ ( 'Supported file type is %s' ), $types_allowed [ 0 ]);
2020-08-28 23:20:22 +00:00
}
2020-10-22 15:24:11 +00:00
$last_type = array_pop ( $types_allowed );
return sprintf ( __ ( 'Supported file types are %1$s and %2$s.' ), implode ( ', ' , $types_allowed ), $last_type );
2014-07-05 19:27:18 +00:00
}
2021-04-09 15:40:43 +00:00
function _makeLinksClickable ( $matches ) {
if ( ! isset ( $matches [ 1 ])) {
return '' ;
}
2022-03-31 17:45:48 +00:00
$url = cleanQuotes ( $matches [ 1 ]);
$text = $matches [ 1 ];
2021-07-09 02:45:10 +00:00
return '<a href="' . $url . '" target="_blank">' . $text . '</a>' ;
2021-04-09 15:40:43 +00:00
}
2015-08-07 07:01:18 +00:00
function makeLinksClickable ( $text ) {
2021-07-09 02:45:10 +00:00
$text = preg_replace_callback ( '!(((f|ht)tp(s)?://)[-a-zA-Zа -яА-Я()0-9@%\!_+.,~#?&;:|\'/=]+)!i' , '_makeLinksClickable' , $text );
2015-08-07 07:01:18 +00:00
$text = preg_replace ( '/\(\<a href\=\"(.*)\)"\ target\=\"\_blank\">(.*)\)\<\/a>/i' , '(<a href="$1" target="_blank">$2</a>)' , $text );
$text = preg_replace ( '/\<a href\=\"(.*)\."\ target\=\"\_blank\">(.*)\.\<\/a>/i' , '<a href="$1" target="_blank">$2</a>.' , $text );
$text = preg_replace ( '/\<a href\=\"(.*)\,"\ target\=\"\_blank\">(.*)\,\<\/a>/i' , '<a href="$1" target="_blank">$2</a>,' , $text );
return $text ;
}
2021-06-07 02:42:09 +00:00
function buildPostForm ( $parent , $staff_post = false ) {
2018-09-12 21:47:13 +00:00
global $tinyib_hidefieldsop , $tinyib_hidefields , $tinyib_uploads , $tinyib_embeds ;
$hide_fields = $parent == TINYIB_NEWTHREAD ? $tinyib_hidefieldsop : $tinyib_hidefields ;
2018-07-20 23:32:54 +00:00
2018-08-06 23:22:50 +00:00
$postform_extra = array ( 'name' => '' , 'email' => '' , 'subject' => '' , 'footer' => '' );
2020-09-06 16:42:29 +00:00
$input_submit = '<input type="submit" value="' . __ ( 'Submit' ) . '" accesskey="z">' ;
2021-06-07 02:42:09 +00:00
if ( $staff_post || ! in_array ( 'subject' , $hide_fields )) {
2018-08-06 23:22:50 +00:00
$postform_extra [ 'subject' ] = $input_submit ;
} else if ( ! in_array ( 'email' , $hide_fields )) {
$postform_extra [ 'email' ] = $input_submit ;
} else if ( ! in_array ( 'name' , $hide_fields )) {
$postform_extra [ 'name' ] = $input_submit ;
} else if ( ! in_array ( 'email' , $hide_fields )) {
$postform_extra [ 'email' ] = $input_submit ;
} else {
$postform_extra [ 'footer' ] = $input_submit ;
}
2018-07-20 23:32:54 +00:00
$form_action = 'imgboard.php' ;
2018-07-24 23:46:58 +00:00
$form_extra = '<input type="hidden" name="parent" value="' . $parent . '">' ;
2018-07-20 23:32:54 +00:00
$input_extra = '' ;
$rules_extra = '' ;
2021-01-28 23:03:30 +00:00
$maxlen_name = - 1 ;
$maxlen_email = - 1 ;
$maxlen_subject = - 1 ;
$maxlen_message = - 1 ;
if ( TINYIB_MAXNAME > 0 ) {
$maxlen_name = TINYIB_MAXNAME ;
}
if ( TINYIB_MAXEMAIL > 0 ) {
$maxlen_email = TINYIB_MAXEMAIL ;
}
if ( TINYIB_MAXSUBJECT > 0 ) {
$maxlen_subject = TINYIB_MAXSUBJECT ;
}
if ( TINYIB_MAXMESSAGE > 0 ) {
$maxlen_message = TINYIB_MAXMESSAGE ;
}
2021-06-07 02:42:09 +00:00
if ( $staff_post ) {
$txt_raw_html = __ ( 'Raw HTML' );
2021-06-08 19:47:52 +00:00
$txt_enable = __ ( 'Enable' );
2021-06-07 02:42:09 +00:00
$txt_raw_html_info_1 = __ ( 'Text entered in the Message field will be posted as is with no formatting applied.' );
$txt_raw_html_info_2 = __ ( 'Line-breaks must be specified with "<br>".' );
2020-09-01 03:51:14 +00:00
$txt_reply_to = __ ( 'Reply to' );
$txt_new_thread = __ ( '0 to start a new thread' );
2020-08-28 23:20:22 +00:00
2018-07-20 23:32:54 +00:00
$form_action = '?' ;
2021-06-07 02:42:09 +00:00
$form_extra = '<input type="hidden" name="staffpost" value="1">' ;
2018-07-20 23:32:54 +00:00
$input_extra = <<< EOF
2021-06-07 02:42:09 +00:00
< tr >
< td class = " postblock " >
2021-06-08 19:47:52 +00:00
$txt_raw_html
2021-06-07 02:42:09 +00:00
</ td >
< td >
2021-06-08 19:47:52 +00:00
< label >
< input type = " checkbox " name = " raw " value = " 1 " accesskey = " r " >& nbsp ; $txt_enable < br >
& nbsp ; < small > $txt_raw_html_info_1 </ small >< br >
& nbsp ; < small > $txt_raw_html_info_2 </ small >
</ label >
2021-06-07 02:42:09 +00:00
</ td >
</ tr >
2018-07-20 23:32:54 +00:00
< tr >
< td class = " postblock " >
2020-08-28 23:20:22 +00:00
$txt_reply_to
2018-07-20 23:32:54 +00:00
</ td >
< td >
2020-08-28 23:20:22 +00:00
< input type = " text " name = " parent " size = " 28 " maxlength = " 75 " value = " 0 " accesskey = " t " >& nbsp ; $txt_new_thread
2018-07-20 23:32:54 +00:00
</ td >
</ tr >
EOF ;
2021-01-28 23:03:30 +00:00
$maxlen_name = - 1 ;
$maxlen_email = - 1 ;
$maxlen_subject = - 1 ;
$maxlen_message = - 1 ;
2018-07-20 23:32:54 +00:00
}
$max_file_size_input_html = '' ;
$max_file_size_rules_html = '' ;
$reqmod_html = '' ;
$filetypes_html = '' ;
$file_input_html = '' ;
$embed_input_html = '' ;
$unique_posts_html = '' ;
2021-07-09 07:22:02 +00:00
$captcha_setting = $parent == TINYIB_NEWTHREAD ? TINYIB_CAPTCHA : TINYIB_REPLYCAPTCHA ;
2018-07-20 23:32:54 +00:00
$captcha_html = '' ;
2021-07-09 07:22:02 +00:00
if ( $captcha_setting && ! $staff_post ) {
if ( $captcha_setting === 'hcaptcha' ) {
2021-03-10 18:45:54 +00:00
$captcha_inner_html = '
< div style = " min-height: 82px; " >
< div class = " h-captcha " data - sitekey = " ' . TINYIB_HCAPTCHA_SITE . ' " ></ div >
</ div > ' ;
2021-07-09 07:22:02 +00:00
} else if ( $captcha_setting === 'recaptcha' ) {
2018-07-20 23:32:54 +00:00
$captcha_inner_html = '
< div style = " min-height: 80px; " >
< div class = " g-recaptcha " data - sitekey = " ' . TINYIB_RECAPTCHA_SITE . ' " ></ div >
< noscript >
< div >
< div style = " width: 302px; height: 422px; position: relative; " >
< div style = " width: 302px; height: 422px; position: absolute; " >
< iframe src = " https://www.google.com/recaptcha/api/fallback?k=' . TINYIB_RECAPTCHA_SITE . ' " frameborder = " 0 " scrolling = " no " style = " width: 302px; height:422px; border-style: none; " ></ iframe >
</ div >
</ div >
< div style = " width: 300px; height: 60px; border-style: none;bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px;background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; " >
< textarea id = " g-recaptcha-response " name = " g-recaptcha-response " class = " g-recaptcha-response " style = " width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px; padding: 0px; resize: none; " ></ textarea >
</ div >
</ div >
</ noscript >
</ div > ' ;
} else { // Simple CAPTCHA
$captcha_inner_html = '
2020-09-01 03:51:14 +00:00
< input type = " text " name = " captcha " id = " captcha " size = " 6 " accesskey = " c " autocomplete = " off " >& nbsp ; & nbsp ; ' . __(' ( enter the text below ) ') . ' < br >
2018-07-20 23:32:54 +00:00
< img id = " captchaimage " src = " inc/captcha.php " width = " 175 " height = " 55 " alt = " CAPTCHA " onclick = " javascript:reloadCAPTCHA() " style = " margin-top: 5px;cursor: pointer; " > ' ;
}
2020-09-01 03:51:14 +00:00
$txt_captcha = __ ( 'CAPTCHA' );
2018-07-20 23:32:54 +00:00
$captcha_html = <<< EOF
< tr >
< td class = " postblock " >
2020-08-28 23:20:22 +00:00
$txt_captcha
2018-07-20 23:32:54 +00:00
</ td >
< td >
$captcha_inner_html
</ td >
</ tr >
EOF ;
}
2021-06-07 02:42:09 +00:00
if ( ! empty ( $tinyib_uploads ) && ( $staff_post || ! in_array ( 'file' , $hide_fields ))) {
2018-07-20 23:32:54 +00:00
if ( TINYIB_MAXKB > 0 ) {
$max_file_size_input_html = '<input type="hidden" name="MAX_FILE_SIZE" value="' . strval ( TINYIB_MAXKB * 1024 ) . '">' ;
2020-09-01 03:51:14 +00:00
$max_file_size_rules_html = '<li>' . sprintf ( __ ( 'Maximum file size allowed is %s.' ), TINYIB_MAXKBDESC ) . '</li>' ;
2018-07-20 23:32:54 +00:00
}
$filetypes_html = '<li>' . supportedFileTypes () . '</li>' ;
2020-09-01 03:51:14 +00:00
$txt_file = __ ( 'File' );
2021-05-08 06:16:43 +00:00
$spoiler_html = '' ;
if ( TINYIB_SPOILERIMAGE ) {
$spoiler_html = '<label><input type="checkbox" name="spoiler" value="1"> Spoiler</label>' ;
}
2018-07-20 23:32:54 +00:00
$file_input_html = <<< EOF
< tr >
< td class = " postblock " >
2020-08-28 23:20:22 +00:00
$txt_file
2018-07-20 23:32:54 +00:00
</ td >
< td >
< input type = " file " name = " file " size = " 35 " accesskey = " f " >
2021-05-08 06:16:43 +00:00
$spoiler_html
2018-07-20 23:32:54 +00:00
</ td >
</ tr >
EOF ;
}
2021-06-07 02:42:09 +00:00
$embeds_enabled = ( ! empty ( $tinyib_embeds ) || TINYIB_UPLOADVIAURL ) && ( $staff_post || ! in_array ( 'embed' , $hide_fields ));
2020-12-06 02:02:24 +00:00
if ( $embeds_enabled ) {
2020-09-01 03:51:14 +00:00
$txt_embed = __ ( 'Embed' );
2020-10-08 18:02:25 +00:00
$txt_embed_help = '' ;
if ( $embeds_enabled ) {
$txt_embed_help = __ ( '(paste a YouTube URL)' );
}
2018-07-20 23:32:54 +00:00
$embed_input_html = <<< EOF
< tr >
< td class = " postblock " >
2020-08-28 23:20:22 +00:00
$txt_embed
2018-07-20 23:32:54 +00:00
</ td >
< td >
2020-08-28 23:20:22 +00:00
< input type = " text " name = " embed " size = " 28 " accesskey = " x " autocomplete = " off " >& nbsp ; & nbsp ; $txt_embed_help
2018-07-20 23:32:54 +00:00
</ td >
</ tr >
EOF ;
}
2020-10-08 18:02:25 +00:00
if ( TINYIB_REQMOD == 'all' ) {
$reqmod_html = '<li>' . __ ( 'All posts are moderated before being shown.' ) . '</li>' ;
} else if ( TINYIB_REQMOD == 'files' ) {
$reqmod_html = '<li>' . __ ( 'All posts with a file attached are moderated before being shown.' ) . '</li>' ;
}
2018-07-20 23:32:54 +00:00
$thumbnails_html = '' ;
if ( isset ( $tinyib_uploads [ 'image/jpeg' ]) || isset ( $tinyib_uploads [ 'image/pjpeg' ]) || isset ( $tinyib_uploads [ 'image/png' ]) || isset ( $tinyib_uploads [ 'image/gif' ])) {
$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)' ;
}
2020-09-01 03:51:14 +00:00
$thumbnails_html = '<li>' . sprintf ( __ ( 'Images greater than %s will be thumbnailed.' ), $maxdimensions ) . '</li>' ;
2018-07-20 23:32:54 +00:00
}
$unique_posts = uniquePosts ();
if ( $unique_posts > 0 ) {
2020-10-08 18:02:25 +00:00
$unique_posts_html = '<li>' . sprintf ( __ ( 'Currently %s unique user posts.' ), $unique_posts ) . '</li>' . " \n " ;
2018-07-20 23:32:54 +00:00
}
2018-08-01 17:05:25 +00:00
$output = <<< EOF
2018-07-20 23:32:54 +00:00
< div class = " postarea " >
< form name = " postform " id = " postform " action = " $form_action " method = " post " enctype = " multipart/form-data " >
$max_file_size_input_html
$form_extra
< table class = " postform " >
< tbody >
$input_extra
2018-08-01 17:05:25 +00:00
EOF ;
2021-06-07 02:42:09 +00:00
if ( $staff_post || ! in_array ( 'name' , $hide_fields )) {
2020-09-01 03:51:14 +00:00
$txt_name = __ ( 'Name' );
2018-08-01 17:05:25 +00:00
$output .= <<< EOF
2018-07-20 23:32:54 +00:00
< tr >
< td class = " postblock " >
2020-08-28 23:20:22 +00:00
$txt_name
2018-07-20 23:32:54 +00:00
</ td >
< td >
2021-01-28 23:03:30 +00:00
< input type = " text " name = " name " size = " 28 " maxlength = " { $maxlen_name } " accesskey = " n " >
2018-08-06 23:22:50 +00:00
{ $postform_extra [ 'name' ]}
2018-07-20 23:32:54 +00:00
</ td >
</ tr >
2018-08-01 17:05:25 +00:00
EOF ;
}
2021-06-07 02:42:09 +00:00
if ( $staff_post || ! in_array ( 'email' , $hide_fields )) {
2020-09-01 03:51:14 +00:00
$txt_email = __ ( 'E-mail' );
2018-08-01 17:05:25 +00:00
$output .= <<< EOF
2018-07-20 23:32:54 +00:00
< tr >
< td class = " postblock " >
2020-08-28 23:20:22 +00:00
$txt_email
2018-07-20 23:32:54 +00:00
</ td >
< td >
2021-01-28 23:03:30 +00:00
< input type = " text " name = " email " size = " 28 " maxlength = " { $maxlen_email } " accesskey = " e " >
2018-08-06 23:22:50 +00:00
{ $postform_extra [ 'email' ]}
2018-07-20 23:32:54 +00:00
</ td >
</ tr >
2018-08-01 17:05:25 +00:00
EOF ;
}
2021-06-07 02:42:09 +00:00
if ( $staff_post || ! in_array ( 'subject' , $hide_fields )) {
2020-09-01 03:51:14 +00:00
$txt_subject = __ ( 'Subject' );
2018-08-01 17:05:25 +00:00
$output .= <<< EOF
2018-07-20 23:32:54 +00:00
< tr >
< td class = " postblock " >
2020-08-28 23:20:22 +00:00
$txt_subject
2018-07-20 23:32:54 +00:00
</ td >
< td >
2021-01-28 23:03:30 +00:00
< input type = " text " name = " subject " size = " 40 " maxlength = " { $maxlen_subject } " accesskey = " s " autocomplete = " off " >
2018-08-06 23:22:50 +00:00
{ $postform_extra [ 'subject' ]}
2018-07-20 23:32:54 +00:00
</ td >
</ tr >
2018-08-01 17:05:25 +00:00
EOF ;
}
2021-06-07 02:42:09 +00:00
if ( $staff_post || ! in_array ( 'message' , $hide_fields )) {
2020-09-01 03:51:14 +00:00
$txt_message = __ ( 'Message' );
2018-08-01 17:05:25 +00:00
$output .= <<< EOF
2018-07-20 23:32:54 +00:00
< tr >
< td class = " postblock " >
2020-08-28 23:20:22 +00:00
$txt_message
2018-07-20 23:32:54 +00:00
</ td >
< td >
2021-01-28 23:03:30 +00:00
< textarea id = " message " name = " message " cols = " 48 " rows = " 4 " maxlength = " { $maxlen_message } " accesskey = " m " ></ textarea >
2018-07-20 23:32:54 +00:00
</ td >
</ tr >
2018-08-01 17:05:25 +00:00
EOF ;
}
$output .= <<< EOF
2018-07-20 23:32:54 +00:00
$captcha_html
$file_input_html
$embed_input_html
2018-08-01 17:05:25 +00:00
EOF ;
2021-06-07 02:42:09 +00:00
if ( $staff_post || ! in_array ( 'password' , $hide_fields )) {
2020-09-01 03:51:14 +00:00
$txt_password = __ ( 'Password' );
$txt_password_help = __ ( '(for post and file deletion)' );
2018-08-01 17:05:25 +00:00
$output .= <<< EOF
2018-07-20 23:32:54 +00:00
< tr >
< td class = " postblock " >
2020-08-28 23:20:22 +00:00
$txt_password
2018-07-20 23:32:54 +00:00
</ td >
< td >
2020-08-28 23:20:22 +00:00
< input type = " password " name = " password " id = " newpostpassword " size = " 8 " accesskey = " p " >& nbsp ; & nbsp ; $txt_password_help
2018-07-20 23:32:54 +00:00
</ td >
</ tr >
2018-08-06 23:22:50 +00:00
EOF ;
}
if ( $postform_extra [ 'footer' ] != '' ) {
$output .= <<< EOF
< tr >
< td >
& nbsp ;
</ td >
< td >
{ $postform_extra [ 'footer' ]}
</ td >
</ tr >
2018-08-01 17:05:25 +00:00
EOF ;
}
$output .= <<< EOF
2018-07-20 23:32:54 +00:00
< tr >
< td colspan = " 2 " class = " rules " >
$rules_extra
< ul >
$reqmod_html
$filetypes_html
$max_file_size_rules_html
$thumbnails_html
$unique_posts_html
</ ul >
</ td >
</ tr >
</ tbody >
</ table >
</ form >
</ div >
EOF ;
2018-08-01 17:05:25 +00:00
return $output ;
2018-07-20 23:32:54 +00:00
}
2021-06-03 06:04:59 +00:00
function backlinks ( $post ) {
if ( ! TINYIB_BACKLINKS ) {
return '' ;
}
2021-06-04 00:57:10 +00:00
$posts = postsInThreadByID ( getParent ( $post ));
2021-06-03 06:04:59 +00:00
$needle = '>>' . $post [ 'id' ];
$return = '' ;
2021-06-04 00:57:10 +00:00
foreach ( $posts as $reply ) {
2021-06-03 06:04:59 +00:00
if ( strpos ( $reply [ 'message' ], $needle ) !== false ) {
if ( $return != '' ) {
$return .= ', ' ;
}
$return .= postLink ( '>>' . $reply [ 'id' ]);
}
}
if ( $return != '' ) {
$return = ' ' . $return ;
}
2021-06-11 07:31:40 +00:00
return ' <small><span id="backlinks' . $post [ 'id' ] . '" class="backlinks">' . $return . '</span></small>' ;
2021-06-03 06:04:59 +00:00
}
function buildPost ( $post , $res , $compact = false ) {
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' ];
2014-08-23 06:10:10 +00:00
2020-11-13 20:53:14 +00:00
if ( TINYIB_REPORT ) {
$reflink = '<a href="imgboard.php?report=' . $post [ 'id' ] . '" title="' . __ ( 'Report' ) . '">R</a> ' ;
} else {
$reflink = '' ;
}
2014-08-23 06:10:10 +00:00
if ( $res == TINYIB_RESPAGE ) {
2020-11-13 20:53:14 +00:00
$reflink .= " <a href= \" $threadid .html# { $post [ 'id' ] } \" >No.</a><a href= \" $threadid .html#q { $post [ 'id' ] } \" onclick= \" javascript:quotePost(' { $post [ 'id' ] } ') \" > { $post [ 'id' ] } </a> " ;
2014-08-23 06:10:10 +00:00
} else {
2020-11-13 20:53:14 +00:00
$reflink .= " <a href= \" res/ $threadid .html# { $post [ 'id' ] } \" >No.</a><a href= \" res/ $threadid .html#q { $post [ 'id' ] } \" > { $post [ 'id' ] } </a> " ;
2014-08-23 06:10:10 +00:00
}
2015-08-21 07:45:01 +00:00
if ( $post [ " stickied " ] == 1 ) {
2020-10-01 20:45:48 +00:00
$reflink .= ' <img src="sticky.png" alt="' . __ ( 'Stickied' ) . '" title="' . __ ( 'Stickied' ) . '" width="16" height="16">' ;
2015-08-21 07:45:01 +00:00
}
2020-07-31 23:16:37 +00:00
if ( $post [ " locked " ] == 1 ) {
2020-10-01 20:45:48 +00:00
$reflink .= ' <img src="lock.png" alt="' . __ ( 'Locked' ) . '" title="' . __ ( 'Locked' ) . '" width="16" height="16">' ;
2020-07-31 23:16:37 +00:00
}
2014-06-24 19:51:22 +00:00
if ( ! isset ( $post [ " omitted " ])) {
$post [ " omitted " ] = 0 ;
}
2016-09-22 00:47:58 +00:00
$filehtml = '' ;
$filesize = '' ;
$expandhtml = '' ;
2016-09-24 03:59:09 +00:00
$direct_link = isEmbed ( $post [ " file_hex " ]) ? " # " : (( $res == TINYIB_RESPAGE ? " ../ " : " " ) . " src/ " . $post [ " file " ]);
2016-09-22 00:47:58 +00:00
if ( $post [ 'parent' ] == TINYIB_NEWTHREAD && $post [ " file " ] != '' ) {
2021-08-05 18:20:51 +00:00
$filesize .= ( isEmbed ( $post [ 'file_hex' ]) ? __ ( 'Embed' ) : __ ( 'File' )) . ': ' ;
2016-09-22 00:47:58 +00:00
}
2021-05-04 07:06:20 +00:00
$w = TINYIB_EXPANDWIDTH ;
2016-09-22 00:47:58 +00:00
if ( isEmbed ( $post [ " file_hex " ])) {
$expandhtml = $post [ 'file' ];
2020-06-02 23:14:44 +00:00
} else if ( substr ( $post [ 'file' ], - 5 ) == '.webm' || substr ( $post [ 'file' ], - 4 ) == '.mp4' ) {
2016-09-24 03:59:09 +00:00
$dimensions = 'width="500" height="50"' ;
if ( $post [ 'image_width' ] > 0 && $post [ 'image_height' ] > 0 ) {
$dimensions = 'width="' . $post [ 'image_width' ] . '" height="' . $post [ 'image_height' ] . '"' ;
}
2016-09-30 07:17:24 +00:00
$expandhtml = <<< EOF
2021-05-05 00:12:44 +00:00
< video $dimensions style = " position: static; pointer-events: inherit; display: inline; max-width: { $w } vw; height: auto; max-height: 100%; " controls autoplay loop >
2016-09-24 03:59:09 +00:00
< source src = " $direct_link " ></ source >
</ video >
EOF ;
2016-09-30 07:17:24 +00:00
} else if ( in_array ( substr ( $post [ 'file' ], - 4 ), array ( '.jpg' , '.png' , '.gif' ))) {
2023-09-25 06:03:43 +00:00
$expandhtml = " <a href= \" $direct_link\ " onclick = \ " return expandFile(event, ' { $post [ 'id' ] } '); \" ><img src= \" " . ( $res == TINYIB_RESPAGE ? " ../ " : " " ) . " src/ { $post [ " file " ] } \" width= \" { $post [ " image_width " ] } \" style= \" min-width: { $post [ " thumb_width " ] } px;min-height: { $post [ " thumb_height " ] } px;max-width: { $w } vw;height: auto; \" ></a> " ;
2016-09-22 00:47:58 +00:00
}
2023-01-05 18:27:06 +00:00
$thumblink = " <a href= \" $direct_link\ " target = \ " _blank \" " . (( isEmbed ( $post [ " file_hex " ]) || in_array ( substr ( $post [ 'file' ], - 4 ), array ( '.jpg' , '.png' , '.gif' , 'webm' , '.mp4' ))) ? " onclick= \" return expandFile(event, ' { $post [ 'id' ] } '); \" " : " " ) . " > " ;
2016-09-22 00:47:58 +00:00
$expandhtml = rawurlencode ( $expandhtml );
if ( isEmbed ( $post [ " file_hex " ])) {
2023-01-05 18:27:06 +00:00
$filesize .= " <a href= \" $direct_link\ " onclick = \ " return expandFile(event, ' { $post [ 'id' ] } '); \" > { $post [ 'file_original' ] } </a>–( { $post [ 'file_hex' ] } ) " ;
2016-09-22 00:47:58 +00:00
} else if ( $post [ " file " ] != '' ) {
2023-01-05 18:27:06 +00:00
$filesize .= $thumblink . " { $post [ " file " ] } </a>–( { $post [ " file_size_formatted " ] } " ;
2016-09-24 03:59:09 +00:00
if ( $post [ " image_width " ] > 0 && $post [ " image_height " ] > 0 ) {
$filesize .= " , " . $post [ " image_width " ] . " x " . $post [ " image_height " ];
}
if ( $post [ " file_original " ] != " " ) {
$filesize .= " , " . $post [ " file_original " ];
}
$filesize .= " ) " ;
2016-09-22 00:47:58 +00:00
}
if ( $filesize != '' ) {
$filesize = '<span class="filesize">' . $filesize . '</span>' ;
2015-08-07 07:01:18 +00:00
}
2016-09-22 00:47:58 +00:00
if ( $filesize != '' ) {
if ( $post [ 'parent' ] != TINYIB_NEWTHREAD ) {
$filehtml .= '<br>' ;
}
2016-09-24 03:59:09 +00:00
$filehtml .= $filesize . '<br><div id="thumbfile' . $post [ 'id' ] . '">' ;
if ( $post [ " thumb_width " ] > 0 && $post [ " thumb_height " ] > 0 ) {
$filehtml .= <<< EOF
2016-09-22 00:47:58 +00:00
$thumblink
2023-01-05 18:27:06 +00:00
< img src = " thumb/ { $post [ " thumb " ] } " alt = " { $post [ " id " ] } " class = " thumb " id = " thumbnail { $post [ 'id' ] } " width = " { $post [ " thumb_width " ] } " height = " { $post [ " thumb_height " ] } " >
2016-09-22 00:47:58 +00:00
</ a >
EOF ;
2016-09-24 03:59:09 +00:00
}
$filehtml .= '</div>' ;
2016-09-22 00:47:58 +00:00
if ( $expandhtml != '' ) {
$filehtml .= <<< EOF
2023-01-05 18:27:06 +00:00
< div id = " expand { $post [ 'id' ] } " style = " display: none; " > $expandhtml </ div >
< div id = " file { $post [ 'id' ] } " class = " thumb " style = " display: none; " ></ div >
2016-09-22 00:47:58 +00:00
EOF ;
}
}
2020-10-22 16:05:49 +00:00
if ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) {
2021-06-03 06:04:59 +00:00
$return .= '<div id="post' . $post [ 'id' ] . '" class="op">' ;
2016-09-22 00:47:58 +00:00
$return .= $filehtml ;
} else {
2021-06-03 06:04:59 +00:00
if ( $compact ) {
$return .= '<div id="' . $post [ 'id' ] . '" class="' . ( $post [ 'parent' ] == TINYIB_NEWTHREAD ? 'op' : 'reply' ) . '">' ;
} else {
$return .= <<< EOF
2009-09-20 02:53:15 +00:00
< table >
< tbody >
< tr >
< td class = " doubledash " >
& #0168;
</ td >
2023-01-05 18:27:06 +00:00
< td class = " reply " id = " post { $post [ " id " ] } " >
2009-09-20 02:53:15 +00:00
EOF ;
2021-06-03 06:04:59 +00:00
}
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
2023-01-05 18:27:06 +00:00
< a id = " { $post [ 'id' ] } " ></ a >
2009-09-20 02:53:15 +00:00
< label >
2023-01-05 18:27:06 +00:00
< input type = " checkbox " name = " delete[] " value = " { $post [ 'id' ] } " >
2009-09-20 02:53:15 +00:00
EOF ;
2011-09-06 06:53:37 +00:00
if ( $post [ 'subject' ] != '' ) {
2016-09-22 00:47:58 +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
2023-01-05 18:27:06 +00:00
{ $post [ " nameblock " ]}
2009-09-20 02:53:15 +00:00
</ label >
< span class = " reflink " >
2014-08-23 06:10:10 +00:00
$reflink
2009-09-20 02:53:15 +00:00
</ span >
EOF ;
2014-06-24 19:51:22 +00:00
2021-06-03 06:04:59 +00:00
if ( $post [ 'parent' ] != TINYIB_NEWTHREAD ) {
$return .= backlinks ( $post );
}
2015-08-07 07:01:18 +00:00
if ( $post [ 'parent' ] != TINYIB_NEWTHREAD ) {
2016-09-22 00:47:58 +00:00
$return .= $filehtml ;
2009-09-20 02:53:15 +00:00
}
2014-06-24 19:51:22 +00:00
2021-06-03 06:04:59 +00:00
if ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) {
if ( $res == TINYIB_INDEXPAGE ) {
2023-01-05 18:27:06 +00:00
$return .= " [<a href= \" res/ { $post [ " id " ] } .html \" > " . __ ( " Reply " ) . " </a>] " ;
2021-06-03 06:04:59 +00:00
}
$return .= backlinks ( $post );
2009-09-20 02:53:15 +00:00
}
2014-06-24 19:51:22 +00:00
2023-09-24 21:17:24 +00:00
if ( TINYIB_TRUNCATE > 0 && ! $res && _substr_count ( $post [ 'message' ], '<br>' ) > TINYIB_TRUNCATE ) { // Truncate messages on board index pages for readability
2011-09-06 06:53:37 +00:00
$br_offsets = strallpos ( $post [ 'message' ], '<br>' );
2023-09-24 21:17:24 +00:00
$post [ 'message' ] = _substr ( $post [ 'message' ], 0 , $br_offsets [ TINYIB_TRUNCATE - 1 ]);
2020-10-01 20:45:48 +00:00
$post [ 'message' ] .= '<br><span class="omittedposts">' . __ ( 'Post truncated. Click Reply to view.' ) . '</span><br>' ;
2011-08-07 07:24:39 +00:00
}
2009-09-20 02:53:15 +00:00
$return .= <<< EOF
2013-06-07 05:39:36 +00:00
< div class = " message " >
2023-01-05 18:27:06 +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 ) {
2021-06-03 06:04:59 +00:00
$return .= '</div>' ;
2011-09-06 06:53:37 +00:00
if ( $res == TINYIB_INDEXPAGE && $post [ 'omitted' ] > 0 ) {
2020-08-28 23:20:22 +00:00
if ( $post [ 'omitted' ] == 1 ) {
2020-09-01 03:51:14 +00:00
$return .= '<span class="omittedposts">' . __ ( '1 post omitted. Click Reply to view.' ) . '</span>' ;
2020-08-28 23:20:22 +00:00
} else {
2020-09-01 03:51:14 +00:00
$return .= '<span class="omittedposts">' . sprintf ( __ ( '%d posts omitted. Click Reply to view.' ), $post [ 'omitted' ]) . '</span>' ;
2020-08-28 23:20:22 +00:00
}
2009-09-20 02:53:15 +00:00
}
2021-06-03 06:04:59 +00:00
} else if ( $compact ) {
$return .= '</div>' ;
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 ;
}
2021-03-13 08:39:08 +00:00
function buildPage ( $htmlposts , $parent , $pages = 0 , $thispage = 0 , $lastpostid = 0 ) {
2021-06-03 00:07:31 +00:00
global $tinyib_stylesheets ;
2020-09-01 03:51:14 +00:00
$cataloglink = TINYIB_CATALOG ? ( '[<a href="catalog.html" style="text-decoration: underline;">' . __ ( 'Catalog' ) . '</a>]' ) : '' ;
2021-03-14 02:49:09 +00:00
$managelink = ( TINYIB_MANAGEKEY == '' ) ? ( '[<a href="' . basename ( $_SERVER [ 'PHP_SELF' ]) . '?manage"" style="text-decoration: underline;">' . __ ( 'Manage' ) . '</a>]' ) : '' ;
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
2020-09-01 03:51:14 +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
2020-09-01 03:51:14 +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
2020-08-11 13:01:00 +00:00
< table border = " 1 " style = " display: inline-block; " >
2009-09-20 02:53:15 +00:00
< tbody >
< tr >
$pagelinks
</ tr >
</ tbody >
</ table >
EOF ;
2020-08-11 13:01:00 +00:00
if ( TINYIB_CATALOG ) {
2020-09-06 16:42:29 +00:00
$txt_catalog = __ ( 'Catalog' );
2020-08-11 13:01:00 +00:00
$pagenavigator .= <<< EOF
< table border = " 1 " style = " display: inline-block;margin-left: 21px; " >
< tbody >
< tr >
2020-09-06 16:42:29 +00:00
< td >< form method = " get " action = " catalog.html " >< input value = " $txt_catalog " type = " submit " ></ form ></ td >
2020-08-11 13:01:00 +00:00
</ tr >
</ tbody >
</ table >
EOF ;
}
} else if ( $parent == - 1 ) {
2020-09-06 16:42:29 +00:00
$postingmode = '[<a href="index.html">' . __ ( 'Return' ) . '</a>]<div class="replymode">' . __ ( 'Catalog' ) . '</div> ' ;
2009-09-20 02:53:15 +00:00
} else {
2020-09-06 16:42:29 +00:00
$postingmode = '[<a href="../">' . __ ( 'Return' ) . '</a>]<div class="replymode">' . __ ( 'Posting mode: Reply' ) . '</div> ' ;
2009-09-20 02:53:15 +00:00
}
2014-06-24 19:51:22 +00:00
2020-08-11 13:01:00 +00:00
$postform = '' ;
2021-03-13 08:39:08 +00:00
if ( $parent >= 0 ) { // Negative values indicate the post form should be hidden
$postform = buildPostForm ( $parent ) . '<hr>' ;
}
2021-06-03 06:04:59 +00:00
$js = '<script type="text/javascript">' ;
$js .= 'var enablebacklinks = ' . ( TINYIB_BACKLINKS ? 'true' : 'false' ) . ';' ;
2021-03-13 08:39:08 +00:00
if ( $parent != TINYIB_NEWTHREAD && TINYIB_AUTOREFRESH > 0 ) {
2021-06-03 06:04:59 +00:00
$js .= 'var autoRefreshDelay = ' . TINYIB_AUTOREFRESH . ';' ;
$js .= 'var autoRefreshThreadID = ' . $parent . ';' ;
$js .= 'var autoRefreshPostID = ' . $lastpostid . ';' ;
2020-08-11 13:01:00 +00:00
}
2021-06-03 06:04:59 +00:00
$js .= '</script>' ;
2014-06-24 19:51:22 +00:00
2020-09-01 03:51:14 +00:00
$txt_style = __ ( 'Style' );
2020-09-06 16:42:29 +00:00
$txt_password = __ ( 'Password' );
$txt_delete = __ ( 'Delete' );
$txt_delete_post = __ ( 'Delete Post' );
2021-06-03 00:07:31 +00:00
2021-06-03 00:17:06 +00:00
$select_style = '' ;
2021-06-03 00:07:31 +00:00
if ( count ( $tinyib_stylesheets ) > 1 ) {
2021-06-03 00:17:06 +00:00
$select_style = '<select id="switchStylesheet">' ;
2021-06-03 00:07:31 +00:00
2021-06-03 00:17:06 +00:00
$select_style .= '<option value="">' . $txt_style . '</option>' ;
foreach ( $tinyib_stylesheets as $filename => $title ) {
$select_style .= '<option value="' . htmlentities ( $filename , ENT_QUOTES ) . '">' . htmlentities ( $title ) . '</option>' ;
2021-06-03 00:07:31 +00:00
}
2021-06-03 00:17:06 +00:00
$select_style .= '</select>' ;
2021-06-03 00:07:31 +00:00
}
2009-09-22 21:29:27 +00:00
$body = <<< EOF
2009-09-20 02:53:15 +00:00
< body >
< div class = " adminbar " >
2020-08-11 13:09:11 +00:00
$cataloglink
2021-03-14 02:49:09 +00:00
$managelink
2021-06-03 00:17:06 +00:00
$select_style
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 >
2015-10-27 04:31:52 +00:00
< hr width = " 90% " >
2009-09-20 02:53:15 +00:00
$postingmode
2018-07-20 23:32:54 +00:00
$postform
2021-06-03 06:04:59 +00:00
$js
2009-09-20 02:53:15 +00:00
< 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
2021-03-13 08:39:08 +00:00
< div id = " posts " >
2009-09-20 02:53:15 +00:00
$htmlposts
2021-03-13 08:39:08 +00:00
</ div >
< hr >
2021-04-18 08:10:52 +00:00
< table class = " userdelete " >
2009-09-20 02:53:15 +00:00
< tbody >
< tr >
< td >
2020-09-06 16:42:29 +00:00
$txt_delete_post < input type = " password " name = " password " id = " deletepostpassword " size = " 8 " placeholder = " $txt_password " >& nbsp ; < input name = " deletepost " value = " $txt_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
}
2020-08-11 13:01:00 +00:00
function buildCatalogPost ( $post ) {
$maxwidth = max ( 100 , $post [ 'thumb_width' ]);
2020-10-22 16:13:29 +00:00
$thumb = '#' . $post [ 'id' ];
if ( $post [ 'thumb' ] != '' ) {
$thumb = <<< EOF
< img src = " thumb/ { $post [ 'thumb' ] } " alt = " { $post [ 'id' ] } " width = " { $post [ 'thumb_width' ] } " height = " { $post [ 'thumb_height' ] } " border = " 0 " >
EOF ;
}
2020-08-11 13:01:00 +00:00
$replies = numRepliesToThreadByID ( $post [ 'id' ]);
2023-09-24 21:17:24 +00:00
$subject = trim ( $post [ 'subject' ]) != '' ? $post [ 'subject' ] : _substr ( trim ( str_ireplace ( " \n " , '' , strip_tags ( $post [ 'message' ]))), 0 , 75 );
2020-10-30 16:36:44 +00:00
2020-08-11 13:01:00 +00:00
return <<< EOF
< div class = " catalogpost " style = " max-width: { $maxwidth } px; " >
< a href = " res/ { $post [ 'id' ] } .html " >
2020-10-22 16:13:29 +00:00
$thumb
2020-08-11 13:01:00 +00:00
</ a >< br >
< b > $replies </ b >< br >
$subject
</ div >
EOF ;
}
function rebuildCatalog () {
$threads = allThreads ();
$htmlposts = '' ;
foreach ( $threads as $post ) {
$htmlposts .= buildCatalogPost ( $post );
}
writePage ( 'catalog.html' , buildPage ( $htmlposts , - 1 ));
}
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
2021-03-13 08:39:08 +00:00
if ( $i > 0 ) {
$htmlposts .= " \n <hr> " ;
}
$htmlposts .= buildPost ( $thread , TINYIB_INDEXPAGE ) . implode ( '' , array_reverse ( $htmlreplies ));
2014-06-24 19:51:22 +00:00
2013-01-13 13:40:34 +00:00
if ( ++ $i >= TINYIB_THREADSPERPAGE ) {
2018-07-20 22:48:07 +00:00
$file = ( $page == 0 ) ? TINYIB_INDEX : ( $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 != '' ) {
2018-07-20 22:48:07 +00:00
$file = ( $page == 0 ) ? TINYIB_INDEX : ( $page . '.html' );
2009-09-20 02:53:15 +00:00
writePage ( $file , buildPage ( $htmlposts , 0 , $pages , $page ));
}
2020-08-11 13:01:00 +00:00
if ( TINYIB_CATALOG ) {
rebuildCatalog ();
}
2020-08-11 20:04:09 +00:00
if ( TINYIB_JSON ) {
2020-08-12 16:28:41 +00:00
writePage ( 'threads.json' , buildIndexJSON ());
2020-08-11 20:04:09 +00:00
writePage ( 'catalog.json' , buildCatalogJSON ());
}
2009-09-20 02:53:15 +00:00
}
function rebuildThread ( $id ) {
2020-08-12 16:28:41 +00:00
$id = intval ( $id );
2021-05-06 02:55:18 +00:00
$post = postByID ( $id );
2021-06-07 02:27:10 +00:00
if ( empty ( $post ) || $post [ 'moderated' ] == 0 ) {
2021-05-06 02:55:18 +00:00
@ unlink ( 'res/' . $id . '.html' );
return ;
}
2009-09-20 02:53:15 +00:00
$posts = postsInThreadByID ( $id );
2020-11-13 20:32:42 +00:00
if ( count ( $posts ) == 0 ) {
@ unlink ( 'res/' . $id . '.html' );
return ;
}
$htmlposts = " " ;
2021-03-13 08:39:08 +00:00
$lastpostid = 0 ;
2009-09-20 02:53:15 +00:00
foreach ( $posts as $post ) {
2011-08-07 07:24:39 +00:00
$htmlposts .= buildPost ( $post , TINYIB_RESPAGE );
2021-03-13 08:39:08 +00:00
$lastpostid = $post [ 'id' ];
2009-09-20 02:53:15 +00:00
}
2014-06-24 19:51:22 +00:00
2021-03-13 08:39:08 +00:00
writePage ( 'res/' . $id . '.html' , fixLinksInRes ( buildPage ( $htmlposts , $id , 0 , 0 , $lastpostid )));
2020-08-12 16:28:41 +00:00
if ( TINYIB_JSON ) {
writePage ( 'res/' . $id . '.json' , buildSingleThreadJSON ( $id ));
}
2009-09-20 02:53:15 +00:00
}
2009-09-22 21:29:27 +00:00
function adminBar () {
2021-04-04 20:01:56 +00:00
global $account , $loggedin , $isadmin , $returnlink ;
2020-09-06 16:42:29 +00:00
$return = '[<a href="' . $returnlink . '" style="text-decoration: underline;">' . __ ( 'Return' ) . '</a>]' ;
2014-06-24 19:51:22 +00:00
if ( ! $loggedin ) {
return $return ;
}
2017-12-14 22:51:59 +00:00
2021-06-11 07:19:03 +00:00
$output = '' ;
2020-09-06 16:42:29 +00:00
if ( $isadmin ) {
2021-04-04 20:01:56 +00:00
if ( $account [ 'role' ] == TINYIB_SUPER_ADMINISTRATOR ) {
2021-06-11 07:19:03 +00:00
$output .= ' [<a href="?manage&accounts">' . __ ( 'Accounts' ) . '</a>]' ;
}
$output .= ' [<a href="?manage&bans">' . __ ( 'Bans' ) . '</a>]' ;
$output .= ' [<a href="?manage&keywords">' . __ ( 'Keywords' ) . '</a>]' ;
if ( TINYIB_DBMIGRATE ) {
$output .= ' [<a href="?manage&dbmigrate"><b>' . __ ( 'Migrate Database' ) . '</b></a>]' ;
2021-04-04 20:01:56 +00:00
}
2021-04-10 03:38:10 +00:00
}
2021-06-11 07:19:03 +00:00
$output .= ' [<a href="?manage&moderate">' . __ ( 'Moderate Post' ) . '</a>]' ;
2020-09-06 16:42:29 +00:00
if ( $isadmin ) {
2021-06-11 07:19:03 +00:00
$output .= ' [<a href="?manage&modlog">' . __ ( 'Moderation Log' ) . '</a>]' ;
$output .= ' [<a href="?manage&rebuildall">' . __ ( 'Rebuild All' ) . '</a>]' ;
2021-06-08 19:47:52 +00:00
if ( TINYIB_REPORT ) {
2021-06-11 07:19:03 +00:00
$output .= ' [<a href="?manage&reports">' . __ ( 'Reports' ) . '</a>]' ;
2021-06-08 19:47:52 +00:00
}
2020-09-06 16:42:29 +00:00
}
2021-06-11 07:19:03 +00:00
$output .= ' [<a href="?manage&staffpost">' . __ ( 'Staff Post' ) . '</a>]' ;
$output .= ' [<a href="?manage">' . __ ( 'Status' ) . '</a>]' ;
2020-09-06 16:42:29 +00:00
if ( $isadmin && installedViaGit ()) {
2021-06-11 07:19:03 +00:00
$output .= ' [<a href="?manage&update">' . __ ( 'Update' ) . '</a>]' ;
2020-09-06 16:42:29 +00:00
}
2021-06-11 07:19:03 +00:00
$output .= ' · [<a href="?manage&changepassword">' . __ ( 'Change Password' ) . '</a>]' ;
$output .= ' [<a href="?manage&logout">' . __ ( 'Log Out' ) . '</a>]' ;
$output .= ' · ' . $return ;
2020-09-06 16:42:29 +00:00
return $output ;
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 ();
2020-09-01 03:51:14 +00:00
$txt_manage_mode = __ ( 'Manage mode' );
2009-09-22 21:29:27 +00:00
$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 >
2015-10-27 04:31:52 +00:00
< hr width = " 90% " >
2020-08-28 23:20:22 +00:00
< div class = " replymode " > $txt_manage_mode </ div >
2009-09-20 02:53:15 +00:00
$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 ) {
2021-04-10 17:25:23 +00:00
case 'accounts' :
2009-09-20 02:53:15 +00:00
case 'login' :
2021-04-10 06:02:31 +00:00
return ' onload="document.tinyib.username.focus();"' ;
2021-04-10 17:25:23 +00:00
case 'bans' :
return ' onload="document.tinyib.ip.focus();"' ;
2020-11-23 20:44:02 +00:00
case 'keywords' :
return ' onload="document.tinyib.text.focus();"' ;
2021-04-10 17:25:23 +00:00
case 'moderate' :
return ' onload="document.tinyib.moderate.focus();"' ;
2021-06-07 02:42:09 +00:00
case 'staffpost' :
2010-06-22 09:26:45 +00:00
return ' onload="document.tinyib.message.focus();"' ;
2009-09-20 02:53:15 +00:00
}
}
function manageLogInForm () {
2020-09-01 03:51:14 +00:00
$txt_login = __ ( 'Log In' );
2021-04-04 20:01:56 +00:00
$txt_login_prompt = __ ( 'Enter a username and password' );
2020-10-30 16:36:44 +00:00
$captcha_inner_html = '' ;
2021-03-10 18:45:54 +00:00
if ( TINYIB_MANAGECAPTCHA === 'hcaptcha' ) {
$captcha_inner_html = '
< br >
< div style = " min-height: 82px; " >
< div class = " h-captcha " data - sitekey = " ' . TINYIB_HCAPTCHA_SITE . ' " ></ div >
</ div >< br >< br > ' ;
} else if ( TINYIB_MANAGECAPTCHA === 'recaptcha' ) {
2020-10-30 16:36:44 +00:00
$captcha_inner_html = '
< br >
< div style = " min-height: 80px; " >
< div class = " g-recaptcha " data - sitekey = " ' . TINYIB_RECAPTCHA_SITE . ' " ></ div >
< noscript >
< div >
< div style = " width: 302px; height: 422px; position: relative; " >
< div style = " width: 302px; height: 422px; position: absolute; " >
< iframe src = " https://www.google.com/recaptcha/api/fallback?k=' . TINYIB_RECAPTCHA_SITE . ' " frameborder = " 0 " scrolling = " no " style = " width: 302px; height:422px; border-style: none; " ></ iframe >
</ div >
</ div >
< div style = " width: 300px; height: 60px; border-style: none;bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px;background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; " >
< textarea id = " g-recaptcha-response " name = " g-recaptcha-response " class = " g-recaptcha-response " style = " width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px; padding: 0px; resize: none; " ></ textarea >
</ div >
</ div >
</ noscript >
</ div >< br >< br > ' ;
} else if ( TINYIB_MANAGECAPTCHA ) { // Simple CAPTCHA
$captcha_inner_html = '
< br >
< input type = " text " name = " captcha " id = " captcha " size = " 6 " accesskey = " c " autocomplete = " off " >& nbsp ; & nbsp ; ' . __(' ( enter the text below ) ') . ' < br >
< img id = " captchaimage " src = " inc/captcha.php " width = " 175 " height = " 55 " alt = " CAPTCHA " onclick = " javascript:reloadCAPTCHA() " style = " margin-top: 5px;cursor: pointer; " >< br >< br > ' ;
}
2021-03-14 02:49:09 +00:00
$managekey = htmlentities ( $_GET [ 'manage' ], ENT_QUOTES );
2009-09-20 02:53:15 +00:00
return <<< EOF
2021-03-14 02:49:09 +00:00
< form id = " tinyib " name = " tinyib " method = " post " action = " ?manage= $managekey " >
2009-09-20 02:53:15 +00:00
< fieldset >
2020-08-28 23:20:22 +00:00
< legend align = " center " > $txt_login_prompt </ legend >
2009-09-22 21:29:27 +00:00
< div class = " login " >
2021-04-04 20:01:56 +00:00
< input type = " text " id = " username " name = " username " placeholder = " Username " >< br >
< input type = " password " id = " managepassword " name = " managepassword " placeholder = " Password " >< br >
2020-10-30 16:36:44 +00:00
$captcha_inner_html
2020-08-28 23:20:22 +00:00
< input type = " submit " value = " $txt_login " class = " managebutton " >
2009-09-20 02:53:15 +00:00
</ div >
</ fieldset >
</ form >
< br >
EOF ;
}
2021-04-10 03:38:10 +00:00
function manageModerationLog ( $offset ) {
$offset = intval ( $offset );
$limit = 50 ;
$logs = getLogs ( $offset , $limit );
$u = array ();
$text = '' ;
foreach ( $logs as $log ) {
if ( ! isset ( $u [ $log [ 'account' ]])) {
$username = '' ;
if ( $log [ 'account' ] > 0 ) {
$a = accountByID ( $log [ 'account' ]);
if ( ! empty ( $a )) {
$username = $a [ 'username' ];
}
}
$u [ $log [ 'account' ]] = $username ;
}
2022-03-16 18:03:05 +00:00
$text .= '<tr><td>' . formatDate ( $log [ 'timestamp' ]) . '</td><td>' . htmlentities ( $u [ $log [ 'account' ]]) . '</td><td>' . $log [ 'message' ] . '</td></tr>' ;
2021-04-10 03:38:10 +00:00
}
if ( $text == '' ) {
$text = '<i>' . __ ( 'No logs.' ) . '</i>' ;
}
$txt_moderation_log = __ ( 'Moderation log' );
$nav = '' ;
if ( $offset > 0 ) {
2021-04-26 15:36:59 +00:00
$nav .= '<a href="?manage&modlog=' . ( $offset - $limit ) . '">Previous ' . $limit . '</a> ' ;
2021-04-10 03:38:10 +00:00
}
if ( count ( $logs ) == $limit ) {
2021-04-26 15:36:59 +00:00
$nav .= '<a href="?manage&modlog=' . ( $offset + $limit ) . '">Next ' . $limit . '</a> ' ;
2021-04-10 03:38:10 +00:00
}
$nav_top = '' ;
$nav_bottom = '' ;
if ( $nav != '' ) {
$nav_top = $nav . '<br><br>' ;
$nav_bottom = '<br><br>' . $nav ;
}
return <<< EOF
$nav_top
< fieldset >
< legend > $txt_moderation_log </ legend >
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tr >< th align = " left " > Date / time </ th >< th align = " left " > Account </ th >< th align = " left " > Action </ th ></ tr >
$text
</ table >
</ fieldset >
$nav_bottom
EOF ;
}
2021-03-11 22:11:24 +00:00
function manageReportsPage ( $ip ) {
$reports = allReports ();
$report_counts = array ();
$posts = array ();
foreach ( $reports as $report ) {
if ( $ip != '' && $report [ 'ip' ] != $ip && $report [ 'ip' ] != hashData ( $ip )) {
continue ;
}
$post = postByID ( $report [ 'post' ]);
if ( empty ( $post )) {
continue ;
}
if ( $ip == '' ) {
$post [ 'reportedby' ] = $report [ 'ip' ];
if ( ! isset ( $report_counts [ $report [ 'ip' ]])) {
$report_counts [ $report [ 'ip' ]] = 0 ;
}
$report_counts [ $report [ 'ip' ]] ++ ;
}
$posts [] = $post ;
}
$txt_reported = __ ( 'Reported posts' );
if ( $ip != '' ) {
if ( count ( $posts ) == 1 ) {
$format = __ ( '%1$d report by %2$s' );
} else {
$format = __ ( '%1$d reports by %2$s' );
}
$txt_reported = sprintf ( $format , count ( $posts ), '<a href="?manage&bans=' . htmlentities ( $ip , ENT_QUOTES ) . '">' . htmlentities ( $ip ) . '</a>' );
}
$post_html = '' ;
foreach ( $posts as $post ) {
if ( $post_html != '' ) {
$post_html .= '<tr><td colspan="2"><hr></td></tr>' ;
}
if ( isset ( $post [ 'reportedby' ])) {
$reportedby_html = '<a href="?manage&bans=' . htmlentities ( $post [ 'reportedby' ], ENT_QUOTES ) . '">' . htmlentities ( $post [ 'reportedby' ]) . '</a>' ;
if ( $report_counts [ $post [ 'reportedby' ]] > 1 ) {
$reportedby_html .= ' <a href="?manage&reports=' . htmlentities ( $post [ 'reportedby' ], ENT_QUOTES ) . '">(' . sprintf ( __ ( '%d reports' ), $report_counts [ $post [ 'reportedby' ]]) . ')</a>' ;
}
$post_html .= '<tr><td colspan=""><small>' . sprintf ( __ ( 'Reported by %s' ), $reportedby_html ) . '</small></td></tr>' ;
}
$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>' ;
}
if ( $post_html == '' ) {
$post_html = '<i>' . __ ( 'There are currently no reported posts.' ) . '</i>' ;
}
return <<< EOF
< fieldset >
< legend > $txt_reported </ legend >
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
$post_html
</ table >
</ fieldset >
EOF ;
}
2021-04-04 20:01:56 +00:00
function manageChangePasswordForm () {
2021-06-11 07:19:03 +00:00
$txt_header = __ ( 'Change Password' );
2021-04-04 20:01:56 +00:00
$txt_submit = __ ( 'Submit' );
return <<< EOF
< form id = " tinyib " name = " tinyib " method = " post " action = " ?manage&changepassword " >
< fieldset >
< legend > $txt_header </ legend >
2021-06-11 06:56:19 +00:00
< table border = " 0 " >
< tr >< td > New password </ td >< td >< input type = " password " name = " password " id = " password " value = " " ></ td ></ tr >
< tr >< td > Confirm </ td >< td >< input type = " password " name = " confirm " id = " confirm " value = " " ></ td ></ tr >
< tr >< td >& nbsp ; </ td >< td >< input type = " submit " value = " $txt_submit " class = " managebutton " ></ td ></ tr >
</ table >
2021-04-04 20:01:56 +00:00
< legend >
</ fieldset >
</ form >< br >
EOF ;
}
2021-04-10 03:38:10 +00:00
function manageAccountForm ( $id = 0 ) {
2021-04-04 20:01:56 +00:00
$a = array (
'id' => 0 ,
'username' => '' ,
'password' => '' ,
'role' => 0 ,
);
$txt_header = __ ( 'Add an account' );
$txt_password_hint = '' ;
2021-04-10 03:38:10 +00:00
if ( $id > 0 ) {
2021-04-04 20:01:56 +00:00
$txt_header = __ ( 'Update an account' );
$txt_password_hint = '(' . __ ( 'Leave blank to maintain current password' ) . ')' ;
$a = accountByID ( $id );
}
$a [ 'id' ] = htmlentities ( $a [ 'id' ], ENT_QUOTES );
$a [ 'username' ] = htmlentities ( $a [ 'username' ], ENT_QUOTES );
$txt_username = __ ( 'Username' );
$txt_password = __ ( 'Password' );
$txt_role = __ ( 'Role' );
$return = <<< EOF
< form id = " tinyib " name = " tinyib " method = " post " action = " ?manage&accounts " >
< input type = " hidden " name = " id " value = " { $a [ 'id' ] } " >
< fieldset >
< legend > $txt_header </ legend >
2021-06-11 07:09:59 +00:00
< table border = " 0 " >
< tr >< td >< label for = " username " > $txt_username </ label ></ td >< td >< input type = " text " name = " username " id = " username " value = " { $a [ 'username' ] } " ></ td ></ tr >
< tr >< td >< label for = " password " > $txt_password </ label ></ td >< td >< input type = " password " name = " password " id = " password " value = " " > < small > $txt_password_hint </ small ></ td ></ tr >
< tr >< td >< label for = " role " > $txt_role </ label ></ td >< td >< select name = " role " id = " role " >
2021-04-04 20:01:56 +00:00
EOF ;
$return .= '<option value="0" ' . ( $a [ 'role' ] == 0 ? ' selected' : '' ) . '>' . __ ( 'Choose a role' ) . '</option>' ;
$return .= '<option value="1" ' . ( $a [ 'role' ] == 1 ? ' selected' : '' ) . '>' . __ ( 'Super-administrator' ) . '</option>' ;
$return .= '<option value="2" ' . ( $a [ 'role' ] == 2 ? ' selected' : '' ) . '>' . __ ( 'Administrator' ) . '</option>' ;
$return .= '<option value="3" ' . ( $a [ 'role' ] == 3 ? ' selected' : '' ) . '>' . __ ( 'Moderator' ) . '</option>' ;
$return .= '<option value="99" ' . ( $a [ 'role' ] == 99 ? ' selected' : '' ) . '>' . __ ( 'Disabled' ) . '</option>' ;
$txt_submit = __ ( 'Submit' );
$return .= <<< EOF
2021-06-11 07:09:59 +00:00
</ select ></ td ></ tr >
< tr >< td >& nbsp ; </ td >< td >< input type = " submit " value = " $txt_submit " class = " managebutton " ></ td ></ tr >
</ table >
2021-04-04 20:01:56 +00:00
</ fieldset >
</ form >< br >
EOF ;
return $return ;
}
function manageAccountsTable () {
$text = '' ;
$allaccounts = allAccounts ();
if ( count ( $allaccounts ) > 0 ) {
$text .= '<table border="1"><tr><th>' . __ ( 'Username' ) . '</th><th>' . __ ( 'Role' ) . '</th><th>' . __ ( 'Last active' ) . '</th><th> </th></tr>' ;
foreach ( $allaccounts as $account ) {
2022-03-16 18:03:05 +00:00
$lastactive = ( $account [ 'lastactive' ] > 0 ) ? formatDate ( $account [ 'lastactive' ]) : __ ( 'Never' );
2021-04-04 20:01:56 +00:00
$text .= '<tr><td>' . htmlentities ( $account [ 'username' ]) . '</td><td>' ;
switch ( intval ( $account [ 'role' ])) {
case TINYIB_SUPER_ADMINISTRATOR :
$text .= __ ( 'Super-administrator' );
break ;
case TINYIB_ADMINISTRATOR :
$text .= __ ( 'Administrator' );
break ;
case TINYIB_MODERATOR :
$text .= __ ( 'Moderator' );
break ;
case TINYIB_DISABLED :
$text .= __ ( 'Disabled' );
break ;
}
$text .= '</td><td>' . $lastactive . '</td><td><a href="?manage&accounts=' . $account [ 'id' ] . '">' . __ ( 'update' ) . '</a></td></tr>' ;
}
$text .= '</table>' ;
}
return $text ;
}
2009-09-20 02:53:15 +00:00
function manageBanForm () {
2020-10-22 16:05:49 +00:00
$txt_ban = __ ( 'Add a ban' );
2021-04-18 08:10:52 +00:00
$txt_ban_help = __ ( 'Multiple IP addresses may be banned at once by separating each address with a comma.' );
2020-10-22 16:05:49 +00:00
$txt_ban_ip = __ ( 'IP Address' );
$txt_ban_expire = __ ( 'Expire(sec)' );
$txt_ban_reason = __ ( 'Reason' );
2020-09-01 03:51:14 +00:00
$txt_ban_never = __ ( 'never' );
2021-06-24 02:08:22 +00:00
$txt_ban_optional = __ ( 'Optional.' );
2020-09-06 16:42:29 +00:00
$txt_submit = __ ( 'Submit' );
2020-10-22 16:05:49 +00:00
$txt_1h = __ ( '1 hour' );
$txt_1d = __ ( '1 day' );
$txt_2d = __ ( '2 days' );
$txt_1w = __ ( '1 week' );
$txt_2w = __ ( '2 weeks' );
$txt_1m = __ ( '1 month' );
2021-06-24 02:08:22 +00:00
$banmessage_html = '' ;
$post_ids = '' ;
if ( TINYIB_BANMESSAGE && isset ( $_GET [ 'posts' ]) && $_GET [ 'posts' ] != '' ) {
$post_ids = htmlentities ( $_GET [ 'posts' ], ENT_QUOTES );
$banmessage_html = '<tr><td><label for="message">' . __ ( 'Message' ) . '</label></td><td><input type="text" name="message" id="message"></td><td><small>' . __ ( " Append a message to the post. Optional. " ) . '</small></td></tr>' ;
}
2009-09-20 02:53:15 +00:00
return <<< EOF
2021-06-24 02:08:22 +00:00
< form id = " tinyib " name = " tinyib " method = " post " action = " ?manage&bans&posts= $post_ids " >
2009-09-20 02:53:15 +00:00
< fieldset >
2020-10-22 16:05:49 +00:00
< legend > $txt_ban </ legend >
2021-06-11 07:09:59 +00:00
< table border = " 0 " >
2023-01-05 18:27:06 +00:00
< tr >< td >< label for = " ip " > $txt_ban_ip </ label ></ td >< td >< input type = " text " name = " ip " id = " ip " value = " { $_GET [ 'bans' ] } " ></ td >< td >< input type = " submit " value = " $txt_submit " class = " managebutton " ></ td ></ tr >
2021-06-11 07:09:59 +00:00
< tr >< td >< label for = " expire " > $txt_ban_expire </ label ></ td >< td >< input type = " text " name = " expire " id = " expire " value = " 0 " ></ td >< td >< small >< a href = " # " onclick = " document.tinyib.expire.value='3600';return false; " > $txt_1h </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='86400';return false; " > $txt_1d </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='172800';return false; " > $txt_2d </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='604800';return false; " > $txt_1w </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='1209600';return false; " > $txt_2w </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='2592000';return false; " > $txt_1m </ a >& nbsp ; < a href = " # " onclick = " document.tinyib.expire.value='0';return false; " > $txt_ban_never </ a ></ small ></ td ></ tr >
< tr >< td >< label for = " reason " > $txt_ban_reason </ label ></ td >< td >< input type = " text " name = " reason " id = " reason " ></ td >< td >< small > $txt_ban_optional </ small ></ td ></ tr >
2021-06-24 02:08:22 +00:00
$banmessage_html
2021-06-11 07:09:59 +00:00
</ table >< br >
2021-04-18 08:10:52 +00:00
< small > $txt_ban_help </ small >
2009-09-20 02:53:15 +00:00
< legend >
</ fieldset >
</ form >< br >
EOF ;
}
function manageBansTable () {
$text = '' ;
$allbans = allBans ();
if ( count ( $allbans ) > 0 ) {
2020-09-01 03:51:14 +00:00
$text .= '<table border="1"><tr><th>' . __ ( 'IP Address' ) . '</th><th>' . __ ( 'Set At' ) . '</th><th>' . __ ( 'Expires' ) . '</th><th>' . __ ( 'Reason' ) . '</th><th> </th></tr>' ;
2009-09-20 02:53:15 +00:00
foreach ( $allbans as $ban ) {
2022-03-16 18:03:05 +00:00
$expire = ( $ban [ 'expire' ] > 0 ) ? formatDate ( $ban [ 'expire' ]) : __ ( 'Does not expire' );
2009-09-20 02:53:15 +00:00
$reason = ( $ban [ 'reason' ] == '' ) ? ' ' : htmlentities ( $ban [ 'reason' ]);
2022-03-16 18:03:05 +00:00
$text .= '<tr><td>' . $ban [ 'ip' ] . '</td><td>' . formatDate ( $ban [ 'timestamp' ]) . '</td><td>' . $expire . '</td><td>' . $reason . '</td><td><a href="?manage&bans&lift=' . $ban [ 'id' ] . '">' . __ ( 'lift' ) . '</a></td></tr>' ;
2009-09-20 02:53:15 +00:00
}
$text .= '</table>' ;
}
return $text ;
}
function manageModeratePostForm () {
2020-10-22 16:05:49 +00:00
$txt_moderate = __ ( 'Moderate a post' );
$txt_postid = __ ( 'Post ID' );
2020-09-06 16:42:29 +00:00
$txt_submit = __ ( 'Submit' );
2021-08-05 18:20:51 +00:00
$txt_tip = __ ( 'Tip' );
2020-10-22 16:05:49 +00:00
$txt_tiptext1 = __ ( 'While browsing the image board, you can easily moderate a post if you are logged in.' );
$txt_tiptext2 = __ ( 'Tick the box next to a post and click "Delete" at the bottom of the page with a blank password.' );
2009-09-20 02:53:15 +00:00
return <<< EOF
< form id = " tinyib " name = " tinyib " method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
< fieldset >
2020-10-22 16:05:49 +00:00
< legend > $txt_moderate </ legend >
< div valign = " top " >< label for = " moderate " > $txt_postid </ label > < input type = " text " name = " moderate " id = " moderate " > < input type = " submit " value = " $txt_submit " class = " managebutton " ></ div >< br >
2021-08-05 18:20:51 +00:00
< b > $txt_tip :</ b > $txt_tiptext1 < br >
2020-10-22 16:05:49 +00:00
$txt_tiptext2 < br >
2009-09-20 02:53:15 +00:00
</ fieldset >
</ form >< br >
EOF ;
}
2021-04-18 08:10:52 +00:00
function manageModerateAll ( $post_ids , $threads , $replies , $ips ) {
global $isadmin ;
$txt_moderate = sprintf ( __ ( 'Moderate %d posts' ), count ( $post_ids ));
$txt_delete_all = __ ( 'Delete all' );
$txt_ban_all = __ ( 'Ban all' );
if ( $threads == 1 && $replies == 1 ) {
$delete_info = __ ( '1 thread and 1 reply will be deleted.' );
} else if ( $threads == 1 ) {
$delete_info = sprintf ( __ ( '1 thread and %d replies will be deleted.' ), $replies );
} else if ( $replies == 1 ) {
$delete_info = sprintf ( __ ( '%d threads and 1 reply will be deleted.' ), $threads );
} else {
$delete_info = sprintf ( __ ( '%1$d threads and %2$d replies will be deleted.' ), $threads , $replies );
}
if ( count ( $ips ) == 1 ) {
$ban_info = __ ( '1 IP address will be banned.' );
} else {
$ban_info = sprintf ( __ ( '%d IP addresses will be banned.' ), count ( $ips ));
}
$ban_disabled = 'disabled' ;
if ( $isadmin ) {
$ban_disabled = '' ;
}
$post_ids_quoted = htmlentities ( implode ( ',' , $post_ids ), ENT_QUOTES );
$ips_comma = implode ( ',' , $ips );
return <<< EOF
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tr >< td width = " 50% " >
& nbsp ;
</ td >< td width = " 50% " >
< fieldset >
< legend > $txt_moderate </ legend >
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tr >< td >
& nbsp ;
</ td >< td valign = " top " >
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
< input type = " hidden " name = " delete " value = " { $post_ids_quoted } " >
< input type = " submit " value = " $txt_delete_all " class = " managebutton " >
</ form >
</ td >< td >< small > $delete_info </ small ></ td ></ tr >
< tr >< td >
& nbsp ;
</ td >< td valign = " top " >
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
< input type = " hidden " name = " bans " value = " { $ips_comma } " >
2021-06-24 02:08:22 +00:00
< input type = " hidden " name = " posts " value = " { $post_ids_quoted } " >
2021-04-18 08:10:52 +00:00
< input type = " submit " value = " $txt_ban_all " class = " managebutton " $ban_disabled >
</ form >
</ td >< td >< small > $ban_info </ small ></ td ></ tr >
</ table >
</ fieldset >
</ td ></ tr >
</ table >
EOF ;
}
function manageModeratePost ( $post , $compact = false ) {
2009-09-20 02:53:15 +00:00
global $isadmin ;
$ban = banByIP ( $post [ 'ip' ]);
$ban_disabled = ( ! $ban && $isadmin ) ? '' : ' disabled' ;
2020-10-22 16:05:49 +00:00
if ( $ban ) {
$ban_info = sprintf ( __ ( ' A ban record already exists for %s' ), $post [ 'ip' ]);
} else {
if ( ! $isadmin ) {
$ban_info = __ ( 'Only an administrator may ban an IP address.' );
} else {
$ban_info = sprintf ( __ ( 'IP address: %s' ), $post [ 'ip' ]);
}
}
2021-04-18 08:10:52 +00:00
$thread_or_reply = ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) ? __ ( 'Thread' ) : __ ( 'Reply' );
$delete_info = '' ;
if ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) {
$allPosts = postsInThreadByID ( $post [ 'id' ]);
if ( count ( $allPosts ) > 1 ) {
if ( count ( $allPosts ) == 2 ) {
$delete_info = __ ( '1 reply will be deleted.' );
} else {
$delete_info = sprintf ( __ ( '%d replies will be deleted.' ), count ( $allPosts ) - 1 );
}
}
} else {
2023-01-05 18:22:07 +00:00
$delete_info = sprintf ( __ ( 'Belongs to %s' ), postLink ( '>>' . $post [ 'id' ]));
2021-04-18 08:10:52 +00:00
}
2014-06-24 19:51:22 +00:00
2015-08-21 07:45:01 +00:00
$sticky_html = " " ;
2020-07-31 23:16:37 +00:00
$lock_html = " " ;
2021-04-18 08:10:52 +00:00
if ( $post [ 'parent' ] == TINYIB_NEWTHREAD && ! $compact ) {
2015-08-21 07:45:01 +00:00
$sticky_set = $post [ 'stickied' ] == 1 ? '0' : '1' ;
2020-09-06 16:42:29 +00:00
$sticky_unsticky = $post [ 'stickied' ] == 1 ? __ ( 'Un-sticky' ) : __ ( 'Sticky' );
$sticky_unsticky_help = $post [ 'stickied' ] == 1 ? __ ( 'Return this thread to a normal state.' ) : __ ( 'Keep this thread at the top of the board.' );
2015-08-21 07:45:01 +00:00
$sticky_html = <<< EOF
2021-04-18 08:10:52 +00:00
< tr >< td >
2015-08-21 07:45:01 +00:00
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
2023-01-05 18:27:06 +00:00
< input type = " hidden " name = " sticky " value = " { $post [ 'id' ] } " >
2015-08-21 07:45:01 +00:00
< input type = " hidden " name = " setsticky " value = " $sticky_set " >
2021-04-18 08:10:52 +00:00
< input type = " submit " value = " $sticky_unsticky " class = " managebutton " >
2015-08-21 07:45:01 +00:00
</ form >
</ td >< td >< small > $sticky_unsticky_help </ small ></ td ></ tr >
EOF ;
2020-07-31 23:16:37 +00:00
$lock_set = $post [ 'locked' ] == 1 ? '0' : '1' ;
2020-09-06 16:42:29 +00:00
$lock_label = $post [ 'locked' ] == 1 ? __ ( 'Unlock' ) : __ ( 'Lock' );
$lock_help = $post [ 'locked' ] == 1 ? __ ( 'Allow replying to this thread.' ) : __ ( 'Disallow replying to this thread.' );
2020-07-31 23:16:37 +00:00
$lock_html = <<< EOF
2021-04-18 08:10:52 +00:00
< tr >< td >
2020-07-31 23:16:37 +00:00
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
2023-01-05 18:27:06 +00:00
< input type = " hidden " name = " lock " value = " { $post [ 'id' ] } " >
2020-07-31 23:16:37 +00:00
< input type = " hidden " name = " setlock " value = " $lock_set " >
2021-04-18 08:10:52 +00:00
< input type = " submit " value = " $lock_label " class = " managebutton " >
2020-07-31 23:16:37 +00:00
</ form >
</ td >< td >< small > $lock_help </ small ></ td ></ tr >
EOF ;
2011-08-07 07:24:39 +00:00
}
2021-04-18 08:10:52 +00:00
$post_html = buildPost ( $post , TINYIB_INDEXPAGE );
2014-06-24 19:51:22 +00:00
2020-10-22 16:13:29 +00:00
$txt_moderating = sprintf ( __ ( 'Moderating No.%d' ), $post [ 'id' ]);
2020-09-06 16:42:29 +00:00
$txt_action = __ ( 'Action' );
2020-10-22 16:05:49 +00:00
if ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) {
$txt_delete = __ ( 'Delete thread' );
} else {
2021-04-18 08:10:52 +00:00
$txt_delete = __ ( 'Delete reply' );
2020-10-22 16:05:49 +00:00
}
$txt_ban = __ ( 'Ban poster' );
2020-11-13 20:32:42 +00:00
$report_html = '' ;
$reports = reportsByPost ( $post [ 'id' ]);
2021-04-18 08:10:52 +00:00
if ( TINYIB_REPORT && count ( $reports ) > 0 && ! $compact ) {
2021-04-16 04:16:01 +00:00
$txt_clear_reports = __ ( 'Approve' );
2020-11-13 20:32:42 +00:00
$report_info = count ( $reports ) . ' ' . plural ( count ( $reports ), __ ( 'report' ), __ ( 'reports' ));
$report_html = <<< EOF
2021-04-18 08:10:52 +00:00
< tr >< td >
2020-11-13 20:32:42 +00:00
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
2023-01-05 18:27:06 +00:00
< input type = " hidden " name = " clearreports " value = " { $post [ 'id' ] } " >
2021-04-18 08:10:52 +00:00
< input type = " submit " value = " $txt_clear_reports " class = " managebutton " >
2020-11-13 20:32:42 +00:00
</ form >
</ td >< td >< small > $report_info </ small ></ td ></ tr >
EOF ;
}
2009-09-20 02:53:15 +00:00
return <<< EOF
< fieldset >
2020-10-22 16:05:49 +00:00
< legend > $txt_moderating </ legend >
2009-09-20 02:53:15 +00:00
2021-04-18 08:10:52 +00:00
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tr >< td width = " 50% " valign = " top " >
< fieldset >
< legend > $thread_or_reply </ legend >
$post_html
</ fieldset >
</ td >< td width = " 50% " valign = " top " >
2009-09-20 02:53:15 +00:00
< fieldset >
2020-09-06 16:42:29 +00:00
< legend > $txt_action </ legend >
2011-08-07 07:24:39 +00:00
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
2021-04-18 08:10:52 +00:00
< tr >< td >
2009-09-20 02:53:15 +00:00
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
2023-01-05 18:27:06 +00:00
< input type = " hidden " name = " delete " value = " { $post [ 'id' ] } " >
2021-04-18 08:10:52 +00:00
< input type = " submit " value = " $txt_delete " class = " managebutton " >
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 >
2021-04-18 08:10:52 +00:00
< tr >< td >
2011-08-07 07:24:39 +00:00
2009-09-20 02:53:15 +00:00
< form method = " get " action = " ? " >
< input type = " hidden " name = " manage " value = " " >
2023-01-05 18:27:06 +00:00
< input type = " hidden " name = " bans " value = " { $post [ 'ip' ] } " >
< input type = " hidden " name = " posts " value = " { $post [ 'id' ] } " >
2021-04-18 08:10:52 +00:00
< input type = " submit " value = " $txt_ban " class = " managebutton " $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 >
2015-08-21 07:45:01 +00:00
$sticky_html
2011-08-07 07:24:39 +00:00
2020-07-31 23:16:37 +00:00
$lock_html
2020-11-13 20:32:42 +00:00
$report_html
2011-08-07 07:24:39 +00:00
</ table >
</ fieldset >
2021-04-18 08:10:52 +00:00
</ td ></ tr >
</ table >
2009-09-20 02:53:15 +00:00
</ fieldset >
< br >
EOF ;
}
2011-08-07 07:24:39 +00:00
2020-11-23 20:44:02 +00:00
function manageEditKeyword ( $id ) {
$id = intval ( $id );
$v_text = '' ;
$v_action = '' ;
2021-05-01 06:12:19 +00:00
$v_regexp_checked = '' ;
2020-11-23 20:44:02 +00:00
if ( $id > 0 ) {
$keyword = keywordByID ( $id );
if ( empty ( $keyword )) {
fancyDie ( __ ( " Sorry, there doesn't appear to be a keyword with that ID. " ));
}
$v_text = htmlentities ( $keyword [ 'text' ], ENT_QUOTES );
$v_action = $keyword [ 'action' ];
2021-05-01 06:12:19 +00:00
if ( substr ( $v_text , 0 , 7 ) == 'REGEXP:' ) {
$v_regexp_checked = 'selected' ;
$v_text = substr ( $v_text , 7 );
}
2020-11-23 20:44:02 +00:00
}
$txt_keyword = __ ( 'Keyword' );
$txt_keywords = __ ( 'Keywords' );
2021-08-05 18:20:51 +00:00
$txt_action = __ ( 'Action' );
2020-11-23 20:44:02 +00:00
$txt_submit = $id > 0 ? __ ( 'Update' ) : __ ( 'Add' );
$return = <<< EOF
< form id = " tinyib " name = " tinyib " method = " post " action = " ?manage&keywords= $id " >
< fieldset >
< legend > $txt_keywords </ legend >
2021-06-11 07:09:59 +00:00
< table border = " 0 " >
< tr >< td >< label for = " keyword " > $txt_keyword </ label ></ td >< td >< input type = " text " name = " text " id = " text " value = " $v_text " > < label for = " regexp " >& nbsp ; < input type = " checkbox " name = " regexp " value = " 1 " $v_regexp_checked > Regular expression </ label ></ td ></ tr >
< tr >< td >< label for = " action " > $txt_action </ label ></ td >< td >< select name = " action " >
2020-11-23 20:44:02 +00:00
EOF ;
2021-04-16 04:16:01 +00:00
if ( TINYIB_REPORT && TINYIB_REQMOD != 'all' ) {
2020-11-23 20:44:02 +00:00
$return .= '<option value="report"' . ( $v_action == 'report' ? ' selected' : '' ) . '>' . __ ( 'Report' ) . '</option>' ;
}
$return .= '<option value="delete"' . ( $v_action == 'delete' ? ' selected' : '' ) . '>' . __ ( 'Delete' ) . '</option>' ;
2021-05-06 05:24:07 +00:00
$return .= '<option value="hide"' . ( $v_action == 'hide' ? ' selected' : '' ) . '>' . __ ( 'Hide until approved' ) . '</option>' ;
2020-11-23 20:44:02 +00:00
$return .= '<option value="ban1h"' . ( $v_action == 'ban1h' ? ' selected' : '' ) . '>' . __ ( 'Delete and ban for 1 hour' ) . '</option>' ;
$return .= '<option value="ban1d"' . ( $v_action == 'ban1d' ? ' selected' : '' ) . '>' . __ ( 'Delete and ban for 1 day' ) . '</option>' ;
$return .= '<option value="ban2d"' . ( $v_action == 'ban2d' ? ' selected' : '' ) . '>' . __ ( 'Delete and ban for 2 days' ) . '</option>' ;
$return .= '<option value="ban1w"' . ( $v_action == 'ban1w' ? ' selected' : '' ) . '>' . __ ( 'Delete and ban for 1 week' ) . '</option>' ;
$return .= '<option value="ban2w"' . ( $v_action == 'ban2w' ? ' selected' : '' ) . '>' . __ ( 'Delete and ban for 2 weeks' ) . '</option>' ;
$return .= '<option value="ban1m"' . ( $v_action == 'ban1m' ? ' selected' : '' ) . '>' . __ ( 'Delete and ban for 1 month' ) . '</option>' ;
$return .= '<option value="ban0"' . ( $v_action == 'ban0' ? ' selected' : '' ) . '>' . __ ( 'Delete and ban permanently' ) . '</option>' ;
return $return . <<< EOF
2021-06-11 07:09:59 +00:00
</ select ></ td ></ tr >
< tr >< td >& nbsp ; </ td >< td >< input type = " submit " value = " $txt_submit " class = " managebutton " ></ td ></ tr >
</ table >
2020-11-23 20:44:02 +00:00
</ fieldset >
</ form >< br >
EOF ;
}
function manageKeywordsTable () {
$text = '' ;
$keywords = allKeywords ();
if ( count ( $keywords ) > 0 ) {
$text .= '<table border="1"><tr><th>' . __ ( 'Keyword' ) . '</th><th>' . __ ( 'Action' ) . '</th><th> </th></tr>' ;
foreach ( $keywords as $keyword ) {
$action = '' ;
switch ( $keyword [ 'action' ]) {
case 'report' :
$action = __ ( 'Report' );
break ;
2021-05-06 05:24:07 +00:00
case 'hide' :
$action = __ ( 'Hide until approved' );
break ;
2020-11-23 20:44:02 +00:00
case 'delete' :
$action = __ ( 'Delete' );
break ;
case 'ban0' :
$action = __ ( 'Delete and ban permanently' );
break ;
case 'ban1h' :
$action = __ ( 'Delete and ban for 1 hour' );
break ;
case 'ban1d' :
$action = __ ( 'Delete and ban for 1 day' );
break ;
case 'ban2d' :
$action = __ ( 'Delete and ban for 2 days' );
break ;
case 'ban1w' :
$action = __ ( 'Delete and ban for 1 week' );
break ;
case 'ban2w' :
$action = __ ( 'Delete and ban for 2 weeks' );
break ;
case 'ban1m' :
$action = __ ( 'Delete and ban for 1 month' );
break ;
}
$text .= '<tr><td>' . htmlentities ( $keyword [ 'text' ]) . '</td><td>' . $action . '</td><td><a href="?manage&keywords=' . $keyword [ 'id' ] . '">' . __ ( 'Edit' ) . '</a> <a href="?manage&keywords&deletekeyword=' . $keyword [ 'id' ] . '">' . __ ( 'Delete' ) . '</a></td></tr>' ;
}
$text .= '</table>' ;
}
return $text ;
}
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 ());
2020-11-13 20:32:42 +00:00
$reports = allReports ();
2020-09-06 16:42:29 +00:00
2020-11-13 20:32:42 +00:00
$info = $threads . ' ' . plural ( $threads , __ ( 'thread' ), __ ( 'threads' ));
if ( TINYIB_REPORT ) {
2020-11-23 20:44:02 +00:00
$info .= ', ' . count ( $reports ) . ' ' . plural ( count ( $reports ), __ ( 'report' ), __ ( 'reports' ));
2020-11-13 20:32:42 +00:00
}
$info .= ', ' . $bans . ' ' . plural ( $bans , __ ( 'ban' ), __ ( 'bans' ));
2014-06-28 08:45:56 +00:00
2020-11-13 20:32:42 +00:00
$output = '' ;
2014-06-28 08:45:56 +00:00
if ( $isadmin && TINYIB_DBMODE == 'mysql' && function_exists ( 'mysqli_connect' )) { // Recommend MySQLi
$output .= <<< EOF
< fieldset >
< legend > Notice </ legend >
2020-11-13 20:32:42 +00:00
< p >< b > TINYIB_DBMODE </ b > is currently set to < 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 >
2014-06-28 08:45:56 +00:00
</ fieldset >
EOF ;
}
2014-06-24 19:51:22 +00:00
2014-10-17 01:12:52 +00:00
$reqmod_html = '' ;
2016-07-19 21:14:54 +00:00
if ( TINYIB_REQMOD == 'files' || TINYIB_REQMOD == 'all' ) {
2014-10-17 01:12:52 +00:00
$reqmod_post_html = '' ;
$reqmod_posts = latestPosts ( false );
foreach ( $reqmod_posts as $post ) {
if ( $reqmod_post_html != '' ) {
$reqmod_post_html .= '<tr><td colspan="2"><hr></td></tr>' ;
}
$reqmod_post_html .= '<tr><td>' . buildPost ( $post , TINYIB_INDEXPAGE ) . ' </ td >< td valign = " top " align = " right " >
< table border = " 0 " >< tr >< td >
2020-09-06 16:42:29 +00:00
< form method = " get " action = " ? " >< input type = " hidden " name = " manage " value = " " >< input type = " hidden " name = " approve " value = " ' . $post['id'] . ' " >< input type = " submit " value = " ' . __('Approve') . ' " class = " managebutton " ></ form >
2014-10-17 01:12:52 +00:00
</ td >< td >
2020-09-06 16:42:29 +00:00
< form method = " get " action = " ? " >< input type = " hidden " name = " manage " value = " " >< input type = " hidden " name = " moderate " value = " ' . $post['id'] . ' " >< input type = " submit " value = " ' . __('More Info') . ' " class = " managebutton " ></ form >
2014-10-17 01:12:52 +00:00
</ td ></ tr >< tr >< td align = " right " colspan = " 2 " >
2020-09-06 16:42:29 +00:00
< form method = " get " action = " ? " >< input type = " hidden " name = " manage " value = " " >< input type = " hidden " name = " delete " value = " ' . $post['id'] . ' " >< input type = " submit " value = " ' . __('Delete') . ' " class = " managebutton " ></ form >
2014-10-17 01:12:52 +00:00
</ td ></ tr ></ table >
</ td ></ tr > ' ;
}
if ( $reqmod_post_html != '' ) {
2020-09-06 16:42:29 +00:00
$txt_pending = __ ( 'Pending posts' );
2014-10-17 01:12:52 +00:00
$reqmod_html = <<< EOF
< fieldset >
2020-09-06 16:42:29 +00:00
< legend > $txt_pending </ legend >
2014-10-17 01:12:52 +00:00
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
$reqmod_post_html
</ table >
</ fieldset >
EOF ;
}
}
2020-11-13 20:32:42 +00:00
if ( TINYIB_REPORT && ! empty ( $reports )) {
2021-03-11 22:11:24 +00:00
$status_html = manageReportsPage ( '' );
2020-11-13 20:32:42 +00:00
} else {
$posts = latestPosts ( true );
$txt_recent_posts = __ ( 'Recent posts' );
2021-03-11 22:11:24 +00:00
$post_html = '' ;
foreach ( $posts as $post ) {
if ( $post_html != '' ) {
$post_html .= '<tr><td colspan="2"><hr></td></tr>' ;
}
$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>' ;
2014-06-24 19:51:22 +00:00
}
2021-03-11 22:11:24 +00:00
$status_html = <<< EOF
< fieldset >
< legend > $txt_recent_posts </ legend >
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
$post_html
</ table >
</ fieldset >
EOF ;
2011-08-07 07:24:39 +00:00
}
2014-06-24 19:51:22 +00:00
2020-09-06 16:42:29 +00:00
$txt_status = __ ( 'Status' );
$txt_info = __ ( 'Info' );
2014-06-28 08:45:56 +00:00
$output .= <<< EOF
2011-08-07 07:24:39 +00:00
< fieldset >
2020-09-06 16:42:29 +00:00
< legend > $txt_status </ legend >
2011-08-07 07:24:39 +00:00
< fieldset >
2020-09-06 16:42:29 +00:00
< legend > $txt_info </ legend >
2013-04-16 01:53:16 +00:00
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tbody >
< tr >< td >
$info
</ td >
</ tr >
</ tbody >
</ table >
2011-08-07 07:24:39 +00:00
</ fieldset >
2014-10-17 01:12:52 +00:00
$reqmod_html
2011-08-07 07:24:39 +00:00
2021-03-11 22:11:24 +00:00
$status_html
2011-08-07 07:24:39 +00:00
</ 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>' ;
}
2020-08-12 16:28:41 +00:00
function encodeJSON ( $array ) {
2020-11-13 20:32:42 +00:00
return json_encode ( $array , JSON_PRETTY_PRINT );
2020-08-12 16:28:41 +00:00
}
function buildSinglePostJSON ( $post ) {
$name = $post [ 'name' ];
if ( $name == '' ) {
2021-01-31 08:09:51 +00:00
$name = 'Anonymous' ;
2020-08-12 16:28:41 +00:00
}
$output = array ( 'id' => $post [ 'id' ], 'parent' => $post [ 'parent' ], 'timestamp' => $post [ 'timestamp' ], 'bumped' => $post [ 'bumped' ], 'name' => $name , 'tripcode' => $post [ 'tripcode' ], 'subject' => $post [ 'subject' ], 'message' => $post [ 'message' ], 'file' => $post [ 'file' ], 'file_hex' => $post [ 'file_hex' ], 'file_original' => $post [ 'file_original' ], 'file_size' => $post [ 'file_size' ], 'file_size_formated' => $post [ 'file_size_formatted' ], 'image_width' => $post [ 'image_width' ], 'image_height' => $post [ 'image_height' ], 'thumb' => $post [ 'thumb' ], 'thumb_width' => $post [ 'thumb_width' ], 'thumb_height' => $post [ 'thumb_height' ]);
2020-10-08 18:02:25 +00:00
if ( $post [ 'parent' ] == TINYIB_NEWTHREAD ) {
2020-08-12 16:28:41 +00:00
$replies = count ( postsInThreadByID ( $post [ 'id' ])) - 1 ;
$images = imagesInThreadByID ( $post [ 'id' ]);
$output = array_merge ( $output , array ( 'stickied' => $post [ 'stickied' ], 'locked' => $post [ 'locked' ], 'replies' => $replies , 'images' => $images ));
}
return $output ;
}
function buildIndexJSON () {
$output = array ( 'threads' => array ());
$threads = allThreads ();
foreach ( $threads as $thread ) {
array_push ( $output [ 'threads' ], array ( 'id' => $thread [ 'id' ], 'subject' => $thread [ 'subject' ], 'bumped' => $thread [ 'bumped' ]));
}
return encodeJSON ( $output );
}
function buildCatalogJSON () {
$output = array ( 'threads' => array ());
$threads = allThreads ();
foreach ( $threads as $post ) {
array_push ( $output [ 'threads' ], buildSinglePostJSON ( $post ));
}
return encodeJSON ( $output );
}
function buildSingleThreadJSON ( $id ) {
$output = array ( 'posts' => array ());
$posts = postsInThreadByID ( $id );
foreach ( $posts as $post ) {
array_push ( $output [ 'posts' ], buildSinglePostJSON ( $post ));
}
return encodeJSON ( $output );
2020-09-01 03:51:14 +00:00
}