Esempio n. 1
0
 static function get($select = '*', $where = '', $opt = array())
 {
     $dbTags = new DBTags();
     $unviewable = $dbTags->getUnviewable('threads');
     $opt = array_merge(array('limit' => '', 'orderBy' => '', 'orderType' => 'asc', 'groupBy' => 'tags.hash'), $opt);
     if (!$where) {
         $where = '1=1';
     }
     $where = "({$where}) AND threads.tid != '0' AND threads.visible = '1' AND threads.closed NOT LIKE 'moved|%' AND {$unviewable}" . tags_getbads();
     $query = "SELECT {$select} FROM `" . TABLE_PREFIX . "tags` tags\n";
     $query .= "LEFT JOIN `" . TABLE_PREFIX . "threads` threads on(tags.tid = threads.tid)\n";
     $query .= "LEFT JOIN `" . TABLE_PREFIX . "posts` posts on(threads.firstpost = posts.pid)\n";
     $query .= "WHERE " . $where . "\n";
     if ($opt['groupBy']) {
         $query .= "group by {$opt['groupBy']}\n";
     }
     if ($opt['orderBy']) {
         if (strstr($opt['orderBy'], '.')) {
             $opt['orderBy'] = '`' . TABLE_PREFIX . $opt['orderBy'] . '`';
         }
         $query .= "order by {$opt['orderBy']} {$opt['orderType']}\n";
     }
     if ($opt['limit']) {
         $query .= "limit {$opt['limit']}\n";
     }
     global $db;
     return $db->query($query);
 }
Esempio n. 2
0
function tags_editpost_end()
{
    global $mybb, $db, $lang, $templates, $thread, $post, $tags, $tags_value;
    if ($mybb->settings['tags_enabled'] == 0 || tags_in_disforum($thread['fid']) || $mybb->settings['tags_groups'] != -1 && !is_member($mybb->settings['tags_groups'])) {
        return;
    }
    $lang->load('tags');
    if ($thread['firstpost'] != $mybb->get_input('pid', 1)) {
        return;
    }
    $tags_value = $mybb->get_input('tags');
    if (!$tags_value) {
        $bad_tags = tags_getbads(true, false);
        $query = $db->simple_select('tags', '*', "tid='{$thread['tid']}'{$bad_tags}");
        $thread['tags'] = array();
        while ($tag = $db->fetch_array($query)) {
            if (!in_array($tag['name'], $thread['tags']) && $tag['name'] != '') {
                array_push($thread['tags'], $tag['name']);
            }
        }
        $tags_value = implode(',', $thread['tags']);
    }
    $tags_value = htmlspecialchars_uni(tags_string2tag($tags_value));
    eval('$tags = "' . $templates->get('tags_input') . '";');
}
Esempio n. 3
0
 add_breadcrumb($name, get_tag_link($name));
 $bad_tags = tags_getbads(true);
 $count = DBTags::countThreads("tags.hash IN ({$hash})");
 $pages = $count / $mybb->settings['tags_per_page'];
 $pages = ceil($pages);
 if ($page > $pages || $page <= 0) {
     $page = 1;
 }
 if ($page) {
     $start = ($page - 1) * $mybb->settings['tags_per_page'];
 } else {
     $start = 0;
     $page = 1;
 }
 $multipage = multipage($count, $mybb->settings['tags_per_page'], $page, get_tag_link($name));
 $bad_tags = tags_getbads(true);
 $query = DBTags::get("threads.tid, posts.message, posts.username, posts.uid, threads.subject, threads.views, threads.replies", "tags.hash IN ({$hash})", array('groupBy' => 'threads.tid', 'limit' => "{$start}, {$mybb->settings['tags_per_page']}"));
 $tags = '';
 while ($tag = $db->fetch_array($query)) {
     if (!$tag['tid']) {
         continue;
     }
     if ($mybb->seo_support == true) {
         $highlight = "?highlight=" . urlencode($name);
     } else {
         $highlight = "&amp;highlight=" . urlencode($name);
     }
     $tag['message'] = my_substr($tag['message'], 0, 500);
     $tag['message'] = $parser->parse_message($tag['message'], $parser_options);
     $tag['subject'] = htmlspecialchars_uni($parser->parse_badwords($tag['subject']));
     $tag['threadlink'] = get_thread_link($tag['tid']);