');             }             if($boardid !== '1') {                 $title = '#PetPonies Forums - ' . $view['title'];             }             else {                 $title = '#PetPonies Forums';             }         }         else {             $title = '#PetPonies Forum - 404';         }       }     if (session_status() == PHP_SESSION_NONE) { session_start(); }     mysqli_close($gcon);     include_once '../lib/libOpen.php'; ?>
       
   
                                                           
                         ';                 }                 $qpost = mysqli_query($gcon, "SELECT * FROM f_Posts WHERE parentid='" . $threadid . "' ORDER BY id ASC");                 $posts = array();                 while($x = mysqli_fetch_array($qpost)) {                     $posts[$x['id']] = $x;                 }                 $posts_sort = array();                 foreach($posts as $y) {                     array_push($posts_sort, $y);                 }                 if(count($posts_sort) > 10) {                     echo makePageSwitcher($posts_sort);                 }                 $post_page = pagify($posts_sort);                 echo formatPost($post_page[0], array_slice($post_page, 1));                 for($i = 1; $i < count($post_page) - 1; $i++) {                     if($post_page[$i]['authorid'] == $post_page[$i - 1]['authorid']) {                         $i++;                         continue;                     }                     echo formatPost($post_page[$i], array_slice($post_page, $i + 1));                 }                 if(count($post_page) > 1) {                     echo formatPost($post_page[count($post_page) - 1]);                 }                 if(count($posts_sort) > 10) {                     echo makePageSwitcher($posts_sort);                 }                 if(isset($_SESSION['account']) and $_SESSION['acctype'] !== 'new') {                     echo '
                                                       
                         
';                 }                 else {                     echo '

A petponies.com account is required to post.  You can register here.

';                 }             }             else {                 echo '
Error 404
                   

404 - Thread not found.  Try to be less terrible at links from now on.

';             }         }         else {             if($view !== null) {                 if($view['type'] == 'normal') {                     $qchildren = mysqli_query($gcon, "SELECT * FROM f_Threads AS t JOIN f_Posts as p ON p.id = t.lastid WHERE t.parentid='" . $boardid . "' ORDER BY p.date_posted DESC");                     echo '
Threads
';                     $threads = array();                     while($x = mysqli_fetch_array($qchildren)) {                         array_push($threads, $x);                     }                     if(checkPermSet($view['perm_post'])) {                         echo '
                                                               
                             
';                     }                     if(count($threads) > 20) {                         echo makePageSwitcher($threads);                     }                     $thread_page = pagify($threads, 20);                     if(count($threads) == 0) {                         echo '

It's so empty in here. I'm scared.  Hold me.

';                     }                     foreach($thread_page as $cthread) {                         $qlp = mysqli_query($gcon, "SELECT * FROM f_Posts WHERE id='" . $cthread['lastid'] . "'");                         $qop = mysqli_query($gcon, "SELECT * FROM f_Posts WHERE id='" . $cthread['opid'] . "'");                         $qnp = mysqli_query($gcon, "SELECT * FROM f_Posts WHERE parentid='" . $cthread[0] . "'");                         $lp = mysqli_fetch_array($qlp);                         $op = mysqli_fetch_array($qop);                         $qlu = mysqli_query($gcon, "SELECT * FROM Accounts WHERE id='" . $lp['authorid'] . "'");                         $lu = mysqli_fetch_array($qlu);                         $qou = mysqli_query($gcon, "SELECT * FROM Accounts WHERE id='" . $op['authorid'] . "'");                         $ou = mysqli_fetch_array($qou);                         echo '
' . $cthread['title'] . '';                         echo '
' . stripBBCode($op['text']) . '
' . PHP_EOL;                         echo '
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
RepliesStarted ByLast PosterLast Post
' . (mysqli_num_rows($qnp) - 1) . '' . $ou['name'] . '' . $lu['name'] . '' . convertLocalTime($lp['date_posted'], $_SESSION['timezone'], true) . '
                             
' . PHP_EOL;                     }                     if(count($threads) > 20)                         echo makePageSwitcher($threads);                     if(checkPermSet($view['perm_post'])) {                         echo '
                                                               
                             
';                     }                 }                 else {                     $qchildren = mysqli_query($gcon, "SELECT * FROM f_Boards WHERE parentid='" . $boardid . "'");                     while($cboard = mysqli_fetch_array($qchildren)) {                         if(!checkPermSet($cboard['perm_view'])) {                             continue;                         }                         if($cboard['type'] == 'category') {                             echo '
' . $cboard['title'] . '
' . PHP_EOL;                             $qsc = mysqli_query($gcon, "SELECT * FROM f_Boards WHERE parentid='" . $cboard['id'] . "'");                             while($csboard = mysqli_fetch_array($qsc)) {                                 if(!checkPermSet($csboard['perm_view'])) {                                     continue;                                 }                                 $qnt = mysqli_query($gcon, "SELECT * FROM f_Threads WHERE parentid='" . $csboard['id'] . "'");                                 $qlp = mysqli_query($gcon, "SELECT * FROM f_Threads AS t JOIN f_Posts AS p ON t.id=p.parentid WHERE t.parentid='" . $csboard['id'] . "' ORDER BY p.id DESC LIMIT 1");                                 $slp = 'Unknown';                                 $slu = 'Unknown';                                 $lp = mysqli_fetch_array($qlp);                                 if($lp !== null) {                                     $slp = convertLocalTime($lp['date_posted'], $_SESSION['timezone'], true);                                     $qlu = mysqli_query($gcon, "SELECT * FROM Accounts WHERE id='" . $lp['authorid'] . "'");                                     $lu = mysqli_fetch_array($qlu);                                     if($lu !== null) {                                         $slu = $lu['name'];                                     }                                 }                                 echo '
' . $csboard['title'] . '';                                 echo '
' . $csboard['description'] . '
' . PHP_EOL;                                 echo '
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
ThreadsLast PosterLast Post
' . mysqli_num_rows($qnt) . '' . $slu . '' . $slp . '
                                     
' . PHP_EOL;                             }                         }                         else {                             $qnt = mysqli_query($gcon, "SELECT * FROM f_Threads WHERE parentid='" . $cboard['id'] . "'");                             $qlp = mysqli_query($gcon, "SELECT * FROM f_Threads AS t JOIN f_Posts AS p ON t.id=p.parentid WHERE t.parentid='" . $cboard['id'] . "' ORDER BY p.id DESC LIMIT 1");                             $slp = 'Unknown';                             $slu = 'Unknown';                             $lp = mysqli_fetch_array($qlp);                             if($lp !== null) {                                 $slp = convertLocalTime($lp['date_posted'], $_SESSION['timezone'], true);                                 $qlu = mysqli_query($gcon, "SELECT * FROM Accounts WHERE id='" . $lp['authorid'] . "'");                                 $lu = mysqli_fetch_array($qlu);                                 if($lu !== null) {                                     $slu = $lu['name'];                                 }                             }                             echo '
' . $cboard['title'] . '';                             echo '
' . $cboard['description'] . '
' . PHP_EOL;                             echo '
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
ThreadsLast PosterLast Post
' . mysqli_num_rows($qnt) . '' . $slu . '' . $slp . '
                                 
' . PHP_EOL;                         }                     }                 }             }             else {                 echo '
Error 404
                   

404 - Board not found.  Try to be less terrible at links from now on.

';             }         }     ?>