예제 #1
0
 public function process_request($request)
 {
     require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
     // smiley replacement regexes
     $rxSearch = '<(img|a)([^>]+)(src|href)="([^"]+)/wysiwyg-editor/plugins/smiley/images/([^"]+)"';
     $rxReplace = '<$1$2$3="$4/wysiwyg-editor/ckeditor/plugins/smiley/images/$5"';
     qa_suspend_event_reports(true);
     // avoid infinite loop
     // prevent race conditions
     $locks = array('posts', 'categories', 'users', 'users AS lastusers', 'userpoints', 'words', 'titlewords', 'contentwords', 'tagwords', 'words AS x', 'posttags', 'options');
     foreach ($locks as &$tbl) {
         $tbl = '^' . $tbl . ' WRITE';
     }
     qa_db_query_sub('LOCK TABLES ' . implode(',', $locks));
     $sql = 'SELECT postid, title, content FROM ^posts WHERE format="html" ' . 'AND content LIKE "%/wysiwyg-editor/plugins/smiley/images/%" ' . 'AND content RLIKE \'' . $rxSearch . '\' ' . 'LIMIT 5';
     $result = qa_db_query_sub($sql);
     $numPosts = 0;
     while (($post = qa_db_read_one_assoc($result, true)) !== null) {
         $newcontent = preg_replace("#{$rxSearch}#", $rxReplace, $post['content']);
         qa_post_set_content($post['postid'], $post['title'], $newcontent);
         $numPosts++;
     }
     qa_db_query_raw('UNLOCK TABLES');
     qa_suspend_event_reports(false);
     echo $numPosts;
 }
예제 #2
0
 function process_event($event, $userid, $handle, $cookieid, $params)
 {
     // check we have the correct event and the option is set
     if ($event != 'a_to_c') {
         return;
     }
     if (!qa_opt($this->convopt)) {
         return;
     }
     qa_post_set_content($params['postid'], null, null, '', null, null, null, qa_get_logged_in_userid());
 }
예제 #3
0
 function do_edit($data, $post)
 {
     if (!isset($data['action_data']) || !isset($data['action_data']['type'])) {
         return false;
     }
     $userid = qa_get_logged_in_userid();
     $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
     // create a new cookie if necessary
     $postid = (int) @$data['action_id'];
     $input = $data['action_data'];
     $type = $input['type'];
     $title = @$input['title'];
     $content = @$input['content'];
     $format = @$input['format'];
     $tags = @$input['tags'];
     $notify = @$input['notify'];
     $email = @$input['email'];
     $parentid = @$input['parentid'];
     if ($post['userid'] != $userid) {
         $permiterror = qa_user_permit_error('permit_edit_' . strtolower($type));
         if ($permiterror || $post['basetype'] == 'Q' && (isset($post['closedbyid']) || isset($post['selchildid']) && qa_opt('do_close_on_select'))) {
             return false;
         }
     }
     require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
     qa_post_set_content($postid, $title, $content, $format, $tags, $notify, $email, $userid);
     return true;
 }
예제 #4
0
 function process_event($event, $userid, $handle, $cookieid, $params)
 {
     // only interested in q_post & q_edit
     if ($event != 'q_post' && $event != 'q_edit') {
         return;
     }
     // get config data
     $config = qa_opt('tag_synonyms');
     if (!$config) {
         return;
     }
     $oldtags = qa_tagstring_to_tags($params['tags']);
     $synonyms = $this->_synonyms_to_array($config);
     $newtags = $this->_convert_tags($oldtags, $synonyms);
     // updating content would trigger another event, so we suspend events to avoid an infinite loop
     qa_suspend_event_reports(true);
     qa_post_set_content($params['postid'], $params['title'], $params['content'], $params['format'], $newtags);
     qa_suspend_event_reports(false);
 }