Exemplo n.º 1
0
 function q_results($sql, $dbr)
 {
     global $wgOut, $LimitJump_top, $LimitJump_bot, $first_return, $todo, $tplt, $awcUser;
     $thread_tools = new awcs_forum_thread_list_tools();
     $thread_tools->extra_column = true;
     $word_headers = array('replies' => get_awcsforum_word('word_replies'), 'views' => get_awcsforum_word('views'), 'last_action' => get_awcsforum_word('last_action'), 'started_by' => get_awcsforum_word('thread_title_started_by'));
     $word = array('started_by' => get_awcsforum_word('forum_started_by'));
     $sql = str_replace('AND   AND', ' AND ', $sql);
     $sql = str_replace('WHERE   AND', 'WHERE ', $sql);
     #die($sql);
     $res = $dbr->query($sql);
     $r = $dbr->fetchRow($res);
     $total = $dbr->numRows($res);
     $dbr->freeResult($res);
     $this->total = $total;
     $send['TotalPosts'] = $total;
     $limit = GetLimit($send, 'search');
     $i = 0;
     $tmp = '';
     $dbr = wfGetDB(DB_SLAVE);
     #awcsforum_funcs::limitSplit($limit);
     #die($limit);
     #$res = $dbr->query($sql . ' ' . $limit);
     require_once awc_dir . 'dBase.php';
     $dbase = new awcforum_cls_dBase();
     $limit = $dbase->limit($limit);
     $res = $dbr->query("{$sql} {$limit}");
     while ($r = $dbr->fetchObject($res)) {
         // ++$i;
         $to_skin = $thread_tools->loop_thread_list($r);
         $e['NewPost'] = $thread_tools->new_thread_check($r->t_id, $r->t_lastdate);
         if ($todo == 'recent') {
             if (isset($e['NewPost']) and strlen($e['NewPost']) > 0) {
                 ++$i;
                 $thread_tools->link = awc_url;
                 $thread_tools->tID = $r->t_id;
                 $thread_tools->total_posts = $r->t_topics;
                 $to_skin['search_words'] = '';
                 $tmp .= $tplt->phase($word, $to_skin, 'thread_list_rows');
             }
         } else {
             ++$i;
             $thread_tools->link = awc_url;
             $thread_tools->tID = $r->t_id;
             $thread_tools->total_posts = $r->t_topics;
             $to_skin['search_words'] = '';
             $tmp .= $tplt->phase($word, $to_skin, 'thread_list_rows');
         }
         unset($e);
     }
     $dbr->freeResult($res);
     if ($LimitJump_top) {
         #kw
         $tID = isset($this->tID) ? '/tID' . $this->tID : null;
         $fID = isset($this->fID) ? '/fID' . $this->fID : null;
         $cID = isset($this->cID) ? '/cID' . $this->cID : null;
         $what = isset($this->what) ? '/what' . $this->what : null;
         $this->searchword = str_replace(' ', '_', $this->searchword);
         # die($LimitJump);
         # $this->fID = $wgRequest->getVal('fID');
         # $this->cID = $wgRequest->getVal('cID');
         # $LimitJump = $LimitJump . "/kw:$this->searchword$tID$fID$cID";
         # die(">". print_r($LimitJump) );
         if ($first_return) {
             $LimitJump_bot = str_replace('limit:', "kw:{$this->searchword}{$tID}{$fID}{$cID}{$what}" . '/limit:', $LimitJump_bot);
             $LimitJump_top = str_replace('limit:', "kw:{$this->searchword}{$tID}{$fID}{$cID}{$what}" . '/limit:', $LimitJump_top);
         }
         $LimitJump = '<tr><td width="100%" colspan="6" align="right" class="page_jumps_holderBot">' . $LimitJump_bot . '</td></tr>';
     } else {
         $LimitJump_top = null;
         $LimitJump = null;
     }
     $to_tplt['col_5_isSearch_forum_name'] = '<td class="thread_col_head" width="20%" align="center" nowrap="nowrap">' . get_awcsforum_word('word_forum') . '</td>';
     $to_tplt['tr_id'] = '';
     $to_tplt['first_col_name'] = get_awcsforum_word('thread_title');
     $html = $tplt->phase($word_headers, $to_tplt, 'thread_list_header');
     $html .= $tmp . $LimitJump;
     $html .= '</table>';
     if (!$this->searchword) {
         $this->searchword = $this->MemSearch;
     }
     $end = '';
     if ($this->what == 'c') {
         $end = ', ' . get_awcsforum_word('word_inCat') . ' ' . $cat_name . '';
     }
     if ($this->what == 'f') {
         $end = ', ' . get_awcsforum_word('word_inForum') . ' ' . $cat_name . '/' . $forum_name . '';
     }
     if ($this->what == 't') {
         $end = ', ' . get_awcsforum_word('word_inThread') . ' ' . $thread_name;
     }
     $title = str_replace("|\$|", $i, get_awcsforum_word('search_SearchResultsFound')) . ": {$this->searchword}" . $end;
     /*
     broken...
     $read_threads = (isset($_SESSION['awc_rActive'])) ? count($_SESSION['awc_rActive']) : 0;
     if($this->todo == 'search/recent/') $this->total = ($this->total - $read_threads) ;
     */
     if ($this->todo == 'search/recent/') {
         $this->total = '';
     }
     Set_AWC_Forum_SubTitle('(' . $this->total . ') ' . get_awcsforum_word('search_SearchResults'), $title);
     Set_AWC_Forum_BreadCrumbs($this->searchword, true);
     # $str = $wgOut->parse($html);
     $wgOut->addHTML($html);
     return;
 }
