function __construct()
 {
     if (strstr(UserGroupPerm, 'bureaucrat')) {
         $this->bureaucrat = true;
     }
     awcsforum_funcs::get_table_names(array('awc_f_cats', 'awc_f_forums'));
     $this->UserGroupPerm = explode(',', UserGroupPerm);
 }
 function css_import($for_new_css = false, $xml_string = null, $fresh_install = false)
 {
     global $wgRequest, $awcs_forum_config;
     if (!$for_new_css) {
         if ($_FILES["new_css_file"]["error"] == '0') {
             $css_Path = $_FILES["new_css_file"]["tmp_name"];
             // $css_name = $_FILES["new_css_file"]["name"] ;
             $css_type = $_FILES["new_css_file"]["type"];
         } else {
             return awcs_forum_error('word_cssfile');
         }
         if (!file_exists($css_Path)) {
             return awcs_forum_error('word_cssfile');
         }
         if ($css_type != 'text/xml') {
             return awcs_forum_error('word_cssfile');
         }
     }
     if (!$for_new_css) {
         $css = simplexml_load_file($css_Path);
     } else {
         $css = simplexml_load_string($xml_string);
     }
     if ($fresh_install) {
         $css = simplexml_load_file($for_new_css);
     }
     $css_info = $css->attributes();
     $title = html_entity_decode($css_info['title'], ENT_QUOTES, 'UTF-8');
     $css_ver = $css_info['css_ver'];
     $who = html_entity_decode($css_info['who'], ENT_QUOTES, 'UTF-8');
     $where = html_entity_decode($css_info['where'], ENT_QUOTES, 'UTF-8');
     $css_name_count = html_entity_decode($css_info['count'], ENT_QUOTES, 'UTF-8');
     $info = array('who' => $who, 'where' => $where);
     $dbw = wfGetDB(DB_MASTER);
     # $theme_names_CSS_id = $dbw->nextSequenceValue( 'awc_f_theme_names_thmn_id_seq' );
     $dbw->insert('awc_f_theme_names', array('thmn_title' => $title, 'thmn_when' => $dbw->timestamp(), 'thmn_who' => $who, 'thmn_what' => 'css', 'thmn_where' => $where, 'thmn_item_count' => $css_name_count));
     $theme_names_CSS_id = awcsforum_funcs::lastID($dbw, 'awc_f_theme_names', 'thmn_id');
     # print('>thmn_css_id=' . $theme_names_CSS_id . '<br>');
     $css_code_count = 0;
     foreach ($css as $obj) {
         $att_attributes = $obj->attributes();
         $css_section = $att_attributes['css_section'];
         $css_att = $att_attributes['css_att'];
         $css_att = html_entity_decode($css_att, ENT_QUOTES, 'UTF-8');
         $css_forumver = $att_attributes['forum_ver'];
         $css_ver = $att_attributes['css_ver'];
         $css_custom = $att_attributes['custom'];
         $css_date = $att_attributes['css_date'];
         $css_code = html_entity_decode($obj, ENT_QUOTES, 'UTF-8');
         $dbw->insert('awc_f_theme_css', array('css_section' => $css_section, 'css_att' => $css_att, 'css_thmn_id' => $theme_names_CSS_id, 'css_code' => $css_code, 'css_thm_id' => $this->thm_id, 'css_custom' => $css_custom, 'css_ver' => $css_ver, 'css_date' => $dbw->timestamp(), 'css_forumver' => $css_forumver));
     }
     if ($fresh_install) {
         $dbw->begin();
         $dbw->update('awc_f_theme', array('thm_css_id' => $theme_names_CSS_id), array('thm_id' => $this->thm_id), '');
         $dbw->commit();
     }
     if (!$fresh_install) {
         awc_admin_css_cls::add_new_values(awc_dir . "updates/{$awcs_forum_config->cf_forumversion}/css.xml");
     }
     return true;
 }
