本文整理汇总了PHP中qa_get_userids_from_public函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_get_userids_from_public函数的具体用法?PHP qa_get_userids_from_public怎么用?PHP qa_get_userids_from_public使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_get_userids_from_public函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getuserfromhandle
function getuserfromhandle($handle)
{
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
if (QA_FINAL_EXTERNAL_USERS) {
$publictouserid = qa_get_userids_from_public(array($handle));
$userid = @$publictouserid[$handle];
} else {
$userid = qa_db_read_one_value(qa_db_query_sub('SELECT userid FROM ^users WHERE handle = $', $handle), true);
}
return $userid;
}
示例2: qa_handle_to_userid
function qa_handle_to_userid($handle)
{
if (QA_FINAL_EXTERNAL_USERS) {
$handleuserids = qa_get_userids_from_public(array($handle));
} else {
require_once QA_INCLUDE_DIR . 'db/users.php';
$handleuserids = qa_db_user_get_handle_userids(array($handle));
}
if (count($handleuserids) == 1) {
return reset($handleuserids);
}
// don't use $handleuserids[$handle] since capitalization might be different
return null;
}
示例3: header
if (!defined('QA_VERSION')) {
// don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
$handle = qa_request_part(1);
if (!strlen($handle)) {
qa_redirect('users');
}
// Get the HTML to display for the handle, and if we're using external users, determine the userid
if (QA_FINAL_EXTERNAL_USERS) {
$publictouserid = qa_get_userids_from_public(array($handle));
if (!count($publictouserid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
$userid = reset($publictouserid);
// don't use $publictouserid[$handle] since $handle capitalization might be different
$usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true);
$userhtml = @$usershtml[$userid];
} else {
$userhtml = qa_html($handle);
}
// Find the user profile and questions and answers for this handle
$loginuserid = qa_get_logged_in_userid();
$identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
@(list($useraccount, $userprofile, $userfields, $userpoints, $userrank, $questions, $answerqs, $commentqs, $editqs, $favorite) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(), qa_db_user_points_selectspec($identifier), qa_db_user_rank_selectspec($identifier), qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_user_posts')), qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_c_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_edit_qs_selectspec($loginuserid, $identifier), isset($loginuserid) && !QA_FINAL_EXTERNAL_USERS ? qa_db_is_favorite_selectspec($loginuserid, QA_ENTITY_USER, $handle) : null));
// Check the user exists and work out what can and can't be set (if not using single sign-on)
示例4: qa_db_search_posts_selectspec
function qa_db_search_posts_selectspec($voteuserid, $titlewords, $contentwords, $tagwords, $handlewords, $handle, $start, $full = false, $count = null)
{
$count = isset($count) ? min($count, QA_DB_RETRIEVE_QS_AS) : QA_DB_RETRIEVE_QS_AS;
// add LOG(postid)/1000000 here to ensure ordering is deterministic even if several posts have same score
// The score also gives a bonus for hot questions, where the bonus scales linearly with hotness. The hottest
// question gets a bonus equivalent to a matching unique tag, and the least hot question gets zero bonus.
$selectspec = qa_db_posts_basic_selectspec($voteuserid, $full);
$selectspec['columns'][] = 'score';
$selectspec['columns'][] = 'matchparts';
$selectspec['source'] .= " JOIN (SELECT questionid, SUM(score)+2*(LOG(#)*(^posts.hotness-(SELECT MIN(hotness) FROM ^posts WHERE type='Q'))/((SELECT MAX(hotness) FROM ^posts WHERE type='Q')-(SELECT MIN(hotness) FROM ^posts WHERE type='Q')))+LOG(questionid)/1000000 AS score, GROUP_CONCAT(CONCAT_WS(':', matchposttype, matchpostid, ROUND(score,3))) AS matchparts FROM (";
$selectspec['sortdesc'] = 'score';
array_push($selectspec['arguments'], QA_IGNORED_WORDS_FREQ);
$selectparts = 0;
if (!empty($titlewords)) {
// At the indexing stage, duplicate words in title are ignored, so this doesn't count multiple appearances.
$selectspec['source'] .= ($selectparts++ ? " UNION ALL " : "") . "(SELECT postid AS questionid, LOG(#/titlecount) AS score, 'Q' AS matchposttype, postid AS matchpostid FROM ^titlewords JOIN ^words ON ^titlewords.wordid=^words.wordid WHERE word IN (\$) AND titlecount<#)";
array_push($selectspec['arguments'], QA_IGNORED_WORDS_FREQ, $titlewords, QA_IGNORED_WORDS_FREQ);
}
if (!empty($contentwords)) {
// (1-1/(1+count)) weights words in content based on their frequency: If a word appears once in content
// it's equivalent to 1/2 an appearance in the title (ignoring the contentcount/titlecount factor).
// If it appears an infinite number of times, it's equivalent to one appearance in the title.
// This will discourage keyword stuffing while still giving some weight to multiple appearances.
// On top of that, answer matches are worth half a question match, and comment/note matches half again.
$selectspec['source'] .= ($selectparts++ ? " UNION ALL " : "") . "(SELECT questionid, (1-1/(1+count))*LOG(#/contentcount)*(CASE ^contentwords.type WHEN 'Q' THEN 1.0 WHEN 'A' THEN 0.5 ELSE 0.25 END) AS score, ^contentwords.type AS matchposttype, ^contentwords.postid AS matchpostid FROM ^contentwords JOIN ^words ON ^contentwords.wordid=^words.wordid WHERE word IN (\$) AND contentcount<#)";
array_push($selectspec['arguments'], QA_IGNORED_WORDS_FREQ, $contentwords, QA_IGNORED_WORDS_FREQ);
}
if (!empty($tagwords)) {
// Appearances in the tag words count like 2 appearances in the title (ignoring the tagcount/titlecount factor).
// This is because tags express explicit semantic intent, whereas titles do not necessarily.
$selectspec['source'] .= ($selectparts++ ? " UNION ALL " : "") . "(SELECT postid AS questionid, 2*LOG(#/tagwordcount) AS score, 'Q' AS matchposttype, postid AS matchpostid FROM ^tagwords JOIN ^words ON ^tagwords.wordid=^words.wordid WHERE word IN (\$) AND tagwordcount<#)";
array_push($selectspec['arguments'], QA_IGNORED_WORDS_FREQ, $tagwords, QA_IGNORED_WORDS_FREQ);
}
if (!empty($handlewords)) {
if (QA_FINAL_EXTERNAL_USERS) {
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
$userids = qa_get_userids_from_public($handlewords);
if (count($userids)) {
$selectspec['source'] .= ($selectparts++ ? " UNION ALL " : "") . "(SELECT postid AS questionid, LOG(#/qposts) AS score, 'Q' AS matchposttype, postid AS matchpostid FROM ^posts JOIN ^userpoints ON ^posts.userid=^userpoints.userid WHERE ^posts.userid IN (\$) AND type='Q')";
array_push($selectspec['arguments'], QA_IGNORED_WORDS_FREQ, $userids);
}
} else {
$selectspec['source'] .= ($selectparts++ ? " UNION ALL " : "") . "(SELECT postid AS questionid, LOG(#/qposts) AS score, 'Q' AS matchposttype, postid AS matchpostid FROM ^posts JOIN ^users ON ^posts.userid=^users.userid JOIN ^userpoints ON ^userpoints.userid=^users.userid WHERE handle IN (\$) AND type='Q')";
array_push($selectspec['arguments'], QA_IGNORED_WORDS_FREQ, $handlewords);
}
}
if (strlen($handle)) {
// to allow searching for multi-word usernames (only works if search query contains full username and nothing else)
if (QA_FINAL_EXTERNAL_USERS) {
$userids = qa_get_userids_from_public(array($handle));
if (count($userids)) {
$selectspec['source'] .= ($selectparts++ ? " UNION ALL " : "") . "(SELECT postid AS questionid, LOG(#/qposts) AS score, 'Q' AS matchposttype, postid AS matchpostid FROM ^posts JOIN ^userpoints ON ^posts.userid=^userpoints.userid WHERE ^posts.userid=\$ AND type='Q')";
array_push($selectspec['arguments'], QA_IGNORED_WORDS_FREQ, reset($userids));
}
} else {
$selectspec['source'] .= ($selectparts++ ? " UNION ALL " : "") . "(SELECT postid AS questionid, LOG(#/qposts) AS score, 'Q' AS matchposttype, postid AS matchpostid FROM ^posts JOIN ^users ON ^posts.userid=^users.userid JOIN ^userpoints ON ^userpoints.userid=^users.userid WHERE handle=\$ AND type='Q')";
array_push($selectspec['arguments'], QA_IGNORED_WORDS_FREQ, $handle);
}
}
if ($selectparts == 0) {
$selectspec['source'] .= '(SELECT NULL as questionid, 0 AS score, NULL AS matchposttype, NULL AS matchpostid FROM ^posts WHERE postid IS NULL)';
}
$selectspec['source'] .= ") x LEFT JOIN ^posts ON ^posts.postid=questionid GROUP BY questionid ORDER BY score DESC LIMIT #,#) y ON ^posts.postid=y.questionid";
array_push($selectspec['arguments'], $start, $count);
return $selectspec;
}
示例5: qa_handles_to_userids
function qa_handles_to_userids($handles, $exactonly = false)
{
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
if (QA_FINAL_EXTERNAL_USERS) {
$rawhandleuserids = qa_get_userids_from_public($handles);
} else {
require_once QA_INCLUDE_DIR . 'qa-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;
}
示例6: header
*/
if (!defined('QA_VERSION')) {
// don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
// report that we entered this page
qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'], 'path' => $_SERVER['SCRIPT_NAME']));
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
if (!strlen(@$pass_subrequests[0])) {
qa_redirect('users');
}
if (QA_FINAL_EXTERNAL_USERS) {
$publictouserid = qa_get_userids_from_public(array(@$pass_subrequests[0]));
$userid = @$publictouserid[@$pass_subrequests[0]];
if (!isset($userid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
$usershtml = qa_get_users_html(array($userid), false, $qa_root_url_relative, true);
$userhtml = @$usershtml[$userid];
} else {
$handle = @$pass_subrequests[0];
// picked up from qa-page.php
$userhtml = qa_html($handle);
}
// Find the user profile and questions and answers for this handle
$identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
@(list($useraccount, $userprofile, $userfields, $userpoints, $userrank, $questions, $answerquestions, $commentquestions) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(), qa_db_user_points_selectspec($identifier), qa_db_user_rank_selectspec($identifier), qa_db_user_recent_qs_selectspec($qa_login_userid, $identifier), qa_db_user_recent_a_qs_selectspec($qa_login_userid, $identifier), qa_db_user_recent_c_qs_selectspec($qa_login_userid, $identifier)));
// Check the user exists and work out what can and can't be set (if not using single sign-on)
示例7: getuserfromhandle
function getuserfromhandle($handle)
{
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
$publictouserid = qa_get_userids_from_public(array($handle));
$userid = @$publictouserid[$handle];
if (!isset($userid)) {
return;
}
return $userid;
}