Exemplo n.º 2
0
 function GetForumDisplayInfo($info)
 {
     global $awc, $wgOut, $awcs_forum_config, $str_len, $forum, $perm_sql;
     $thread_tools = new awcs_forum_thread_list_tools();
     if ($info['both']) {
         $info['classThreadtitle'] = 'class="' . $info['classThreadtitle'] . '" id="' . $info['idThreadtitle'] . '"';
         $info['classReplies'] = 'class="' . $info['classReplies'] . '" id="' . $info['idReplies'] . '"';
         $info['classViews'] = 'class="' . $info['classViews'] . '" id="' . $info['diViews'] . '"';
         $info['classLastAction'] = 'class="' . $info['classLastAction'] . '" id="' . $info['idLastAction'] . '"';
     } elseif (!$info['id']) {
         $info['classThreadtitle'] = 'class="' . $info['classThreadtitle'] . '"';
         $info['classReplies'] = 'class="' . $info['classReplies'] . '"';
         $info['classViews'] = 'class="' . $info['classViews'] . '"';
         $info['classLastAction'] = 'class="' . $info['classLastAction'] . '"';
     } else {
         $info['classThreadtitle'] = 'id="' . $info['idThreadtitle'] . '"';
         $info['classReplies'] = 'id="' . $info['idReplies'] . '"';
         $info['classViews'] = 'id="' . $info['idViews'] . '"';
         $info['classLastAction'] = 'id="' . $info['idLastAction'] . '"';
     }
     # die(">". $UserPerm);
     $dbr = wfGetDB(DB_SLAVE);
     $permsql = substr($perm_sql, 0, -4);
     // if(strlen($info['forum']) > 0) $permsql = substr($permsql, 0, -4);
     $info['forum'] = substr($info['forum'], 4, strlen($info['forum']));
     if (strlen($info['forum']) > 0 and strlen($permsql) > 0) {
         $permsql .= ' AND ';
     }
     $awc_f_threads = $dbr->tableName('awc_f_threads');
     $awc_f_forums = $dbr->tableName('awc_f_forums');
     $awc_f_cats = $dbr->tableName('awc_f_cats');
     $awc_f_posts = $dbr->tableName('awc_f_posts');
     $sql = "SELECT {$awc_f_threads}.*, {$awc_f_forums}.f_name, {$awc_f_forums}.f_desc, {$awc_f_forums}.f_id, {$awc_f_forums}.f_parentid, {$awc_f_cats}.cat_name, {$awc_f_cats}.cat_id, {$awc_f_cats}.c_wiki_perm\n                        FROM {$awc_f_threads}\n                        INNER JOIN {$awc_f_forums}\n                            ON {$awc_f_threads}.t_forumid={$awc_f_forums}.f_id\n                        INNER JOIN {$awc_f_cats}\n                            ON {$awc_f_cats}.cat_id={$awc_f_forums}.f_parentid\n                        WHERE {$permsql} \n                         " . $info['forum'] . " AND {$awc_f_forums}.f_passworded = 0\n                        ORDER BY {$awc_f_threads}.t_lastdate DESC\n                        LIMIT " . $info['howmanythreads'];
     #  die(">".$permsql);
     /*  
                    * GROUP BY $awc_f_threads.t_id
                    *  
                   
                 $sql = "SELECT $awc_f_threads.*, $awc_f_forums.f_name, $awc_f_forums.f_desc, $awc_f_forums.f_id, $awc_f_forums.parent_id, $awc_f_cats.cat_name, $awc_f_cats.cat_id, $awc_f_cats.c_wiki_perm
                             FROM $awc_f_threads
                             INNER JOIN $awc_f_forums
                                 ON $awc_f_threads.t_forumid=$awc_f_forums.f_id
                             INNER JOIN $awc_f_cats
                                 ON $awc_f_cats.cat_id=$awc_f_forums.parent_id
                             WHERE $permsql 
                              ".$info['forum']." AND $awc_f_forums.f_passworded = 0
                             GROUP BY $awc_f_threads.t_id
                             ORDER BY $awc_f_threads.t_lastdate DESC
                             LIMIT " . $info['howmanythreads'];
                             
                             
                             
                             
            
            
            
               $sql = $dbr->selectSQLText( array( 'awc_f_threads', 'awc_f_posts', 'awc_f_forums', 'awc_f_cats' ), 
                        array( "$awc_f_posts.*, $awc_f_threads.*, f_name, f_desc, f_id, parent_id, cat_name, cat_id" ),
                         "$permsql ".$info['forum']." AND f_passworded = 0", 
                        __METHOD__, 
                        array('OFFSET' => 0, 
                        		 'LIMIT' => $info['howmanythreads'], 
                        		 'GROUP BY' => 't_id',
                        		 'ORDER BY' => 't_lastdate DESC, p_id DESC',),
                        array( 'awc_f_posts' => array('JOIN','t_id=thread_id'),
            						'awc_f_forums' => array('JOIN','t_forumid=f_id'),
            						'awc_f_cats' => array('JOIN','parent_id=cat_id'))
                         );
     */
     if (strlen($info['forum']) == 0 and strlen($permsql) == 0) {
         $sql = str_replace('WHERE', '', $sql);
     }
     //  awc_pdie($sql);
     $html = null;
     $singleline = null;
     if ($res = $dbr->query($sql)) {
         while ($r = $dbr->fetchObject($res)) {
             $f_name = $r->f_name;
             $f_id = $r->f_id;
             $tTitle = awcsforum_funcs::awc_html_entity_decode($r->t_name);
             $str_len($tTitle) > $awcs_forum_config->cf_forumTag_titlecutoff ? $t_name = awcsforum_funcs::awc_shorten($tTitle, $awcs_forum_config->cf_forumTag_titlecutoff) . "..." : ($t_name = $tTitle);
             $tmp = $info['imgBeforeThreadTitle'] . ' ' . $info['txtBeforeThreadTitle'] . ' <a href="' . $awc['link'] . 'st/id' . $r->t_id . '">' . $t_name . '</a>';
             $limit = null;
             #$total['TotalPosts'] = null;
             $send['t_topics'] = $r->t_topics;
             $send['t_id'] = $r->t_id;
             $send['t_name'] = $r->t_name;
             $send['link'] = $this->awc_url;
             $t = null;
             if ($r->t_ann == "1") {
                 $t = get_awcsforum_word('thread_makeAnnouncement') . " ";
             }
             if ($r->t_status == "1") {
                 $t = get_awcsforum_word('1indicator_locked') . " ";
             }
             if ($r->t_pin == "1") {
                 $t = get_awcsforum_word('1indicator_sticky') . " ";
             }
             if ($r->t_pin == "1" and $r->t_status == "1") {
                 $t = get_awcsforum_word('1indicator_lockSticky') . " ";
             }
             if ($r->t_poll == "1") {
                 $t = get_awcsforum_word('1indicator_poll') . " ";
             }
             # $TotalPosts = $tmp['TotalPosts'];
             # $limit = GetLimit($TotalPosts);
             $thread_tools->link = $this->awc_url;
             $thread_tools->tID = $r->t_id;
             $thread_tools->total_posts = $r->t_topics;
             $limit = $thread_tools->GetThreadPostLimit();
             //$limit = GetThreadPostLimit($send);
             $tmp = $t . $tmp . ' ' . $limit;
             # die($awc['link']);
             $html .= '<tr>';
             $html .= '<td width="100%" ' . $info['classThreadtitle'] . ' style="' . $info['styleThreadtitle'] . '" nowrap>' . $tmp . '</td>';
             $singleline .= '<tr><td width="100%" ' . $info['classThreadtitle'] . ' style="' . $info['styleThreadtitle'] . '" >';
             $singleline .= $tmp;
             # $singleline .= ;
             if ($info['replies'] == "yes") {
                 $html .= '<td ' . $info['classReplies'] . ' style="' . $info['styleReplies'] . '" nowrap>' . $r->t_topics . '</td>';
                 $singleline .= ' <SPAN STYLE="' . $info['styleReplies'] . '"> (' . $r->t_topics . ' ' . $info['wReplies'] . ') </SPAN>';
             }
             if ($info['postcount'] == "yes") {
                 $html .= '<td ' . $info['classViews'] . ' style="' . $info['styleViews'] . '" nowrap>' . $r->t_hits . '</td>';
                 $singleline .= ' <SPAN STYLE="' . $info['styleViews'] . '"> (' . $r->t_hits . ' ' . $info['wViews'] . ') </SPAN>  ';
             }
             if ($info['date'] == "yes" || $info['users'] == "yes") {
                 $u = $r->t_lastuser == '' ? $r->p_user : $r->t_lastuser;
                 $uID = $r->t_lastuser == '' ? $r->p_userid : $r->t_lastuserid;
                 #$u = $wgOut->parse("[[User:$u|$u]]");
                 $u = "<a href='" . $awc['link'] . "mem_profile/{$u}/{$uID}'>{$u}</a>";
                 $rplac = array('<p>', '</p>', chr(10));
                 $u = str_replace($rplac, '', $u);
                 $u = $info['users'] == "yes" ? ' - ' . $u : null;
                 $d = $info['date'] == "yes" ? '<a href="' . $awc['link'] . 'last_post/id' . $r->t_id . '"> ' . awcsforum_funcs::convert_date($r->t_lastdate, "s") . ' </a>' . ' ' : null;
                 $html .= '<td ' . $info['classLastAction'] . ' style="' . $info['styleLastAction'] . '" nowrap>' . $d . $u . '</td>';
                 $singleline .= ' <SPAN STYLE="' . $info['styleLastAction'] . '"> (' . $d . $u . ') </SPAN><td></tr>';
             }
             $html .= '</tr>';
         }
         $dbr->freeResult($res);
     }
     if ($f_name == '') {
         return;
     }
     if ($info['header_both']) {
         $info['classThreadtitle'] = 'class="' . $info['header_classThreadtitle'] . '" id="' . $info['header_idThreadtitle'] . '"';
         $info['classReplies'] = 'class="' . $info['header_classReplies'] . '" id="' . $info['header_idReplies'] . '"';
         $info['classViews'] = 'class="' . $info['header_classViews'] . '" id="' . $info['header_diViews'] . '"';
         $info['classLastAction'] = 'class="' . $info['header_classLastAction'] . '" id="' . $info['header_idLastAction'] . '"';
     } elseif (!$info['header_id']) {
         $info['classThreadtitle'] = 'class="' . $info['header_classThreadtitle'] . '"';
         $info['classReplies'] = 'class="' . $info['header_classReplies'] . '"';
         $info['classViews'] = 'class="' . $info['header_classViews'] . '"';
         $info['classLastAction'] = 'class="' . $info['header_classLastAction'] . '"';
     } else {
         $info['classThreadtitle'] = 'id="' . $info['header_idThreadtitle'] . '"';
         $info['classReplies'] = 'id="' . $info['header_idReplies'] . '"';
         $info['classViews'] = 'id="' . $info['header_idViews'] . '"';
         $info['classLastAction'] = 'id="' . $info['header_idLastAction'] . '"';
     }
     $out = null;
     if ($info['showall'] == false) {
         $out = '<table width="' . $info['width'] . '" cellpadding="0" cellspacing="0"><tr><td nowrap><a href="' . $awc['link'] . 'sf/id' . $f_id . '">' . $f_name . '</a><hr></td></tr></table>';
     }
     $out .= '<table width="' . $info['width'] . '" cellpadding="2" cellspacing="0">';
     $out .= '<tr>';
     $singleline_out = '<table width="' . $info['width'] . '" cellpadding="2" cellspacing="0"><tr>';
     $out .= '<td width="75%" align="left" class="' . $info['header_classThreadtitle'] . '" style="' . $info['header_styleThreadtitle'] . '" nowrap>' . $info['wThreadtitle'] . '</td>';
     if ($info['replies'] == "yes") {
         $out .= '<td width="1%" align="left" class="' . $info['header_classReplies'] . '" style="' . $info['header_styleReplies'] . '" nowrap>' . $info['wReplies'] . '</td>';
     }
     if ($info['postcount'] == "yes") {
         $out .= '<td width="1%" align="left" class="' . $info['header_classViews'] . '" style="' . $info['header_styleViews'] . '" nowrap>' . $info['wViews'] . '</td>';
     }
     #if($info['users'] == true) $out .= '<td width="1%" align="left" nowrap>'.get_awcsforum_word('forum_started_by').'</td>';
     if ($info['date'] == "yes" || $info['users'] == "yes") {
         $out .= '<td width="20%" align="left" class="' . $info['header_classLastAction'] . '" style="' . $info['header_styleLastAction'] . '" nowrap>' . $info['wLastAction'] . '</td>';
     }
     $out .= '</tr>';
     $out .= $html;
     $out .= '</table><br />';
     $singleline_out = '<table width="' . $info['width'] . '" cellpadding="2" cellspacing="0">';
     $singleline_out .= $singleline;
     $singleline_out .= '</table><br />';
     $out = str_replace(chr(10), '', $out);
     $singleline_out = str_replace(chr(10), '', $singleline_out);
     if ($info['inline']) {
         return $singleline_out;
     }
     return $out;
 }