function Set_AWC_Forum_SubTitle($title, $sub = '', $extra = '')
{
    global $wgOut, $tplt;
    #die($title);
    $title = strtr($title, "_", " ");
    $title = str_replace("&#039;", "'", $title);
    $title = awcsforum_funcs::awc_html_entity_decode($title);
    if ($sub == '') {
        $sub = ' &nbsp; ';
    }
    $sub = awcsforum_funcs::awc_html_entity_decode($sub);
    //$sub = strtr($sub, "_", " "); // note - commented out on 3-23-09
    if (CanSearch() and isset($extra) and !empty($extra)) {
        $info['url'] = awc_url;
        # awc_pdie($extra);
        $info['hidden_tID'] = isset($extra['tID']) ? '<input name="tID" type="hidden" value="' . $extra['tID'] . '">' : null;
        $info['hidden_fID'] = isset($extra['fID']) ? '<input name="fID" type="hidden" value="' . $extra['fID'] . '">' : null;
        $info['hidden_cID'] = isset($extra['cID']) ? '<input name="cID" type="hidden" value="' . $extra['cID'] . '">' : null;
        $info['drop_cID'] = isset($extra['cID']) ? '<option value="c">' . get_awcsforum_word('search_whatCat') . '</option>' : null;
        $info['drop_fID'] = isset($extra['fID']) ? '<option value="f">' . get_awcsforum_word('search_whatForum') . '</option>' : null;
        $info['drop_tID'] = isset($extra['tID']) ? '<option value="t">' . get_awcsforum_word('search_whatThread') . '</option>' : null;
        #awc_pdie($info);
        $word['search_search'] = get_awcsforum_word('search_search');
        $word['search_whatAll'] = get_awcsforum_word('search_whatAll');
        $search = $tplt->phase($word, $info, 'top_search_box');
    } else {
        $search = '';
    }
    $tplt->kill('top_search_box');
    $wgOut->setPagetitle($title);
    $wgOut->setSubtitle($search . $sub);
    wfRunHooks('awcsforum_before_addKeyword', array(&$title, &$sub));
    $wgOut->addKeyword($title . ' ' . $sub);
    unset($title, $search, $sub);
}
 function mem_profile($action)
 {
     global $wgOut, $rev_timestamp, $awc, $wgOut, $wgParser, $WhoWhere, $tplt, $awcs_forum_config, $wgScriptPath, $awcUser;
     // require(awc_dir . 'skins/members_skin.php');
     //  $skin_mem = New mem_skin();
     require_once awc_dir . 'includes/post_phase.php';
     require_once awc_dir . 'includes/thread_funk.php';
     $post_cls = new awcs_forum_post_phase();
     $WhoWhere = $action;
     $WhoWhere['type'] = 'forum';
     $WhoWhere['where'] = $action . '||awc-split||' . $action;
     # die($action);
     $spl = explode("/", $action);
     if (isset($spl[1])) {
         $mem_name = $spl[1];
         $mem_id = $spl[2];
     } else {
         return awcs_forum_error('');
     }
     $user_get = array('*');
     $mem_page = array();
     $mem_page = GetMemInfo($mem_id, $user_get);
     if ($mem_id == 0 and UserPerm != 10) {
         $mem_name = get_awcsforum_word('word_guest');
     }
     #$out = $wgOut->parse($info);
     $mem_page['body'] = awc_clean_wikipase($wgOut->parse('[[User:'******'|' . get_awcsforum_word('edit') . ']]')) . ' ';
     # $mem_page['body'] = str_replace('User:'******'User:'******'&amp;action=edit', $mem_page['body']);
     $mem_page['body'] .= awc_clean_wikipase($wgOut->parse('[[User_talk:' . $mem_name . '|' . get_awcsforum_word('word_discussion') . ']]')) . '<hr>';
     $mem_page['body'] = str_replace('action=edit', 'awc_redirect=' . $mem_id . '&amp;action=edit', $mem_page['body']);
     $mem_page['body'] = str_replace('action=edit', 'awc_mem_redirect=' . $mem_name . '&amp;action=edit', $mem_page['body']);
     #  die($mem_page['body']);
     # $post = awc_wikipase($post, $wgOut) ;
     $GetWikiPage_body = GetWikiPage('<wiki>' . $mem_name . '</wiki>', '', '2', $mem_id);
     $post_cls->displaysmiles = '0';
     $post_cls->convert_wTitle = '0';
     $GetWikiPage_body = $post_cls->phase_post($GetWikiPage_body, '', false);
     // die(awcsforum_funcs::convert_date($rev_timestamp, 'l'));
     /*
             $GetWikiPage_body = convert_pre($GetWikiPage_body);
             $GetWikiPage_body = remove_forum_tag_from_post($GetWikiPage_body);
             $GetWikiPage_body = br_convert($GetWikiPage_body);
             $GetWikiPage_body = awc_wikipase($GetWikiPage_body, $wgOut) ;
     */
     $mem_page['body'] .= $GetWikiPage_body;
     $post = str_replace('&lt;/a&gt;', '</a>', $mem_page['body']);
     $post = str_replace('&lt;a href', '<a href', $post);
     $post = str_replace('"&gt;', '">', $post);
     $mem_page['body'] = $post;
     // needs to be in the loop to check against each post for other extensions triggered
     foreach ($wgParser->mOutput->mHeadItems as $k_ID => $mHeadItems) {
         $wgOut->addHeadItem($k_ID, $mHeadItems);
     }
     $Pass['body_info'] = isset($mem_page['body']) ? $mem_page['body'] : ' ';
     $Pass['sig'] = isset($mem_page['m_sig']) ? $post_cls->phase_post($mem_page['m_sig'], '', false) : ' ';
     $Pass['group '] = isset($mem_page['group']) ? $mem_page['group'] : null;
     $Pass['m_topics'] = $awcs_forum_config->cf_showThreadCount == '1' ? isset($mem_page['m_topics']) ? get_awcsforum_word('word_threads') . '  <a href="' . awc_url . 'search/memtopics/' . urlencode($mem_page['name']) . '/' . $mem_id . '">' . $mem_page['m_topics'] . '</a>' : null : null;
     $Pass['m_posts'] = $awcs_forum_config->cf_showPostCount == '1' ? isset($mem_page['m_posts']) ? get_awcsforum_word('word_posts') . ' <a href="' . awc_url . 'search/memposts/' . urlencode($mem_page['name']) . '/' . $mem_id . '">' . $mem_page['m_posts'] . '</a>' : null : null;
     $Pass['m_pm'] = $awcUser->guest == '0' ? get_awcsforum_word('word_send') . ' <a href="' . awc_url . 'member_options/pmnew/' . $mem_page['name'] . '">' . get_awcsforum_word('word_pm') . '</a>' : null;
     $Pass['wikiedits'] = isset($mem_page['edit_count']) ? get_awcsforum_word('word_postsWikiedits') . ' <a href="' . awcsf_wiki_url . 'Special:Contributions/' . $mem_page['name'] . '">' . $mem_page['edit_count'] . '</a>' : get_awcsforum_word('word_postsWikiedits') . ' <a href="' . awcsf_wiki_url . 'Special:Contributions/' . $mem_page['name'] . '">0</a>';
     $m_adv = isset($mem_page['m_adv']) ? 1 : 0;
     if ($m_adv == 0 || empty($mem_page['m_adv'])) {
         $m_adv = 1;
         $AvatraSize = explode('x', $awcs_forum_config->cf_AvatraSize);
         if ($mem_page['m_topics'] == '0' and $mem_page['m_posts'] == '0') {
             $mem_page['m_adv'] = "{$wgScriptPath}" . awcForumPath . "images/avatars/avatar_guest.gif";
             $mem_page['m_advw'] = $AvatraSize[0];
             $mem_page['m_advh'] = $AvatraSize[1];
             $this->pm_enable = 0;
         } else {
             $mem_page['m_adv'] = "{$wgScriptPath}" . awcForumPath . "images/avatars/avatar_default.gif";
             $mem_page['m_advw'] = $AvatraSize[0];
             $mem_page['m_advh'] = $AvatraSize[1];
         }
     }
     $Pass['m_adv'] = ($m_adv == 1 and $mem_page['m_adv'] != '') ? '<DIV align="center"><img class="adv" src="' . $mem_page['m_adv'] . '" border="0" height="' . $mem_page['m_advh'] . '" width="' . $mem_page['m_advw'] . '" align="middle"/></div>' : null;
     $Pass['avatarwidth'] = $mem_page['m_advw'];
     $out = $tplt->phase('', $Pass, 'mem_profile_table', true);
     Set_AWC_Forum_SubTitle(get_awcsforum_word('mem_profile') . $mem_name, get_awcsforum_word('mem_lastmod') . " " . awcsforum_funcs::convert_date($rev_timestamp, 'l'));
     Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('mem_profile') . ' ' . $mem_name, true);
     $wgOut->addHTML($out);
     # $dbr = wfGetDB( DB_SLAVE );
 }
 /** Gets Members forum options
  * 
  * @uses GetMemInfo
  * @uses get_mem_forum_options
  * @uses clear_session
  * @uses set_session
  * @since Version 2.5.8 
  */
 function get_mem_forum_options($where = '')
 {
     global $awc_ver;
     $this->has_mem_info = true;
     if ($this->mId != '0') {
         $this->guest = false;
         $user = array();
         $user_get = array();
         $user_get[] = 'm_idname';
         $user_get[] = 'm_displaysigonce';
         $user_get[] = 'm_displaysig';
         $user_get[] = 'm_viewaadv';
         $user_get[] = 'm_posts';
         $user_get[] = 'm_topics';
         if (version_compare(awcs_forum_ver, '2.5.3', '>=')) {
             // need a check for this
             $user_get[] = 'm_pmunread';
             // .2.5.2
             $user_get[] = 'm_pmoptions';
             $user_get[] = 'm_pmpop';
             $user_get[] = 'm_thread_subsrib';
             $user_get[] = 'm_forum_subsrib';
             $user_get[] = 'm_lasthere';
             $user_get[] = 'm_lasttouch';
             $user_get[] = 'm_where';
             $user_get[] = 'm_forumoptions';
             $user_get[] = 'm_menu_options';
         }
         $user = GetMemInfo($this->mId, $user_get, false);
         if ($user == 'error') {
             return;
         }
         if ($user['name'] == '') {
             #  die($this->mName);
             /** @changeVer 2.5.8 - Added default PM options for new members*/
             $dbw = wfGetDB(DB_MASTER);
             $dbw->insert('awc_f_mems', array('m_idname' => $this->mName, 'm_id' => $this->mId, 'm_forumoptions' => serialize($this->m_forumoptions), 'm_pmoptions' => serialize($this->m_pmoptions)));
             $m_id = awcsforum_funcs::lastID($dbw, 'awc_f_mems', 'm_id');
             wfRunHooks('awcsforum_memAddedToDbase', array($m_id, $this));
             // added 2.5.8
             $sql = $dbw->selectSQLText(array('awc_f_stats'), array('*'), '', __METHOD__, array('OFFSET' => '0', 'LIMIT' => '1'));
             # $awc_f_stats = $dbw->tableName('awc_f_stats');
             # $sql = "SELECT * FROM $awc_f_stats LIMIT 1";
             $dbw->ignoreErrors(true);
             if ($res = $dbw->query($sql)) {
                 $r = $dbw->fetchRow($res);
                 $stats_id = $r['stats_id'];
                 $stat_mems = $r['stat_mems'] + 1;
                 $dbw->freeResult($res);
                 unset($r);
                 $dbw->update('awc_f_stats', array('stat_mems' => $stat_mems), array('stats_id' => $stats_id), '');
             }
             $dbw->ignoreErrors(false);
             unset($m_forumoptions, $dbw, $res);
             self::get_mem_forum_options();
         }
         foreach ($user as $u => $v) {
             $this->{$u} = $v;
         }
         unset($user, $user_get);
         if (!isset($awcs_forum_config->cf_save_recent_in_dabase) or $awcs_forum_config->cf_save_recent_in_dabase == '0') {
             // $this->m_lasthere - has already been set from dbase info, this will set for cookie info...
             $this->m_lasthere = isset($_COOKIE["awc_startTime"]) ? $_COOKIE["awc_startTime"] : awcsforum_funcs::wikidate(wfTimestampNow());
         }
         //  awc_pdie($this);
         // $awcstart = isset($_SESSION['awc_startTime']) ?  $_SESSION['awc_startTime'] :  null;
         if (!isset($_SESSION['awc_startTime']) or empty($_SESSION['awc_startTime'])) {
             awcsforum_funcs::clear_session();
             awcsforum_funcs::set_session($this->m_lasthere);
         }
     }
 }
         awcs_forum_tplt_disaply_post();
         awcs_forum_tplt_post_box();
         $tplt->add_tplts(array("'thread_list_header'", "'thread_list_rows'", "'bottom_page_jumps'", "'top_page_jumps'", "'bottom_blocks'", "'top_blocks'", "'thread_list_header_menu'", "'forum:start_new_thread'", "'forum:subscrib_to_forum'", "'postblocks_threadlisting'", "'col_5_isSearch_forum_name'", "'close_table'"));
         $tplt->add_tplts(array("'subscrib_links'", "'options_dropdown'", "'top_page_jumps'", "'bottom_page_jumps'", "'thread_header'", "'top_blocks'", "'bottom_blocks'", "'mod_thread_dropdown'", "'mod_thread_dropdown_ann'", "'post_date_link'", "'close_table'"));
         break;
     case 'todo_new_t':
         awcs_forum_tplt_post_box();
         break;
     case 'sub':
     case 'submit_poll':
     case 'create_cat_do':
     case 'fsub':
     case 'close_poll':
     case 'delete_poll':
     case 'reopen_poll':
         awcsforum_funcs::get_page_lang(array('lang_txt_redirects'));
         // get lang difinitions...
         $tplt->add_tplts(array("'redirect'", "'close_table'"), true);
         break;
     case 'todo_add_thread':
     case 'todo_add_post':
         // need a preview check...
         awcs_forum_tplt_disaply_post();
         awcs_forum_tplt_post_box();
         $tplt->add_tplts(array("'redirect'", "'close_table'"));
         break;
     case 'edithistory':
         // need a preview check...
         awcs_forum_tplt_disaply_post();
         break;
 }
    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 lang_do_export_lang()
 {
     global $awcs_forum_config;
     $out = "<?PHP " . chr(10) . chr(10);
     $fields = array();
     $fields[] = 'lang_txt_admin_raw';
     $fields[] = 'lang_txt_mem_raw';
     $fields[] = 'lang_txt_forum_raw';
     $fields[] = 'lang_txt_tag_raw';
     $fields[] = 'lang_txt_search_raw';
     $fields[] = 'lang_txt_thread_raw';
     $fields[] = 'lang_txt_redirects_raw';
     $lang_info = lang_getinfo($this->lang_code, $fields);
     unset($fields);
     foreach ($lang_info as $id => $info) {
         if ($id != 'array_fields' and $id != 'single_fields') {
             foreach ($lang_info[$id] as $section => $key) {
                 #          die($section);
                 if ($id != 'array_fields' and $id != 'single_fields' and !in_array($section, $lang_info['single_fields']) and strstr($section, '_raw')) {
                     $section_name = str_replace('_raw', '', $section);
                     $section_name = $section;
                     $out .= "\${$section_name} = array( " . chr(10);
                     foreach ($lang_info[$id][$section] as $k => $v) {
                         $out .= "'" . $k . "' => \"" . str_replace('"', '\\"', trim($v)) . '", ' . chr(10);
                         # $out .= "[[" . $k . " - Forum Definition|" . $k . "]] = " . str_replace('"', '\"', $v) . chr(10) . chr(10);
                     }
                     $out .= ");" . chr(10) . chr(10);
                     #$out .= chr(10)  . chr(10);
                 }
             }
         }
     }
     $d = awcsforum_funcs::readabledate(wfTimestampNow());
     $filename = awc_dir . "xported_files/lang_{$this->lang_code}_{$d}.txt";
     $hd = @fopen($filename . "", "w");
     @fwrite($hd, $out);
     @fclose($hd);
     return true;
 }
 function check_msg_len($msg, $len)
 {
     if (function_exists('mb_strlen')) {
         $str_len = 'awc_mbstrlen';
     } else {
         $str_len = 'awcsforum_funcs::awc_strlen';
     }
     if ($str_len($msg) > $len and $len != '0') {
         if (function_exists('mb_substr')) {
             $msg = awcsforum_funcs::awc_shorten($msg, $len);
         } else {
             $msg = substr($msg, 0, $len);
         }
     }
     require_once awc_dir . 'includes/post_phase.php';
     $post_phase = new awcs_forum_post_phase();
     $post_phase->convert_wTitle = 0;
     $post_phase->displaysmiles = 1;
     $msg = $post_phase->phase_post($msg, 0, false);
     return $msg;
 }
 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;
 }
 function splitmerge_get($id)
 {
     global $wgOut, $tplt, $awc_tables;
     if (UserPerm < 2) {
         return $wgOut->loginToUse();
     }
     $id = $id[0];
     awcsforum_funcs::get_page_lang(array('lang_txt_thread'));
     // get lang difinitions...
     Set_AWC_Forum_SubTitle(get_awcsforum_word('word_split_merge'), '');
     Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('word_split_merge'), true);
     $dbr = wfGetDB(DB_SLAVE);
     $r = $dbr->selectRow('awc_f_posts', array('p_title'), "p_id={$id}", __METHOD__, array('OFFSET' => 0, 'LIMIT' => 1));
     $title = $r->p_title;
     unset($r);
     $sql = "SELECT f_id, f_name FROM {$awc_tables['awc_f_forums']} WHERE f_perm <= '" . UserPerm . "' ORDER BY f_order ASC ";
     $info['forums_dropdown'] = '<select name="fID">';
     $res = $dbr->query($sql);
     while ($r = $dbr->fetchObject($res)) {
         $info['forums_dropdown'] .= '<option value="' . $r->f_id . '">' . $r->f_name . '</option>';
     }
     $dbr->freeResult($res);
     unset($dbr, $r, $res);
     $info['forums_dropdown'] .= '</select>';
     $info['pID'] = $id;
     $word['word_create_new_thread'] = get_awcsforum_word('word_create_new_thread');
     $word['word_thread_title_for_new_thread'] = get_awcsforum_word('word_thread_title_for_new_thread');
     $word['submit'] = get_awcsforum_word('submit');
     $word['word_merge_this_post_to_this_thread'] = get_awcsforum_word('word_merge_this_post_to_this_thread');
     $tplt->add_tplts(array("'split_and_merge'"), true);
     $out = $tplt->phase($word, $info, 'split_and_merge', true);
     $wgOut->addHTML($out);
 }
