Esempio n. 1
0
 function edit_post($preview = '', $action = '')
 {
     global $wgOut, $awcUser, $wgRequest, $wgParser, $wgTitle, $awc_tables;
     if (strlen($preview) > 0) {
         return self::GetEdit($this->pID, $this->isThread, true);
     }
     // awc_f_post_edits
     if ($this->post == "") {
         die(get_awcsforum_word('blank_post_warning'));
     }
     if ($this->forum_Antispam != "") {
         die("spam");
     }
     wfRunHooks('awcsforum_edit_thread', array(&$this));
     // 2.5.8
     $rDB = wfGetDB(DB_SLAVE);
     $sql = "SELECT p.p_wiki_hidden, p.p_wiki_ver_id, p.p_user, p.p_editwho, p.p_post, p.p_title, p.p_editdate,\r\r\n                        t.t_id, t.t_wiki_pageid\r\r\n                FROM {$awc_tables['awc_f_posts']} p \r\r\n                JOIN {$awc_tables['awc_f_threads']} t\r\r\n                    ON p.p_threadid=t.t_id\r\r\n                WHERE p.p_id=" . $this->pID;
     $res = $rDB->query($sql);
     $r = $rDB->fetchRow($res);
     if (!CanEdit($r['p_user'])) {
         $wgOut->loginToUse();
         return;
     }
     $rDB->freeResult($res);
     $current_post = $r['p_post'];
     $current_title = $r['p_title'];
     $current_date = $r['p_editdate'];
     $current_p_wiki_hidden = $r['p_wiki_hidden'];
     $current_p_wiki_ver_id = $r['p_wiki_ver_id'];
     $current_p_user = $r['p_editwho'];
     if (strlen($current_p_user) <= 0) {
         $current_p_user = $r['p_user'];
     }
     $wDB = wfGetDB(DB_MASTER);
     $p_wiki_hidden = $wDB->timestamp();
     $wDB->update('awc_f_posts', array('p_post' => $this->post, 'p_title' => $this->p_title, 'p_editdate' => $wDB->timestamp(), 'p_editwho' => $this->mName, 'p_editwhy' => "testing", 'p_wiki_hidden' => $p_wiki_hidden), array('p_id' => $this->pID), '');
     if ($this->cf_add_post_text_to_wiki) {
         require_once awc_dir . 'includes/to_wiki_dbase.php';
         $ws = new awcs_forum_wikisearch_cls();
         $ws->post = $this->post;
         $ws->title = $this->p_title;
         $ws->tID = $r['t_id'];
         $ws->pID = $this->pID;
         $ws->p_wiki_hidden = $p_wiki_hidden;
         $ws->pageID = $r['t_wiki_pageid'];
         $ws->old_p_wiki_hidden = $current_p_wiki_hidden;
         $ws->old_p_wiki_ver_id = $current_p_wiki_ver_id;
         $ws->old_post_text = $current_post . ' ' . $current_title;
         $ws->edit_post();
     }
     if ($this->isThread == "yes") {
         $wDB->update('awc_f_threads', array('t_name' => $this->title), array('t_id' => $this->tID), '');
         /*          
         	             if (UserPerm == 10){
         $wDB->update( 'awc_f_threads',
         						            array(  't_name'    => $this->title, 
                                 't_ann'     => $this->ann,
                                 't_pin'     => $this->sticky,
                                 't_status'  => $this->lock,), 
         						            array('t_id' => $this->tID),
         						            '' ); 
                         
                         } else if (UserPerm == 10){
         $wDB->update( 'awc_f_threads',
         						            array(  't_name'    => $this->title, 
                                 't_pin'     => $this->sticky,
                                 't_status'  => $this->lock,), 
         						            array('t_id' => $this->tID),
         						            '' ); 
         } else {
         $wDB->update( 'awc_f_threads',
         						            array(  't_name'    => $this->title), 
         						            array('t_id' => $this->tID),
         						            '' );  
         
         }
         */
     }
     $wDB->insert('awc_f_post_edits', array('pe_pid' => $this->pID, 'pe_post' => $current_post, 'pe_title' => $current_title, 'pe_who' => $current_p_user, 'pe_whoid' => '0', 'pe_when' => $current_date));
     /* 
             
             $cutoff_limit = $this->postlimit;
             if($this->num_topics >= $cutoff_limit) {
         $limit = '/limit:'. (($this->num_topics +1) - $cutoff_limit) . ',' . $cutoff_limit;
     } else {
        $limit = null;
     }
             # die(">". $limit);
     */
     $wgOut->redirect(awc_url . "st/id" . $this->tID . $limit . "/#post_" . $this->pID);
     #$wgOut->redirect( awc_url . "st/id" . $this->tID . "#post_" .$this->pID  );
 }