Exemplo n.º 3
0
 function threadsubscribe($where = '')
 {
     global $wgOut, $awc, $awc_tables, $tplt;
     $thread_tools = new awcs_forum_thread_list_tools();
     $tplt->add_tplts(array("'memcp_recent_header'", "'memcp_recent_row'", "'memcp_recent_close'", "'postblocks_threadlisting'"), true);
     $words = array();
     $words['thread_title'] = get_awcsforum_word('thread_title');
     $words['word_replies'] = get_awcsforum_word('word_replies');
     $words['last_action'] = get_awcsforum_word('last_action');
     $words['thread_title_started_by'] = get_awcsforum_word('thread_title_started_by');
     $words['delete'] = get_awcsforum_word('delete');
     Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('mem_subscriptionthread'));
     if (function_exists('bcmod')) {
         $row_class = 1;
     } else {
         $row_class = 0;
     }
     $html = '<form action="' . awc_url . 'member_options/delete_tsub" method="post"  enctype="multipart/form-data">';
     $html .= $tplt->phase($words, '', 'memcp_recent_header', true);
     $dbr = wfGetDB(DB_SLAVE);
     if ($where == 'list') {
         Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('word_subscribe_memcp'), true);
         $sql = "SELECT w.wtcht_todo, t.t_postid, t.t_id, t.t_topics, t.t_lastdate, t.t_name, t.t_starterid, t.t_starter, t.t_lastuser, t.t_lastuserid\r\r\n                        FROM {$awc_tables['awc_f_watchthreads']} w, {$awc_tables['awc_f_threads']} t \r\r\n                        WHERE w.wtcht_todo='list' AND t.t_id=w.wtcht_thread_id AND w.wtcht_mem_id=" . $this->m_id . " ORDER BY t.t_lastdate DESC";
     } elseif ($where == 'email') {
         Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('word_subscribe_email'), true);
         $sql = "SELECT w.wtcht_todo, t.t_postid, t.t_id, t.t_topics, t.t_lastdate, t.t_name, t.t_starterid, t.t_starter, t.t_lastuser, t.t_lastuserid\r\r\n                        FROM {$awc_tables['awc_f_watchthreads']} w, {$awc_tables['awc_f_threads']} t \r\r\n                        WHERE w.wtcht_todo='email' AND t.t_id=w.wtcht_thread_id AND w.wtcht_mem_id=" . $this->m_id . " ORDER BY t.t_lastdate DESC";
     } else {
         Set_AWC_Forum_BreadCrumbs('', true);
         $sql = "SELECT w.wtcht_todo, t.t_postid, t.t_id, t.t_topics, t.t_lastdate, t.t_name, t.t_starterid, t.t_starter, t.t_lastuser, t.t_lastuserid\r\r\n                        FROM {$awc_tables['awc_f_watchthreads']} w, {$awc_tables['awc_f_threads']} t \r\r\n                        WHERE t.t_id=w.wtcht_thread_id AND w.wtcht_mem_id=" . $this->m_id . " ORDER BY t.t_lastdate DESC";
     }
     $res = $dbr->query($sql);
     $c = 0;
     while ($r = $dbr->fetchObject($res)) {
         $info['t_id'] = $r->t_id;
         $info['t_name'] = awcsforum_funcs::awc_html_entity_decode($r->t_name);
         $info['t_topics'] = $r->t_topics;
         $info['t_starter'] = $r->t_starter;
         $info['t_starterid'] = $r->t_starterid;
         $info['last'] = '<a href="' . awc_url . 'last_post/' . $r->t_id . '">' . awcsforum_funcs::convert_date($r->t_lastdate, "s") . '</a>';
         /* 
         if($awcUser->guest == false){ 
             $info['NewPost'] = awcs_forum_CheckIfThreadIsNew($r->t_id, $r->t_lastdate);
         } else {
             $info['NewPost'] = null;
         }
         */
         $info['NewPost'] = $thread_tools->new_thread_check($r->t_id, $r->t_lastdate);
         $info['url'] = awc_url . 'st/' . $r->t_id;
         if ($where == 'email' or $where == 'list') {
             $info['wtcht_todo'] = null;
         } else {
             $info['wtcht_todo'] = $r->wtcht_todo;
         }
         $thread_tools->link = awc_url;
         $thread_tools->tID = $r->t_id;
         $thread_tools->total_posts = $r->t_topics;
         $info['t_jump'] = $thread_tools->GetThreadPostLimit();
         $c++;
         if ($row_class) {
             $info['row_class'] = 'thread_rows' . bcmod($c, '2');
         } else {
             $info['row_class'] = 'thread_rows';
         }
         $html .= $tplt->phase($words, $info, 'memcp_recent_row');
     }
     $dbr->freeResult($res);
     $tplt->kill('memcp_recent_row');
     $html .= $tplt->phase($words, '', 'memcp_recent_close', true);
     $html .= '</form>';
     self::display_memcp($html);
 }
