function enter_search() { global $awcs_forum_config, $wgRequest, $wgOut, $todo, $WhoWhere, $awc_tables, $action_url, $tplt; $perm = new awcs_forum_perm_checks(); //$WhoWhere = 'search'; $WhoWhere['type'] = 'forum'; $WhoWhere['where'] = 'search||awc-split||search'; Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('search_search')); $this->titlelimit = $awcs_forum_config->cfl_ThreadTitleLength - 15; $this->ChrLimit = $awcs_forum_config->cf_Search_ChrLimit; $this->searchword = $wgRequest->getVal('kw'); $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'); #need to do somthing with User topics and posts for URL blocks $action = $wgRequest->action; $this->todo = $action_url['all']; $spl = explode("/", $action_url['all']); foreach ($spl as $k => $value) { if (substr($value, 0, 3) == "kw:") { $this->searchword = str_replace('kw:', '', $value); } if (substr($value, 0, 3) == "tID") { $this->tID = str_replace('tID', '', $value); } if (substr($value, 0, 3) == "fID") { $this->fID = str_replace('fID', '', $value); } if (substr($value, 0, 3) == "cID") { $this->cID = str_replace('cID', '', $value); } if (substr($value, 0, 4) == "what") { $this->what = str_replace('what', '', $value); } if (substr($value, 0, 6) == "limit:") { $this->limit = str_replace('limit:', '', $value); } } $this->searchword = str_replace(array('[', ']', '{', '}'), '', $this->searchword); $this->searchword = strip_tags($this->searchword); $todo = isset($spl[1]) ? $spl[1] : ''; $user = isset($spl[2]) ? $spl[2] : 'NoNameForSearch'; $user_id = isset($spl[3]) ? $spl[3] : '0'; #die(">". $todo); define('what_page', $todo); if ($todo == 's_form') { return $this->s_form(); } # die(">". $todo); if ($todo == '') { $perm_sql = $perm->forum_sql(); if (strlen($perm_sql) > 0) { $perm_sql = 'WHERE ' . $perm_sql; } Set_AWC_Forum_SubTitle(get_awcsforum_word('search_search'), get_awcsforum_word('search_search') . ' ' . get_awcsforum_word('search_whatAll')); Set_AWC_Forum_BreadCrumbs('', true); $tplt->add_tplts(array("'main_search_form'", "'main_seach_form_forum_drop'"), true); $words = array(); $words['search_refine'] = get_awcsforum_word('search_refine'); $words['search_full'] = get_awcsforum_word('search_full'); $words['search_title'] = get_awcsforum_word('search_title'); $words['word_is'] = get_awcsforum_word('word_is'); $words['word_like'] = get_awcsforum_word('word_like'); $words['search_membersname'] = get_awcsforum_word('search_membersname'); $words['search_whatAll'] = get_awcsforum_word('search_whatAll'); $words['search_search'] = get_awcsforum_word('search_search'); $to_tplt['search_forums'] = null; $dbr = wfGetDB(DB_SLAVE); if ($perm_sql) { $perm_sql .= "AND {$awc_f_forums}.f_passworded = 0"; } else { #$perm_sql = 'f.f_passworded = 0'; } $sql = "SELECT {$awc_f_forums}.f_id, {$awc_f_forums}.f_name FROM {$awc_f_forums} {$perm_sql} ORDER BY f_order "; $res = $dbr->query($sql); while ($r = $dbr->fetchObject($res)) { $info['f_id'] = $r->f_id; $info['f_name'] = $r->f_name; $to_tplt['search_forums'] .= $tplt->phase('', $info, 'main_seach_form_forum_drop'); } $dbr->freeResult($res); $tplt->kill('main_seach_form_forum_drop'); unset($res, $sql, $awc_f_forums); return $wgOut->addHTML($tplt->phase($words, $to_tplt, 'main_search_form', true)); } if ($todo == 'todate') { $perm_sql = $perm->forum_sql(); if (strlen($perm_sql) > 0) { $perm_sql .= ' AND '; } $this->total = 0; $this->searchword = get_awcsforum_word('word_todatesposts'); $today = awcsforum_funcs::date_seperated(date('Y') . date('m') . date('d') . '000000'); # die($perm_sql); $sql = "SELECT {$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 INNER JOIN {$awc_tables['awc_f_forums']}\r\r\n \t\tON {$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} {$awc_f_threads}.t_lastdate > '{$today}' AND {$awc_f_forums}.f_passworded = 0\r\r\n ORDER BY {$awc_f_threads}.t_lastdate DESC"; # die($sql); return $this->q_results($sql, $dbr); } if ($todo == 's') { $kw = $wgRequest->getVal('kw'); #$sql = str_replace('\r\n', '', $sql); $kw = $this->searchword; if ($this->searchword == "") { /* $action = $wgRequest->action; $spl = explode("/", $action); foreach($spl as $k => $value){ if (substr($value , 0, 3) == "kw:") $this->searchword = str_replace('kw:', '', $value); if (substr($value , 0, 3) == "tID") $this->tID = str_replace('tID', '', $value); if (substr($value , 0, 3) == "fID") $this->fID = str_replace('fID', '', $value); if (substr($value , 0, 3) == "cID") $this->cID = str_replace('cID', '', $value); if (substr($value , 0, 4) == "what")$this->what = str_replace('what', '', $value); if (substr($value , 0, 6) == "limit:")$this->limit = str_replace('limit:', '', $value); } */ } $s_check = $this->check_searchword(); if (!$s_check) { return $this->search_error; } if ($this->what == null) { $this->what = $wgRequest->getVal('search_what'); } if (strstr($kw, "+") || strstr($kw, " AND ")) { if (strstr($kw, "+")) { $s = $this->CreatePostTitleSearch(explode("+", $kw), 'AND', true); } elseif (strstr($kw, " AND ")) { $s = $this->CreatePostTitleSearch(explode(" AND ", $kw), 'AND', true); } } elseif (strstr($kw, " OR ")) { $s = $this->CreatePostTitleSearch(explode(" OR ", $kw), 'OR', true); } else { $s = $this->CreatePostTitleSearch($kw); } if ($this->tID == 0) { $this->tID = $wgRequest->getVal('tID'); } if ($this->fID == 0) { $this->fID = $wgRequest->getVal('fID'); } if ($this->cID == 0) { $this->cID = $wgRequest->getVal('cID'); } if ($this->what == null) { $this->what = $wgRequest->getVal('search_what'); } //die(">" . $this->what); switch ($this->what) { case 'c': $s .= " AND {$awc_f_forums}.f_parentid = " . $this->cID . " "; $cat = true; break; case 'f': $s .= " AND {$awc_f_forums}.f_id = " . $this->fID . " "; $forum = true; break; case 't': $s .= " AND {$awc_f_threads}.t_id = " . $this->tID . " "; $thread = true; if ($this->what == 't') { return $this->q_thread($s, $dbr); } # return $this->q_thread(); break; } $perm_sql = $perm->cat_forum_sql(); //if(strlen($s) > 0) $perm_sql = 'WHERE ' . $perm_sql ; $sql = "SELECT DISTINCT {$awc_f_threads}.t_id, {$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_f_threads}.t_id\r\r\n INNER JOIN {$awc_tables['awc_f_forums']} \r\r\n \t\tON {$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_f_threads}.t_lastdate DESC"; return $this->q_results($sql, $dbr); } $perm = new awcs_forum_perm_checks(); $perm_sql = $perm->cat_forum_sql(); # die($todo); switch ($todo) { case 'memtopics': $this->MemSearch = $user . ' ' . get_awcsforum_word('word_topics'); $sql = "SELECT {$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 INNER JOIN {$awc_tables['awc_f_forums']}\r\r\n \t\tON {$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} {$awc_f_threads}.t_starterid={$user_id} AND {$awc_f_forums}.f_passworded = 0\r\r\n ORDER BY {$awc_f_threads}.t_lastdate DESC"; break; case 'memposts': $this->MemSearch = $user . ' ' . get_awcsforum_word('word_posts'); $sql = "SELECT DISTINCT {$awc_f_threads}.t_id, {$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_f_threads}.t_id\r\r\n INNER JOIN {$awc_tables['awc_f_forums']}\r\r\n \t\tON {$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} (awc_f_posts.p_threadid={$awc_f_threads}.t_id) AND (awc_f_posts.p_userid={$user_id} AND awc_f_posts.p_thread_start!=1) AND {$awc_f_forums}.f_passworded = 0\r\r\n ORDER BY {$awc_f_threads}.t_lastdate DESC"; break; case 'recent': $this->total = 0; $this->searchword = get_awcsforum_word('word_recent_posts'); // die(awcsforum_funcs::date_seperated($_SESSION['awc_startTime'])); $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\r\r\n FROM {$awc_tables['awc_f_threads']},\r\r\n {$awc_tables['awc_f_forums']},\r\r\n {$awc_tables['awc_f_cats']}\r\r\n WHERE {$perm_sql}\r\r\n {$awc_f_cats}.cat_id={$awc_f_forums}.f_parentid AND {$awc_f_forums}.f_passworded = 0 AND\r\r\n {$awc_f_forums}.f_id={$awc_f_threads}.t_forumid AND \r\r\n {$awc_f_threads}.t_lastdate >= '" . awcsforum_funcs::date_seperated($_SESSION['awc_startTime']) . "' \r\r\n ORDER BY {$awc_f_threads}.t_lastdate DESC, {$awc_f_threads}.t_name DESC"; // die($sql); break; } return $this->q_results($sql, $dbr); }
function preview_show($post_or_thread_or_misc) { global $wgOut, $wgRequest, $awc_tables; include_once awc_dir . 'includes/post_phase.php'; $post_cls = new awcs_forum_post_phase(); require awc_dir . 'includes/post_box.php'; $posting_box = new awcs_forum_posting_box(); $posting_box->Thread_Title = $this->ThreadTitle; $posting_box->f_name = $this->f_name; $f_posting_mesage_tmpt = null; $f_name = null; if ($post_or_thread_or_misc == 'thread') { $rDB = wfGetDB(DB_SLAVE); $r = $rDB->selectRow('awc_f_forums', array('f_name', 'f_posting_mesage_tmpt'), array('f_id' => $this->fID)); $f_name = $r->f_name; $f_posting_mesage_tmpt = $r->f_posting_mesage_tmpt; unset($r); Set_AWC_Forum_SubTitle(get_awcsforum_word('posting_Preview_word') . ': ' . str_replace('_', ' ', $this->title), '', ''); Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'sf/id' . $this->fID . '">' . strtr($f_name, "_", " ") . '</a>'); Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('posting_Preview_word'), true); $posting_box->Show_ann_sticky_lock = true; $posting_box->url = awc_url . 'post/todo_add_thread'; $posting_box->javaCheck = 'onsubmit="return check_NewThread()"'; } if ($post_or_thread_or_misc == 'post') { Set_AWC_Forum_SubTitle(get_awcsforum_word('word_postingreply'), get_awcsforum_word('word_postingreplyfor') . " " . $this->ThreadTitle); Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'sf/id' . $this->fID . '">' . $this->f_name . '</a>'); Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'st/id' . $this->tID . '">' . $this->ThreadTitle . '</a>'); Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('posting_Preview_word'), true); $posting_box->Show_ann_sticky_lock = false; $posting_box->javaCheck = 'onsubmit="return check_quickPost()"'; $posting_box->url = awc_url . 'post/todo_add_post'; } if ($post_or_thread_or_misc == 'quote') { $posting_box->Show_ann_sticky_lock = false; $posting_box->javaCheck = 'onsubmit="return check_quickPost()"'; $posting_box->url = awc_url . 'post/todo_add_post'; $this->subscribe = isset($this->m_thread_subsrib[$this->tID]) ? $this->m_thread_subsrib[$this->tID] : ''; } if ($post_or_thread_or_misc == 'edit') { $posting_box->Show_ann_sticky_lock = false; $posting_box->javaCheck = $this->javaCheck; $posting_box->url = awc_url . 'post/todo_edit_post'; $posting_box->preview_button = true; $posting_box->isThread = $this->isThread; } $post_cls->preview = true; $post_cls->p_userid = $this->cur_memID; $post_cls->p_user = $this->cur_memName; $post_cls->p_post = $this->post; $post_cls->p_title = $this->title; $post_cls->p_date = awcsforum_funcs::date_seperated(wfTimestampNow()); $post_cls->ann = $this->ann; $post_cls->sticky = $this->sticky; $post_cls->lock = $this->lock; $post_cls->member_title = ''; $post_cls->member_title = ''; $html = $post_cls->display_post(); $wgOut->addHTML($html); switch ($this->subscribe) { case 'no': $posting_box->subscribed_no = 'selected'; break; case 'email': $posting_box->subscribed_email = 'selected'; break; case 'list': $posting_box->subscribed_list = 'selected'; break; } $posting_box->subscribe = $this->subscribe; if (strlen($f_posting_mesage_tmpt) > 2) { $posting_box->f_posting_mesage_tmpt = awc_wikipase($f_posting_mesage_tmpt, $wgOut); } $posting_box->f_name = urlencode($f_name); #$posting_box->Thread_Title = awcsforum_funcs::awc_html_entity_decode($this->title); $posting_box->title = $this->title; $posting_box->post = $this->post; if ($this->f_name) { $posting_box->f_name = urlencode($this->f_name); } $posting_box->fID = $this->fID; $posting_box->tID = $this->tID; $posting_box->pID = $this->pID; $posting_box->t_wiki_pageid = $this->t_wiki_pageid; //$e['do_poll'] = $is_poll; $posting_box->ann = $this->ann; $posting_box->sticky = $this->sticky; $posting_box->lock = $this->lock; $posting_box->quick_box = false; $html = $posting_box->box(); $wgOut->addHTML($html); return; }