예제 #1
0
function ProcessThread($thread)
{
    global $vbulletin, $vbphrase;
    //RSS?
    $checkrss = $vbulletin->db->query_read_slave("\r\n\t\tSELECT rssfeedid\r\n\t\tFROM " . TABLE_PREFIX . "rsslog\r\n\t\tWHERE itemid=" . $thread['threadid'] . " AND itemtype='thread'\r\n\t");
    $thread['rssfeedid'] = 0;
    if ($vbulletin->db->num_rows($checkrss) > 0) {
        $arrrssfeed = $vbulletin->db->fetch_array($checkrss);
        $thread['rssfeedid'] = $arrrssfeed['rssfeedid'];
    }
    unset($checkrss);
    if ($vbulletin->options['autotag_tag_prefix']) {
        $thread['prefix'] = htmlspecialchars_uni($vbphrase["prefix_{$thread['prefixid']}_title_plain"]);
    }
    $taglist = GetAutoTags($thread);
    if (!$taglist or !is_array($taglist)) {
        $vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "thread SET autoskip=2 WHERE threadid=" . $thread['threadid']);
        return;
    } else {
        $vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "thread SET autoskip=0 WHERE threadid=" . $thread['threadid']);
    }
    $taglist = array_unique($taglist);
    $taglist_db = array();
    $taglist_insert = array();
    foreach ($taglist as $tag) {
        $tag = $vbulletin->db->escape_string($tag);
        $taglist_db[] = $tag;
        $taglist_insert[] = "('{$tag}', " . $thread['dateline'] . ", 1)";
    }
    $vbulletin->db->query_write("\r\n\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "tag\r\n\t\t\t(tagtext, dateline, autotag)\r\n\t\tVALUES\r\n\t\t\t" . implode(',', $taglist_insert));
    $tagthread = array();
    $tagid_sql = $vbulletin->db->query_read("\r\n\t\tSELECT tagid\r\n\t\tFROM " . TABLE_PREFIX . "tag\r\n\t\tWHERE tagtext IN ('" . implode("', '", $taglist_db) . "')\r\n\t");
    while ($tag = $vbulletin->db->fetch_array($tagid_sql)) {
        $tagthread[] = "(" . $thread['threadid'] . ", " . $tag['tagid'] . ", " . $thread['postuserid'] . ", " . $thread['dateline'] . ", 1)";
    }
    if ($tagthread) {
        $vbulletin->db->query_write("\r\n\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "tagthread\r\n\t\t\t\t(threadid, tagid, userid, dateline, autotag)\r\n\t\t\tVALUES\r\n\t\t\t\t" . implode(',', $tagthread));
    }
    rebuild_thread_taglist($thread['threadid']);
}
예제 #2
0
/**
* Inserts tags into the DB and adds them to the specified thread.
*
* @param	integer	Thread to add tags to
* @param	array	Array of tags. Should already be validated!
*/
function insert_tags_thread($threadid, $taglist)
{
    global $vbulletin;
    if (!$taglist or !is_array($taglist)) {
        return;
    }
    $taglist_db = array();
    $taglist_insert = array();
    foreach ($taglist as $tag) {
        $tag = $vbulletin->db->escape_string($tag);
        $taglist_db[] = $tag;
        $taglist_insert[] = "('{$tag}', " . TIMENOW . ")";
    }
    // create new tags
    $vbulletin->db->query_write("\n\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "tag\n\t\t\t(tagtext, dateline)\n\t\tVALUES\n\t\t\t" . implode(',', $taglist_insert));
    // now associate with thread
    $tagthread = array();
    $tagid_sql = $vbulletin->db->query_read("\n\t\tSELECT tagid\n\t\tFROM " . TABLE_PREFIX . "tag\n\t\tWHERE tagtext IN ('" . implode("', '", $taglist_db) . "')\n\t");
    while ($tag = $vbulletin->db->fetch_array($tagid_sql)) {
        $tagthread[] = "({$threadid}, {$tag['tagid']}, " . $vbulletin->userinfo['userid'] . ", " . TIMENOW . ")";
    }
    if ($tagthread) {
        // this should always happen
        $vbulletin->db->query_write("\n\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "tagthread\n\t\t\t\t(threadid, tagid, userid, dateline)\n\t\t\tVALUES\n\t\t\t\t" . implode(',', $tagthread));
    }
    // now rebuild the tag list for the thread
    rebuild_thread_taglist($threadid);
}
예제 #3
0
파일: threadtag.php 프로젝트: holandacz/nb4
     $vbulletin->GPC['taglist'] = convert_urlencoded_unicode($vbulletin->GPC['taglist']);
 }
 if ($vbulletin->GPC['tagsshown'] and $show['manage_existing_option']) {
     $tags_sql = $db->query_read("\n\t\t\tSELECT tag.*, tagthread.userid\n\t\t\tFROM " . TABLE_PREFIX . "tagthread AS tagthread\n\t\t\tINNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tag.tagid = tagthread.tagid)\n\t\t\tWHERE tagthread.threadid = {$threadinfo['threadid']}\n\t\t\t\tAND tagthread.tagid IN (" . implode(',', $vbulletin->GPC['tagsshown']) . ")\n\t\t");
     $delete = array();
     while ($tag = $db->fetch_array($tags_sql)) {
         if ($tag['userid'] == $vbulletin->userinfo['userid'] or $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletetagown'] and $threadinfo['postuserid'] == $vbulletin->userinfo['userid'] or can_moderate($threadinfo['forumid'], 'caneditthreads')) {
             if (!in_array($tag['tagid'], $vbulletin->GPC['tagskept'])) {
                 $delete[] = $tag['tagid'];
             }
         }
     }
     ($hook = vBulletinHook::fetch_hook('threadtag_domanage_delete')) ? eval($hook) : false;
     if ($delete) {
         $db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "tagthread\n\t\t\t\tWHERE threadid = {$threadinfo['threadid']}\n\t\t\t\t\tAND tagid IN (" . implode(',', $delete) . ")\n\t\t\t");
         $threadinfo['taglist'] = rebuild_thread_taglist($threadinfo['threadid']);
     }
 }
 ($hook = vBulletinHook::fetch_hook('threadtag_domanage_postdelete')) ? eval($hook) : false;
 if ($vbulletin->GPC['taglist'] and $show['add_option']) {
     $errors = add_tags_to_thread($threadinfo, $vbulletin->GPC['taglist']);
 } else {
     $errors = array();
 }
 if ($vbulletin->GPC['ajax']) {
     $threadinfo = fetch_threadinfo($threadinfo['threadid'], false);
     // get updated tag list
     $tagcount = $threadinfo['taglist'] ? count(explode(',', $threadinfo['taglist'])) : 0;
     require_once DIR . '/includes/class_xml.php';
     $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
     $xml->add_group('tag');
예제 #4
0
파일: inlinemod.php 프로젝트: holandacz/nb4
 }
 // Update first post in each thread as title information in relation to the sames words being in the first post may have changed now.
 foreach ($firstpostids as $firstpostid) {
     delete_post_index($firstpostid);
     build_post_index($firstpostid, $destforuminfo);
 }
 // Update post threadids
 $db->query_write("\n\t\tUPDATE " . TABLE_PREFIX . "post\n\t\tSET threadid = {$destthread['threadid']}\n\t\tWHERE threadid IN(" . implode(',', array_keys($threadarray)) . ")\n\t");
 // kill the post cache for the dest thread
 delete_post_cache_threads(array($destthread['threadid']));
 // Update subscribed threads
 $db->query_write("\n\t\tUPDATE IGNORE " . TABLE_PREFIX . "subscribethread\n\t\tSET threadid = {$destthread['threadid']}\n\t\tWHERE threadid IN(" . implode(',', array_keys($threadarray)) . ")\n\t");
 // update tags
 $db->query_write("\n\t\tUPDATE IGNORE " . TABLE_PREFIX . "tagthread\n\t\tSET threadid = {$destthread['threadid']}\n\t\tWHERE threadid IN(" . implode(',', array_keys($threadarray)) . ")\n\t");
 require_once DIR . '/includes/functions_newpost.php';
 rebuild_thread_taglist($destthread['threadid']);
 $users = array();
 $ratings = $db->query_read_slave("\n\t\tSELECT threadrateid, threadid, userid, vote, ipaddress\n\t\tFROM " . TABLE_PREFIX . "threadrate\n\t\tWHERE threadid IN(" . implode(',', array_keys($threadarray)) . ")\n\t");
 while ($rating = $db->fetch_array($ratings)) {
     $id = !empty($rating['userid']) ? $rating['userid'] : $rating['ipaddress'];
     $users["{$id}"]['vote'] += $rating['vote'];
     $users["{$id}"]['total'] += 1;
 }
 if (!empty($users)) {
     $sql = array();
     $db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "threadrate\n\t\t\tWHERE threadid IN(" . implode(',', array_keys($threadarray)) . ")\n\t\t");
     foreach ($users as $id => $rating) {
         if (is_int($id)) {
             $userid = $id;
             $ipaddress = '';
         } else {