/** * Read file from awc server for update forum version * * Step one (of 3) in Auto Update process. * @uses Set_AWC_Forum_BreadCrumbs * @since Version 2.5.8 */ function forum_autoupdate() { Set_AWC_Forum_BreadCrumbs(get_awcsforum_word('admin_autoupdate') . ' - ' . get_awcsforum_word('admin_expearimental'), true); $ver_check_file = awc_forum_update_url; // die($ver_check_file); $ver_file = @fopen($ver_check_file . 'forum_currentver.txt', "rb"); $ver = ''; $update = true; if (!$ver_file) { if (function_exists('fopen')) { $up = 'no file found or file is empty'; } else { $up = 'no PHP "fopen()" function'; } $update = false; } else { if ($update) { while (!@feof($ver_file)) { $ver .= @fread($ver_file, 8192); } @fclose($ver_file); if ($ver != '') { $savefilename = awc_dir . 'updates/update_ver.holder'; if (!($save_ver_file = @fopen($savefilename, 'w'))) { $up = "Cannot open file ({$savefilename})"; $update = false; } // Write $somecontent to our opened file. if (@fwrite($save_ver_file, $ver) === FALSE) { $up = "Cannot write to file ({$savefilename})"; $update = false; } @fclose($save_ver_file); } else { $update = false; $up = 'file is empty'; } } } if (!$update) { return awcs_forum_error($up); } global $wgOut, $awcs_forum_config; $wgOut->addHTML('<br /><br />' . get_awcsforum_word('admin_yourforumver') . ' <b>' . $awcs_forum_config->cf_forumversion . '</b>'); if (version_compare($ver, $awcs_forum_config->cf_forumversion, '>')) { $html = '<form action="' . awc_url . 'admin/get_autoupdate" method="post">'; $html .= '<input name="get_ver" type="hidden" value="' . $ver . '">'; $html .= ' <input type="submit" value="' . get_awcsforum_word('admin_update_to') . ' ' . $ver . '"></form>'; } else { $html = '<br />' . get_awcsforum_word('admin_yourcurrentlyuptodate'); } $wgOut->addHTML($html . '<br /> <hr />'); //$wgOut->addHTML( $html ); // die($ver); }
/** * Delete Cat * * @uses get_all_cats * @uses awcf_redirect * @since Version 2.5.8 */ function delete_cat() { global $wgRequest; self::get_all_cats(); $current_id = $cid = $wgRequest->getVal('cID'); $move_to_id = $cid = $wgRequest->getVal('move_to'); if (strlen($current_id) == 0) { return awcs_forum_error('admin_no_cat_to_delete'); } if (strlen($move_to_id) == 0) { return awcs_forum_error('admin_no_forum_to_move_to'); } if ($current_id == $move_to_id) { return awcs_forum_error('admin_deletemovethesamecat'); } if (empty($this->cat_info[$move_to_id])) { return awcs_forum_error('admin_no_forum_to_move_to'); } if (empty($this->cat_info[$current_id])) { return awcs_forum_error('admin_no_cat_to_delete'); } $dbw = wfGetDB(DB_MASTER); $dbw->update('awc_f_forums', array('f_parentid' => $move_to_id), array('f_parentid' => $current_id), ''); $dbw->delete('awc_f_cats', array('cat_id' => $current_id), ''); $info['msg'] = 'cat_was_deleted'; $info['url'] = awc_url . 'sc/id' . $move_to_id; return awcf_redirect($info); }
function enter_threads($action) { global $wgRequest, $awcs_forum_config, $WhoWhere; $this->cf_AvatraSize = $awcs_forum_config->cf_AvatraSize; include_once awc_dir . 'includes/thread_funk.php'; $this->cookie_expir = $awcs_forum_config->cfl_Post_cookie_postcountexpire; $this->quick_height = $awcs_forum_config->cfl_Post_quickpost_box_height; $this->cf_SigGuestView = $awcs_forum_config->cf_SigGuestView; $this->cf_AdvatarGuestView = $awcs_forum_config->cf_AdvatarGuestView; $this->displaysmiles = $awcs_forum_config->cf_displaysmiles; $this->wiki_title_search_len = $awcs_forum_config->cf_wiki_title_search_len; $this->cf_threadsubscrip = $awcs_forum_config->cf_threadsubscrip; $this->wiki_titles = $awcs_forum_config->cf_wiki_titles; $this->wiki_pages = $awcs_forum_config->cf_wiki_pages; $this->display_mem_titles = $awcs_forum_config->cf_display_mem_titles; $this->emotions = GetEmotions(); $spl = explode("/", $action); $todo = $spl[0]; if (isset($spl[1])) { $id = str_replace(array('id', '_'), '', $spl[1]); } else { $id = $wgRequest->getVal('id'); } if (!is_numeric($id)) { return awcs_forum_error('word_nothread'); } $this->id = $id; if (!$this->id) { $this->id = $wgRequest->getVal('id'); } define('what_page', $todo); $WhoWhere['type'] = 'forum'; switch ($todo) { case 'st': $str = $this->GetPosts($this->id); break; case 'sp': $str = $this->GetPost($this->id); break; case 'ann_thread': $this->do_ann_thread($this->id, str_replace('fid', '', $spl[3]), '1'); break; case 'edit_post': # $str = $this->edit_post(); break; case 'last_post': self::get_latest_post($this->id); break; } #$str = $wgOut->parse($str); #$wgOut->addHTML($str); }
function update_tplt($load_file = false, $redirect = true) { global $wgRequest, $awcs_forum_config; if (strlen($load_file) < 0) { if ($_FILES["new_tplt_file"]["error"] == '0') { $tplt_Path = $_FILES["new_tplt_file"]["tmp_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'); } $tplt = @simplexml_load_file($tplt_Path); } else { $tplt = @simplexml_load_file($load_file); } if ($tplt == null) { return; } $awc_f_theme_tplt = $this->rDB->tableName('awc_f_theme_tplt'); $sql = "SELECT tplt_thmn_id, tplt_function FROM {$awc_f_theme_tplt} "; $res = $this->rDB->query($sql); while ($r = $this->rDB->fetchObject($res)) { $curr_tplt[$r->tplt_thmn_id][$r->tplt_function] = true; #" <tplt section=\"{$r->tplt_section}\" function=\"".$r->tplt_function."\" tplt_ver=\"{$r->tplt_ver}\" tplt_forum_ver=\"{$r->tplt_forum_ver}\" tplt_when=\"{$r->tplt_when}\" tplt_who=\"{$r->tplt_who}\" tplt_when=\"{$r->tplt_when}\"><![CDATA[".$r->tplt_code."]]></tplt>\n"; } $this->rDB->freeResult($res); $tplt_info = $tplt->attributes(); foreach ($tplt as $code) { $info = $code->attributes(); #awc_pdie($code->tplt_section); $section = $code->tplt_section; $function = $code->tplt_function; $tplt_code = $code->tplt_code; $tplt_ver = $info['tplt_ver']; $tplt_forum_ver = $info['tplt_forum_ver']; foreach ($curr_tplt as $theme_id => $curr_tplt_array) { $function = html_entity_decode($function, ENT_NOQUOTES, 'UTF-8'); $section = html_entity_decode($section, ENT_NOQUOTES, 'UTF-8'); $tplt_code = html_entity_decode($tplt_code, ENT_NOQUOTES, 'UTF-8'); # awc_pdie($tplt_code); if (!array_key_exists($function, $curr_tplt_array)) { $this->wDB->insert('awc_f_theme_tplt', array('tplt_section' => $section, 'tplt_function' => $function, 'tplt_code' => $tplt_code, 'tplt_ver' => $tplt_ver, 'tplt_forum_ver' => $tplt_forum_ver, 'tplt_thmn_id' => $theme_id)); } } } $this->wDB->commit(); unset($info); if ($redirect) { $info['msg'] = 'tplt_has_been_updated'; $info['url'] = awc_url . "admin/tplt/display"; return awcf_redirect($info); } return true; }
/** @changeVer 2.5.8 did a bit of work to this function... */ function lang_do_import_lang($lang_Path = '') { global $wgRequest, $wgOut; if ($lang_Path == '') { if ($_FILES["new_lang"]["error"] == '0') { $lang_Path = $_FILES["new_lang"]["tmp_name"]; $lang_name = $_FILES["new_lang"]["name"]; } else { $lang_Path = $lang_Path; } if ($wgRequest->getVal('lang_code') == '') { return awcs_forum_error('admin_lang_needtoselectlang'); } $lang_code = $wgRequest->getVal('lang_code'); } # put a check if file exitsts... if (!file_exists($lang_Path)) { return awcs_forum_error('admin_update_sorrynofile'); } require $lang_Path; $lang_info = array(); $save_lang_info = array(); $save_lang_info_raw = array(); $lang_info_raw = array(); $fields = array(); #$fields[] = 'lang_owner_info'; $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_errormsg_raw'; $fields[] = 'lang_txt_redirects_raw'; /** @todo get rid of this and add a query to get id */ $lang_info = lang_getinfo($this->lang_code, $fields); #awc_pdie($lang_info); // get ID from first key $lang_id = key($lang_info); $update_vals = array(); foreach ($fields as $key) { $import_key = str_replace('_raw', '', $key); if (isset(${$key})) { foreach (${$key} as $k => $v) { $lang_info[$key][$k] = $v; $lang_info[$import_key][$k] = awc_wikipase($v, $wgOut); } $update_vals[$key] = serialize($lang_info[$key]); $update_vals[$import_key] = serialize($lang_info[$import_key]); } } if (empty($lang_owner_info) or !isset($lang_owner_info)) { $lang_owner_info = array('lang_owner_when' => "", 'lang_owner' => "", 'lang_owner_contact' => ""); } $update_vals['lang_owner_info'] = serialize($lang_owner_info); # awc_pdie($update_vals); $dbw = wfGetDB(DB_MASTER); $dbw->update('awc_f_langs', $update_vals, array('lang_id' => $lang_id), ''); return; }
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:'******'&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 . '&action=edit', $mem_page['body']); $mem_page['body'] = str_replace('action=edit', 'awc_mem_redirect=' . $mem_name . '&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('</a>', '</a>', $mem_page['body']); $post = str_replace('<a href', '<a href', $post); $post = str_replace('">', '">', $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 ); }
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 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'); }
function pm_change() { global $wgOut, $awc, $awcUser, $wgRequest, $awc_tables, $action_url; $pm_changetodo = $wgRequest->getVal('pm_changetodo'); $where = $wgRequest->getVal('where'); if ($pm_changetodo == null) { $pm_changetodo = $action_url[2]; } if (isset($_POST['pm_ids'])) { $pm_ids = array(); $pm_ids = $_POST['pm_ids']; } if (!isset($pm_ids)) { if (!empty($action_url['id'])) { $pm_ids = array(); $pm_ids[] = $action_url['id']; } } if (!isset($pm_ids)) { die("no pms"); } $dbr = wfGetDB(DB_SLAVE); $dbw = wfGetDB(DB_MASTER); $inbox_count = 0; $sent_count = 0; $save_count = 0; $pm_count = 0; foreach ($pm_ids as $num => $id) { $sql = "SELECT pmi_folder_id FROM {$awc_tables['awc_f_pms_info']} WHERE pmi_id = {$id} AND pmi_receipt_id= " . $this->m_id . " LIMIT 1"; $res = $dbr->query($sql); $r = $dbr->fetchRow($res); $pm_count++; if ($pm_changetodo == 'pm_move' and $r['pmi_folder_id'] == '2') { unset($pm_ids[$num]); } if ($pm_changetodo == 'pm_moveinbox' and $r['pmi_folder_id'] == '0') { unset($pm_ids[$num]); } switch ($r['pmi_folder_id']) { case '0': $inbox_count++; break; case '1': $sent_count++; break; case '2': $save_count++; break; } $dbr->freeResult($res); } if ($pm_changetodo == 'pm_delete') { foreach ($pm_ids as $num => $pmi_id) { $sql = "SELECT pmi_pmid FROM {$awc_tables['awc_f_pms_info']} WHERE pmi_id = {$id} AND pmi_receipt_id= " . $this->m_id . " LIMIT 1"; $res = $dbr->query($sql); $r = $dbr->fetchRow($res); $pms_id[$pmi_id] = $r['pmi_pmid']; $dbr->freeResult($res); $sql = "SELECT count(pmi_id) as num_pms FROM {$awc_tables['awc_f_pms_info']} WHERE pmi_pmid = {$pms_id[$pmi_id]}"; $res = $dbr->query($sql); $r = $dbr->fetchRow($res); $num_pms[$pmi_id] = $r['num_pms']; $dbr->freeResult($res); if ($num_pms[$pmi_id] == 1) { $dbw->delete('awc_f_pms', array('pm_id' => $pms_id[$pmi_id]), ''); $dbw->delete('awc_f_pms_info', array('pmi_id' => $pmi_id), ''); } else { $dbw->delete('awc_f_pms_info', array('pmi_id' => $pmi_id), ''); } } $dbw->query("UPDATE {$awc_tables['awc_f_mems']} \r\r\n SET m_pmsave = m_pmsave - {$save_count},\r\r\n m_pmsent = m_pmsent - {$sent_count},\r\r\n m_pmtotal = m_pmtotal - {$pm_count},\r\r\n m_pminbox = m_pminbox - {$inbox_count}\r\r\n WHERE m_id =" . $this->m_id); return $wgOut->redirect(awcsforum_funcs::awcforum_url('member_options/pminbox')); } if (isset($this->mem_info['m_pmtotal'])) { if (UserPerm == 2 and $this->mem_info['m_pmtotal'] > $this->modPMlimit) { return awcs_forum_error(get_awcsforum_word('mem_pm_toomany') . ' ' . $this->modPMlimit); } elseif (UserPerm == 1 and $this->mem_info['m_pmtotal'] > $this->userPMlimit) { return awcs_forum_error(get_awcsforum_word('mem_pm_toomany') . ' ' . $this->userPMlimit); } } if (count($pm_ids) != 0) { if ($pm_changetodo == 'pm_move') { $dbw->query("UPDATE {$awc_tables['awc_f_mems']} \r\r\n SET m_pminbox = m_pminbox - {$inbox_count},\r\r\n m_pmsent = m_pmsent - {$sent_count},\r\r\n m_pmsave = m_pmsave + {$pm_count}\r\r\n WHERE m_id =" . $this->m_id); foreach ($pm_ids as $id) { $dbw->query("UPDATE {$awc_tables['awc_f_pms_info']} \r\r\n SET pmi_folder_id = 2\r\r\n WHERE pmi_id = {$id} AND pmi_receipt_id = " . $this->m_id); } } # return $wgOut->redirect( awcsforum_funcs::awcforum_url('member_options/pmsaved') ); } if (count($pm_ids) != 0) { if ($pm_changetodo == 'pm_moveinbox') { $dbw->query("UPDATE {$awc_tables['awc_f_mems']} \r\r\n SET m_pmsave = m_pmsave - {$save_count},\r\r\n m_pmsent = m_pmsent - {$sent_count},\r\r\n m_pminbox = m_pminbox + {$pm_count}\r\r\n WHERE m_id =" . $this->m_id); foreach ($pm_ids as $id) { $dbw->query("UPDATE {$awc_tables['awc_f_pms_info']} \r\r\n SET pmi_folder_id = 0\r\r\n WHERE pmi_id = {$id} AND pmi_receipt_id = " . $this->m_id); } } # return $wgOut->redirect( awcsforum_funcs::awcforum_url('member_options/pminbox') ); } return $wgOut->redirect(awcsforum_funcs::awcforum_url('member_options/' . $where)); //$wgOut->redirect( awcsforum_funcs::awcforum_url('member_options') ); }
function do_merge() { global $wgRequest, $awc_tables; $dbw = wfGetDB(DB_MASTER); $dbr = wfGetDB(DB_SLAVE); $this->tID = $wgRequest->getVal('tID'); $this->pID = $wgRequest->getVal('pID'); $r = $dbr->selectRow('awc_f_threads', array('t_forumid, t_topics'), "t_id={$this->tID}", __METHOD__, array('OFFSET' => 0, 'LIMIT' => 1)); $new_forum_id = $r->t_forumid; $new_t_topics = $r->t_topics; $new_t_topics = $new_t_topics + 1; if ($new_forum_id == '') { return awcs_forum_error(get_awcsforum_word('word_no_thread_id_for_move') . ' ' . $this->tID); } # die(">" . $this->pID); $sql = $dbr->selectSQLText(array('awc_f_posts', 'awc_f_threads'), array('p_threadid, p_forumid, t_topics'), "p_id={$this->pID}", __METHOD__, array('OFFSET' => '0', 'LIMIT' => '1'), array('awc_f_threads' => array('LEFT JOIN', 'p_threadid=t_id'))); /* $r = $dbr->selectRow( 'awc_f_posts, awc_f_threads', array( 'p_threadid, p_forumid, t_topics' ), "p_id = {$this->pID} AND p_threadid=t_id" , __METHOD__, array('OFFSET' => 0 , 'LIMIT' => 1)); */ $res = $dbr->query($sql); $r = $dbr->fetchObject($res); $current_thread_id = $r->p_threadid; $current_forum_id = $r->p_forumid; $current_t_topics = $r->t_topics; $current_t_topics = $current_t_topics - 1; # die("$current_thread_id"); $dbw->update('awc_f_posts', array('p_threadid' => $this->tID, 'p_forumid' => $new_forum_id), array('p_ID' => $this->pID), ''); #self::update_thread_last_post($this->tID); #self::update_thread_last_post($current_thread_id); $sql = "UPDATE {$awc_tables['awc_f_forums']} SET f_replies = f_replies - 1 "; $sql .= " WHERE f_id =" . $current_forum_id; $dbw->query($sql); $sql = "UPDATE {$awc_tables['awc_f_forums']} SET f_replies = f_replies + 1 "; $sql .= " WHERE f_id =" . $new_forum_id; $dbw->query($sql); $dbw->update('awc_f_threads', array('t_topics' => $current_t_topics), array('t_id' => $current_thread_id), ''); $dbw->update('awc_f_threads', array('t_topics' => $new_t_topics), array('t_id' => $this->tID), ''); $dbw->commit(); unset($dbw, $dbr, $r); // Update threads first $this->update_thread_last_post($this->tID); $this->update_thread_last_post($current_thread_id); // Update forums second... $this->update_forum_last_thread($new_forum_id); $this->update_forum_last_thread($current_forum_id); $info['msg'] = 'post_has_been_merged'; $info['url'] = awc_url . "st/id" . $this->tID; return awcf_redirect($info); }
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(' ', ' ', 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 delete_forum() { global $wgRequest; self::get_all_forums(); $current_id = $cid = $wgRequest->getVal('fID'); $move_to_id = $cid = $wgRequest->getVal('move_to'); if (strlen($current_id) == 0) { return awcs_forum_error('admin_no_forum_to_delete'); } if (strlen($move_to_id) == 0) { return awcs_forum_error('admin_no_forum_to_move_to'); } if ($current_id == $move_to_id) { return awcs_forum_error('admin_deletemovethesameforum'); } if (empty($this->forum_info[$move_to_id])) { return awcs_forum_error('admin_no_forum_to_move_to'); } if (empty($this->forum_info[$current_id])) { return awcs_forum_error('admin_no_forum_to_delete'); } $t_count = 0; $p_count = 0; foreach ($this->forum_info as $id => $info) { if ($id == $current_id or $id == $move_to_id) { $t_count = $t_count + $info['f_threads']; $p_count = $p_count + $info['f_replies']; } } $dbw = wfGetDB(DB_MASTER); $dbw->update('awc_f_forums', array('f_threads' => $t_count, 'f_replies' => $p_count), array('f_id' => $move_to_id), ''); $dbw->update('awc_f_threads', array('t_forumid' => $move_to_id), array('t_forumid' => $current_id), ''); require_once awc_dir . 'includes/mod_post.php'; awcs_forum_mod_post::update_forum_last_thread($move_to_id); $dbw->delete('awc_f_forums', array('f_id' => $current_id), ''); $info['msg'] = 'forum_was_deleted'; $info['url'] = awc_url . 'sf/id' . $move_to_id; return awcf_redirect($info); }