function GetPosts($tID, $sql2 = '', $single_post = false) { global $LimitJump_top, $LimitJump_bot, $total_thread_count, $thread_title_for_search; global $wgOut, $wgRequest, $wgCookieExpiration, $wgCookiePath, $wgCookieDomain; global $WhoWhere, $awc_tables, $tplt; global $awcUser; if (!$awcUser->canRead) { return $wgOut->loginToUse(); } $perm = new awcs_forum_perm_checks(); $post_cls = new awcs_forum_post_phase(); if ($single_post) { $post_cls->single_post = true; } $word = null; $i = null; $html = null; $e = array(); $tPass = array(); if ($sql2 == '') { $check_subscribe = self::check_subscribe($tID); if ($check_subscribe != 'no') { $e = $check_subscribe['e']; $tPass = $check_subscribe['tPass']; $subscribe_info = $check_subscribe['subscribe_info']; } else { $tPass['subscrib_links'] = null; } } else { $tPass['subscrib_links'] = null; $tplt->kill('subscrib_links'); } $dbr = wfGetDB(DB_SLAVE); $this->display_mem_titles = 1; if ($this->display_mem_titles) { $sql = "SELECT * FROM {$awc_tables['awc_f_member_titles']} ORDER BY memtitle_postcount ASC"; $res = $dbr->query($sql); while ($r = $dbr->fetchObject($res)) { $post_cls->mem_post_title[$r->memtitle_id] = array('count' => $r->memtitle_postcount, 'title' => $r->memtitle_title, 'img' => $r->memtitle_img, 'css' => $r->memtitle_css); } unset($res, $r); } else { $post_cls->mem_post_title[0] = 'do_not_show'; } // get number of threads so we can make the Page Blocks # do something different, maybe move to sessions ro somehting $sql = $dbr->selectSQLText(array('awc_f_threads'), array('t_topics, t_postid'), "t_id={$tID}", __METHOD__, array('OFFSET' => '0', 'LIMIT' => '1')); $limit = ''; $tPass['page_jumps'] = null; if ($sql2 == '') { #$sql = "SELECT p_id FROM {$awc_tables['awc_f_posts']} WHERE p_id = $tID "; $res = $dbr->query($sql); $r = $dbr->fetchRow($res); $ex['TotalPosts'] = $r['t_topics']; $dbr->freeResult($res); $total['TotalPosts'] = $ex['TotalPosts']; $total['last'] = $r['t_postid']; $limit = GetLimit($total, 'thread'); $tPass['page_jumps'] = $LimitJump_top; #die($LimitJump_bot); } else { # $ex['sql2'] = $sql2; } # DIE($limit); $limit_is_there = false; # sw: highlightsearchword $action = $wgRequest->action; $spl = explode("/", $action); $search_word = null; # loop through "action" to find seach word foreach ($spl as $k => $value) { if (stristr($value, 'limit')) { $post_cls->has_limit = true; } if (substr($value, 0, 3) == "sw:") { $sw1 = explode("sw:", $value); $search_word = $sw1[1]; break; } } $search_word = str_replace("_", " ", $search_word); $spl2 = explode(" ", $search_word); # loop through seach word's foreach ($spl2 as $k => $value) { $sw[] = $value; } $perm_where = $perm->cat_forum_sql(); $limit = awcsforum_funcs::limitSplit($limit); # awc_pdie($limit); $sql = $dbr->selectSQLText(array('awc_f_threads', 'awc_f_posts', 'awc_f_forums', 'awc_f_cats'), array('p_id, p_title, p_post, p_user, p_userid, p_editwhy, p_editwho, p_editdate, p_date, t_id, t_ann, t_pin, t_status, t_name, t_topics, t_hits, t_perm, t_poll, t_wiki_pageid, t_lastdate, t_pollopen, f_posting_mesage_tmpt, f_name, f_id, f_wiki_write_perm, f_wiki_read_perm, f_passworded, cat_name, cat_id'), "{$perm_where} t_id = {$tID}", __METHOD__, array('OFFSET' => $limit['offset'], 'LIMIT' => $limit['limit'], 'ORDER BY' => 'p_thread_start DESC, p_date ASC'), array('awc_f_posts' => array('JOIN', 't_id=p_threadid'), 'awc_f_forums' => array('JOIN', 't_forumid=f_id'), 'awc_f_cats' => array('JOIN', 'f_parentid=cat_id'))); # die($sql); if (strlen($sql2) > 0) { $sql = $sql2; } $res = $dbr->query($sql); $i = 0; $out = array(); # $e['html'] = null; while ($r = $dbr->fetchObject($res)) { ++$i; if ($i == 1) { # awc_pdie($r); // stuff this stuff here so its not looped... $WhoWhere['where'] = 'cid' . $r->cat_id . '|fid' . $r->f_id . '|tid' . $r->t_id . '||awc-split||' . $r->t_name; $WhoWhere['perm'] = isset($r->f_wiki_read_perm) ? $r->f_wiki_read_perm : ''; $thread_title = $r->t_name; $t_status = $r->t_status; $f_posting_mesage_tmpt = isset($r->f_posting_mesage_tmpt) ? $r->f_posting_mesage_tmpt : ''; $f_wiki_write_perm = isset($r->f_wiki_write_perm) ? $r->f_wiki_write_perm : ''; if (!$awcUser->guest and awcsforum_funcs::wikidate($r->t_lastdate) > $_SESSION['awc_startTime']) { $_SESSION['awc_rActive'][$r->t_id] = awcsforum_funcs::wikidate($r->t_lastdate); } $e['PostTitle'] = $r->t_name; $e['num_topics'] = $r->t_topics; $f_name = $r->f_name; $fID = $r->f_id; $t_wiki_pageid = $r->t_wiki_pageid; if (!isset($awcUser->pw)) { $awcUser->pw[0] = 0; } #die(">" . $r->f_id); if ($perm->is_password($r->f_passworded) and !in_array($r->f_id, $awcUser->pw)) { 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="' . $r->f_id . '"> <input name="pw" type="password" size="20"> <input type="submit" value="' . get_awcsforum_word('submit') . '"> </form><br /><br />'; $wgOut->addHTML($password_field); return; } $this->forum_perm_can_post = false; if ($awcUser->canPost and $perm->can_post($f_wiki_write_perm)) { $this->forum_perm_can_post = true; $post_cls->forum_perm_can_post = true; } // end stuffed... if (!$single_post) { Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'sc/id' . $r->cat_id . '">' . $r->cat_name . '</a>'); $BreadCrumb = Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'sf/id' . $r->f_id . '">' . $r->f_name . '</a>', true); $t = null; if ($r->t_ann == "1") { $t = get_awcsforum_word('thread_makeAnnouncement') . " "; $e['ann'] = true; } if ($r->t_status == "1") { $t = get_awcsforum_word('1indicator_locked') . " "; $e['lock'] = true; } if ($r->t_pin == "1") { $t = get_awcsforum_word('1indicator_sticky') . " "; $e['sticky'] = true; } if ($r->t_pin == "1" and $r->t_status == "1") { $t = get_awcsforum_word('1indicator_lockSticky') . " "; } $e['tID'] = $r->t_id; $e['fID'] = $r->f_id; $e['cID'] = $r->cat_id; $e['pID'] = $r->p_id; Set_AWC_Forum_SubTitle($r->t_name, $t . get_awcsforum_word('word_viewed') . " " . $r->t_hits . " " . get_awcsforum_word('word_times') . ", " . get_awcsforum_word('word_Withatotalof') . " " . $r->t_topics . " " . get_awcsforum_word('word_posts'), $e); $tPass['mod_buttons'] = null; if (UserPerm >= 2) { $e['ann'] = $r->t_ann == '1' ? 'checked' : null; $e['sticky'] = $r->t_pin == '1' ? 'checked' : null; $e['lock'] = $r->t_status == '1' ? 'checked' : null; $e['threadname'] = awcsforum_funcs::awc_html_entity_decode($thread_title); $word['pinned_word'] = get_awcsforum_word('pinned_word'); $word['lockThread_word'] = get_awcsforum_word('lockThread_word'); $word['mod_movethread'] = get_awcsforum_word('mod_movethread'); $word['thread_makeAnnouncement'] = get_awcsforum_word('thread_makeAnnouncement'); $word['mod_post'] = get_awcsforum_word('mod_post'); if ($r->t_ann != "1" || UserPerm == 10) { #$to_skin['mod_buttons'] = ModFormStart($r->t_id, $r->p_id, $r->f_id, awc_url, $r->t_name, $total_topics) ; } #if (UserPerm == 10) $to_skin['mod_buttons'] .= IsAnnonc($r->t_ann); if (UserPerm == 10) { $e['ann'] = $tplt->phase($word, $e, 'mod_thread_dropdown_ann', true); } else { $e['ann'] = ''; } if ((UserPerm >= 2 and $r->t_ann != "1") || UserPerm == 10) { $tPass['mod_buttons'] = $tplt->phase($word, $e, 'mod_thread_dropdown', true); } unset($word); } if ($this->userID != '0') { $tPass['options_menu'] = null; $word['word_thread_options_button'] = get_awcsforum_word('word_thread_options_button'); $tPass['thread_options'] = $tplt->phase($word, $tPass, 'options_dropdown', true); } else { $tplt->kill('options_dropdown'); $tPass['thread_options'] = null; } # $tPass['page_jumps'] // is set above... $html = $tplt->phase($word, $tPass, 'thread_header', true); unset($info, $word, $tPass); #awc_pdie($tplt_info); } else { // single Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'sc/id' . $r->cat_id . '">' . $r->cat_name . '</a>'); Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'sf/id' . $r->f_id . '">' . $r->f_name . '</a>'); Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'st/id' . $r->t_id . '">' . awcsforum_funcs::awc_html_entity_decode($r->t_name) . '</a>', TRUE); $e = array(); $e['tID'] = $r->p_threadid; $e['fID'] = $r->f_id; $e['cID'] = $r->cat_id; $tPass['page_jumps'] = "<b><a href='" . awc_url . "st/id" . $r->t_id . "'>" . get_awcsforum_word('click_here_for_full_thread') . "</a></b>"; $tPass['thread_options'] = null; $html = $tplt->phase($word, $tPass, 'thread_header', true); Set_AWC_Forum_SubTitle($r->t_name, get_awcsforum_word('single_post_sub_title'), $e); } if ($r->t_poll and !$single_post) { $poll = $post_cls->display_poll($tID); $html = $poll . $html; } } // unset($_SESSION['awc_nActive'][$r->p_id]); #if($r->p_wikipage_id != '0') $p_wikipage_id[] = $r->p_wikipage_id ; $post_cls->load_post_phase_info($r); // awc_pdie($post_cls); $html .= $post_cls->display_post(); } # end SQL loop... unset($post_cls); if ($i == 0) { return; } $dbr->freeResult($res); unset($dbr, $res, $r); /* if($this->cf_add_post_text_to_wiki){ $dbw = wfGetDB( DB_MASTER ); $wp_ids = implode(',',$p_wikipage_id); $wiki_page = $dbw->tableName( 'page' ); $dbw->query( "UPDATE {$wiki_page} SET page_counter = page_counter + 1 WHERE page_id IN ($wp_ids)" ); } */ # unset($r, $this, $user_get, $ex, $sql); if (!$single_post and strlen($sql2) == 0) { $total_thread_count = $i; $thread_title_for_search = $thread_title; $yes = false; # $awc_ViewForum = $_COOKIE['awc_forum_ThreadView'] ; $awc_ViewForum = isset($_COOKIE['awc_forum_ThreadView']) ? $_COOKIE['awc_forum_ThreadView'] : null; $spl = explode(",", $awc_ViewForum); foreach ($spl as $fid) { if ($tID == $fid) { $yes = true; } } if (!$yes) { $dbw = wfGetDB(DB_MASTER); $dbw->query("UPDATE {$awc_tables['awc_f_threads']} SET t_hits = t_hits + 1 WHERE t_id = {$tID}"); $expir = $this->cookie_expir; if ($expir >= 1) { $expir = $expir * 60 * 60; } $exp = time() + $expir; # $exp = time() + $wgCookieExpiration; setcookie('awc_forum_ThreadView', $awc_ViewForum . "," . $tID, $exp, $wgCookiePath, $wgCookieDomain); #$_SESSION['awc_forum_ThreadView'] = $awc_ViewForum ; unset($dbw); } # die($LimitJump_top); # $html = $e['html']; $info['page_jumps'] = $LimitJump_bot ? $LimitJump_bot : null; $info['BreadCrumb'] = $BreadCrumb; $html .= $tplt->phase('', $info, 'bottom_page_jumps', true); } $wgOut->addHTML($html); //forum-wiki-perm //if ($awcUser->canPost AND $t_status == "0" || UserPerm >= 2 && $i AND !$single_post){ if ((strlen($sql2) == 0 and $awcUser->canPost and $this->forum_perm_can_post and $t_status == "0" and !$single_post) || (UserPerm >= 2 && $i and !$single_post)) { require awc_dir . '/includes/post_box.php'; $posting_box = new awcs_forum_posting_box(); $posting_box->quick_box = true; $posting_box->f_posting_mesage_tmpt = strlen($f_posting_mesage_tmpt) > 1 ? add_tmpl_to_skin($f_posting_mesage_tmpt) : null; #$posting_box->Thread_Title = awcsforum_funcs::awc_html_entity_decode($thread_title); $posting_box->Thread_Title = awcsforum_funcs::awc_htmlentities($thread_title); $posting_box->tbRows = $this->quick_height; $posting_box->Show_ann_sticky_lock = false; $posting_box->f_name = urlencode($f_name); $posting_box->fID = $fID; $posting_box->tID = $tID; $posting_box->t_wiki_pageid = $t_wiki_pageid; $posting_box->javaCheck = 'onsubmit="return check_quickPost()"'; $posting_box->url = awc_url . 'post/todo_' . urlencode('add_post'); //awc_pdie($subscribe_info); if (!$awcUser->guest) { $posting_box->subscribed_email = $subscribe_info['values']['subscribed_email']; $posting_box->subscribed_list = $subscribe_info['values']['subscribed_list']; $posting_box->subscribed_no = $subscribe_info['values']['subscribed_no']; } $html = $posting_box->box(); unset($posting_box); $wgOut->addHTML($html); } return; }
function __construct() { global $awcUser, $wgUser, $awcs_forum_config; global $wgShowSQLErrors, $wgTitle, $tplt, $perm_sql; static $already_here; self::get_url(); if ($already_here == 'yes') { return; } $already_here = 'yes'; global $wgCachePages; $wgCachePages = false; require_once awc_dir . "includes/funcs.php"; require_once awc_dir . "includes/gen_class.php"; require_once awc_dir . "includes/perm_checks.php"; if (!isset($awcUser)) { $awcUser = new awcs_forum_user(); // gen_class.php - call this first, forum_config/lang needs info from here } // if(!isset($awcs_forum_config)) { $awcs_forum_config = new awcs_forum_config(); // gen_class.php $awcs_forum_config->get_config(); // } // Check to see if forum is installed but checking of the Dbase config table is there... if (!$awcs_forum_config->installed or $awcs_forum_config->updating) { return ''; } // Note: // This needs to be after the awcs_forum_config() // for some reason the unserialize() gets messed you with the default CSS and cant read it correctly if (awcs_forum_convert_latin) { $dbw = wfGetDB(DB_MASTER); $dbw->query("SET NAMES latin1"); } $perm = new awcs_forum_perm_checks(); $perm_sql = $perm->cat_forum_sql(); // $awcs_forum_config->get_css(); //self::get_url(); if (!isset($tplt)) { $tplt = new awcs_forum_skin_templetes(); } // ??? error poped up, not sure why... $tplt->add_tplts(array("'postblocks_threadlisting'")); $tplt->add_tplts(array("'poll_display_options'", "'poll_display_results'", "'poll_opt_options'", "'poll_display_result_bars'", "'poll_display'"), true); }
function s_form() { global $wgOut, $LimitJump, $first_return, $wgRequest, $kw, $awc_tables; #die(">". print_r( $_POST['fID[]'] ) ); $dbr = wfGetDB(DB_SLAVE); $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'); $kw = $wgRequest->getVal('kw'); $this->searchword = $kw; $s_check = $this->check_searchword(); if (!$s_check) { return $this->search_error; } $perm = new awcs_forum_perm_checks(); $perm_sql = $perm->cat_forum_sql(); $wgRequest->getVal('Sis_like') == 'is' ? $Sis_like = '=' : ($Sis_like = ''); $wgRequest->getVal('full') == 'full' ? $full = '1' : ($full = '0'); # die(">". $Sis_like); if (strstr($kw, "+") || strstr($kw, " AND ")) { if (strstr($kw, "+")) { $s = $this->CreatePostTitleSearch(explode("+", $kw), 'AND', true, $Sis_like, $full); } elseif (strstr($kw, " AND ")) { $s = $this->CreatePostTitleSearch(explode(" AND ", $kw), 'AND', true, $Sis_like, $full); } } elseif (strstr($kw, " OR ")) { $s = $this->CreatePostTitleSearch(explode(" OR ", $kw), 'OR', true, $Sis_like, $full); } else { $s = $this->CreatePostTitleSearch($kw, '', '', $Sis_like, $full); } $forums_to_search = ''; foreach ($_POST['fID'] as $fid) { if ($fid == 'all') { $forums_to_search = null; break; } $forums_to_search .= "{$awc_f_forums}.f_id={$fid} OR "; } if ($forums_to_search != null) { $forums_to_search = ' AND (' . substr($forums_to_search, 0, strlen($forums_to_search) - 4) . ')'; } $mem = $wgRequest->getVal('is_like') == 'is' ? ' AND ' . $awc_f_posts . '.p_user = \'' . $wgRequest->getVal('memname') . '\'' : ' AND ' . $awc_f_posts . '.p_user LIKE \'%' . $wgRequest->getVal('memname') . '%\''; $mem_search = ''; $wgRequest->getVal('s_memposts') == 'on' and $wgRequest->getVal('memname') != '' ? $mem_search = $mem : ($mem_search = ''); $s .= $forums_to_search . $mem_search; $s = substr($s, 4, strlen($s)); # die(">". $s); $sql = "SELECT DISTINCT {$awc_tables['awc_f_threads']}.t_id, {$awc_tables['awc_f_threads']}.*, {$awc_f_forums}.f_name, {$awc_f_forums}.f_id, {$awc_f_forums}.f_name, {$awc_f_cats}.cat_name\r\r\n FROM {$awc_tables['awc_f_threads']}\r\r\n \tINNER JOIN {$awc_tables['awc_f_posts']} awc_f_posts\r\r\n \t\tON awc_f_posts.p_threadid={$awc_tables['awc_f_threads']}.t_id\r\r\n INNER JOIN {$awc_tables['awc_f_forums']}\r\r\n \t\tON {$awc_tables['awc_f_threads']}.t_forumid={$awc_f_forums}.f_id\r\r\n INNER JOIN {$awc_tables['awc_f_cats']}\r\r\n \t\tON {$awc_f_forums}.f_parentid={$awc_f_cats}.cat_id\r\r\n \tWHERE {$perm_sql} {$s} AND {$awc_f_forums}.f_passworded = 0\r\r\n ORDER BY {$awc_tables['awc_f_threads']}.t_lastdate DESC"; # die($sql); return $this->q_results($sql, $dbr); }
function display_forums($cID = NULL) { global $WhoWhere, $awc_tables, $tplt; $perm = new awcs_forum_perm_checks(); if ($cID == null) { $test['all'] = 'all'; Set_AWC_Forum_SubTitle($this->cf__forumname, $this->cf__forumsubtitle, $test); $WhoWhere['type'] = 'forum'; $WhoWhere['where'] = 'index'; $WhoWhere['perm'] = '*'; } /* $sql = "SELECT c.cat_id,c.cat_order,c.cat_name, $cat_desc f.* FROM {$awc_tables['awc_f_cats']} c, {$awc_tables['awc_f_forums']} f WHERE c.cat_perm IN ( ". UserPerm ." ) AND f.f_perm <= ". UserPerm ." AND c.cat_id=f.parent_id $SQL ORDER BY c.cat_order ASC, c.cat_name, f.f_order, f.f_name ASC "; */ $c = $awc_tables['awc_f_cats']; $f = $awc_tables['awc_f_forums']; $cat_desc = ''; if ($cID != NULL) { $cat_desc = "{$c}.cat_desc, "; $cID = " AND {$c}.cat_id={$cID} "; } $perm_where = $perm->cat_forum_sql(); $sql = "SELECT {$c}.cat_id,{$c}.cat_order,{$c}.cat_name, {$c}.c_wiki_perm, {$cat_desc} {$f}.*\r\r\n FROM {$awc_tables['awc_f_cats']} , {$awc_tables['awc_f_forums']}\r\r\n WHERE {$perm_where} {$c}.cat_id={$f}.f_parentid {$cID}\r\r\n ORDER BY {$c}.cat_order ASC, {$c}.cat_name, {$f}.f_order, {$f}.f_name ASC "; $res = $this->rDB->query($sql); $cats = array(); $children = array(); $last_c_id = null; while ($r = $this->rDB->fetchObject($res)) { $cat_id = $r->cat_id; $cat_name = $r->cat_name; $cat_perm = $r->c_wiki_perm; if ($cID != NULL) { $cat_desc = $r->cat_desc; } if ($last_c_id != $r->cat_id) { $cats[$r->cat_id] = array('id' => $r->cat_id, 'position' => $r->cat_order, 'name' => $r->cat_name); $last_c_id = $r->cat_id; } $children[$r->f_id] = array('f_id' => $r->f_id, 'f_parentid' => $r->f_parentid, 'f_name' => $r->f_name, 'f_desc' => $r->f_desc, 'f_threads' => $r->f_threads, 'f_replies' => $r->f_replies, 'f_lastdate' => $r->f_lastdate, 'f_lastuser' => $r->f_lastuser, 'f_lastuserid' => $r->f_lastuserid, 'f_lasttitle' => $r->f_lasttitle, 'f_threadid' => $r->f_threadid); } $this->rDB->freeResult($res); if ($cID != NULL) { $e = array(); $e['cID'] = $cat_id; Set_AWC_Forum_SubTitle(get_awcsforum_word('word_ForumsFor') . ' ' . $cat_name, $cat_desc, $e); unset($e); Set_AWC_Forum_BreadCrumbs($cat_name, true); $w = explode('=', $cID); $WhoWhere['type'] = 'forum'; $WhoWhere['where'] = 'cid' . $cID . '||awc-split||' . $cat_name; $WhoWhere['perm'] = $cat_perm; } $str = self::process_all_cats($cats, $children, $cID); unset($children); unset($cats); return $str; }