function qa_tag_html($tag, $microformats = false, $favorited = false)
{
    global $plugin_tag_desc_list;
    $taghtml = qa_tag_html_base($tag, $microformats, $favorited);
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    $taglc = qa_strtolower($tag);
    $plugin_tag_desc_list[$taglc] = true;
    $anglepos = strpos($taghtml, '>');
    if ($anglepos !== false) {
        $taghtml = substr_replace($taghtml, ' TITLE=",TAG_DESC,' . $taglc . ',"', $anglepos, 0);
    }
    return $taghtml;
}
Beispiel #2
0
 function process_request($request)
 {
     $parts = explode('/', $request);
     $tag = $parts[1];
     $qa_content = qa_content_prepare();
     $qa_content['title'] = 'Edit the description for Fture test ' . qa_html($tag);
     require_once QA_INCLUDE_DIR . 'qa-db-metas.php';
     $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(array('type' => 'text', 'rows' => 4, 'tags' => 'NAME="tagdesc" ID="tagdesc"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'description')))), 'buttons' => array(array('tags' => 'NAME="dosave"', 'label' => 'Save Description')));
     if (qa_clicked('dosave')) {
         require_once QA_INCLUDE_DIR . 'qa-util-string.php';
         $taglc = qa_strtolower($tag);
         qa_db_tagmeta_set($taglc, 'description', qa_post_text('tagdesc'));
         qa_redirect('tag/' . $tag);
     }
     $qa_content['focusid'] = 'tagdesc';
     return $qa_content;
 }
 function process_request($request)
 {
     $parts = explode('/', $request);
     $tag = $parts[1];
     $qa_content = qa_content_prepare();
     $qa_content['title'] = qa_lang_html_sub('useo/edit_desc_for_x', qa_html($tag));
     if (qa_user_permit_error('useo_tag_desc_permit_edit')) {
         $qa_content['error'] = qa_lang_html('users/no_permission');
         return $qa_content;
     }
     require_once QA_INCLUDE_DIR . 'qa-db-metas.php';
     if (qa_clicked('dosave')) {
         require_once QA_INCLUDE_DIR . 'qa-util-string.php';
         $taglc = qa_strtolower($tag);
         qa_db_tagmeta_set($taglc, 'title', qa_post_text('tagtitle'));
         qa_db_tagmeta_set($taglc, 'description', qa_post_text('tagdesc'));
         qa_db_tagmeta_set($taglc, 'icon', qa_post_text('tagicon'));
         qa_redirect('tag/' . $tag);
     }
     $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(array('label' => 'Title:', 'type' => 'text', 'rows' => 2, 'tags' => 'NAME="tagtitle" ID="tagtitle"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'title'))), array('label' => 'Description:', 'type' => 'text', 'rows' => 4, 'tags' => 'NAME="tagdesc" ID="tagdesc"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'description'))), array('label' => 'Icon image:', 'type' => 'text', 'rows' => 1, 'tags' => 'NAME="tagicon" ID="tagicon"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'icon')))), 'buttons' => array(array('tags' => 'NAME="dosave"', 'label' => qa_lang_html('useo/save_desc_button'))));
     $qa_content['focusid'] = 'tagdesc';
     return $qa_content;
 }
function qa_tag_html($tag, $microformats = false, $favorited = false)
{
    // URL Customization
    $type = qa_opt('useo_url_tag_uppercase_type');
    if ($type == 1) {
        // first word's first letter
        $taglink = ucfirst($tag);
    } else {
        if ($type == 2) {
            // all word's first letter
            $taglink = str_replace(' ', '?', ucwords(str_replace('?', ' ', str_replace(' ', '/', ucwords(str_replace('/', ' ', str_replace(' ', '-', ucwords(str_replace('-', ' ', strtolower($tag))))))))));
        } else {
            // whole words
            $taglink = strtoupper($tag);
        }
    }
    // Tag Description
    global $useo_tag_desc_list;
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    $taglc = qa_strtolower($tag);
    $useo_tag_desc_list[$taglc] = true;
    return '<a href="' . qa_path_html('tag/' . $taglink) . '"' . ($microformats ? ' rel="tag"' : '') . ' class="qa-tag-link' . ($favorited ? ' qa-tag-favorited' : '') . '">' . qa_html($tag) . '</a>';
}
Beispiel #5
0
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
//	Get popular tags
$start = qa_get_start();
$userid = qa_get_logged_in_userid();
$populartags = qa_db_select_with_pending(qa_db_popular_tags_selectspec($start, qa_opt_if_loaded('page_size_tags')));
$tagcount = qa_opt('cache_tagcount');
$pagesize = qa_opt('page_size_tags');
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('main/popular_tags');
$qa_content['ranking'] = array('items' => array(), 'rows' => ceil($pagesize / qa_opt('columns_tags')), 'type' => 'tags');
if (count($populartags)) {
    $favoritemap = qa_get_favorite_non_qs_map();
    $output = 0;
    foreach ($populartags as $word => $count) {
        $qa_content['ranking']['items'][] = array('label' => qa_tag_html($word, false, @$favoritemap['tag'][qa_strtolower($word)]), 'count' => number_format($count));
        if (++$output >= $pagesize) {
            break;
        }
    }
} else {
    $qa_content['title'] = qa_lang_html('main/no_tags_found');
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagcount, qa_opt('pages_prev_next'));
if (empty($qa_content['page_links'])) {
    $qa_content['suggest_next'] = qa_html_suggest_ask();
}
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
Beispiel #6
0
function qa_post_tags_to_tagstring($tags)
{
    if (is_array($tags)) {
        $tags = implode(',', $tags);
    }
    return qa_tags_to_tagstring(array_unique(preg_split('/\\s*[,,]\\s*/', qa_strtolower(strtr($tags, '/', ' ')), -1, PREG_SPLIT_NO_EMPTY)));
}
Beispiel #7
0
function qa_get_tags_field_value($fieldname)
{
    require_once QA_INCLUDE_DIR . 'util/string.php';
    $text = qa_remove_utf8mb4(qa_post_text($fieldname));
    if (qa_opt('tag_separator_comma')) {
        return array_unique(preg_split('/\\s*,\\s*/', trim(qa_strtolower(strtr($text, '/', ' '))), -1, PREG_SPLIT_NO_EMPTY));
    } else {
        return array_unique(qa_string_to_words($text, true, false, false, false));
    }
}
 require_once QA_INCLUDE_DIR . 'util/string.php';
 $inname = qa_post_text('name');
 $incontent = qa_post_text('content');
 $inparentid = $setparent ? qa_get_category_field_value('parent') : $editcategory['parentid'];
 $inposition = qa_post_text('position');
 $errors = array();
 //	Check the parent ID
 $incategories = qa_db_select_with_pending(qa_db_category_nav_selectspec($inparentid, true));
 //	Verify the name is legitimate for that parent ID
 if (empty($inname)) {
     $errors['name'] = qa_lang('main/field_required');
 } elseif (qa_strlen($inname) > QA_DB_MAX_CAT_PAGE_TITLE_LENGTH) {
     $errors['name'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TITLE_LENGTH);
 } else {
     foreach ($incategories as $category) {
         if (!strcmp($category['parentid'], $inparentid) && strcmp($category['categoryid'], @$editcategory['categoryid']) && qa_strtolower($category['title']) == qa_strtolower($inname)) {
             $errors['name'] = qa_lang('admin/category_already_used');
         }
     }
 }
 //	Verify the slug is legitimate for that parent ID
 for ($attempt = 0; $attempt < 100; $attempt++) {
     switch ($attempt) {
         case 0:
             $inslug = qa_post_text('slug');
             if (!isset($inslug)) {
                 $inslug = implode('-', qa_string_to_words($inname));
             }
             break;
         case 1:
             $inslug = qa_lang_sub('admin/category_default_slug', $inslug);
Beispiel #9
0
function qa_block_words_match_all($string, $wordspreg)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    global $qa_utf8punctuation, $qa_utf8punctuation_keeplength;
    if (strlen($wordspreg)) {
        // replace all word separators with spaces of same length
        if (!is_array($qa_utf8punctuation_keeplength)) {
            $qa_utf8punctuation_keeplength = array();
            foreach ($qa_utf8punctuation as $key => $value) {
                $qa_utf8punctuation_keeplength[$key] = str_repeat(' ', strlen($key));
            }
        }
        $string = strtr(qa_strtolower($string), $qa_utf8punctuation_keeplength);
        // assumes UTF-8 case conversion in qa_strtolower does not change byte length
        $string = preg_replace('/' . QA_PREG_BLOCK_WORD_SEPARATOR . '/', ' ', $string);
        preg_match_all('/' . $wordspreg . '/', ' ' . $string . ' ', $pregmatches, PREG_OFFSET_CAPTURE);
        $outmatches = array();
        foreach ($pregmatches[0] as $pregmatch) {
            $outmatches[$pregmatch[1] - 1] = strlen($pregmatch[0]);
        }
        return $outmatches;
    }
    return array();
}
$start = qa_get_start();
$userid = qa_get_logged_in_userid();
//	Find the questions with this tag
if (!strlen($tag)) {
    qa_redirect('tags');
}
list($questions, $tagword) = qa_db_select_with_pending(qa_db_tag_recent_qs_selectspec($userid, $tag, $start, false, qa_opt_if_loaded('page_size_tag_qs')), qa_db_tag_word_selectspec($tag));
$pagesize = qa_opt('page_size_tag_qs');
$questions = array_slice($questions, 0, $pagesize);
$usershtml = qa_userids_handles_html($questions);
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html_sub('main/questions_tagged_x', qa_html($tag));
if (isset($userid) && isset($tagword)) {
    $favoritemap = qa_get_favorite_non_qs_map();
    $favorite = @$favoritemap['tag'][qa_strtolower($tagword['word'])];
    $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite, qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word']));
}
if (!count($questions)) {
    $qa_content['q_list']['title'] = qa_lang_html('main/no_questions_found');
}
$qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
$qa_content['q_list']['qs'] = array();
foreach ($questions as $postid => $question) {
    $qa_content['q_list']['qs'][] = qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question));
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagword['tagcount'], qa_opt('pages_prev_next'));
if (empty($qa_content['page_links'])) {
    $qa_content['suggest_next'] = qa_html_suggest_qs_tags(true);
}
if (qa_opt('feed_for_tag_qs')) {
Beispiel #11
0
function qa_db_tag_word_selectspec($tag)
{
    return array('columns' => array('wordid', 'word', 'tagcount'), 'source' => '^words WHERE word=$ AND word=$ COLLATE utf8_bin', 'arguments' => array($tag, qa_strtolower($tag)), 'single' => true);
}
 public function test__qa_strtolower()
 {
     $test = qa_strtolower('hElLo WoRld');
     $this->assertEquals($test, 'hello world');
 }
                $userfields = qa_db_select_with_pending(qa_db_userfields_selectspec());
                // reload after changes
                foreach ($userfields as $userfield) {
                    if ($userfield['fieldid'] == $editfield['fieldid']) {
                        $editfield = $userfield;
                    }
                }
            }
        } elseif (empty($errors)) {
            // creating a new user field
            for ($attempt = 0; $attempt < 1000; $attempt++) {
                $suffix = $attempt ? '-' . (1 + $attempt) : '';
                $newtag = qa_substr(implode('-', qa_string_to_words($inname)), 0, QA_DB_MAX_PROFILE_TITLE_LENGTH - strlen($suffix)) . $suffix;
                $uniquetag = true;
                foreach ($userfields as $userfield) {
                    if (qa_strtolower(trim($newtag)) == qa_strtolower(trim($userfield['title']))) {
                        $uniquetag = false;
                    }
                }
                if ($uniquetag) {
                    $fieldid = qa_db_userfield_create($newtag, $inname, $inflags);
                    qa_db_userfield_move($fieldid, $inposition);
                    qa_redirect('admin/users');
                }
            }
            qa_fatal_error('Could not create a unique database tag');
        }
    }
}
//	Prepare content for theme
$qa_content = qa_content_prepare();
Beispiel #14
0
    function cs_relative_post_list($limit, $slug, $type, $return = false, $avatar_size)
    {
        require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
        if (!empty($slug)) {
            if ($type == 'Category') {
                $post_type = 'Q';
                $categories = explode("/", $slug);
                if (count($categories)) {
                    $category_bread_crup = implode(" > ", $categories);
                    $category_link = implode("/", $categories);
                    $categories = array_reverse($categories);
                    $slug = implode("/", $categories);
                }
                $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$
							AND categoryid=(SELECT categoryid FROM ^categories WHERE ^categories.backpath=$ LIMIT 1) 
							ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, $limit));
                //refresh every 15 minutes
                $title = 'Questions in <a href="' . qa_path_html('questions/' . qa_strtolower($category_link)) . '">' . $category_bread_crup . '</a>';
            } elseif ($type == 'Tags') {
                $post_type = 'Q';
                $title = 'Questions in <a href="' . qa_path_html('tag/' . qa_strtolower($slug)) . '">' . $slug . '</a>';
                $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$
						AND ^posts.postid IN (SELECT postid FROM ^posttags WHERE 
							wordid=(SELECT wordid FROM ^words WHERE word=$ OR word=$ COLLATE utf8_bin LIMIT 1) ORDER BY postcreated DESC)
						ORDER BY ^posts.created DESC LIMIT #', 'Q', $slug, qa_strtolower($slug), $limit));
            } else {
                // Relative to Keyword
                require_once QA_INCLUDE_DIR . 'qa-app-search.php';
                $keyword = $slug;
                $userid = qa_get_logged_in_userid();
                $title = 'Posts About <a href="' . qa_path_html('search/' . qa_strtolower($keyword)) . '">' . $keyword . '</a>';
                //$post=qa_get_search_results($keyword, 0, $limit, $userid , false, false);
                $words = qa_string_to_words($keyword);
                $posts = qa_db_select_with_pending(qa_db_search_posts_selectspec($userid, $words, $words, $words, $words, trim($keyword), 0, false, $limit));
                $output = '<h3 class="widget-title">' . $title . '</h3>';
                $output .= '<ul class="question-list">';
                foreach ($posts as $post) {
                    $post_type = $post['type'];
                    if ($post_type == 'Q') {
                        $what = qa_lang('cleanstrap/asked');
                    } elseif ($post_type == 'A') {
                        $what = qa_lang('cleanstrap/answered');
                    } elseif ('C') {
                        $what = qa_lang('cleanstrap/commented');
                    }
                    $handle = qa_post_userid_to_handle($post['userid']);
                    $avatar = cs_get_post_avatar($post, $avatar_size);
                    $output .= '<li id="q-list-' . $post['postid'] . '" class="question-item">';
                    $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . $post['userid'] . '">' . $avatar . '</div>';
                    $output .= '<div class="list-right">';
                    if ($post_type == 'Q') {
                        $output .= '<a class="title" href="' . qa_q_path_html($post['postid'], $post['title']) . '" title="' . $post['title'] . '">' . cs_truncate(strip_tags($post['title']), 70) . '</a>';
                    } elseif ($post_type == 'A') {
                        $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#a' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>';
                    } else {
                        $output .= '<p><a href="' . cs_post_link($post['parentid']) . '#c' . $post['postid'] . '">' . cs_truncate(strip_tags($post['content']), 70) . '</a></p>';
                    }
                    $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what;
                    if ($post_type == 'Q') {
                        $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>';
                        $output .= ' <span class="ans-count">' . $post['acount'] . ' ans</span>';
                    } elseif ($post_type == 'A') {
                        $output .= ' <span class="vote-count">' . $post['netvotes'] . ' votes</span>';
                    }
                    $output .= '</div></div>';
                    $output .= '</li>';
                }
                $output .= '</ul>';
                if ($return) {
                    return $output;
                }
                echo $output;
                return;
            }
        } else {
            return;
        }
        $output = '<h3 class="widget-title">' . $title . '</h3>';
        $output .= '<ul class="question-list">';
        foreach ($posts as $p) {
            if (empty($p['userid'])) {
                $p['userid'] = NULL;
            }
            // to prevent error for anonymous posts while calling qa_post_userid_to_handle()
            if ($post_type == 'Q') {
                $what = qa_lang_html('cleanstrap/asked');
            } elseif ($post_type == 'A') {
                $what = qa_lang_html('cleanstrap/answered');
            } elseif ('C') {
                $what = qa_lang_html('cleanstrap/commented');
            }
            $handle = qa_post_userid_to_handle($p['userid']);
            $avatar = cs_get_avatar($handle, 35, false);
            $output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">';
            $output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . qa_handle_to_userid($handle) . '">' . (isset($avatar) ? '<img src="' . $avatar . '" />' : '') . '</div>';
            $output .= '<div class="list-right">';
            if ($post_type == 'Q') {
                $output .= '<a class="title" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . cs_truncate(qa_html($p['title']), 70) . '</a>';
            } elseif ($post_type == 'A') {
                $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>';
            } else {
                $output .= '<p><a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 70) . '</a></p>';
            }
            $output .= '<div class="meta"><a href="' . qa_path_html('user/' . $handle) . '">' . cs_name($handle) . '</a> ' . $what;
            if ($post_type == 'Q') {
                $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>';
                $output .= ' <span class="ans-count">' . $p['acount'] . ' ans</span>';
            } elseif ($post_type == 'A') {
                $output .= ' <span class="vote-count">' . $p['netvotes'] . ' votes</span>';
            }
            $output .= '</div></div>';
            $output .= '</li>';
        }
        $output .= '</ul>';
        if ($return) {
            return $output;
        }
        echo $output;
    }