Exemplo n.º 4
0
 function ShowThreads($id)
 {
     global $LimitJump_top, $LimitJump_bot, $awcUser;
     global $wgOut, $wgUser, $WhoWhere, $awc_tables, $numthreadcols, $tplt;
     $perm = new awcs_forum_perm_checks();
     $thread_tools = new awcs_forum_thread_list_tools();
     $word_headers = array('replies' => get_awcsforum_word('word_replies'), 'views' => get_awcsforum_word('views'), 'last_action' => get_awcsforum_word('last_action'), 'started_by' => get_awcsforum_word('thread_title_started_by'));
     $word = array('replies' => get_awcsforum_word('word_replies'), 'views' => get_awcsforum_word('views'), 'last_action' => get_awcsforum_word('last_action'), 'started_by' => get_awcsforum_word('forum_started_by'));
     $f_id = (int) $id;
     $sql = $this->rDB->selectSQLText(array('awc_f_forums', 'awc_f_cats'), array('f_name, f_desc, f_top_tmplt, f_parentid, f_id, f_threads,
              f_wiki_read_perm, f_wiki_write_perm, f_passworded, cat_name'), "f_id={$f_id}", __METHOD__, array('OFFSET' => '0', 'LIMIT' => '1'), array('awc_f_cats' => array('LEFT JOIN', 'cat_id=f_parentid')));
     $res = $this->rDB->query($sql);
     $r = $this->rDB->fetchRow($res);
     $this->rDB->freeResult($res);
     $forum_info = array();
     $forum_info['f_name'] = $r['f_name'];
     $forum_info['f_desc'] = $r['f_desc'];
     $forum_info['f_top_tmplt'] = $r['f_top_tmplt'];
     $forum_info['cid'] = $r['f_parentid'];
     $forum_info['cat_name'] = $r['cat_name'];
     $forum_info['fid'] = $r['f_id'];
     $forum_info['f_threads'] = $r['f_threads'];
     $forum_info['f_wiki_write_perm'] = $r['f_wiki_write_perm'];
     $forum_info['f_wiki_read_perm'] = $r['f_wiki_read_perm'];
     $forum_info['f_passworded'] = $r['f_passworded'];
     $WhoWhere['type'] = 'forum';
     $WhoWhere['where'] = 'cid' . $r['f_parentid'] . '|fid' . $r['f_id'] . '||awc-split||' . $forum_info['f_name'];
     $WhoWhere['perm'] = $forum_info['f_wiki_read_perm'];
     unset($r, $res);
     // check for Forums Subscriptions
     if ($awcUser->isLoggedIn and $this->cf_forumsubscrip == '1') {
         $m_forum_subsrib = array();
         $m_forum_subsrib = $awcUser->m_forum_subsrib;
         if (!empty($m_forum_subsrib)) {
             if (!array_key_exists($id, $m_forum_subsrib)) {
                 $word_subscribe = get_awcsforum_word('word_subscribe');
                 $options_menu = null;
             } else {
                 $word_subscribe = get_awcsforum_word('word_unsubscrib');
                 $options_menu = get_awcsforum_word('word_youraresubscribed');
                 if ($awcUser->m_forum_subsrib[$id] == '') {
                     $dbw = wfGetDB(DB_MASTER);
                     $awcUser->m_forum_subsrib[$id] = 'seen';
                     awcsforum_funcs::get_table_names(array('awc_f_mems', 'awc_f_watchforums'));
                     $sql = "UPDATE {$awc_tables['awc_f_watchforums']} f \r\r\n                                        JOIN {$awc_tables['awc_f_mems']} m\r\r\n                                        ON f.wtchf_mem_id=m.m_id \r\r\n                                        SET f.wtchf_sent=0, m.m_forum_subsrib='" . serialize($awcUser->m_forum_subsrib) . "' \r\r\n                                    WHERE f.wtchf_forum_id = {$id} AND f.wtchf_mem_id = {$awcUser->mId}";
                     $dbw->query($sql);
                 }
             }
         } else {
             $word_subscribe = get_awcsforum_word('word_subscribe');
             $options_menu = null;
         }
     }
     $ann_threads = '<form name="mod_form" enctype="multipart/form-data" action="' . awc_url . 'mod/" method="post">
                     <input name="todo" type="hidden" value="mod_thread">';
     # query for Announcement threads...
     $totalAnnocments = 0;
     $sql = "SELECT t.t_id,t.t_ann,t.t_pin,t.t_status,t.t_poll,t.t_name,t.t_starter,t.t_starterid,t.t_topics,t.t_hits,t.t_lastdate, t.t_lastuser, t.t_lastuserid, t.t_forumid \r\r\n\t\t\t\tFROM {$awc_tables['awc_f_anns']} a\r\r\n                INNER JOIN {$awc_tables['awc_f_threads']} t ON a.ann_id=t.t_id \r\r\n\t\t\t\tORDER BY t.t_lastdate DESC, t.t_name DESC ";
     $res = $this->rDB->query($sql);
     $a = null;
     $sa = null;
     $to_skin = array();
     while ($r = $this->rDB->fetchObject($res)) {
         $a++;
         if ($a == 1) {
             // create announcements header
             $to_skin['col_5_isSearch_forum_name'] = '';
             $to_skin['tr_id'] = 'id="annc"';
             $to_skin['first_col_name'] = get_awcsforum_word('announcement');
             $ann_threads .= $tplt->phase($word_headers, $to_skin, 'thread_list_header');
             unset($to_skin);
         }
         /*
          check if threads being looped are part of the current forum
          if so, count them for the "math" in the thread-display-limit
         */
         if ($r->forum_id == $id) {
             $totalAnnocments++;
         }
         $to_skin = $thread_tools->loop_thread_list($r);
         $ann_threads .= $tplt->phase($word, $to_skin, 'thread_list_rows');
         // unset($to_skin);
     }
     $this->rDB->freeResult($res);
     unset($r, $res);
     if ($a >= 1) {
         $ann_threads .= "</table><br />";
     }
     $can_read = $perm->can_read($forum_info['f_wiki_read_perm']);
     if (!$can_read) {
         global $wgOut;
         $wgOut->addHTML($ann_threads);
         return awcs_forum_error('no_forum_read_perm');
     }
     if (!isset($awcUser->pw)) {
         $awcUser->pw[0] = 0;
     }
     if ($perm->is_password($forum_info['f_passworded']) and !in_array($id, $awcUser->pw)) {
         // show Announcement's then password field
         Set_AWC_Forum_SubTitle($forum_info['f_name'], $forum_info['f_desc'], '');
         Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'sc/id' . $forum_info['cid'] . '">' . $forum_info['cat_name'] . '</a>');
         Set_AWC_Forum_BreadCrumbs(strtr($forum_info['f_name'], "_", " "), true);
         global $wgOut;
         $password_field = '<br /><hr />' . get_awcsforum_word('forum_passworded') . '<hr />';
         $password_field .= '</form><form action="' . awc_url . 'fpw" method="post"  enctype="multipart/form-data">
             <input name="fid" type="hidden" value="' . $id . '">
             <input name="pw" type="password" size="20">
             <input type="submit" value="' . get_awcsforum_word('submit') . '">
             </form><br /><br />';
         $wgOut->addHTML($ann_threads . $password_field);
         return;
     }
     $post_button = '';
     if ($awcUser->canPost and $perm->can_post($forum_info['f_wiki_write_perm'])) {
         $word1['start_new_thread'] = str_replace(' ', '&nbsp;', get_awcsforum_word('start_new_thread'));
         $info['url'] = awc_url . 'post/todo_new_t/id' . $id;
         $post_button = $tplt->phase($word1, $info, 'forum:start_new_thread');
     }
     $tplt->kill('forum:start_new_thread');
     // add templet after anncoments... todo
     if (strlen($forum_info['f_top_tmplt']) > 1) {
         $ann_threads .= add_tmpl_to_skin($forum_info['f_top_tmplt']);
     }
     $TotalPosts = intval($forum_info['f_threads'] - $totalAnnocments);
     $total['TotalPosts'] = $TotalPosts;
     $limit = GetLimit($total, 'cat');
     if ($awcUser->isLoggedIn and $this->cf_forumsubscrip == '1') {
         $info['url'] = awc_url . 'post/fsub/id' . $id;
         $word1['subscrib'] = $word_subscribe;
         $sb = $tplt->phase($word1, $info, 'forum:subscrib_to_forum');
     } else {
         $sb = null;
     }
     unset($word1);
     $tplt->kill('forum:subscrib_to_forum');
     // add tplt, start new thread button, subscrib, page jumps
     $info['jump'] = $LimitJump_top;
     $info['new_thread_button'] = $post_button;
     $info['subscrib_button'] = $sb;
     $html = $tplt->phase('', $info, 'thread_list_header_menu', true);
     unset($info);
     $info['col_5_isSearch_forum_name'] = '';
     $info['tr_id'] = null;
     $info['first_col_name'] = UserPerm >= 2 ? '<INPUT type="checkbox" name="checkbox_toggle" onChange="return checkall_toggle(\'mod_form\',\'tID[]\', this.checked)">  ' : null;
     $info['first_col_name'] .= get_awcsforum_word('thread_title');
     $html .= $tplt->phase($word_headers, $info, 'thread_list_header', true);
     unset($info, $word_headers);
     $limit = str_replace('LIMIT ', '', $limit);
     $limitSPLIT = explode(',', $limit);
     $offset = isset($limitSPLIT[0]) ? $limitSPLIT[0] : 0;
     $limit = isset($limitSPLIT[1]) ? $limitSPLIT[1] : 15;
     $t_forumid = (int) $id;
     $sql = $this->rDB->selectSQLText(array('awc_f_threads'), array('t_id,t_ann,t_pin,t_status,t_poll,t_name,t_starter,t_starterid,t_topics,t_hits,t_lastdate,t_lastuser,t_lastuserid'), "t_forumid={$t_forumid} AND t_ann=0", __METHOD__, array('OFFSET' => $offset, 'LIMIT' => $limit, 'ORDER BY' => 't_pin DESC, t_lastdate DESC,t_name'));
     $res = $this->rDB->query($sql);
     $isThreads = false;
     $thread_tools->thread_count = 0;
     while ($r = $this->rDB->fetchObject($res)) {
         $isThreads = true;
         $to_tplt = $thread_tools->loop_thread_list($r);
         $html .= $tplt->phase($word, $to_tplt, 'thread_list_rows');
     }
     $this->rDB->freeResult($res);
     unset($r, $res);
     $tplt->kill('thread_list_rows');
     if (!$isThreads) {
         //  keep this here...
         $tplt->add_tplts(array("'empty_forum'"), true);
         $info['new_thread_button'] = $post_button;
         $info['subscrib_button'] = $sb;
         $word['empty_forum'] = get_awcsforum_word('word_emptyforum');
         $html = $tplt->phase($word, $info, 'empty_forum', true);
     }
     $html .= "</table>";
     $e = array();
     $e['fID'] = $id;
     $e['cID'] = $forum_info['cid'];
     Set_AWC_Forum_SubTitle($forum_info['f_name'], $forum_info['f_desc'], $e);
     unset($e);
     Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'sc/id' . $forum_info['cid'] . '">' . $forum_info['cat_name'] . '</a>');
     $BreadCrumb = Set_AWC_Forum_BreadCrumbs(strtr($forum_info['f_name'], "_", " "), true);
     #
     #
     $info['page_jumps'] = $LimitJump_bot ? $LimitJump_bot : null;
     if (UserPerm >= 2) {
         $words['ann'] = get_awcsforum_word('thread_makeAnnouncement');
         $words['unann'] = get_awcsforum_word('thread_UnMakeAnnouncement');
         $mod['ann'] = UserPerm >= 10 ? $tplt->phase($words, '', 'thread_listing_mod_drop_ann') : null;
         $tplt->kill('thread_listing_mod_drop_ann');
         $words['pinn'] = get_awcsforum_word('pinned_word');
         $words['unpinn'] = get_awcsforum_word('pinnedUn_word');
         $words['lock'] = get_awcsforum_word('lockThread_word');
         $words['unlock'] = get_awcsforum_word('lockThreadUn_word');
         $words['move'] = get_awcsforum_word('mod_movethread');
         $words['delete'] = get_awcsforum_word('delete');
         $words['mod_options'] = get_awcsforum_word('mod_post');
         $info['page_jumps'] = ' ' . $tplt->phase($words, $mod, 'thread_listing_mod_drop', true) . $info['page_jumps'];
         unset($words, $mod);
     }
     $info['BreadCrumb'] = $BreadCrumb;
     $html .= $tplt->phase($word, $info, 'bottom_page_jumps', true);
     return $ann_threads . $html . '</form>';
 }