if (isset($mods[$forum]) and is_array($mods[$forum])) {
                foreach ($mods[$forum] as $ms) {
                    if (isset($modsForums[$ms])) {
                        $moderatorsList .= $modsForums[$ms] . ', ';
                    }
                }
                if ($moderatorsList != '') {
                    $moderatorsList = '<br /><span class="txtSm">' . $l_moderatorsAre . ': ' . substr($moderatorsList, 0, strlen($moderatorsList) - 2) . '</span>';
                }
            }
            if ($cols[6] != '') {
                $list_forums .= ParseTpl($tplg);
                $keyAr++;
            }
            if (isset($mod_rewrite) and $mod_rewrite) {
                $linkToForums = addForumURLPage(genForumURL($main_url, $forum, $forum_title), PAGE1_OFFSET + 1);
            } else {
                $linkToForums = "{$main_url}/{$indexphp}action=vtopic&amp;forum={$forum}";
            }
            $list_forums .= ParseTpl($tpl);
            $i = -$i;
        }
    } while ($cols = db_simpleSelect(1));
    unset($result);
    unset($countRes);
    $title = $sitename;
    echo load_header();
    if (!isset($startPageModern) or !$startPageModern) {
        echo ParseTpl(makeUp('main_forums'));
    }
} else {
        return;
    }
    //CSRF cookie delete
    setcookie($cookiename . 'csrf', '', time() - 2592000, $cookiepath, $cookiedomain, $cookiesecure);
    if ($user_sort == 1) {
        if (isset($metaLocation)) {
            $meta_relocate = "{$main_url}/{$indexphp}action=vtopic&forum={$forum}&page={$return}&h={$h}";
            echo ParseTpl(makeUp($metaLocation));
            exit;
        } else {
            header("Location: {$main_url}/{$indexphp}action=vtopic&forum={$forum}&page={$return}&h={$h}");
            exit;
        }
    } else {
        if (isset($mod_rewrite) and $mod_rewrite) {
            $urlp = addForumURLPage(genForumURL($main_url, $forum, '#GET#'), PAGE1_OFFSET + 1);
        } else {
            $urlp = "{$main_url}/{$indexphp}action=vtopic&forum={$forum}";
        }
        if (isset($metaLocation)) {
            $meta_relocate = $urlp;
            echo ParseTpl(makeUp($metaLocation));
            exit;
        } else {
            header("Location: {$urlp}");
            exit;
        }
    }
} else {
    $errorMSG = $l_forbidden;
    $correctErr = '';
     }
 } else {
     $lastPostText = 'N/A';
 }
 if ($cols[3] == '') {
     $cols[3] = $l_anonymous;
 }
 $topicAuthor = $cols[3];
 if ($i > 0) {
     $bg = 'tbCel1';
 } else {
     $bg = 'tbCel2';
 }
 if (isset($mod_rewrite) and $mod_rewrite) {
     $urlp = genTopicURL($main_url, $forum, $fTitle[$forum], $topic, $topic_title);
     $urlForum = addForumURLPage(genForumURL($main_url, $forum, $fTitle[$forum]), PAGE1_OFFSET + 1);
     $urlType = 'Topic';
 } else {
     $urlp = "{$main_url}/{$indexphp}action=vthread&amp;forum={$forum}&amp;topic={$topic}";
     $urlForum = "{$main_url}/{$indexphp}action=vtopic&amp;forum={$forum}";
     $urlType = 'Gen';
 }
 $pageNavCell = pageNav(PAGE1_OFFSET + 1, $numReplies + 1, $urlp, $viewmaxreplys, TRUE, $urlType);
 $whenPosted = convert_date($cols[4]);
 if (trim($cols[1]) == '') {
     $cols[1] = $l_emptyTopic;
 }
 //Forum icon
 if (isset($fIcon[$forum])) {
     $forumIcon = $fIcon[$forum];
 } else {
     } while ($rw = db_simpleSelect(1));
     asort($forums, SORT_NUMERIC);
     $forums = array_reverse($forums, TRUE);
     //$xtr=getClForums($forumIds,'where','','forum_id','OR','=');
     $userID = $user + 0;
     $key2 = '';
     $whatValue = '';
     $tpl = makeUp('stats_bar');
     if (sizeof($forumNames) > 0) {
         foreach ($forums as $k => $val) {
             if (!isset($vMax)) {
                 $vMax = $val;
             }
             $stats_barWidth = round(100 * ($val / $vMax));
             if (isset($mod_rewrite) and $mod_rewrite) {
                 $urlp = addForumURLPage(genForumURL($main_url, $k, $forumNames[$k]), PAGE1_OFFSET + 1);
             } else {
                 $urlp = "{$main_url}/{$indexphp}action=vtopic&amp;forum={$k}";
             }
             if ($stats_barWidth > $stats_barWidthLim) {
                 $key = "<a href=\"{$urlp}\" {$nof}>{$forumNames[$k]}</a>";
             } else {
                 $key2 = "<a href=\"{$urlp}\" {$nof}>{$forumNames[$k]}</a>";
                 $key = "<a href=\"{$urlp}\" {$nof}>...</a>";
             }
             $whatValue .= ParseTpl($tpl);
         }
     }
     $USERINFO .= ParseTpl($usrCell);
 }
 //if posts
    $user_pwd = '';
}
$queryStr = rawurldecode($queryStr);
if (strstr($queryStr, 'vtopic')) {
    $queryStr .= '#newtopic';
} elseif (strstr($queryStr, 'vthread')) {
    $queryStr .= '#newreply';
}
if ($action == 'pthread' and isset($_POST['postText']) and $_POST['postText'] == '' or $action == 'ptopic' and isset($_POST['postText']) and $_POST['postText'] == '') {
    $action = '';
}
/* */
$urlp = "{$indexphp}{$queryStr}";
if (isset($mod_rewrite) and $mod_rewrite) {
    $urlp = preg_replace("@" . str_replace('?', '\\?', $indexphp) . "action=vthread&forum=([0-9]+)&topic=([0-9]+)&page=([-0-9]+)&mdrw=on(#newreply)?@", addTopicURLPage(genTopicURL($main_url, "\\1", '#GET#', "\\2", '#GET#'), "\\3") . "\\4", $urlp);
    $urlp = preg_replace("@" . str_replace('?', '\\?', $indexphp) . "action=vtopic&forum=([0-9]+)&page=([-0-9]+)&mdrw=on(#newtopic)?@", addForumURLPage(genForumURL($main_url, "\\1", '#GET#'), "\\2") . "\\3", $urlp);
    $urlp = preg_replace("@" . str_replace('?', '\\?', $indexphp) . "mdrw=on@", $main_url . '/' . $startIndex, $urlp);
}
if ($urlp == $indexphp) {
    $urlp = $main_url . '/' . $startIndex;
}
/* */
if (strlen($admin_pwd) == 32) {
    $user_pwd_cmp = writeUserPwd($user_pwd);
} else {
    $user_pwd_cmp = $user_pwd;
}
if ($user_usr == $admin_usr or isset($loginsCase) and $loginsCase and strtolower($user_usr) == strtolower($admin_usr)) {
    if ($user_pwd_cmp == $admin_pwd) {
        $logged_admin = 1;
        $cook = $admin_usr . "|" . writeUserPwd($user_pwd) . "|" . $cookieexptime;
        }
    } elseif ($user_id == $topicPoster and $user_id != 0 and $user_id != 1 and $topicSticky != 1 and !$c4) {
        if ($topicStatus == 0 and $userUnlock != 2) {
            $closeTopic = "<a href=\"{$main_url}/{$indexphp}action=locktopic&amp;forum={$forum}&amp;topic={$topic}&amp;chstat=1\">{$l_closeTopic}</a>";
        } elseif ($topicStatus == 1 and $userUnlock == 1 and $userUnlock != 2) {
            $closeTopic = "<a href=\"{$main_url}/{$indexphp}action=locktopic&amp;forum={$forum}&amp;topic={$topic}&amp;chstat=0\">{$l_unlockTopic}</a>";
        } else {
            $closeTopic = '';
        }
    }
    if ($page > PAGE1_OFFSET + 1) {
        $tpage = ' - ' . $l_page . ' ' . ($page - PAGE1_OFFSET);
    } else {
        $tpage = '';
    }
    $title1 = $title;
    $title = strip_tags($topicName);
    if (isset($addMainTitle)) {
        $title .= ' - ' . str_replace(' - ', '', $title1);
    }
    $title .= $tpage;
    //$title=strip_tags($topicName).' - '.str_replace(' - ','',$title).$tpage;
}
//if posts
if (isset($mod_rewrite) and $mod_rewrite) {
    $linkToForums = addForumURLPage(genForumURL($main_url, $forum, $forumsArray[$forum][0]), PAGE1_OFFSET + 1);
} else {
    $linkToForums = "{$main_url}/{$indexphp}action=vtopic&amp;forum={$forum}";
}
echo load_header();
echo ParseTpl(makeUp('main_posts'));
     $urlType = 'Forum';
 } else {
     if ($user_sort == 0 and !isset($_GET['sortBy'])) {
         $sburl = '';
     } else {
         $sburl = "&amp;sortBy={$user_sort}";
     }
     $urlp = "{$main_url}/{$indexphp}action=vtopic&amp;forum={$forum}{$sburl}";
     $urlType = 'Gen';
 }
 //avoiding duplicated content issues
 $totalPages = ceil($numRows / $viewmaxtopic);
 if ($page < PAGE1_OFFSET + 1 or $page - PAGE1_OFFSET > $totalPages) {
     $realPage = pageChk($page, $numRows, $viewmaxtopic);
     if (isset($mod_rewrite) and $mod_rewrite and $sortBy == 0) {
         $urlp = addForumURLPage(genForumURL($main_url, $forum, $forumName), $realPage);
     } else {
         $urlp = "{$main_url}/{$indexphp}action=vtopic&forum={$forum}&page={$realPage}";
     }
     header("HTTP/1.1 301 Moved Permanently");
     if (isset($metaLocation)) {
         $meta_relocate = "{$urlp}";
         echo ParseTpl(makeUp($metaLocation));
         exit;
     } else {
         header("Location: {$urlp}");
         exit;
     }
 }
 $pageNav = pageNav($page, $numRows, $urlp, $viewmaxtopic, FALSE, $urlType);
 if ($pageNav != '') {
     } else {
         $post_status = 1;
     }
     $fif = updateArray(array('post_text', 'post_status'), $Tp, 'post_id', $post);
     if ($fif != 0) {
         $errorMSG .= $l_topicTextUpdated . "<br />";
     }
     $title .= $l_editPost;
     if (isset($mod_rewrite) and $mod_rewrite) {
         if (isset($topic_title)) {
             $tt = $topic_title;
         } else {
             $tt = '#GET#';
         }
         $furl = $furlCl = addTopicURLPage(genTopicURL($main_url, $forum, '#GET#', $topic, $tt), $page) . "#msg{$anchor}";
         $topicsLink = "<a href=\"" . addTopicURLPage(genForumURL($main_url, $forum, '#GET#'), PAGE1_OFFSET + 1) . "\">{$l_returntotopics}</a><br />";
     } else {
         $furl = addGenURLPage("{$main_url}/{$indexphp}action=vthread&amp;forum={$forum}&amp;topic={$topic}", $page) . "#msg{$anchor}";
         $furlCl = addGenURLPage("{$main_url}/{$indexphp}action=vthread&forum={$forum}&topic={$topic}", $page, '&') . "#msg{$anchor}";
         $topicsLink = "<a href=\"" . addGenURLPage("{$main_url}/{$indexphp}action=vtopic&amp;forum={$forum}", PAGE1_OFFSET + 1) . "\">{$l_returntotopics}</a><br />";
     }
     $correctErr = "<a href=\"{$furl}\">{$l_back}</a>";
 }
 if (isset($editMsgReloc)) {
     header("Refresh: 0; url={$furlCl}");
     exit;
 } else {
     echo load_header();
     echo ParseTpl(makeUp('main_warning'));
     return;
 }