Esempio n. 2
0
 /**
  *  Loop posts and add to wiki search table(s)
  * 
  * Loop from 'awc_f_posts' table<br />
  * Save posts text to wo Wiki tables<br />
  * Flag post 't_wiki_pageid' columne
  * @parameter string $limit (how many entries to work with)
  * @uses awcs_forum_wikisearch_cls
  * @since Version 2.5.8
  */
 function threads_to_wiki($limit)
 {
     global $wgOut;
     require_once awc_dir . 'includes/to_wiki_dbase.php';
     $dbr = wfGetDB(DB_SLAVE);
     $awc_f_threads = $dbr->tableName('awc_f_threads');
     $awc_f_posts = $dbr->tableName('awc_f_posts');
     $sql = "SELECT t.t_id, t.t_name, p.p_post \r\r\n                    FROM {$awc_f_threads} t\r\r\n                    JOIN {$awc_f_posts} p\r\r\n                        ON p.p_threadid=t.t_id\r\r\n                    WHERE t.t_wiki_pageid=0 AND t.t_date = p.p_date\r\r\n                    ORDER BY t.t_date DESC\r\r\n                    LIMIT 0, {$limit}";
     $res = $dbr->query($sql);
     while ($r = $dbr->fetchObject($res)) {
         $tmp[] = array('p_post' => $r->p_post, 't_id' => $r->t_id, 't_name' => $r->t_name);
     }
     $dbr->freeResult($res);
     foreach ($tmp as $r) {
         // die($r['p_post']);
         $ws = new awcs_forum_wikisearch_cls();
         $ws->post = $r['p_post'];
         $ws->tID = $r['t_id'];
         $ws->title = $r['t_name'];
         $ws->p_wiki_hidden = $dbr->timestamp();
         $ws->add_thread();
         $wgOut->addHTML("pageID({$ws->pageID})  insert_textID({$ws->insert_textID}) insert_revID({$ws->insert_revID}) = {$r['t_name']} <br />");
         unset($ws);
     }
     /*
             
             $dbr = wfGetDB( DB_SLAVE );       
             $awc_f_threads = $dbr->tableName( 'awc_f_threads' ); 
             $awc_f_posts = $dbr->tableName( 'awc_f_posts' );          
             $sql = "SELECT t.t_wiki_pageid
                         FROM $awc_f_threads t
                         JOIN $awc_f_posts p
                             ON p.thread_id=t.t_id
                         WHERE t.t_date = p.p_date and t.t_wiki_pageid != 0
                         ORDER BY t.t_date DESC
                         LIMIT 0, $limit";
                         
             $res = $dbr->query($sql);
             while ($r = $dbr->fetchObject( $res )) {
                 //$tmp[] = array('p_post' => $r->p_post, 't_id' => $r->t_id , 't_name' => $r->t_name );
                 $tmp[] = $r->t_wiki_pageid;
             }
             $dbr->freeResult( $res );
             
             $pIDs = implode(',', $tmp);
             
             $dbw = wfGetDB( DB_MASTER );
             $wiki_page = $dbw->tableName( 'page' );          
             $sql = "UPDATE $wiki_page SET page_namespace = ".NS_AWC_FORUM." WHERE page_id IN ($pIDs) ";
             $res = $dbw->query($sql);   
     */
 }
