2021-08-29 19:39:07 +02:00
< ? php
2021-10-08 20:39:33 +02:00
require 'require.php' ;
2021-08-29 19:39:07 +02:00
2021-08-31 19:16:33 +02:00
//FRONTPAGE
2021-09-24 05:29:57 +02:00
if (( ! isset ( $_GET [ " board " ])) || ( $_GET [ " board " ] == '' ) && $_GET [ " page " ] == '' ) {
2021-08-29 19:39:07 +02:00
$title = $site_name ;
$total_posts = 0 ;
2021-10-07 16:34:26 +02:00
2021-10-08 20:39:33 +02:00
if ( ! file_exists ( $path . '/' . $database_folder . '/frontpage.php' )) { //no frontpage? lets create boards folder
if ( ! file_exists ( $path . '/' . $database_folder . '/boards' )) {
mkdir ( $path . '/' . $database_folder . '/boards' );
2021-10-07 16:34:26 +02:00
}
}
2021-08-29 19:39:07 +02:00
foreach ( $config [ 'boards' ] as $boards ) {
2021-10-07 16:34:26 +02:00
//now lets create counters for each board, no matter if frontpage exists or not in case of new boards being made
2021-10-08 20:39:33 +02:00
if ( ! file_exists ( $path . '/' . $database_folder . '/boards/' . $boards [ 'url' ] . '/counter.php' )) {
mkdir ( $path . '/' . $database_folder . '/boards/' . $boards [ 'url' ]);
file_put_contents ( $path . '/' . $database_folder . '/boards/' . $boards [ 'url' ] . '/counter.php' , 1 );
2021-08-29 19:39:07 +02:00
}
//
2021-10-08 20:39:33 +02:00
$total_posts += file_get_contents ( $path . '/' . $database_folder . '/boards/' . $boards [ 'url' ] . '/counter.php' );
2021-08-29 19:39:07 +02:00
$total_posts -= 1 ; //idk how i fucked up the counter.php in post.php this badly.
}
if ( isset ( $_GET [ " theme " ])) {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . htmlspecialchars ( $_GET [ " theme " ]) . '">' ;
2021-08-29 19:39:07 +02:00
} else {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . $current_theme . '">' ;
2021-08-29 19:39:07 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '<head>' ;
include $path . '/templates/header.php' ;
$output_html .= '</head>' ;
$output_html .= '<body class="frontpage">' ;
include $path . '/templates/boardlist.php' ;
include $path . '/templates/frontpage.php' ;
include $path . '/templates/footer.php' ;
$output_html .= '</body>' ;
$output_html .= '</html>' ;
echo $output_html ;
2021-08-30 05:16:23 +02:00
exit ();
2021-08-29 19:39:07 +02:00
}
2021-09-24 05:29:57 +02:00
// PAGES
if (( ! isset ( $_GET [ " board " ])) || ( $_GET [ " board " ] == '' ) && $_GET [ " page " ] != '' ) {
if ( ! ctype_alnum ( $_GET [ " page " ])) {
error ( 'Invalid page.' );
}
if ( ! file_exists ( $path . '/templates/pages/' . $_GET [ " page " ] . '.php' )) {
2021-10-13 23:25:38 +02:00
http_response_code ( 404 );
2021-09-24 05:29:57 +02:00
error ( 'Page does not exist.' );
}
include $path . '/templates/pages/' . $_GET [ " page " ] . '.php' ;
if ( isset ( $_GET [ " theme " ])) {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . htmlspecialchars ( $_GET [ " theme " ]) . '">' ;
2021-09-24 05:29:57 +02:00
} else {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . $current_theme . '">' ;
2021-09-24 05:29:57 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '<head>' ;
include $path . '/templates/header.php' ;
$output_html .= '</head>' ;
$output_html .= '<body class="page">' ;
include $path . '/templates/boardlist.php' ;
2021-09-24 05:29:57 +02:00
if ( $config [ 'display_banner' ] === true ) {
include $path . '/assets/img/banner.php' ;
}
2021-10-13 23:25:38 +02:00
$output_html .= '<div class="page-info">' ;
$output_html .= '<h1>' . $h1 . '</h1>' ;
$output_html .= '<span class="small">' . $description . '</span>' ;
$output_html .= '</div>' ;
2021-09-24 05:29:57 +02:00
2021-10-13 23:25:38 +02:00
$output_html .= $page_content ; //taken from the file
2021-09-24 05:29:57 +02:00
2021-10-13 23:25:38 +02:00
include $path . '/templates/footer.php' ;
$output_html .= '</body>' ;
$output_html .= '</html>' ;
echo $output_html ;
2021-09-24 05:29:57 +02:00
exit ();
2021-08-31 19:16:33 +02:00
2021-09-24 05:29:57 +02:00
}
2021-08-31 19:16:33 +02:00
//
2021-08-29 19:39:07 +02:00
// IF BOARD EXISTS
if ( in_Array ( htmlspecialchars ( $_GET [ " board " ]), $config [ 'boardlist' ])) {
$current_board = htmlspecialchars ( $_GET [ " board " ]);
$board_description = $config [ 'boards' ][ $current_board ][ 'description' ];
2021-10-13 23:25:38 +02:00
$board_slogan = $config [ 'boards' ][ $current_board ][ 'slogan' ];
2021-08-29 19:39:07 +02:00
$board_title = $config [ 'boards' ][ $current_board ][ 'title' ];
2021-10-12 17:20:53 +02:00
//if modonly
if ( $config [ 'boards' ][ $current_board ][ 'mod_only' ] == 1 ) {
if ( $config [ 'mod' ][ 'mod_only' ] > $mod_level ) {
error ( 'Permission denied. Authenticated staff only.' );
}
$forced_anon = true ; //all names will be username in post.php
}
2021-09-10 20:35:46 +02:00
if ( $catalog_enable == true ) {
//IF IMG CATALOG
if ( htmlspecialchars ( $_GET [ " page " ]) === " catalog " ) {
$current_page = " catalog " ;
$title = '/' . $current_board . '/ - ' . $config [ 'boards' ][ $current_board ][ 'title' ] . ' - Catalog - ' . $site_name ;
if ( isset ( $_GET [ " theme " ])) {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . htmlspecialchars ( $_GET [ " theme " ]) . '">' ;
2021-09-10 20:35:46 +02:00
} else {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . $current_theme . '">' ;
2021-09-10 20:35:46 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '<head>' ;
$output_html .= '<link rel="stylesheet" type="text/css" href="' . $prefix_folder . '/assets/css/catalog.css">' ;
include $path . '/templates/header.php' ;
$output_html .= '</head>' ;
$output_html .= '<body class="' . $current_page . '">' ;
include $path . '/templates/boardlist.php' ;
include $path . '/templates/page-info.php' ;
2021-09-10 20:35:46 +02:00
if ( $config [ 'boards' ][ $current_board ][ 'locked' ] != 1 ) {
2021-10-13 23:25:38 +02:00
include $path . '/templates/post-form.php' ;
2021-09-10 20:35:46 +02:00
} else {
2021-10-13 23:25:38 +02:00
$output_html .= '<div class="blotter">This board is locked by the board owner.</div><hr>' ;
2021-09-10 20:35:46 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '">Return</a>] ' ;
$output_html .= '[<a href="#bottom">Bottom</a>] ' ;
$output_html .= '<hr>' ;
2021-10-08 20:39:33 +02:00
if ( ! file_exists ( $path . '/' . $database_folder . '/boards/' . $current_board )) {
2021-10-13 23:25:38 +02:00
$output_html .= 'This board has no threads yet.' ;
include $path . '/templates/footer.php' ;
echo $output_html ;
2021-09-10 20:35:46 +02:00
exit ();
}
2021-10-08 20:39:33 +02:00
if ( file_get_contents ( $path . '/' . $database_folder . '/boards/' . $current_board . '/counter.php' ) === " 1 " ) {
2021-10-13 23:25:38 +02:00
$output_html .= 'This board has no threads yet.' ;
include $path . '/templates/footer.php' ;
echo $output_html ;
2021-09-10 20:35:46 +02:00
exit ();
}
2021-10-08 20:39:33 +02:00
include $path . '/' . $database_folder . '/boards/' . $current_board . '/threads.php' ;
2021-09-10 20:35:46 +02:00
//i should make this a function instead of reusing code, i'll do that later lol
$original_list = $threads ;
$filter = " 1 " ;
$stick_ = array_filter ( $threads , function ( $var ) use ( $filter ){ //get all sticky threads
return ( $var [ 'sticky' ] == $filter );
});
$count_stickied_threads = count ( $stick_ );
if ( $count_stickied_threads > 0 ) {
$keys_ = array_column ( $original_list , 'sticky' );
array_multisort ( $keys_ , SORT_DESC , $original_list ); //sort by sticky
$stickied_threads = array_slice ( $original_list , 0 , $count_stickied_threads ); //this can be sorted again by oldest vs newest? i think is fine like this tho
$not_sticky_threads = array_slice ( $original_list , $count_stickied_threads ); //get non stickies, then we sort them by bumped
$keys_ = array_column ( $not_sticky_threads , 'bumped' );
array_multisort ( $keys_ , SORT_DESC , $not_sticky_threads ); //sort by bumped
$threads = array_merge ( $stickied_threads , $not_sticky_threads );
}
2021-10-13 23:25:38 +02:00
$output_html .= 'Displaying ' . count ( $threads ) . ' threads in total.' ; //maybe at some point add a limit to IB catalog, or just no thumbnails after 100 threads.
$output_html .= '<hr>' ;
2021-09-10 20:35:46 +02:00
2021-10-13 23:25:38 +02:00
$output_html .= '<div class="catalog-threads">' ;
2021-11-10 02:57:46 +01:00
//IF TEXTBOARD:
if ( $config [ " boards " ][ $current_board ][ " type " ] == " txt " ) {
$output_html .= '<div class="textboard-catalog">' ;
$output_html .= '<table>' ;
$output_html .= '<thead>' ;
$output_html .= '<tr><td>Num</td> <td>Title</td> <td>Posts</td> <td>Last Reply</td> <td>Bumped</td></tr>' ;
$output_html .= '</thead>' ;
$output_html .= '<tbody>' ;
foreach ( array_keys ( $threads ) as $key => $value ) {
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/OP.php' ;
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/info.php' ;
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/recents.php' ;
$post_number_op = $threads [ $key ][ 'id' ];
$output_html .= '<tr>' ;
$output_html .= '<td>' . ( $key + 1 ) . '</td>' ;
$output_html .= '<td><a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '&thread=' . $post_number_op . '">' ;
if ( $op_subject == '' ) {
$output_html .= substr ( strip_tags ( $op_body ), 0 , 120 );
} else {
$output_html .= $op_subject ;
}
$output_html .= '</a></td>' ;
$output_html .= '<td>' . $info_replies . '</td>' ;
$last_reply = end ( $recents );
if ( $last_reply == '' ) {
$output_html .= '<td><span class="post-time" data-timestamp="' . $op_time . '" data-tooltip="' . timeConvert ( $op_time , $time_method_hover ) . '"> ' . timeConvert ( $op_time , $time_method ) . '</span></td>' ;
} else {
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/' . $last_reply . '.php' ;
$output_html .= '<td><span class="post-time" data-timestamp="' . $reply_time . '" data-tooltip="' . timeConvert ( $reply_time , $time_method_hover ) . '"> ' . timeConvert ( $reply_time , $time_method ) . '</span></td>' ;
}
if ( file_exists ( $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/' . 'bumped.php' )) {
$bumped = file_get_contents ( $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/' . 'bumped.php' );
} else {
$bumped = $post_number_op ;
}
if ( $bumped == $post_number_op ) {
$output_html .= '<td><span class="post-time" data-timestamp="' . $op_time . '" data-tooltip="' . timeConvert ( $op_time , $time_method_hover ) . '"> ' . timeConvert ( $op_time , $time_method ) . '</span></td>' ;
} else {
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/' . $bumped . '.php' ;
$output_html .= '<td><span class="post-time" data-timestamp="' . $reply_time . '" data-tooltip="' . timeConvert ( $reply_time , $time_method_hover ) . '"> ' . timeConvert ( $reply_time , $time_method ) . '</span></td>' ;
}
$output_html .= '</tr>' ;
}
$output_html .= '</tbody>' ;
$output_html .= '</table>' ;
$output_html .= '</div><hr>' ;
}
//IMG/else
//if ($config["boards"][$current_board]["type"] != "txt") {
foreach ( array_keys ( $threads ) as $key => $value ) {
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/OP.php' ;
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/info.php' ;
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/recents.php' ;
$post_number_op = $threads [ $key ][ 'id' ];
$output_html .= '<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '&thread=' . $post_number_op . '">' ;
$output_html .= '<div data-thread="' . $post_number_op . '" class="container">' ;
include $path . '/templates/thread-catalog.php' ;
$output_html .= '</div>' ;
$output_html .= '</a>' ;
}
//}
2021-10-13 23:25:38 +02:00
$output_html .= '</div>' ;
$output_html .= '<div class="catalog-footer">' ;
$output_html .= '<hr>' ;
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '">Return</a>] ' ;
$output_html .= '[<a href="#top">Top</a>] ' ;
include $path . '/templates/footer.php' ;
$output_html .= '</div>' ;
$output_html .= '</body>' ;
$output_html .= '</html>' ;
echo $output_html ;
2021-09-10 20:35:46 +02:00
exit ();
}
}
2021-08-29 19:39:07 +02:00
2021-08-31 19:16:33 +02:00
//IF INDEX
2021-08-29 19:39:07 +02:00
if ( htmlspecialchars ( $_GET [ " thread " ]) === " " ) {
$current_page = " index " ;
$title = '/' . $current_board . '/ - ' . $config [ 'boards' ][ $current_board ][ 'title' ] . ' - ' . $site_name ;
if ( isset ( $_GET [ " theme " ])) {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . htmlspecialchars ( $_GET [ " theme " ]) . '">' ;
2021-08-29 19:39:07 +02:00
} else {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . $current_theme . '">' ;
2021-08-29 19:39:07 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '<head>' ;
include $path . '/templates/header.php' ;
$output_html .= '</head>' ;
$output_html .= '<body class="' . $current_page . '">' ;
include $path . '/templates/boardlist.php' ;
include $path . '/templates/page-info.php' ;
2021-09-02 09:52:04 +02:00
if ( $config [ 'boards' ][ $current_board ][ 'locked' ] != 1 ) {
2021-10-13 23:25:38 +02:00
include $path . '/templates/post-form.php' ;
2021-09-02 09:52:04 +02:00
} else {
2021-10-13 23:25:38 +02:00
$output_html .= '<div class="blotter">This board is locked by the board owner.</div><hr>' ;
2021-09-02 09:52:04 +02:00
}
2021-09-10 20:35:46 +02:00
if ( $catalog_enable == true ) {
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '&page=catalog">Catalog</a>] ' ;
2021-09-10 20:35:46 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="#bottom">Bottom</a>] ' ;
$output_html .= '<hr>' ;
2021-08-29 19:39:07 +02:00
2021-08-31 19:16:33 +02:00
//if zero threads aka new board
2021-10-08 20:39:33 +02:00
if ( ! file_exists ( $path . '/' . $database_folder . '/boards/' . $current_board )) {
2021-10-13 23:25:38 +02:00
$output_html .= 'This board has no threads yet.' ;
include $path . '/templates/footer.php' ;
echo $output_html ;
2021-08-31 14:14:54 +02:00
exit ();
}
2021-10-08 20:39:33 +02:00
if ( file_get_contents ( $path . '/' . $database_folder . '/boards/' . $current_board . '/counter.php' ) === " 1 " ) {
2021-10-13 23:25:38 +02:00
$output_html .= 'This board has no threads yet.' ;
include $path . '/templates/footer.php' ;
echo $output_html ;
2021-08-29 19:39:07 +02:00
exit ();
}
2021-10-08 20:39:33 +02:00
include $path . '/' . $database_folder . '/boards/' . $current_board . '/threads.php' ;
2021-09-08 15:19:51 +02:00
//put stickies up front (not doing this in the saved list, if wanna have frontpage with recent threads)
$original_list = $threads ;
$filter = " 1 " ;
$stick_ = array_filter ( $threads , function ( $var ) use ( $filter ){ //get all sticky threads
return ( $var [ 'sticky' ] == $filter );
});
$count_stickied_threads = count ( $stick_ );
if ( $count_stickied_threads > 0 ) {
$keys_ = array_column ( $original_list , 'sticky' );
array_multisort ( $keys_ , SORT_DESC , $original_list ); //sort by sticky
$stickied_threads = array_slice ( $original_list , 0 , $count_stickied_threads ); //this can be sorted again by oldest vs newest? i think is fine like this tho
$not_sticky_threads = array_slice ( $original_list , $count_stickied_threads ); //get non stickies, then we sort them by bumped
$keys_ = array_column ( $not_sticky_threads , 'bumped' );
array_multisort ( $keys_ , SORT_DESC , $not_sticky_threads ); //sort by bumped
$threads = array_merge ( $stickied_threads , $not_sticky_threads );
}
2021-09-07 21:21:18 +02:00
2021-09-07 15:40:49 +02:00
if ( count ( $threads ) > $threads_page ) {
2021-09-07 21:21:18 +02:00
$total_threads = count ( $threads );
$final_page_threads = $threads_page - ( $total_threads % $threads_page ); //how many to offset the arrayslice by for last page
2021-09-10 20:35:46 +02:00
if ( $final_page_threads == 10 ) {
$final_page_threads = 0 ; //this is kinda silly xd, i could substr the line above but this looks more readable? idk
}
2021-09-07 21:21:18 +02:00
//create pages
2021-09-15 21:26:14 +02:00
$pages = ceil ( $total_threads / $threads_page );
2021-09-07 21:21:18 +02:00
if ( $_GET [ 'page' ] == '' ) {
$number_page = 1 ;
} elseif ( ! is_numeric ( $_GET [ 'page' ])) {
error ( 'Page number must be a number.' );
} elseif ( $_GET [ 'page' ] > $pages || $_GET [ 'page' ] < 1 ) {
error ( 'This number is higher or lower than page count...' );
} else {
$number_page = $_GET [ 'page' ];
}
$offset_ = ( $number_page - 1 * $threads_page );
$start_ = $offset_ + 1 ;
$end_ = min (( $offset_ + $threads_page ), $total_threads );
// The "back" link
2021-09-08 11:28:49 +02:00
$prevlink = ( $number_page > 1 ) ? '<form method="get"><button type="submit" value="' . $current_board . ' " name= " board " >Previous</button>
< input type = " hidden " name = " page " value = " ' . ( $number_page - 1) . ' " ></ form > ' : ' < span class = " disabled " > Previous </ span > ' ;
2021-09-07 21:21:18 +02:00
$all_pages = '' ;
for ( $i = 0 ; $i < $pages ; $i ++ ) {
$currentp = $i + 1 ;
if ( $currentp == $number_page ) {
2021-10-09 23:17:39 +02:00
$all_pages .= '[<a href="' . $prefix_folder . '/?board=' . $current_board . '&page=' . $currentp . '"><b>' . $currentp . '</b></a>] ' ;
2021-09-07 21:21:18 +02:00
} else {
$all_pages .= '[<a href="' . $prefix_folder . '/?board=' . $current_board . '&page=' . $currentp . '">' . $currentp . '</a>] ' ;
}
}
2021-09-08 11:28:49 +02:00
$nextlink = ( $number_page < $pages ) ? '<form method="get"><button type="submit" value="' . $current_board . ' " name= " board " >Next</button>
< input type = " hidden " name = " page " value = " ' . ( $number_page + 1) . ' " ></ form > ' : ' < span class = " disabled " > Next </ span > ' ;
2021-09-07 21:21:18 +02:00
//page 1
if ( $number_page == 1 ) {
$threads = array_slice ( $threads , 0 , $threads_page );
} elseif ( $number_page == $pages ) { //if final page
$threads = array_slice ( $threads , - $threads_page , $threads_page );
$threads = array_slice ( $threads , $final_page_threads );
} else {
$threads = array_slice ( $threads , ( $threads_page * $number_page ) - $threads_page );
$threads = array_slice ( $threads , 0 , $threads_page );
}
//$hidden_threads = $total_threads - $threads_page;
2021-10-13 23:25:38 +02:00
//$output_html .= 'There are ' . $hidden_threads . ' undisplayed threads. I\'ll make a pagination for them all...' ;
2021-09-07 21:21:18 +02:00
2021-08-29 19:39:07 +02:00
}
//SHOW THEM
foreach ( array_keys ( $threads ) as $key => $value ) {
2021-10-08 20:39:33 +02:00
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/OP.php' ;
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/info.php' ;
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $threads [ $key ][ 'id' ] . '/recents.php' ;
2021-08-29 19:39:07 +02:00
$post_number_op = $threads [ $key ][ 'id' ];
2021-10-13 23:25:38 +02:00
$output_html .= '<div data-thread="' . $post_number_op . '" class="container">' ;
2021-08-29 19:39:07 +02:00
//SHOW THREADS
2021-10-13 23:25:38 +02:00
include $path . '/templates/thread.php' ;
2021-08-29 19:39:07 +02:00
//SHOW SHOW REPLIES
2021-09-07 15:40:49 +02:00
foreach ( array_keys ( $recents ) as $rkey => $value ) {
2021-10-08 20:39:33 +02:00
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $post_number_op . '/' . $recents [ $value ] . '.php' ;
2021-09-07 15:40:49 +02:00
$post_number_reply = $recents [ $value ];
2021-10-13 23:25:38 +02:00
include $path . '/templates/reply.php' ;
2021-08-29 19:39:07 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '</div>' ;
2021-08-29 19:39:07 +02:00
if ( $key != array_key_last ( $threads )) {
2021-10-13 23:25:38 +02:00
$output_html .= '<hr data-thread="' . $post_number_op . '">' ;
2021-08-29 19:39:07 +02:00
}
}
2021-10-13 23:25:38 +02:00
$output_html .= '<hr>' ;
2021-09-10 20:35:46 +02:00
if ( $catalog_enable == true ) {
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '&page=catalog">Catalog</a>] ' ;
2021-09-10 20:35:46 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="#top">Top</a>] ' ;
include $path . '/templates/footer.php' ;
$output_html .= '</body>' ;
$output_html .= '</html>' ;
echo $output_html ;
2021-08-29 19:39:07 +02:00
exit ();
2021-08-31 14:14:54 +02:00
2021-08-29 19:39:07 +02:00
}
2021-08-31 19:16:33 +02:00
// IF THREAD
2021-08-29 19:39:07 +02:00
if ( htmlspecialchars ( $_GET [ " thread " ]) != '' ) {
2021-08-31 19:16:33 +02:00
if ( isset ( $_GET [ " theme " ])) {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . htmlspecialchars ( $_GET [ " theme " ]) . '">' ;
2021-08-31 19:16:33 +02:00
} else {
2021-10-13 23:25:38 +02:00
$output_html .= '<html data-stylesheet="' . $current_theme . '">' ;
2021-08-31 19:16:33 +02:00
}
2021-10-01 08:10:01 +02:00
if ( ! is_numeric ( $_GET [ " thread " ])) {
error ( 'Thread number must be a number.' );
}
2021-08-31 19:16:33 +02:00
//IF DOESNT EXIST
2021-10-08 20:39:33 +02:00
if ( ! file_exists ( $path . '/' . $database_folder . '/boards/' . $current_board . '/' . htmlspecialchars ( $_GET [ " thread " ]))) {
2021-08-31 19:16:33 +02:00
$title = " Oh no!! A 404... " ;
2021-10-13 23:25:38 +02:00
$output_html .= '<head>' ;
include $path . '/templates/header.php' ;
$output_html .= '</head>' ;
$output_html .= '<body class="' . $current_page . '">' ;
include $path . '/templates/boardlist.php' ;
include $path . '/templates/page-info.php' ;
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '">Return</a>] ' ;
$output_html .= '<hr>' ;
$output_html .= '<div class="message">This thread doesn\'t exist.. Did the glowies get it — or worse, a janny??<br><img style="height: 500px;width: 500px;margin-top: 5px;" src="' . $prefix_folder . '/assets/img/404.png" width="" height=""></div><style>.message { margin-top: 0!important }</style>' ;
$output_html .= '<div class="message">[<a href="' . $prefix_folder . $main_file . '?board=' . $current_board . '">Return</a>]</div>' ;
$output_html .= '<hr>' ;
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '">Return</a>] ' ;
include $path . '/templates/footer.php' ;
echo $output_html ;
2021-08-31 19:16:33 +02:00
exit ();
} else {
//IF DOES EXIST
$current_page = " thread " ;
2021-10-08 20:39:33 +02:00
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . htmlspecialchars ( $_GET [ " thread " ]) . '/OP.php' ;
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . htmlspecialchars ( $_GET [ " thread " ]) . '/info.php' ;
2021-08-31 19:16:33 +02:00
$post_number_op = htmlspecialchars ( $_GET [ " thread " ]);
if ( $op_subject == '' ) {
2021-09-08 11:28:49 +02:00
$title = '/' . $current_board . '/' . ' - ' . substr ( strip_tags ( $op_body ), 0 , 30 ) . ' - ' . $config [ 'boards' ][ $current_board ][ 'title' ] . ' - ' . $site_name ;
2021-08-31 19:16:33 +02:00
} else {
$title = '/' . $current_board . '/' . ' - ' . $op_subject . ' - ' . $config [ 'boards' ][ $current_board ][ 'title' ] . ' - ' . $site_name ;
}
2021-10-13 23:25:38 +02:00
$output_html .= '<head>' ;
include $path . '/templates/header.php' ;
$output_html .= '</head>' ;
$output_html .= '<body class="' . $current_page . '">' ;
include $path . '/templates/boardlist.php' ;
include $path . '/templates/page-info.php' ;
include $path . '/templates/post-form.php' ;
2021-10-08 20:39:33 +02:00
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $post_number_op . " /info.php " ;
2021-08-31 19:16:33 +02:00
$thread_stats = '<span class="thread-stats">Replies: ' . $info_replies . ' Posters: ' . $info_uniqueids . '</span>' ;
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '">Return</a>] ' ;
2021-09-10 20:35:46 +02:00
if ( $catalog_enable == true ) {
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '&page=catalog">Catalog</a>] ' ;
2021-09-10 20:35:46 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="#bottom">Bottom</a>] ' ;
$output_html .= $thread_stats ;
$output_html .= '<hr>' ;
2021-08-31 19:16:33 +02:00
2021-10-08 20:39:33 +02:00
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . htmlspecialchars ( $_GET [ " thread " ]) . '/OP.php' ;
2021-08-31 19:16:33 +02:00
$post_number_op = htmlspecialchars ( $_GET [ " thread " ]);
2021-10-13 23:25:38 +02:00
$output_html .= '<div data-thread="' . $post_number_op . '" class="container">' ; //start thread
include $path . '/templates/thread.php' ;
2021-08-31 19:16:33 +02:00
$current_thread = $post_number_op ;
//ADD ALL REPLIES HERE
//FIND REPLIES
$replies_full = [];
2021-10-08 20:39:33 +02:00
$replies_full = glob ( $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $post_number_op . " /* " );
2021-08-31 19:16:33 +02:00
//SORTING
$replies = [];
foreach ( $replies_full as $reply ) {
2021-09-07 12:22:43 +02:00
if ( is_numeric ( basename ( $reply , '.php' ))) {
2021-08-31 19:16:33 +02:00
$replies [] = basename ( $reply , '.php' );
}
}
sort ( $replies );
//SHOW THEM
foreach ( array_keys ( $replies ) as $key => $value ) {
2021-10-08 20:39:33 +02:00
include $path . '/' . $database_folder . '/boards/' . $current_board . '/' . $post_number_op . '/' . $replies [ $value ] . '.php' ;
2021-08-31 19:16:33 +02:00
$post_number_reply = $replies [ $value ];
2021-10-13 23:25:38 +02:00
include $path . '/templates/reply.php' ;
2021-08-31 19:16:33 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '</div>' ; //end thread
2021-08-31 19:16:33 +02:00
2021-10-13 23:25:38 +02:00
$output_html .= '<hr>' ;
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '">Return</a>] ' ;
2021-09-10 20:35:46 +02:00
if ( $catalog_enable == true ) {
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="' . $prefix_folder . '/' . $main_file . '?board=' . $current_board . '&page=catalog">Catalog</a>] ' ;
2021-09-10 20:35:46 +02:00
}
2021-10-13 23:25:38 +02:00
$output_html .= '[<a href="#top">Top</a>] ' ;
$output_html .= $thread_stats ;
include $path . '/templates/footer.php' ;
$output_html .= '</body>' ;
$output_html .= '</html>' ;
echo $output_html ;
exit ();
2021-08-31 19:16:33 +02:00
}
2021-08-29 19:39:07 +02:00
}
2021-08-31 19:16:33 +02:00
2021-08-29 19:39:07 +02:00
}
2021-08-31 19:16:33 +02:00
//NOT A BOARD
2021-08-29 19:39:07 +02:00
if (( htmlspecialchars ( $_GET [ " board " ]) !== '' ) && ( ! in_Array ( htmlspecialchars ( $_GET [ " board " ]), $config [ 'boardlist' ]))) {
error ( 'This board doesn\'t exist.. You\'re not trying anything funny — are you, Anon-san??' );
}
?>