function new_thread_check($tID, $t_lastdate)
 {
     if ($this->isGuest) {
         return ' ';
     }
     $t_lastdate = awcsforum_funcs::wikidate($t_lastdate);
     if ($t_lastdate > $_SESSION['awc_startTime']) {
         $_SESSION['awc_nActive'][$tID] = $t_lastdate;
     }
     $NewThread = null;
     if (isset($_SESSION['awc_nActive'][$tID])) {
         if (isset($_SESSION['awc_rActive'][$tID]) and isset($_SESSION['awc_rActive'][$tID])) {
             if ($_SESSION['awc_rActive'][$tID] != $_SESSION['awc_nActive'][$tID]) {
                 $NewThread = $this->words['new_thread'];
             }
         } else {
             $NewThread = $this->words['new_thread'];
         }
     }
     return $NewThread;
 }
Example #2
0
    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 export_xml($for_new_css = false, $forum_installer = false)
 {
     global $wgRequest;
     $v = $wgRequest->getVal('ver');
     if (strlen($v) > 1) {
         $and_ver = " AND  css_ver='{$v}'";
     } else {
         $and_ver = null;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
     $awc_f_theme_names = $dbr->tableName('awc_f_theme_names');
     $sql = "SELECT * FROM {$awc_f_theme_names} WHERE thmn_id={$this->css_id} {$and_ver}";
     $res = $dbr->query($sql);
     $r = $dbr->fetchObject($res);
     $dbr->freeResult($res);
     $css_who = $r->thmn_who;
     $title = htmlentities($r->thmn_title, ENT_QUOTES, 'UTF-8');
     //$css_ver = '1.0.0';
     $css_name_count = $r->thmn_item_count;
     $where = $r->thmn_where;
     $who = htmlentities($r->thmn_who, ENT_QUOTES, 'UTF-8');
     if ($for_new_css) {
         # awc_pdie($wgRequest);
         $who = $wgRequest->getVal('css_who');
         $where = $wgRequest->getVal('css_where');
         $title = $wgRequest->getVal('css_title');
     }
     $xml .= "<style title=\"{$title}\" css_ver=\"1.0.0\" who=\"{$who}\" where=\"{$where}\" count=\"{$css_name_count}\">\n";
     $awc_f_theme_css = $dbr->tableName('awc_f_theme_css');
     $sql = "SELECT css_id, css_section, css_ver, css_att, css_code, css_custom, css_forumver, css_date \r\r\n                    FROM {$awc_f_theme_css} \r\r\n                    WHERE css_thmn_id={$this->css_id} ORDER BY css_custom DESC";
     $res = $dbr->query($sql);
     while ($r = $dbr->fetchObject($res)) {
         $xml .= "\t <css css_section=\"{$r->css_section}\" custom=\"{$r->css_custom}\" css_att=\"" . htmlentities($r->css_att, ENT_QUOTES, 'UTF-8') . "\" css_ver=\"{$r->css_ver}\" forum_ver=\"{$r->css_forumver}\" css_date=\"" . awcsforum_funcs::wikidate($r->css_date) . "\">" . htmlentities($r->css_code, ENT_QUOTES, 'UTF-8') . "</css>\n";
         #$css[$r->css_section][$r->css_id] = array($r->css_att, $r->css_code, $r->css_ver, $r->css_custom, $r->css_forumver);
     }
     $dbr->freeResult($res);
     /**
     foreach($css as $group_name => $group_info){
         
         
         $xml .= "   <css_group name=\"$group_name\">\n";
             
             foreach($group_info as $info){
                 
                 if($forum_installer){
                     $dateis = wfTimestampNow() ;
                 } else {
                     $dateis = awcsforum_funcs::wikidate($info[5]);
                 }
                 
                 #$xml .= "       <template css_att=\"".str_replace('"', '\"', $info[0])."\" forum_ver=\"{$info[2]}\">{$info[1]}</template>\n";
                 $xml .= "       <css custom=\"{$info[3]}\" css_att=\"".htmlentities($info[0], ENT_QUOTES, 'UTF-8')."\" css_ver=\"{$info[2]}\" forum_ver=\"{$info[4]}\" css_date=\"{$dateis}\">".htmlentities($info[1], ENT_QUOTES, 'UTF-8')."</css>\n";
             }
         
         $xml .= "   </css_group>\n\n";
     }
     */
     $xml .= '</style>';
     if ($forum_installer) {
         return $xml;
     }
     if ($for_new_css) {
         return $xml;
     }
     $d = awcsforum_funcs::readabledate(wfTimestampNow());
     $filename = awc_dir . "xported_files/css_" . preg_replace("/[^a-z0-9-]/", "-", strtolower($title)) . "_" . preg_replace("/[^a-z0-9-]/", "-", strtolower($who)) . "_{$css_ver}.xml";
     if (strlen($v) > 1) {
         $hd = @fopen(awc_dir . "updates/{$v}/css.xml", "w");
     } else {
         $hd = @fopen($filename . "", "w");
     }
     @fwrite($hd, $xml);
     @fclose($hd);
     return true;
 }
function load_awcs_forum()
{
    # $START = processing_time(); // Used for testing speed... $RESULT at bottom...
    global $wgRequest, $wgOut, $wgScriptPath;
    global $awc, $awcUser, $awc_tables, $awc_ver, $ForumStat, $awcs_forum_config, $WhoWhere, $action_url, $tplt;
    global $awc_url, $wiki_url, $style_path, $button_path, $awc__url;
    require_once awc_dir . "includes/funcs.php";
    require_once awc_dir . "includes/gen_funk.php";
    require_once awc_dir . "includes/gen_class.php";
    // awcs_forum_config, awcs_forum_user, awcs_forum_stats,
    $WhoWhere = null;
    define('awc_path', $wgScriptPath . awcForumPath);
    define('emo_path', awc_path . 'images/emotions/default/');
    define('button_path', awc_path . 'images/buttons/default/');
    $style_path = awc_path . 'skins/';
    // used in awcs_forum_skin_templetes::phase() for "find and replace"
    $button_path = button_path;
    // used in awcs_forum_skin_templetes::phase() for "find and replace"
    $wiki_url = awcsf_wiki_url;
    // used in awcs_forum_skin_templetes::phase() for "find and replace"
    $awc_url = awc_url;
    // used in awcs_forum_skin_templetes::phase() function for "find and replace"
    $awc__url = $awc_url;
    if (!isset($awcUser)) {
        $awcUser = new awcs_forum_user();
    }
    $wgRequest->action = null;
    $clean_todo = null;
    $clean_todo_arr = $wgRequest->getVal('title');
    $clean_todo_arr = rawurldecode($clean_todo_arr);
    $clean_todo_arr = explode('/', $clean_todo_arr);
    if (isset($clean_todo_arr[1]) and (!isset($_GET['action']) or !isset($_POST['action']))) {
        $count_to = count($clean_todo_arr) - 1;
        for ($i = 1; $i <= $count_to; ++$i) {
            $clean_todo .= $clean_todo_arr[$i] . "/";
        }
        $wgRequest->action = $clean_todo;
    }
    $action = $wgRequest->getVal('action');
    if ($action == null) {
        $action = $clean_todo;
    } else {
        $action = str_replace('%2F', '/', $action);
        $wgRequest->action = $action;
    }
    $action_spl = explode("/", $action);
    #$todo = $action_spl[0];
    $action_url = array();
    $action_url['all'] = $action;
    $action_url['what_file'] = $action_spl[0];
    if (isset($action_spl[1])) {
        if (strstr($action_spl[1], "id")) {
            $action_url['id'] = str_replace(array('_', 'id', 'id_'), '', $action_spl[1]);
        } else {
            $action_url['section'] = $action_spl[1];
            $action_url['id'] = $wgRequest->getVal('id');
        }
    } else {
        $action_url['id'] = $wgRequest->getVal('id');
    }
    if (isset($action_spl[2])) {
        $action_url['todo'] = $action_spl[2];
    }
    foreach ($action_spl as $act) {
        if (strstr($act, "id_")) {
            $action_url['id'] = str_replace(array('_', 'id', 'id_'), '', $act);
        } else {
            $action_url[] = $act;
        }
    }
    if ($wgRequest->action == "install_forum" and in_array('sysop', $awcUser->mGroups)) {
        require awc_dir . "updates/install/install_forum.php";
        return;
    }
    if (!isset($awcs_forum_config)) {
        $awcs_forum_config = new awcs_forum_config();
        // gen_class.php
    }
    if ($awcs_forum_config->get_config() === false) {
        $out = $awcs_forum_config->get_install();
        $wgOut->addHTML($out);
        return;
    }
    # die("k,h");
    //  Note:
    // This needs to be after the awcs_forum_config()
    // for some reason the unserialize() gets messed with the default CSS and cant read it correctly
    if (awcs_forum_convert_latin) {
        $dbw = wfGetDB(DB_MASTER);
        $dbw->query("SET NAMES latin1");
        unset($dbw);
    }
    /*                             
        // Check to see if forum is installed by checking of the Dbase config table is there...
        if(!$awcs_forum_config->installed){
            $out =  $awcs_forum_config->get_install() ;
            $wgOut->addHTML($out);
            return ;
        }
    */
    // ckeck forum version...
    if (version_compare(awcs_forum_ver_current, awcs_forum_ver, '<')) {
        global $wgRequest;
        if (!strstr($wgRequest->action, "admin/forum_update") and !strstr($wgRequest->action, "admin/get_updates")) {
            if (!in_array('sysop', $awcUser->mGroups)) {
                awcs_forum_wfLoadExtensionMessages('AWCforum_genral_forum');
                $wgOut->addHTML("<center>" . wfMsg('awcsf_updating') . "<br /> <b>" . wfMsg('awcsf_sysops_login') . "</b></center>");
                return;
            }
            die(header('Location: ' . awc_url . 'admin/forum_update'));
        }
    }
    if (isset($awcs_forum_config->cf_header_import) and !empty($awcs_forum_config->cf_header_import)) {
        $header = awc_wikipase($awcs_forum_config->cf_header_import, $wgOut);
        $wgOut->addHTML($header);
    }
    // load this after config_config
    require awc_dir . "includes/load/load_skin_tplts.php";
    if (!isset($tplt)) {
        require awc_dir . 'admin.php';
        awcsforum_funcs::get_table_names(array('awc_f_cats'), true);
        // Get all the forums d-base table names, check for table pre-fix
        awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search', 'lang_txt_admin'));
        // get lang difinitions...
        $admin = new awcforum_forumAdmin();
        $admin->enterAdmin($action);
        return;
    }
    // load lang difinistions and get sql table names
    switch ($action_url['what_file']) {
        case 'search':
            require awc_dir . 'search.php';
            awcsforum_funcs::get_table_names(array('awc_f_threads', 'awc_f_posts', 'awc_f_forums', 'awc_f_cats'));
            // Get all the forums d-base table names, check for table pre-fix
            awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search'));
            // get lang difinitions...
            break;
        case 'post':
            require awc_dir . 'post.php';
            awcsforum_funcs::get_table_names(array('awc_f_polls', 'awc_f_posts', 'awc_f_forums', 'awc_f_threads', 'awc_f_watchthreads', 'awc_f_watchforums'));
            // Get all the forums d-base table names, check for table pre-fix
            awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search', 'lang_txt_thread', 'lang_txt_redirects'));
            // get lang difinitions...
            break;
        case 'st':
        case 'sp':
        case 'last_post':
        case 'delete_post':
        case 'delete_thread':
            require awc_dir . 'thread.php';
            awcsforum_funcs::get_table_names(array('awc_f_posts', 'awc_f_threads', 'awc_f_polls', 'awc_f_forums', 'awc_f_member_titles', 'awc_f_cats'));
            // Get all the forums d-base table names, check for table pre-fix
            awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search', 'lang_txt_thread'));
            // get lang difinitions...
            break;
        case 'member_options':
            require awc_dir . 'members.php';
            awcsforum_funcs::get_table_names(array('awc_f_watchthreads', 'awc_f_watchforums', 'awc_f_threads', 'awc_f_pms_info', 'awc_f_pms', 'awc_f_mems', 'awc_f_threads'));
            // Get all the forums d-base table names, check for table pre-fix
            awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search', 'lang_txt_mem', 'lang_txt_redirects'));
            // get lang difinitions...
            break;
        case 'admin':
            require awc_dir . 'admin.php';
            awcsforum_funcs::get_table_names(array('awc_f_cats'), true);
            // Get all the forums d-base table names, check for table pre-fix
            awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search', 'lang_txt_admin', 'lang_txt_redirects'));
            // get lang difinitions...
            break;
        case 'pm':
            require awc_dir . 'pm.php';
            awcsforum_funcs::get_table_names(array('awc_f_mems'));
            // Get all the forums d-base table names, check for table pre-fix
            awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search', 'lang_txt_mem'));
            // get lang difinitions...
            break;
        case 'mem_profile':
        case 'credits':
        case 'whoshere':
            require awc_dir . 'misc.php';
            awcsforum_funcs::get_table_names(array('awc_f_langs', 'awc_f_sessions'));
            // Get all the forums d-base table names, check for table pre-fix
            awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search', 'lang_txt_mem'));
            // get lang difinitions...
            break;
        case 'mod':
            awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search', 'lang_txt_thread', 'lang_txt_redirects'));
            // get lang difinitions...
            break;
        case 'sc':
        case 'sf':
        case 'subf':
        default:
            require awc_dir . 'forum.php';
            awcsforum_funcs::get_table_names(array('awc_f_cats', 'awc_f_forums', 'awc_f_anns', 'awc_f_threads'));
            // Get all the forums d-base table names, check for table pre-fix
            awcsforum_funcs::get_page_lang(array('lang_txt_forum', 'lang_txt_search'));
            // get lang difinitions...
            break;
    }
    $awcs_forum_config->ver = isset($awcs_forum_config->cf_forumversion) ? $awcs_forum_config->cf_forumversion : '2.x.x';
    $awcs_forum_config->ver = str_replace('.', '', $awcs_forum_config->ver);
    // need a check, some servers will drop the last zero from the version, version needs to be three digets
    #strlen($awc_ver) == 2 ? $awc_ver = $awc_ver . '0' : $awc_ver = $awc_ver ;
    $awcs_forum_config->ver = !isset($awcs_forum_config->ver[2]) ? $awcs_forum_config->ver . '0' : $awcs_forum_config->ver;
    $awc_ver = $awcs_forum_config->ver;
    $info['url'] = awc_url;
    // Need a check here for Admin Setting....
    if (isset($awcs_forum_config->cf_use_forum_stats) and $awcs_forum_config->cf_use_forum_stats == '1') {
        $ForumStat = new awcs_forum_stats();
        $ForumStat->get_stats();
    }
    // need to do something here....
    // PM check, display pop-up or not, set MemCP text for top menu
    if ($awcUser->mId != '0') {
        $awcUser->get_mem_forum_options();
        // set
        if (isset($awcUser->m_pmunread)) {
            $info['user_title'] = $awcUser->m_pmunread == 0 || $awcUser->m_pmunread == '' ? get_awcsforum_word('word_MemOpts') . '' : get_awcsforum_word('word_MemOpts') . ' <b>' . $awcUser->m_pmunread . '</b> ' . get_awcsforum_word('word_unreadpms');
            $pms = $awcUser->m_pmunread . ' ' . get_awcsforum_word('word_unreadpms');
        } else {
            $info['user_title'] = get_awcsforum_word('word_MemOpts');
            $pms = '';
        }
        $info['user_name'] = urlencode($awcUser->mName) . '/' . $awcUser->mId;
        $word['word_recent_posts'] = get_awcsforum_word('word_recent_posts');
        $word['word_gotomempc'] = get_awcsforum_word('word_gotomempc');
        $word['word_gotopms'] = get_awcsforum_word('word_gotopms');
        $word['word_gotosig'] = get_awcsforum_word('word_gotosig');
        $word['word_gotoavatar'] = get_awcsforum_word('word_gotoavatar');
        $word['word_subscribe_email'] = get_awcsforum_word('word_subscribe_email');
        $word['word_subscribe_memcp'] = get_awcsforum_word('word_subscribe_memcp');
        $word['word_threads'] = get_awcsforum_word('word_threads');
        $word['word_posts'] = get_awcsforum_word('word_posts');
        $word['word_MemClearIndicators'] = get_awcsforum_word('word_MemClearIndicators');
        $info['mem_links'] = $tplt->phase($word, $info, 'top_menu_user_links');
    } else {
        $pms = '';
        $mem_title = null;
        $info['mem_links'] = null;
    }
    $tplt->kill('top_menu_user_links');
    $awcs_forum_config->get_css();
    //$wgOut->addScript('<script type="text/javascript" src="'. awc_path . 'awc.js"></script>');
    $wgOut->mScripts .= '<script type="text/javascript" src="' . awc_path . 'awc.js"></script>';
    if (UserPerm == 10) {
        $word['word_AdminCP'] = get_awcsforum_word('word_AdminCP');
        $word['word_AdminCP'] = strlen($word['word_AdminCP']) < 2 ? "Admin Control Panel" : $word['word_AdminCP'];
        $info['admin_link'] = $tplt->phase($word, '', 'top_menu_admin_link');
    } else {
        $info['admin_link'] = null;
    }
    $tplt->kill('top_menu_admin_link');
    if (CanSearch()) {
        $word['search'] = get_awcsforum_word('search_search');
        $info['search_link'] = $tplt->phase($word, '', 'top_menu_search_link');
    } else {
        $info['search_link'] = null;
    }
    $tplt->kill('top_menu_search_link');
    $word['word_todays_posts'] = get_awcsforum_word('word_todays_posts');
    $info['todays_posts'] = $tplt->phase($word, '', 'top_menu_todays_posts_link', true);
    $word['word_credits'] = get_awcsforum_word('word_credits');
    $top_menu_links = $tplt->phase($word, $info, 'top_menu_top', true);
    $wgOut->addHTML($top_menu_links);
    if ($awcUser->mId != '0') {
        if (isset($awcUser->m_pmpop) and isset($awcUser->m_pmoptions['m_pmpop'])) {
            if ($awcUser->m_pmpop == '1' and $awcUser->m_pmoptions['m_pmpop'] == '1' and $action_url['what_file'] != 'member_options') {
                $wgOut->addHTML('<script type= "text/javascript">  alert("' . get_awcsforum_word('word_newpm') . '"); </script>');
            }
        }
    }
    # $wgOut->addHTML('<hr>');
    global $wgSitename;
    $awcs_forum_config->forum_name = !empty($awcs_forum_config->cf__forumname) ? str_replace('|$|', ' ' . $wgSitename . ' ', $awcs_forum_config->cf__forumname) : $wgSitename . ' ' . get_awcsforum_word('word_forum');
    $awcs_forum_config->forum_subtitle = isset($awcs_forum_config->cf__forumsubtitle) ? $awcs_forum_config->cf__forumsubtitle : '';
    if (!$awcUser->canRead and $action_url['what_file'] != 'credits') {
        global $wgSitename;
        $Tforum_name = str_replace('|$|', ' ' . $wgSitename . ' ', $awcs_forum_config->cf__forumname);
        Set_AWC_Forum_SubTitle($awcs_forum_config->forum_name, $awcs_forum_config->forum_name);
        $wgOut->loginToUse();
        get_awcsforum_word('word_standalongforumextension') == '' ? $awc_info = 'Stand Alone Forum Extension' : ($awc_info = get_awcsforum_word('word_standalongforumextension'));
        $wgOut->addHTML("\r" . '<br /><hr><center> <a href="http://wiki.anotherwebcom.com" target="_blank" title="PHP, Visual Basic  scripts and programs">AWC\'s</a>: <b>' . $awcs_forum_config->cf_forumversion . '</b> MediaWiki - ' . $awc_info . '</center>' . "\r");
        return;
    }
    #
    switch ($action_url['what_file']) {
        case 'mod':
            require awc_dir . 'includes/mod_post.php';
            awcs_forum_mod_options();
            break;
        case 'whoshere':
            //$WhoWhere = 'whoshere' ;
            $WhoWhere['type'] = 'forum';
            $WhoWhere['where'] = 'whoshere||awc-split||whoshere';
            $whoshere = new awcforum_misc();
            $whoshere->whoshere();
            break;
        case 'search':
            awcs_forum_search();
            #$search = new awcforum_search();
            #$search->enter_search($action);
            break;
        case 'post':
            awcs_forum_post();
            #$post=new awcsforum_post_cls();
            #$post->enter_post($action);
            break;
        case 'st':
        case 'sp':
        case 'last_post':
        case 'delete_post':
        case 'delete_thread':
            awcs_forum_threads($action);
            break;
        case 'member_options':
            awcs_forum_members($action);
            break;
        case 'admin':
            $admin = new awcforum_forumAdmin();
            $admin->enterAdmin($action);
            break;
        case 'pm':
            $pm = new awcforum_pm();
            $pm->enter_pm($action);
            break;
        case 'mem_profile':
        case 'credits':
            $pm = new awcforum_misc();
            $pm->enter_misc($action);
            break;
        case 'feed':
            //awc_pdie($action_url);
            $title = str_replace('feed/', '', $action_url['all']);
            $rss = new FeedItem($title, 'Description', awc_url . $title);
            awc_pdie($rss);
            break;
        case 'sc':
        case 'sf':
        case 'subf':
        case 'fpw':
        default:
            awcs_forum_listing();
            break;
    }
    $awc_info = get_awcsforum_word('word_standalongforumextension') == '' ? 'Stand Alone Forum Extension' : get_awcsforum_word('word_standalongforumextension');
    // admin check needed
    if (isset($awcs_forum_config->cf_show_whoes_here) and $awcs_forum_config->cf_show_whoes_here == '1') {
        $whos_here = new awcs_forum_whos_here();
        $whos_here->load_ses($action);
        $word = array('word_forum_stats_whos_here' => get_awcsforum_word('word_forum_stats_whos_here'), 'members' => get_awcsforum_word('word_members'), 'guests' => get_awcsforum_word('word_guests'), 'word_forum_stats_bots' => get_awcsforum_word('word_forum_stats_bots'));
        $info['names'] = substr($whos_here->whos_here['names'], 0, -2);
        $info['num_mems'] = $whos_here->whos_here['mems'];
        $info['num_guests'] = $whos_here->whos_here['guests'];
        $info['num_bots'] = $whos_here->whos_here['bots'];
        $footer_whoshere = $tplt->phase($word, $info, 'footer_whoshere', true);
        $wgOut->addHTML($footer_whoshere);
        unset($word, $info);
    }
    #require(awc_dir . 'dBase.php');
    #$dBase = new awcforum_cls_dBase();
    # die("done");
    /*  
     * top poster, replier, most posts in thread, most viewed thrread.
     */
    global $css_ver_info;
    if ($css_ver_info != null) {
        $css_ver_info = get_awcsforum_word('word_css_style_by') . " {$css_ver_info}";
    }
    // Read the top please... http://google.com/search?q=Special:AWCforum will bring up your site sooner or later...
    $wgOut->addHTML('<br /><hr>
            <center>
                <a href="http://wiki.anotherwebcom.com" target="_blank" title="PHP, Visual Basic  scripts and programs">AWC\'s</a>:
                 <b>' . $awcs_forum_config->cf_forumversion . '</b> MediaWiki - ' . $awc_info . '<br />' . $css_ver_info . '</center>');
    $wgOut->setRobotpolicy($awcs_forum_config->cf_setRobotpolicy);
    if (isset($ForumStat)) {
        $ForumStat->doUpdate();
    }
    if ($awcUser->mId != '0') {
        $now = awcsforum_funcs::wikidate(wfTimestampNow());
        if (isset($awcs_forum_config->cf_save_recent_in_dabase) and $awcs_forum_config->cf_save_recent_in_dabase == '1') {
            $dbw = wfGetDB(DB_MASTER);
            $dbw->update('awc_f_mems', array('m_lasttouch' => wfTimestampNow(), 'm_lasthere' => $now), array('m_id' => $awcUser->mId), '');
        } else {
            global $wgCookieExpiration, $wgCookiePath, $wgCookieDomain;
            $exp = time() + $wgCookieExpiration;
            setcookie('awc_startTime', $now, $exp, $wgCookiePath, $wgCookieDomain);
        }
    }
    # $wgOut->setSubtitle( 'Time Test: ' .  processing_time($START) . ' Memory Peek= ' . memory_get_peak_usage(true) . ' memory_get_usage= ' . memory_get_usage()  ) ;  # testing
}
Example #5
0
 /**
  * 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));
 }
 /** 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);
         }
     }
 }