function lang_add_new_lang($abbr) { global $awcs_forum_config, $wgOut; // redirects and errors... if ($abbr == '') { return $wgOut->addHTML('<hr><br />' . get_awcsforum_word('admin_lang_newlangempty')); } $languages = Language::getLanguageNames(true); $lang_name = $languages[$abbr]; # die("<>>". $lang_name); $en_lang = array(); $dbw = wfGetDB(DB_MASTER); $dbr = wfGetDB(DB_SLAVE); $table_1 = $dbr->tableName('awc_f_langs'); $sql = "SELECT * FROM {$table_1} WHERE lang_code='" . $abbr . "' OR lang_code='en'"; $res = $dbr->query($sql); while ($r = $dbr->fetchObject($res)) { if ($r->lang_code == $abbr) { return awcs_forum_error(get_awcsforum_word('admin_lang_newlangalreadythere') . ' <b>' . $lang_name . '</b>'); } $en_lang['lang_txt_forum'] = $r->lang_txt_forum; $en_lang['lang_txt_thread'] = $r->lang_txt_thread; $en_lang['lang_txt_admin'] = $r->lang_txt_admin; $en_lang['lang_txt_mem'] = $r->lang_txt_mem; $en_lang['lang_txt_tag'] = $r->lang_txt_tag; $en_lang['lang_txt_search'] = $r->lang_txt_search; $en_lang['lang_txt_redirects'] = $r->lang_txt_redirects; $en_lang['lang_txt_forum_raw'] = $r->lang_txt_forum_raw; $en_lang['lang_txt_thread_raw'] = $r->lang_txt_thread_raw; $en_lang['lang_txt_admin_raw'] = $r->lang_txt_admin_raw; $en_lang['lang_txt_mem_raw'] = $r->lang_txt_mem_raw; $en_lang['lang_txt_tag_raw'] = $r->lang_txt_tag_raw; $en_lang['lang_txt_search_raw'] = $r->lang_txt_search_raw; $en_lang['lang_txt_redirects_raw'] = $r->lang_txt_redirects_raw; } $dbr->freeResult($res); $dbw->insert('awc_f_langs', array('lang_code' => $abbr, 'lang_name' => $lang_name, 'lang_txt_forum' => $en_lang['lang_txt_forum_raw'], 'lang_txt_admin' => $en_lang['lang_txt_admin_raw'], 'lang_txt_mem' => $en_lang['lang_txt_mem_raw'], 'lang_txt_search' => $en_lang['lang_txt_search_raw'], 'lang_txt_tag' => $en_lang['lang_txt_tag_raw'], 'lang_txt_thread' => $en_lang['lang_txt_thread_raw'], 'lang_txt_redirects' => $en_lang['lang_txt_redirects'], 'lang_txt_forum_raw' => $en_lang['lang_txt_forum_raw'], 'lang_txt_admin_raw' => $en_lang['lang_txt_admin_raw'], 'lang_txt_mem_raw' => $en_lang['lang_txt_mem_raw'], 'lang_txt_search_raw' => $en_lang['lang_txt_search_raw'], 'lang_txt_tag_raw' => $en_lang['lang_txt_tag_raw'], 'lang_txt_thread_raw' => $en_lang['lang_txt_thread_raw'], 'lang_txt_redirects_raw' => $en_lang['lang_txt_redirects_raw'])); $dbw->update('awc_f_config', array('a' => $awcs_forum_config->cf_forumlang . ',' . $abbr), array('q' => 'cf_forumlang'), ''); $awcs_forum_config->cf_forumlang = $awcs_forum_config->cf_forumlang . ',' . $abbr; $this->lang_update_lang_file(); $info['msg'] = get_awcsforum_word('admin_lang_newlangreated') . ' <b>' . $lang_name . '</b>'; $info['url'] = awc_url . "admin/awc_lang/display_lang_options"; return awcf_redirect($info); # return $wgOut->addHTML('<hr><br />'. get_awcsforum_word('admin_lang_newlangreated') . ' <b>' . $lang_name . '</b>' ); }
/** * 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 css_edit_save($redirect = true) { global $wgOut, $ADskin, $wgRequest; // $info = array('who' => $wgRequest->getVal( 'css_who' ), 'where' => $wgRequest->getVal( 'css_where' ),); $css_id = $wgRequest->getVal('id'); $css_code = $wgRequest->getVal('css_code'); $css_ver = $wgRequest->getVal('ver'); $dbw = wfGetDB(DB_MASTER); $dbr = wfGetDB(DB_SLAVE); $awc_f_theme_css = $dbr->tableName('awc_f_theme_css'); $sql = "SELECT *\r\r\n FROM {$awc_f_theme_css} \r\r\n WHERE css_id={$css_id}"; $res = $dbr->query($sql); while ($r = $dbr->fetchObject($res)) { $dbw->insert('awc_f_theme_css_history', array('cssh_cssid' => $r->css_id, 'cssh_ver' => $r->css_ver, 'cssh_forum_ver' => $r->css_forumver, 'cssh_code' => $r->css_code, 'cssh_date' => $dbw->timestamp())); $tplt_ver = explode('.', $css_ver); $css_save = $tplt_ver[0] . '.' . $tplt_ver[1] . '.' . ($tplt_ver[2] + 1); // $code = $wgRequest->getVal('tplt_code'); $dbw->update('awc_f_theme_css', array('css_code' => $css_code, 'css_ver' => $css_save), array('css_id' => $css_id), ''); } if ($redirect) { $info['msg'] = 'css_has_been_saved'; $info['url'] = awc_url . "admin/css/css_edit_get"; return awcf_redirect($info); } return true; }
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; }
function poll_add($no_redirect = false) { global $wgRequest; if ($this->polls_enabled != '1') { return ''; } $preview = $wgRequest->getVal('preview'); if (strlen($preview) > 0) { global $wgOut; require_once awc_dir . 'includes/post_phase.php'; return $wgOut->addHTML(awcs_forum_post_phase::display_poll('', true)); } $p['poll_info'] = array(); $p['poll_info']['ispoll'] = 'checked'; $p['poll_info']['pollq'] = trim(self::CleanThreadTitle($wgRequest->getVal('pollq'))); if ($p['poll_info']['pollq'] == '') { return awcs_forum_error(get_awcsforum_word('blank_poll_warning')); } $opt = null; foreach ($_POST as $k => $v) { if (!empty($v)) { if (strstr($k, 'poll_opt')) { ++$opt; if (trim(self::CleanThreadTitle($v)) != '') { $p['poll_info']['poll_options']['poll_opt' . $opt] = trim(self::CleanThreadTitle($v)); } } } } /* // $wgRequest - does not work correctly with MW 1.9, Using the above $_POST does foreach($wgRequest as $k => $v){ if(!empty($v) AND is_array($v)){ foreach($v as $k2 => $v2){ if(strstr($k2,'poll_opt')){ ++$opt; if(trim(self::CleanThreadTitle($v[$k2])) != '') $p['poll_info']['poll_options']['poll_opt' . $opt] = trim(self::CleanThreadTitle($v[$k2])); } } } } */ if (count($p['poll_info']['poll_options']) < 2) { return awcs_forum_error(get_awcsforum_word('blank_poll_option')); } wfRunHooks('awcsforum_add_newpoll', array(&$this, &$p)); // 2.5.5 $wDB = wfGetDB(DB_MASTER); $wDB->insert('awc_f_polls', array('poll_threadid' => $this->tID, 'poll_forumid' => $this->fID, 'poll_q' => $p['poll_info']['pollq'], 'poll_num_options' => '1', 'poll_choice' => serialize($p['poll_info']['poll_options']), 'poll_a' => '1', 'poll_open' => '1', 'poll_start_date' => '1', 'poll_close_date' => '1', 'poll_perm' => '1')); $wDB->update('awc_f_threads', array('t_poll' => '1', 't_pollopen' => 1), array('t_id' => $this->tID), ''); if ($no_redirect) { return; } $info['msg'] = 'poll_has_been_add'; $info['url'] = awc_url . "st/id" . $this->tID; return awcf_redirect($info); }
function clearIndicators() { global $wgOut, $tplt; awcsforum_funcs::clear_session(); awcsforum_funcs::clear_awcsforum_cookie(); awcsforum_funcs::set_session(wfTimestampNow()); awcsforum_funcs::get_page_lang(array('lang_txt_redirects')); // get lang difinitions... $tplt->add_tplts(array("'redirect'"), true); $info['msg'] = 'clearIndicators'; $info['url'] = $_SERVER['HTTP_REFERER']; return awcf_redirect($info); // member_options/clearIndicators // $wgOut->redirect( $_SERVER['HTTP_REFERER']); }
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); }
public function checkForumPassword() { global $wgRequest, $wgOut, $awcUser; #awc_pdie($wgRequest); # fid # pw $fid = $wgRequest->getVal('fid'); $pw = $wgRequest->getVal('pw'); $pw = awcsf_encode_password($pw); $dbr = wfGetDB(DB_SLAVE); $r = $dbr->selectRow('awc_f_forums', array('f_password'), array('f_id' => $fid)); if ($pw == $r->f_password) { $_SESSION['forumPW'] = $_SESSION['forumPW'] . ',' . $fid; $awcUser->pw[$fid] = $fid; } $info['msg'] = 'word_CheckingPassword'; $info['url'] = awc_url . 'sf/id' . $fid; return awcf_redirect($info); #$str = $this->ShowThreads($fid); # return $wgOut->addHTML($str); }
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); }