$sql = $installCLS->clearTable($tbl);
$res = $dbw->query($sql);
$tbl = $dbw->tableName('awc_f_theme_names');
$sql = $installCLS->clearTable($tbl);
$res = $dbw->query($sql);
$tbl = $dbw->tableName('awc_f_theme_css');
$sql = $installCLS->clearTable($tbl);
$res = $dbw->query($sql);
$dbw->commit();
$dbw->begin();
/*  $dbw->nextSequenceValue( 'awc_f_TABLE_COL-ID_seq' );
 *  Needed for PostgreSQL
 */
#$thm_id = $dbw->nextSequenceValue( 'awc_f_theme_thm_id_seq' );
$dbw->insert('awc_f_theme', array('thm_title' => 'Default', 'thm_who' => 'AWC', 'thm_css_id' => '1', 'thm_tplt_id' => '2', 'thm_where' => 'wiki.anotherwebcom.com', 'thm_when' => $date_seperated), __METHOD__);
$thm_id = awcsforum_funcs::lastID($dbw, 'awc_f_theme', 'thm_id');
#print(">>thm_id= $thm_id <br>");
$css_cls->thm_id = $thm_id;
$css_cls->css_import($awc_install_dir . 'css.xml', '', true);
$wgOut->addHTML("CSS added... <hr>");
$tplt_cls->thm_id = $thm_id;
$tplt_cls->import_xml($awc_install_dir . 'tplt.xml', null, false, true);
$wgOut->addHTML("Skin Templates added... <hr>");
$res = $dbr->select('awc_f_theme_names', array('*'), '', __METHOD__, array('OFFSET' => '0', 'LIMIT' => '2'));
foreach ($res as $r) {
    if ($r->thmn_what == 'css') {
        $css_id = $r->thmn_id;
        $css_thmn_item_count = $r->thmn_item_count;
        $css_thmn_who = $r->thmn_who;
        $css_thmn_where = $r->thmn_where;
    }
function Convert($txt)
{
    static $t = 0;
    $t++;
    if ($t == 1) {
        #die($txt);
    }
    $txt = awcf_hide_code2($txt);
    $txt = preg_replace("#\\[b\\](.+?)\\[/b\\]#is", "<b>\\1</b>", $txt);
    $txt = preg_replace("#\\[i\\](.+?)\\[/i\\]#is", "<i>\\1</i>", $txt);
    $txt = preg_replace("#\\[u\\](.+?)\\[/u\\]#is", "<u>\\1</u>", $txt);
    $txt = preg_replace("#\\[s\\](.+?)\\[/s\\]#is", "<s>\\1</s>", $txt);
    $txt = preg_replace("#\\[search\\](.+?)\\[/search\\]#is", "<a href='" . awc_url . "search/s/?&kw=\\1'>\\1</a>", $txt);
    $txt = preg_replace("#\\[google\\](.+?)\\[/google\\]#is", "<a href='http://www.google.com/search?q=\\1'>\\1</a>", $txt);
    $txt = preg_replace("#\\[yahoo\\](.+?)\\[/yahoo\\]#is", "<a href='http://search.yahoo.com/search?p=\\1'>\\1</a>", $txt);
    $txt = preg_replace("#\\[size\\s*=\\s*(\\S+?)\\s*\\](.*?)\\[\\/size\\]#is", "<font size='\\1'>\\2</font>", $txt);
    $txt = preg_replace("#\\[size\\s*=\\s*(\\S+?)\\s*\\](.*?)\\<\\/font>(.*?)\\[\\/size\\]#is", "</font><font size='\\1'>\\2</font>", $txt);
    $txt = preg_replace("#\\[color\\s*=\\s*(\\S+?)\\s*\\](.*?)\\[\\/color\\]#is", "<font color='\\1'>\\2</font>", $txt);
    $txt = preg_replace("#\\[color\\s*=\\s*(\\S+?)\\s*\\](.*?)\\<\\/font>(.*?)\\[\\/color\\]#i", "</font><font color='\\1'>\\2</font>", $txt);
    $txt = preg_replace("#\\[center\\](.+?)\\[/center\\]#is", "<center>\\1</center>", $txt);
    # needs work...
    $txt = preg_replace("#\\[right\\](.+?)\\[/right\\]#is", "<div align='right'>\\1</div>", $txt);
    $txt = preg_replace("#\\[left\\](.+?)\\[/left\\]#is", "<div align='left'>\\1</div>", $txt);
    # needs work...
    $txt = preg_replace("#\\[[hr]\\]#is", "<hr>", $txt);
    #$txt = preg_replace( "#\[list\](.+?)\[\*\](.+?)\[/list\]#is"   , "<ul>\\1<li>\\2</li></ul>"  , $txt );
    $match = "#\\[list\\](.+?)\\[/list\\]#is";
    if (preg_match_all($match, $txt, $found)) {
        $txt = str_replace($found[0][0], "<ul>" . $found[1][0] . "</ul>", $txt);
        $match2 = "#\\[\\*\\](.+?)#U";
        if (preg_match_all($match2, $txt, $found2)) {
            foreach ($found2[1] as $k => $v) {
                $txt = str_replace($found2[0][$k], "<li>" . $v . "</li>", $txt);
            }
        }
    }
    // cant do this, wiki phases urls before hand...
    #$txt = preg_replace( "#\[url\s*=\s*(\S+?)\s*\](.*?)\[\/url\]#is"   , "[\\1 \\2]"  , $txt );
    #$txt = preg_replace( "#\[URL\s*=\s*(\S+?)\s*\](.*?)\[\/URL\]#is"   , "[\\1 \\2]"  , $txt );
    $txt = preg_replace("#\\[quote\\]#is", "<div class='quote_title'>Quote:<div class='quote'>\\1", $txt);
    $txt = preg_replace("#\\[quote=([^\\]]+?)\\]#is", "<div class='quote_title'>Quote:\\1<div class='quote'>\\2", $txt);
    $txt = preg_replace("#\\[/quote\\]#is", '</div id="quote"></div id="quote">', $txt);
    /*
             2.5 change, no longer needed...
             
                $txt = str_replace("</li><br />", "</li>", $txt);
                $txt = str_replace("<ul><br />", "<ul>", $txt);
                $txt = str_replace("<br /><ul>", "<ul>", $txt);
                $txt = str_replace("</ul><br />", "</ul>", $txt);
                $txt = str_replace("</div><br />", "</div>", $txt);
    $txt = str_replace("<br /><tr>", '<tr>', $txt);
                $txt = str_replace("<br /><td>", '<td>', $txt);
                $txt = str_replace("<br /></p><br />", '<br />', $txt);
                $txt = str_replace("<br /><p>", '<br />', $txt);
    */
    #  die($txt);
    #$txt = preg_replace( "#\|emotion_tag\|(.+?)\|emotion_tag\|_end\|#is", "<img src=\"\\1\" />", $txt );
    $txt = preg_replace("#\\|emotion_tag\\|(.+?)\\|emotion_tag\\|_end\\|#is", "<img src=\"\\1\" />", $txt);
    #  trying to cut done on URL lenths...
    $match = "#<a(.+?)<\\/a>#is";
    if (preg_match_all($match, $txt, $found)) {
        foreach ($found[0] as $url_title) {
            $match = "#\">(.+?)<\\/a>#is";
            if (preg_match_all($match, $url_title, $found2)) {
                $img_match = "#<img(.+?)>#is";
                if (!preg_match_all($img_match, $found2[0][0], $found3)) {
                    $replace = str_replace('">', '', $found2[0][0]);
                    $replace = str_replace('</a>', '', $replace);
                    if (strlen($replace) > 90) {
                        $txt = str_replace($found2[0][0], '">' . awcsforum_funcs::awc_shorten($replace, 90) . '...</a>', $txt);
                    }
                }
            }
        }
    }
    $f = array('&lt;/a&gt;', '&lt;a href', '"&gt;', "<a href=");
    $r = array('</a>', '<a href', '">', "<a target='blank' href=", '');
    $txt = str_replace($f, $r, $txt);
    $txt = awcf_unhide_code($txt);
    return $txt;
}
 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>';
 }
 function import_xml($for_new_tplt = false, $xml_string = null, $redirect = true, $installer = false)
 {
     global $wgRequest, $awcs_forum_config;
     // $cf_them = unserialize($awcs_forum_config->cf_default_forum_theme);
     // cf_default_forum_theme
     if (!$for_new_tplt) {
         if ($_FILES["new_tplt_file"]["error"] == '0') {
             $tplt_Path = $_FILES["new_tplt_file"]["tmp_name"];
             // $tplt_name = $_FILES["new_tplt_file"]["name"] ;
             $tplt_type = $_FILES["new_tplt_file"]["type"];
         } else {
             return awcs_forum_error('word_tpltfile');
         }
         if (!file_exists($tplt_Path)) {
             return awcs_forum_error('word_tpltfile');
         }
         if ($tplt_type != 'text/xml') {
             return awcs_forum_error('word_tpltfile');
         }
     } else {
         $tplt_Path = $for_new_tplt;
     }
     if (strlen($xml_string) >= 0) {
         $tplt = simplexml_load_file($tplt_Path);
         #$tplt = simplexml_load_file($tplt_Path, 'SimpleXMLElement', LIBXML_NOCDATA);
     } else {
         $tplt = simplexml_load_string($xml_string);
     }
     $t = $tplt->tplt->attributes();
     #$thmn_who = html_entity_decode($t['thmn_who'], ENT_NOQUOTES, 'UTF-8');
     #$thmn_where = html_entity_decode($t['thmn_where'], ENT_NOQUOTES, 'UTF-8');
     #$thmn_title = html_entity_decode($t['thmn_title'], ENT_NOQUOTES, 'UTF-8');
     #$thmn_when = html_entity_decode($t['thmn_when'], ENT_NOQUOTES, 'UTF-8');
     $thmn_who = $t['thmn_who'];
     $thmn_where = $t['thmn_where'];
     $thmn_title = $t['thmn_title'];
     $thmn_when = $t['thmn_when'];
     // $this->wDB->delete( 'awc_f_theme_tplt', array( 'tplt_thmn_id' => $this->thmn_id ), '');
     //  $this->wDB->delete( 'awc_f_theme_names', array( 'thmn_id' => $this->thmn_id ), '');
     if ($thmn_when == "0000.00.00") {
         #$thmn_when = str_replace('.', '', $thmn_when) . '000000';
         $thmn_when = $this->wDB->timestamp();
     }
     # $thmn_id = $this->wDB->nextSequenceValue( 'awc_f_theme_names_thmn_id_seq' );
     $this->wDB->insert('awc_f_theme_names', array('thmn_title' => $thmn_title, 'thmn_when' => $thmn_when, 'thmn_who' => $thmn_who, 'thmn_where' => $thmn_where, 'thmn_what' => 'tplt'));
     $thmn_id = awcsforum_funcs::lastID($this->wDB, 'awc_f_theme_names', 'thmn_id');
     # print('>thmm_tplt_id=' . $thmn_id . '<br>');
     if ($installer) {
         $this->wDB->begin();
         $this->wDB->update('awc_f_theme', array('thm_tplt_id' => $thmn_id), array('thm_id' => $this->thm_id), '');
         $this->wDB->commit();
     }
     foreach ($tplt as $code) {
         $info = $code->attributes();
         #$tplt_ver = html_entity_decode($info['tplt_ver'], ENT_NOQUOTES, 'UTF-8');
         #$tplt_forum_ver = html_entity_decode($info['tplt_forum_ver'], ENT_NOQUOTES, 'UTF-8');
         #$tplt_section = html_entity_decode($code->tplt_section, ENT_NOQUOTES, 'UTF-8');
         #$tplt_function= html_entity_decode($code->tplt_function, ENT_NOQUOTES, 'UTF-8');
         #$tplt_code = html_entity_decode($code->tplt_code, ENT_NOQUOTES, 'UTF-8');
         $tplt_ver = $info['tplt_ver'];
         $tplt_forum_ver = $info['tplt_forum_ver'];
         $tplt_section = $code->tplt_section;
         $tplt_function = $code->tplt_function;
         $tplt_code = $code->tplt_code;
         $this->wDB->insert('awc_f_theme_tplt', array('tplt_section' => $tplt_section, 'tplt_function' => $tplt_function, 'tplt_code' => $tplt_code, 'tplt_ver' => $tplt_ver, 'tplt_forum_ver' => $tplt_forum_ver, 'tplt_thmn_id' => $thmn_id));
         # awc_pdie($code);
     }
     unset($info);
     if ($redirect) {
         $info['msg'] = 'tplt_has_been_imported';
         $info['url'] = awc_url . "admin/tplt/display";
         return awcf_redirect($info);
     }
     return;
 }
 function check_searchword()
 {
     global $kw, $awc, $wgOut;
     $no_search = array();
     require awc_dir . 'config/no_search.php';
     foreach ($no_search as $clear_word) {
         $this->searchword = str_replace($clear_word, "", $this->searchword);
     }
     if (strlen($this->searchword) < $this->ChrLimit) {
         $er = '';
         foreach ($no_search as $clear_word) {
             $er .= $clear_word . "<br />";
         }
         $er .= '';
         Set_AWC_Forum_SubTitle(get_awcsforum_word('search_word_to_short') . ' ' . $this->ChrLimit);
         Set_AWC_Forum_BreadCrumbs($this->searchword, true);
         $this->search_error = $wgOut->addHTML('<hr>' . get_awcsforum_word('search_word_to_short') . ' ' . $this->ChrLimit . '<hr>' . '<br />' . get_awcsforum_word('search_omitted_words') . '<hr>' . $er);
         unset($no_search);
         return false;
     }
     unset($no_search);
     $this->searchword = str_replace('_', ' ', $this->searchword);
     $kw = strip_tags($this->searchword);
     $kw = awcsforum_funcs::awc_htmlentities($kw);
     return true;
 }
 /**
  * Format date numbers to words - check users timezone also
  * @since Version 2.5.0
  * @return string $srt (date numbers)
  * @parameter string $srt (date numbers)
  * @parameter string $t (how to format, long or short)
  * @parameter string $skip (??? dont know, find out why)
  * @todo Find out what the $skip parameter is for
  * @uses wikidate
  * @changeVer 2.5.8 - made method public static
  */
 public static function convert_date($srt, $t, $skip = false)
 {
     global $awcs_forum_config, $awcUser;
     global $wgLang;
     $srt = awcsforum_funcs::wikidate($srt);
     if (isset($awcUser->timecorrection)) {
         $user_timeShift = $awcUser->timecorrection;
         $srt = $wgLang->userAdjust($srt, $user_timeShift);
     } else {
         $srt = $wgLang->userAdjust($srt, 0);
     }
     if ($t == "l") {
         $date = $awcs_forum_config->cf_DateLong;
     } else {
         $date = $awcs_forum_config->cf_DateShort;
     }
     $year = substr($srt, 0, 4);
     $month = substr($srt, 4, 2);
     $day = substr($srt, 6, 2);
     $hour = substr($srt, 8, 2);
     $min = substr($srt, 10, 2);
     $sec = substr($srt, 12, 2);
     # $srt2 = @date( $date, mktime($hour , $min, $sec, $month, $day, $year) ) ;
     return date($date, mktime($hour, $min, $sec, $month, $day, $year));
 }
 function display_post($pm = false, $pm_links = null)
 {
     global $tplt;
     # awc_pdie($this);
     static $mem_Info = array();
     static $word = array();
     static $avatarwidth;
     $height_stuff = array('advar' => 0, 'memtitle' => 0, 'wikicount' => 0, 'postcount' => 0, 'threadcount' => 0);
     # awc_pdie($this);
     static $time_func_called = 0;
     ++$time_func_called;
     if ($time_func_called == 1) {
         $word = self::get_words();
         if (isset($this->cf_AvatraSize)) {
             $spl = explode('x', $this->cf_AvatraSize);
             $avatarwidth = $spl[1] + '20';
         } else {
             $avatarwidth = '135';
         }
     }
     if ($pm == false) {
         // wfRunHooks( 'awcsforum_rawpost', array( &$this ) );
         if ($time_func_called == 1) {
             $tplt_info['LimitJump'] = isset($extras['LimitJump_top']) ? $extras['LimitJump_top'] : null;
             $tplt_info['options_menu'] = isset($extras['options_menu']) ? $extras['options_menu'] : null;
         }
     } else {
         $edit_buttons['edit_buttons'] = $this->pm_links;
         $tplt_info['edit_buttons'] = $edit_buttons['edit_buttons'];
         $tplt_info['post_edited_on'] = null;
     }
     $tplt_info['avatarwidth'] = $avatarwidth;
     # Cache... Create array of Members info then check, cut down on queires on Sig and Group
     $HaveMemInfo = false;
     if (!empty($mem_Info)) {
         foreach ($mem_Info as $id => $value) {
             if ($mem_Info[$id]['m_id'] == $this->p_userid) {
                 $HaveMemInfo = true;
             }
         }
         if (!$HaveMemInfo) {
             $mem_Info[$this->p_userid] = GetMemInfo($this->p_userid, $this->user_info_cols);
         }
     } else {
         $mem_Info[$this->p_userid] = GetMemInfo($this->p_userid, $this->user_info_cols);
     }
     #  awc_pdie($mem_Info);
     $hook_user_info = array();
     $hook_user_info['name'] = $this->p_user;
     $hook_user_info['id'] = $this->p_userid;
     foreach ($mem_Info as $id => $value) {
         // if($id != 2) awc_pdie(">". $id);
         //die("kk");
         // if($id == 0){
         if ($this->p_userid == 0) {
             //  die();
             $AvatraSize = explode('x', $this->cf_AvatraSize);
             $mem_Info[0]['m_adv'] = "{$this->wgScriptPath}" . awcForumPath . "/images/avatars/avatar_guest.gif";
             $mem_Info[0]['m_advw'] = $AvatraSize[0];
             $mem_Info[0]['m_advh'] = $AvatraSize[1];
             $mem_Info[0]['edit_count'] = 0;
             $mem_Info[0]['m_posts'] = 0;
             $mem_Info[0]['m_topics'] = 0;
             $mem_Info[0]['edit_count'] = 0;
             $mem_Info[0]['member_title'] = '';
             $to_skin['member_title'] = '';
             $to_skin['edit_count'] = 0;
             $to_skin['m_posts'] = 0;
             $to_skin['m_topics'] = 0;
             $to_skin['m_advh'] = $mem_Info[0]['m_advh'];
             $to_skin['m_advw'] = $mem_Info[0]['m_advw'];
             $to_skin['m_adv'] = $mem_Info[0]['m_adv'];
             $tplt_info['group'] = '';
             $to_skin['m_sig'] = '';
             $mem_Info[0]['group'] = isset($mem_Info[$this->p_userid]['group']) ? $mem_Info[$this->p_userid]['group'] : '';
             $mem_Info[0]['m_sig'] = '';
             // if($this->p_post != 'guest') die($this->p_userid);
         } else {
             if (!isset($mem_Info[$id]['cached'])) {
                 $mem_Info[$id]['cached'] = true;
                 if ($mem_Info[$id]['m_id'] == $this->p_userid) {
                     //$mem_Info[0]['member_title'] = ''; mem_post_title
                     //  die($this->p_userid);
                     if ($this->viewing_mem_info['displaysigs'] == 1 or $awcUser->guest == '0' and $this->cf_SigGuestView) {
                         $m_sig = $mem_Info[$id]['m_sig'];
                         $m_sig = self::phase_post($m_sig, '', false);
                         $to_skin['m_sig'] = $m_sig;
                         if (isset($mem_Info[$id]['m_sig'])) {
                             $to_skin['m_sig'] = str_replace('<a href=', '<a target="blank" href=', $m_sig);
                         }
                         if ($this->viewing_mem_info['displaysigonce'] == 1 and !isset($mem_Info[$id]['show_sig'])) {
                             $mem_Info[$id]['show_sig'] = true;
                         } elseif ($this->viewing_mem_info['displaysigonce'] == 1) {
                             $to_skin['m_sig'] = null;
                         }
                     } else {
                         $to_skin['m_sig'] = null;
                     }
                     $to_skin['m_adv'] = null;
                     if ($this->viewing_mem_info['viewaadv'] == 1 || ($awcUser->guest == '0' and $this->cf_AdvatarGuestView)) {
                         if (isset($mem_Info[$id]['m_adv']) and !empty($mem_Info[$id]['m_adv'])) {
                             $to_skin['m_adv'] = $mem_Info[$id]['m_adv'];
                             $to_skin['m_advw'] = $mem_Info[$id]['m_advw'];
                             $to_skin['m_advh'] = $mem_Info[$id]['m_advh'];
                         } elseif ($mem_Info[$id]['m_topics'] == '0' and $mem_Info[$id]['m_posts'] == '0') {
                             $AvatraSize = explode('x', $this->cf_AvatraSize);
                             $to_skin['m_adv'] = "{$this->wgScriptPath}" . awcForumPath . "images/avatars/avatar_guest.gif";
                             $to_skin['m_advw'] = $AvatraSize[0];
                             $to_skin['m_advh'] = $AvatraSize[1];
                         } else {
                             $AvatraSize = explode('x', $this->cf_AvatraSize);
                             $to_skin['m_adv'] = "{$this->wgScriptPath}" . awcForumPath . "images/avatars/avatar_default.gif";
                             $to_skin['m_advw'] = $AvatraSize[0];
                             $to_skin['m_advh'] = $AvatraSize[1];
                         }
                     }
                     $mem_Info[$id]['m_adv'] = $to_skin['m_adv'];
                     // flip for caching
                     $mem_Info[$id]['m_advw'] = $to_skin['m_advw'];
                     // flip for caching
                     $mem_Info[$id]['m_advh'] = $to_skin['m_advh'];
                     // flip for caching
                     $mem_Info[$id]['m_sig'] = $to_skin['m_sig'];
                     // flip for caching
                     if (!isset($mem_Info[$id]['m_topics']) or empty($mem_Info[$id]['m_topics'])) {
                         $mem_Info[$id]['m_topics'] = '0';
                     }
                     $to_skin['m_topics'] = $mem_Info[$id]['m_topics'];
                     if (!isset($mem_Info[$id]['m_posts']) or empty($mem_Info[$id]['m_posts'])) {
                         $mem_Info[$id]['m_posts'] = '0';
                     }
                     $to_skin['m_posts'] = $mem_Info[$id]['m_posts'];
                     if (!isset($mem_Info[$id]['edit_count']) or empty($mem_Info[$id]['edit_count'])) {
                         $mem_Info[$id]['edit_count'] = '0';
                     }
                     $to_skin['edit_count'] = $mem_Info[$id]['edit_count'];
                     $tplt_info['group'] = $mem_Info[$id]['group'];
                     // @added 2.5.8
                     if (!isset($this->mem_post_title[0])) {
                         foreach ($this->mem_post_title as $memPostTitleID) {
                             if ($mem_Info[$id]['m_posts'] >= $memPostTitleID['count']) {
                                 $tplt_info['member_title'] = $memPostTitleID['title'];
                                 $tplt_info['member_title_css'] = $memPostTitleID['css'];
                             }
                         }
                     } else {
                         $tplt_info['member_title'] = '';
                         $tplt_info['member_title_css'] = '';
                     }
                     $mem_Info[$id]['member_title'] = $tplt_info['member_title'];
                     $mem_Info[$id]['member_title_css'] = $tplt_info['member_title_css'];
                     $to_skin['member_title'] = $tplt_info['member_title'];
                     $to_skin['member_title_css'] = $tplt_info['member_title_css'];
                     //- @added / 2.5.8
                 }
             } else {
                 $to_skin['edit_count'] = isset($mem_Info[$this->p_userid]['edit_count']) ? $mem_Info[$this->p_userid]['edit_count'] : 0;
                 $to_skin['m_posts'] = $mem_Info[$this->p_userid]['m_posts'];
                 $to_skin['m_topics'] = $mem_Info[$this->p_userid]['m_topics'];
                 $to_skin['m_advh'] = $mem_Info[$this->p_userid]['m_advh'];
                 $to_skin['m_advw'] = $mem_Info[$this->p_userid]['m_advw'];
                 $to_skin['m_adv'] = $mem_Info[$this->p_userid]['m_adv'];
                 $tplt_info['group'] = $mem_Info[$this->p_userid]['group'];
                 $tplt_info['member_title'] = isset($mem_Info[$this->p_userid]['member_title']) ? $mem_Info[$this->p_userid]['member_title'] : '';
                 $tplt_info['member_title_css'] = isset($mem_Info[$this->p_userid]['member_title_css']) ? $mem_Info[$this->p_userid]['member_title_css'] : '';
                 # die();
                 $to_skin['member_title'] = $tplt_info['member_title'];
                 $to_skin['member_title_css'] = $tplt_info['member_title_css'];
                 if ($this->viewing_mem_info['displaysigonce'] == 1) {
                     $to_skin['m_sig'] = '';
                 } else {
                     $to_skin['m_sig'] = $mem_Info[$this->p_userid]['m_sig'];
                 }
             }
         }
     }
     $height_stuff['advar'] = $mem_Info[$this->p_userid]['m_advh'] + 15;
     $height_stuff['memtitle'] = $to_skin['member_title'] == '' ? 0 : 20;
     $height_stuff['wikicount'] = 20;
     $height_stuff['postcount'] = 20;
     $height_stuff['threadcount'] = 20;
     if (!isset($mem_Info[$this->p_userid]['m_topics']) or empty($mem_Info[$this->p_userid]['m_topics'])) {
         $height_stuff['threadcount'] = 0;
     }
     if (!isset($mem_Info[$this->p_userid]['m_posts']) or empty($mem_Info[$this->p_userid]['m_posts'])) {
         $height_stuff['postcount'] = 0;
     }
     if (!isset($mem_Info[$this->p_userid]['edit_count']) or empty($mem_Info[$this->p_userid]['edit_count'])) {
         $height_stuff['wikicount'] = 0;
     }
     $tplt_info['sig_display'] = $tplt->phase($word, $to_skin, 'sig_display');
     $tplt_info['post_avatar'] = $tplt->phase($word, $to_skin, 'post_avatar');
     $to_skin['url'] = awcsf_wiki_url . "Special:Contributions/{$this->p_user}";
     $tplt_info['wikiedits_count_link'] = $this->showWEcount == '1' ? $tplt->phase($word, $to_skin, 'link_wikiedits') : null;
     $to_skin['url'] = awc_url . "search/memtopics/" . urlencode($this->p_user) . '/' . $this->p_userid;
     //  $to_skin['url'] = awc_url ."search/memtopics/".$this->p_userid ;
     $tplt_info['topics_count_link'] = $this->showTcount == '1' ? $tplt->phase($word, $to_skin, 'link_threads') : null;
     $to_skin['url'] = awc_url . "search/memposts/" . urlencode($this->p_user) . '/' . $this->p_userid;
     // $to_skin['url'] = awc_url ."search/memposts/".$this->p_userid ;
     $tplt_info['post_count_link'] = $this->showPcount == '1' ? $tplt->phase($word, $to_skin, 'link_posts') : null;
     $tplt_info['mem_drop_num'] = $time_func_called;
     $tplt_info['user_name'] = "<a href=\"" . awc_url . "mem_profile/{$this->p_user}/{$this->p_userid}\" onmouseover=\"mopen('mem{$tplt_info['mem_drop_num']}')\" onmouseout=\"mclosetime()\">{$this->p_user}</a>";
     $tplt_info['admin_lookup'] = (UserPerm == 10 and !$this->preview) ? '<a target="blank" href="' . awc_url . 'admin/mem_lookup/' . $this->p_user . '/' . $this->p_userid . '">*</a>' : '';
     $to_skin['url'] = awc_url . "mem_profile/{$this->p_user}/{$this->p_userid}";
     $tplt_info['profile_link'] = $tplt->phase($word, $to_skin, 'link_profile');
     $tplt_info['user_options'] = isset($to_skin['user_options']) ? $to_skin['user_options'] . '<br />' : null;
     if ($this->p_userid == 0) {
         //if($this->show_guest_ip == 0)
         if (UserPerm == 10 and !$this->preview) {
             $tplt_info['user_name'] = "<a href='" . awcsf_wiki_url . "Special:Contributions/{$this->p_user}'>{$this->p_user}</a>";
         } elseif ($this->show_guest_ip == 0) {
             $tplt_info['user_name'] = get_awcsforum_word('word_guest');
         }
         $tplt_info['post_count_link'] = null;
         $tplt_info['profile_link'] = null;
         $tplt_info['user_options'] = null;
         $tplt_info['topics_count_link'] = null;
         $tplt_info['group'] = null;
         $tplt_info['member_title'] = '';
         $tplt_info['member_title_css'] = '';
         if (UserPerm == 10 and !$this->preview) {
         } elseif ($this->show_guest_ip == 0) {
             $tplt_info['wikiedits_count_link'] = null;
         }
     }
     if (!isset($tplt_info['member_title'])) {
         $tplt_info['member_title'] = '';
         $tplt_info['member_title_css'] = '';
     }
     $m_pm = ($this->pm_enable == '1' and $this->guest == false) ? $word['word_send'] . ' <a href="' . awc_url . 'member_options/pmnew/' . $this->p_user . '/' . $this->p_id . '">' . $word['word_pm'] . '</a>' : null;
     $to_skin['url'] = awc_url . 'member_options/pmnew/' . $this->p_user . '/' . $this->p_id;
     $tplt_info['m_pm'] = $tplt->phase($word, $to_skin, 'link_send_pm_to');
     $tplt_info['date'] = null;
     $info['date'] = awcsforum_funcs::convert_date($this->p_date, "l") . " ";
     if (!$this->preview) {
         $tplt_info['date'] = $tplt->phase($word, $info, 'post_date_link');
     }
     if ($this->single_post or $pm or $this->preview) {
         $tplt_info['date'] = $info['date'];
     }
     $info['post_title'] = awcsforum_funcs::awc_html_entity_decode($this->p_title);
     #$info['post_title'] = $this->p_title ;
     $tplt_info['post_title'] = (!empty($this->p_title) and $this->p_title != $this->t_name) ? $tplt->phase($word, $info, 'post_title_row') : '';
     if ($time_func_called % 2) {
         $tplt_info['row_class'] = 'post0';
     } else {
         $tplt_info['row_class'] = 'post1';
     }
     /* 
     if ($this->bcmod) {
         //$tplt_info['row_class'] = 'post' . bcmod($time_func_called, '2')  ;
     } else {
         //$tplt_info['row_class'] = 'post' ;
     }
     */
     if ($pm == false) {
         if (!empty($this->p_editwho)) {
             $info['p_editdate'] = awcsforum_funcs::convert_date($this->p_editdate, "l");
             $info['p_editwho'] = $this->p_editwho;
             $tplt_info['post_edited_on'] = $tplt->phase($word, $info, 'post_edited_on');
         } else {
             $tplt_info['post_edited_on'] = null;
         }
         $edit_buttons['edit_buttons'] = null;
         if (UserPerm >= 2 and !$this->preview || CanDelete($this->p_user)) {
             if ($this->t_ann != "1" || UserPerm == 10) {
                 $url = awc_url . 'mod/mod_post/delete/' . $this->p_id;
                 #$url = awc_url .'post/delete_post/id' . $this->p_id ;
                 $t = $word['thread_deletepost'] . ' ? ';
                 $t = str_replace(array(chr(10), chr(13), "'"), '', $t);
                 $info['url'] = $url;
                 $info['msg'] = $t;
                 $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:delete_post');
             }
         }
         #if ( (UserPerm >= 2 || (CanDelete($this->p_user)) AND
         # $this->only_one_post == false) ) {
         # die(">". $this->only_one_post);
         if (UserPerm >= 2 and !$this->preview and !$this->single_post || CanDelete($this->p_user) and $time_func_called == 1 and !$this->has_limit) {
             if ($this->t_ann != "1" || UserPerm == 10) {
                 $url = awc_url . 'mod/mod_thread/delete/' . $this->t_id;
                 $t = $word['thread_deletethread'] . ' ? \\n' . $word['deleteThread'];
                 $t = str_replace(array(chr(10), chr(13), "'"), '', $t);
                 $info['url'] = $url;
                 $info['msg'] = $t;
                 $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:delete_thread');
             }
         }
         // die(">". $this->t_pollopen);
         if (!$this->preview and $time_func_called == 1 and !$this->single_post) {
             if ($this->polls_enabled == '1' and $this->p_userid != '0' and (!$this->t_poll or $this->multi_polls == '1') and UserPerm >= 10 || $this->uID == $this->p_userid) {
                 $word['poll'] = get_awcsforum_word('word_add_poll');
                 $info['url'] = awc_url . "post/add_poll/{$this->t_id}/{$this->f_id}";
                 $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:poll');
             }
         }
         if (UserPerm >= 2 and !$this->preview and $time_func_called != 1) {
             $info['url'] = awc_url . 'mod/mod_thread/splitmerge_get/' . $this->p_id;
             $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:spltmerge_button');
         }
         if (!$this->preview and $time_func_called == 1 and CanEdit($this->p_user) || UserPerm >= 2) {
             $info['url'] = awc_url . 'post/GetEditThread/id' . $this->p_id;
             $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:edit_button');
         }
         if (!$this->preview and $time_func_called != 1 and CanEdit($this->p_user) || UserPerm >= 2) {
             $info['url'] = awc_url . 'post/GetEdit/id' . $this->p_id;
             $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:edit_button');
         }
         // forum-wiki-perm
         if (($this->canPost and !$this->preview and $this->t_status == "0" and $this->forum_perm_can_post) || UserPerm >= 2) {
             $info['url'] = awc_url . "post/quote/id" . $this->p_id;
             $edit_buttons['edit_buttons'] .= $tplt->phase($word, $info, 'post:quote_button');
         }
         # $tplt_info['edit_buttons'] = $tplt->phase($word, $edit_buttons, 'edit_buttons_row');
     }
     $tplt_info['edit_buttons'] = $tplt->phase($word, $edit_buttons, 'edit_buttons_row');
     /*            
     if($this->preview){
         $tplt_info['edit_buttons'] = null;
     } else {
          $tplt_info['edit_buttons'] = $tplt->phase($word, $edit_buttons, 'edit_buttons_row');
     }
     */
     # crap! need to find a way to fill the height of the post-text, work-around
     $add = 0;
     // 2.5.8
     foreach ($height_stuff as $item => $number) {
         $add = $add + $number;
     }
     $tplt_info['table_height'] = $add;
     //($to_skin['m_adv'] == null) ? '65' : ($to_skin['m_advh'] + 65); // 2.5.8
     $tplt_info['post_height'] = $tplt_info['table_height'] - 10;
     $tplt_info['colspan'] = strlen($edit_buttons['edit_buttons']) > 0 ? ' ' : ' width="100%" colspan="2" ';
     $post = $this->p_post;
     $tplt_info['post'] = self::phase_post($post, $this->p_id);
     $tplt_info['p_id'] = $this->p_id;
     $tplt_info['pID'] = $this->p_id;
     wfRunHooks('awcsforum_post_render_display', array(&$tplt_info, $hook_user_info));
     // 2.5.6
     $post_table = $tplt->phase($word, $tplt_info, 'post_table');
     // if($time_func_called == 5) $post_table = '<a name="last"></a>' . $post_table;
     return $post_table;
 }
 function DisplayUserInfo1()
 {
     global $wgOut, $awcUser, $awc_tables;
     $this->pm_list('pminbox');
     return;
     if ($this->todo_url == 'member_options') {
         Set_AWC_Forum_SubTitle(get_awcsforum_word('mem_memCP'), $this->membername);
     }
     $html = '<table width="100%" class="mem_pm_table" cellpadding="0" cellspacing="0">';
     $html .= "<tr><td class='pm_header' width='5%' align='left' nowrap>" . get_awcsforum_word('mem_pm_new') . "</td>\r\r\n                                <td class='pm_header' width='85%' align='left' nowrap>" . get_awcsforum_word('mem_pm_title') . "</td>\r\r\n                                <td class='pm_header' width='5%' align='left' nowrap>" . get_awcsforum_word('mem_pm_sender') . "</td>\r\r\n                                <td class='pm_header' width='5%' align='left' nowrap>" . get_awcsforum_word('mem_pm_sentdate') . "</td>\r\r\n                            </tr>";
     $dbr = wfGetDB(DB_SLAVE);
     $sql = "SELECT p.pm_id, p.pm_title, pi.pmi_sender, pi.pmi_read, pi.pmi_send_date \r\r\n                FROM {$awc_tables['awc_f_pms']} p, {$awc_tables['awc_f_pms_info']} pi \r\r\n                    WHERE  p.pm_id=pi.pmi_pmid AND pi.pmi_receipt_id = " . $awcUser->mId . " AND pi.pmi_folder_id=0 ORDER BY pi.pmi_send_date DESC";
     $res = $dbr->query($sql);
     $c = null;
     while ($r = $dbr->fetchObject($res)) {
         $c++;
         $r->pmi_read == 0 ? $ind = '->' : ($ind = '');
         $html .= "<tr><td class='pm_row' width='5%' align='left' nowrap>{$ind}</td>\r\r\n                                <td class='pm_row' width='85%' align='left' nowrap><a href='" . awc_url . "member_options/readpm/id" . $r->pm_id . "'>" . $r->pm_title . "</a></td>\r\r\n                                <td class='pm_row' width='5%' align='left' nowrap>" . $r->pmi_sender . "</td>\r\r\n                                <td class='pm_row' width='5%' align='left' nowrap>" . awcsforum_funcs::convert_date($r->pmi_send_date, "l") . "</td>\r\r\n                            </tr>";
     }
     $dbr->freeResult($res);
     $html .= '</table>';
     # m_pmcount
     $info = array();
     self::display_memcp($html);
 }
 function Check_ShowForumRows($info)
 {
     global $str_len;
     if ($str_len($info['t_name']) > $this->threadtitlelength) {
         $info['t_name'] = awcsforum_funcs::awc_shorten($info['t_name'], $this->threadtitlelength) . "...";
     }
     if ($info['user']) {
         $info['user'] = "******" . awcsforum_funcs::awcforum_url('mem_profile/' . $info['user'] . '/' . $info['userid']) . "'>" . $info['user'] . "</a>";
     }
     if (isset($info['search_words'])) {
         $info['thread_url'] = awcsforum_funcs::awcforum_url('st/id' . $info['t_id'] . $info['search_words']);
     } else {
         $info['thread_url'] = awcsforum_funcs::awcforum_url('st/id' . $info['t_id'] . '/' . str_replace(array('>', '<'), ' ', $info['t_name'])) . $this->html_ext;
     }
     $classID = "row_info";
     $info['indicator_lock_sticky_ann'] = null;
     if (isset($info['locked']) and $info['locked'] == "1") {
         $info['indicator_lock_sticky_ann'] = $this->words['locked'] . ' ';
         //$info['row_class']  =  'locked_thread' ;
     }
     if (isset($info['sticky']) and $info['sticky'] == "1") {
         $info['indicator_lock_sticky_ann'] = $this->words['sticky'] . ' ';
         $info['row_class'] = 'sticky';
     }
     if (isset($info['sticky']) and isset($info['locked'])) {
         if ($info['sticky'] == "1" and $info['locked'] == "1") {
             $info['indicator_lock_sticky_ann'] = $this->words['locked_sticky'] . ' ';
             $info['row_class'] = 'sticky';
         }
     }
     if (isset($info['poll']) and $info['poll'] == "1") {
         $info['indicator_lock_sticky_ann'] = $this->words['poll'] . ' ';
         $info['row_class'] = 'poll_thread_listing';
     }
     return $info;
 }
 function GetQuote($pID)
 {
     global $wgOut, $wgRequest, $awc_tables, $awcUser;
     // forum-wiki-perm move to top
     if (!$awcUser->canPost) {
         return $wgOut->loginToUse();
     }
     $rDB = wfGetDB(DB_SLAVE);
     $res = $rDB->query("SELECT p.*, t.t_wiki_pageid, t.t_id, t.t_name, t.t_ann, t.t_pin, t.t_status, t.t_topics, f.f_name, f.f_wiki_write_perm\r\r\n                                FROM {$awc_tables['awc_f_posts']} p, {$awc_tables['awc_f_threads']} t, {$awc_tables['awc_f_forums']} f \r\r\n                                WHERE p.p_id={$pID} AND f.f_id=p.p_forumid AND p.p_threadid=t.t_id LIMIT 1");
     $r = $rDB->fetchRow($res);
     $perm = new awcs_forum_perm_checks();
     if (!$awcUser->canPost or !$perm->can_post($r['f_wiki_write_perm'])) {
         return awcs_forum_error('no_forum_read_perm');
     }
     $title = $r['p_title'];
     if ($title == "") {
         $title = $r['t_name'];
     }
     $title = awcsforum_funcs::awc_html_entity_decode($title);
     $ptitle = awcsforum_funcs::awc_html_entity_decode($r['p_title']);
     $ttitle = awcsforum_funcs::awc_html_entity_decode($r['t_name']);
     $this->ThreadTitle = $ttitle;
     $this->f_name = $r['f_name'];
     $this->t_wiki_pageid = $r['t_wiki_pageid'];
     $this->tID = $r['t_id'];
     $this->fID = $r['p_forumid'];
     if ($r['t_ann']) {
         $t_ann = "checked";
     }
     if ($r['t_pin']) {
         $t_pin = "checked";
     }
     if ($r['t_status']) {
         $t_status = "checked";
     }
     $this->post = "[QUOTE=" . $r['p_user'] . " [[Special:AWCforum/sp/id" . $pID . "|" . awcsforum_funcs::convert_date($r['p_date'], "1") . "]]]" . $r['p_post'] . "[/quote]" . chr(10);
     Set_AWC_Forum_SubTitle(get_awcsforum_word('word_quoting'), $ptitle);
     Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('word_quoting'));
     Set_AWC_Forum_BreadCrumbs('<a href="' . awc_url . 'st/id' . $r['p_threadid'] . '">' . $ttitle . '</a>', true);
     return self::preview_show('quote');
 }
 /**
  *  Save forum config
  * 
  * @since Version 2.5.8
  */
 function do_config_forum()
 {
     global $wgRequest, $wgOut, $awc, $table_1, $awcs_forum_config;
     if (UserPerm != 10) {
         die("Nope - Admin");
     }
     $dbr = wfGetDB(DB_SLAVE);
     $dbw = wfGetDB(DB_MASTER);
     #$yes_wikiedit = true;
     # use this to see is WIki's User Table has the user_editcount feild
     $table_1 = $dbr->tableName('user');
     $dBaseCLS = new awcforum_cls_dBase();
     $yes_wikiedit = $dBaseCLS->colCheck($table_1, 'user_editcount');
     foreach ($awcs_forum_config as $q => $a) {
         $a = $wgRequest->getVal($q);
         if ($q != 'cf_forumversion' && $q != 'cf_forumlang') {
             if ($wgRequest->getVal($q) != '') {
                 if ($q == 'cf_css_default') {
                     $css = explode('|', $a);
                     $a = serialize(array('Default' => $css[0]));
                 }
                 if ($q == 'cf__forumsubtitle' || $q == 'cf__forumname') {
                     $a = awcsforum_funcs::awc_htmlentities($a);
                 }
                 $dbw->update('awc_f_config', array('a' => $a), array('q' => $q), '');
             }
         }
     }
     // check what wiki ver this aplies to... might be older, if so elete.
     # no user_editcount feild, so reste Forum Config for the "Show Wiki Edits"
     if ($yes_wikiedit == false) {
         $dbw->update('awc_f_config', array('a' => 'no'), array('q' => 'wikieits'), '');
     }
     $wgOut->redirect(awc_url . "admin");
 }