Esempio n. 3
0
 function delete_thread()
 {
     global $wgOut, $awc_tables, $ForumStat, $awcs_forum_config;
     if (!CanDelete()) {
         $wgOut->loginToUse();
         return;
     }
     if (isset($awcs_forum_config->cf_add_post_text_to_wiki) and $awcs_forum_config->cf_add_post_text_to_wiki == '1') {
         require_once awc_dir . 'includes/to_wiki_dbase.php';
         $ws = new awcs_forum_wikisearch_cls();
     }
     $dbw = wfGetDB(DB_MASTER);
     $dbr = wfGetDB(DB_SLAVE);
     $fID = null;
     $threads = 0;
     $posts = 0;
     foreach ($this->tID as $id) {
         ++$threads;
         $sql = "SELECT t.t_ann, t.t_forumid, t.t_topics, t.t_starterid, t.t_wiki_pageid \n                            FROM  {$awc_tables['awc_f_threads']} t\n                            WHERE t.t_id={$id} LIMIT 1";
         $res = $dbr->query($sql);
         $r = $dbr->fetchRow($res);
         $dbr->freeResult($res);
         $fID = $r['t_forumid'];
         $page_ID = $r['t_wiki_pageid'];
         $t_starterid = $r['t_starterid'];
         $t_ann = $r['t_ann'];
         if ($t_ann == "1" and UserPerm != 10) {
             $wgOut->loginToUse();
             return;
         }
         if ($fID == null or $fID == '') {
             return awcs_forum_error('problem_deleting_thread');
         }
         $user_get = array();
         $user_get[] = 'm_topics';
         $user_get[] = 'm_idname';
         $n = GetMemInfo($t_starterid, $user_get);
         unset($user_get);
         $m_name = $n['name'];
         if ($m_name) {
             $dbw->update('awc_f_mems', array('m_topics' => $n['m_topics'] - 1), array('m_id' => $t_starterid), '');
         }
         unset($user_get, $n);
         $user_get = array();
         $user_get[] = 'm_posts';
         $user_get[] = 'm_idname';
         # get members how created a post in thread... this is abit half-assed, but it works -
         $sql = "SELECT p_userid FROM {$awc_tables['awc_f_posts']} WHERE p_threadid={$id} LIMIT 1";
         $res = $dbr->query($sql);
         while ($r = $dbr->fetchObject($res)) {
             if (isset($r->p_userid)) {
                 if (isset($ForumStat)) {
                     $ForumStat->stat_posts(false);
                 }
                 ++$posts;
                 // use this for the forums post count math...
                 $p_userid = $r->p_userid;
                 $n = GetMemInfo($p_userid, $user_get);
                 $name = $n['name'];
                 if ($name) {
                     $dbw->update('awc_f_mems', array('m_posts' => $n['m_posts'] - 1), array('m_id' => $p_userid), '');
                 }
             }
         }
         $posts = $posts - 1;
         // half/assed  - top loop create one too many
         if (isset($ForumStat)) {
             $ForumStat->stat_posts(1);
         }
         // half/assed - top loop create one too many
         $dbr->freeResult($res);
         unset($user_get, $n);
         if (isset($awcs_forum_config->cf_add_post_text_to_wiki) and $awcs_forum_config->cf_add_post_text_to_wiki == '1') {
             $ws->pageID = $page_ID;
             $ws->delete_thread();
         }
         if (isset($ForumStat)) {
             $ForumStat->stat_threads(false);
         }
     }
     $dbw->query("DELETE FROM {$awc_tables['awc_f_posts']} WHERE p_threadid IN (" . implode(',', $this->tID) . ")");
     $dbw->query("DELETE FROM {$awc_tables['awc_f_threads']} WHERE t_id IN (" . implode(',', $this->tID) . ")");
     $dbw->query("DELETE FROM {$awc_tables['awc_f_anns']} WHERE ann_id IN (" . implode(',', $this->tID) . ")");
     $dbw->query("DELETE FROM {$awc_tables['awc_f_watchthreads']}  WHERE wtcht_thread_id IN (" . implode(',', $this->tID) . ")");
     // polls ???
     $dbw->query("UPDATE {$awc_tables['awc_f_forums']} \n                        SET f_threads = f_threads - {$threads},\n                            f_replies = f_replies - {$posts}\n                        WHERE f_id={$fID}");
     unset($dbr, $r, $res);
     $this->update_forum_last_thread($fID);
     $info['msg'] = 'thread_has_been_deleted';
     $info['url'] = awc_url . "sf/id" . $fID;
     return awcf_redirect($info);
 }