Example #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']);
}
Example #2
0
<?php

/*======================================================================*\
|| #################################################################### ||
|| # Automatic Thread Tagging Ajax Helper                             # ||
|| # Copyright ©2008 Marius Czyz                                      # ||
|| #################################################################### ||
\*======================================================================*/
header("cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
require_once './global.php';
if ($_REQUEST['do'] == 'gettags') {
    require_once DIR . '/includes/functions_autotagger.php';
    if (!$vbulletin->options['autotag_ajax_existing']) {
        $tagger['taglist'] = $vbulletin->input->clean_gpc('r', 'existing', TYPE_NOHTML);
    } else {
        $tagger['taglist'] = "";
    }
    $tagger['prefix'] = $vbulletin->input->clean_gpc('r', 'prefix', TYPE_NOHTML);
    $tagger['title'] = $vbulletin->input->clean_gpc('r', 'title', TYPE_NOHTML);
    $tagger['forumid'] = $vbulletin->input->clean_gpc('r', 'forumid', TYPE_INT);
    $tagger['postuserid'] = $vbulletin->input->clean_gpc('r', 'userid', TYPE_INT);
    $tags_remain = $vbulletin->input->clean_gpc('r', 'tags_remain', TYPE_INT);
    $autotags = GetAutoTags($tagger, true, $tags_remain);
    if (count($autotags) > 0) {
        echo implode(',', $autotags);
    }
}