Beispiel #15
0
 $inname = qa_post_text('name');
 $inposition = qa_post_text('position');
 $inpermit = (int) qa_post_text('permit');
 $inurl = qa_post_text('url');
 $innewwindow = qa_post_text('newwindow');
 $inheading = qa_post_text('heading');
 $incontent = qa_post_text('content');
 $errors = array();
 //	Verify the name (navigation link) is legitimate
 if (empty($inname)) {
     $errors['name'] = qa_lang('main/field_required');
 } elseif (qa_strlen($inname) > QA_DB_MAX_CAT_PAGE_TITLE_LENGTH) {
     $errors['name'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TITLE_LENGTH);
 } else {
     foreach ($pages as $page) {
         if ($page['pageid'] != @$editpage['pageid'] && qa_strtolower($page['title']) == qa_strtolower($inname)) {
             $errors['name'] = qa_lang('admin/page_already_used');
         }
     }
 }
 if ($isexternal) {
     //	Verify the url is legitimate (vaguely)
     if (empty($inurl)) {
         $errors['url'] = qa_lang('main/field_required');
     } elseif (qa_strlen($inurl) > QA_DB_MAX_CAT_PAGE_TAGS_LENGTH) {
         $errors['url'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TAGS_LENGTH);
     }
 } else {
     //	Verify the heading is legitimate
     if (qa_strlen($inheading) > QA_DB_MAX_TITLE_LENGTH) {
         $errors['heading'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_TITLE_LENGTH);
        $htmloptions['flagsview'] = true;
        $htmloptions['elementid'] = $elementid;
        $htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions);
        if (isset($htmlfields['what_url'])) {
            // link directly to relevant content
            $htmlfields['url'] = $htmlfields['what_url'];
        }
        $htmlfields['what_2'] = qa_lang_html('main/hidden');
        if (@$htmloptions['whenview']) {
            $updated = @$question[isset($question['opostid']) ? 'oupdated' : 'updated'];
            if (isset($updated)) {
                $htmlfields['when_2'] = qa_when_to_html($updated, @$htmloptions['fulldatedays']);
            }
        }
        $buttons = array();
        $posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']);
        if (!qa_user_post_permit_error('permit_hide_show', $question)) {
            // Possible values for popup: reshow_q_popup, reshow_a_popup, reshow_c_popup
            $buttons['reshow'] = array('tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_reshow" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('question/reshow_button'), 'popup' => qa_lang_html(sprintf('question/reshow_%s_popup', $posttype)));
        }
        if (!qa_user_post_permit_error('permit_delete_hidden', $question) && !$dependcounts[$qhiddenpostid[$key]]) {
            // Possible values for popup: delete_q_popup, delete_a_popup, delete_c_popup
            $buttons['delete'] = array('tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_delete" onclick="return qa_admin_click(this);"', 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html(sprintf('question/delete_%s_popup', $posttype)));
        }
        if (count($buttons)) {
            $htmlfields['form'] = array('style' => 'light', 'buttons' => $buttons);
        }
        $qa_content['q_list']['qs'][] = $htmlfields;
    }
} else {
    $qa_content['title'] = qa_lang_html('admin/no_hidden_found');
Beispiel #17
0
function qa_handles_to_userids($handles, $exactonly = false)
{
    require_once QA_INCLUDE_DIR . 'util/string.php';
    if (QA_FINAL_EXTERNAL_USERS) {
        $rawhandleuserids = qa_get_userids_from_public($handles);
    } else {
        require_once QA_INCLUDE_DIR . 'db/users.php';
        $rawhandleuserids = qa_db_user_get_handle_userids($handles);
    }
    $gothandleuserids = array();
    if ($exactonly) {
        // only take the exact matches
        foreach ($handles as $handle) {
            $gothandleuserids[$handle] = @$rawhandleuserids[$handle];
        }
    } else {
        // normalize to lowercase without accents, and then find matches
        $normhandleuserids = array();
        foreach ($rawhandleuserids as $handle => $userid) {
            $normhandleuserids[qa_string_remove_accents(qa_strtolower($handle))] = $userid;
        }
        foreach ($handles as $handle) {
            $gothandleuserids[$handle] = @$normhandleuserids[qa_string_remove_accents(qa_strtolower($handle))];
        }
    }
    return $gothandleuserids;
}
function qa_db_tag_recent_qs_selectspec($voteuserid, $tag, $start, $full = false, $count = null)
{
    $count = isset($count) ? min($count, QA_DB_RETRIEVE_QS_AS) : QA_DB_RETRIEVE_QS_AS;
    require_once QA_INCLUDE_DIR . 'qa-util-string.php';
    $selectspec = qa_db_posts_basic_selectspec($voteuserid, $full);
    // use two tests here - one which can use the index, and the other which narrows it down exactly - then limit to 1 just in case
    $selectspec['source'] .= " JOIN (SELECT postid FROM ^posttags WHERE wordid=(SELECT wordid FROM ^words WHERE word=\$ AND word=\$ COLLATE utf8_bin LIMIT 1) ORDER BY postcreated DESC LIMIT #,#) y ON ^posts.postid=y.postid";
    array_push($selectspec['arguments'], $tag, qa_strtolower($tag), $start, $count);
    $selectspec['sortdesc'] = 'created';
    return $selectspec;
}