Exemple #23
0
 function sendpm($to_name, $title, $msg, $save_sent = false, $sendto_names = null)
 {
     global $wgUser, $wgOut, $wgPasswordSender, $IP, $awc_tables, $awcs_forum_config;
     // awcsforum_funcs::get_page_lang(array('lang_txt_mem'));
     /* 
     
     if ( !file_exists($IP . '/includes/AutoLoader.php')){
         require($IP . "/includes/UserMailer.php");
     }
     */
     $sender_name = $wgUser->mName;
     $sender_id = $wgUser->mId;
     $send_msg_text = false;
     if (isset($awcs_forum_config->cf_send_pm_body_in_email) and $awcs_forum_config->cf_send_pm_body_in_email == '1') {
         $send_msg_text = true;
     }
     $user_get = array();
     $user_get[] = 'm_id';
     $dbw = wfGetDB(DB_MASTER);
     $date_seperated = $dbw->timestamp();
     $pm_count = null;
     $to_address = array();
     /* set up email stuff here so its not included in the loop */
     $send_title = get_awcsforum_word('mem_pm_email_newpmawaiting') . ' ' . $title;
     $send_body = get_awcsforum_word('mem_pm_email_newpmawaitingbody');
     $send_body .= " \n" . $sender_name;
     $send_body .= " \n\n <a href='" . awcsforum_funcs::awcforum_url('member_options/pminbox') . "'>" . awcsforum_funcs::awcforum_url('member_options/pminbox') . "</a> \n\r\n\r";
     require_once awc_dir . 'send_mail.php';
     $html = true;
     if ($awcs_forum_config->cf_send_email_html == '0') {
         $html = false;
     }
     foreach ($to_name as $id => $send_to_info) {
         $pm_count++;
         if ($pm_count == 1) {
             #$bs = $dbw->nextSequenceValue( 'awc_f_pms_pm_id_seq' );
             $dbw->insert('awc_f_pms', array('pm_title' => $title, 'pm_text' => $msg));
             $pm_id = awcsforum_funcs::lastID($dbw, 'awc_f_pms', 'pm_id');
         }
         $dbw->insert('awc_f_pms_info', array('pmi_pmid' => $pm_id, 'pmi_sender' => $sender_name, 'pmi_sender_id' => $sender_id, 'pmi_receipt_id' => $send_to_info['id'], 'pmi_receipt' => $sendto_names, 'pmi_send_date' => $date_seperated));
         # $mem = GetMemInfo($id, $user_get);
         # if(isset($mem['name'])){
         # awc_pdie($wgUser->mId);
         if ($send_to_info['forum_username'] != 'no_name' or $send_to_info['id'] == $wgUser->mId) {
             $dbw->query("UPDATE {$awc_tables['awc_f_mems']} \n                                    SET m_pmtotal = m_pmtotal + 1,\n                                    m_pmunread = m_pmunread + 1, \n                                    m_pminbox = m_pminbox + 1,\n                                    m_pmpop = '1'\n                                    WHERE m_id =" . $send_to_info['id']);
         } else {
             $dbw->insert('awc_f_mems', array('m_id' => $send_to_info['id'], 'm_idname' => $send_to_info['name'], 'm_pmtotal' => '1', 'm_pmunread' => '1', 'm_pminbox' => '1', 'm_pmpop' => '1'));
         }
         /* @changeVer 2.5.8 */
         if (isset($send_to_info['email']) && !empty($send_to_info['email']) && $send_to_info['email'] != 'no_email') {
             $to_address[] = new MailAddress($send_to_info['email']);
             if ($send_to_info['pass_pm_text'] == '1' and $send_msg_text) {
                 $send_body .= "\n\r\n\r" . awcsforum_mailer::check_msg_len($msg, 0);
             }
             awcsforum_mailer::send_mail($to_address, $send_title, $send_body, $html);
         }
     }
     if ($save_sent) {
         $dbw->insert('awc_f_pms_info', array('pmi_pmid' => $pm_id, 'pmi_sender' => $sender_name, 'pmi_sender_id' => $sender_id, 'pmi_receipt_id' => $sender_id, 'pmi_receipt' => $sendto_names, 'pmi_send_date' => $date_seperated, 'pmi_folder_id' => '1', 'pmi_read_date' => $date_seperated, 'pmi_read' => '1'));
         $mem = GetMemInfo($id, $user_get);
         if (isset($mem['name'])) {
             $dbw->query("UPDATE {$awc_tables['awc_f_mems']} \n                                    SET m_pmtotal = m_pmtotal + 1,\n                                    m_pmsent = m_pmsent + 1\n                                    WHERE m_id =" . $sender_id);
         } else {
             $dbw->insert('awc_f_mems', array('m_id' => $sender_id, 'm_idname' => $wgUser->mName, 'm_pmtotal' => '1', 'm_pmsent' => '1'));
         }
     }
     $wgOut->redirect(awc_url . 'member_options/pminbox');
 }