本文整理汇总了PHP中qa_db_read_one_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_db_read_one_assoc函数的具体用法?PHP qa_db_read_one_assoc怎么用?PHP qa_db_read_one_assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_db_read_one_assoc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: AddCategoryToPost
function AddCategoryToPost($params, $category)
{
require_once QA_INCLUDE_DIR . 'qa-db-post-update.php';
$postid = $params['postid'];
$result = qa_db_read_one_assoc(qa_db_query_sub('SELECT categoryid,parentid,tags,title,content,qcount,position,backpath FROM ^categories WHERE title=$', $category), true);
if (empty($result)) {
//create category
$tags = str_replace(' ', '-', $category);
$catID = $this->CreatCategory($category, $tags);
qa_db_post_set_category($postid, $catID, null, null);
qa_db_posts_calc_category_path($postid);
$path = qa_db_post_get_category_path($postid);
qa_db_category_path_qcount_update($path);
} else {
// update category
$oldpath = qa_db_post_get_category_path($postid);
$tags = $result['tags'];
$catID = $result['categoryid'];
qa_db_post_set_category($postid, $catID, null, null);
qa_db_posts_calc_category_path($postid);
$path = qa_db_post_get_category_path($postid);
qa_db_category_path_qcount_update($oldpath);
qa_db_category_path_qcount_update($path);
}
}
开发者ID:swuit,项目名称:swuit-q2a,代码行数:25,代码来源:it-event.php
示例2: process_request
function process_request($request)
{
// double check we are admin
if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
return;
}
if (qa_clicked('docancel')) {
qa_redirect('admin/plugins');
}
$qa_content = qa_content_prepare();
$qa_content['title'] = 'Widget Anywhere';
$qa_content['custom'] = '<p><a href="' . qa_path('admin/plugins') . '#' . qa_html($this->anchor) . '">« back to plugin options</a></p>';
$saved_msg = null;
$editid = qa_get('editid');
if (qa_post_text('dodelete')) {
$this->delete_widget();
qa_redirect('admin/plugins');
} else {
if (qa_clicked('save_button')) {
// save widget
$widget = $this->save_widget();
$saved_msg = 'Widget saved.';
} else {
if (empty($editid)) {
// display blank form
$widget = array('id' => 0, 'title' => '', 'pages' => '', 'position' => '', 'ordering' => 1, 'content' => '');
} else {
// load specified widget
$sql = 'SELECT * FROM ^' . $this->pluginkey . ' WHERE id=#';
$result = qa_db_query_sub($sql, $editid);
$widget = qa_db_read_one_assoc($result);
}
}
}
$sel_position = empty($widget['position']) ? null : @$this->positionlangs[$widget['position']];
// set up page (template) list
$widget_pages = explode(',', $widget['pages']);
$sel_pages = array();
$custom_pages = array();
foreach ($widget_pages as $page) {
if (strpos($page, 'custom:') === 0) {
$custom_pages[] = substr($page, 7);
} else {
$sel_pages[] = $page;
}
}
// $chkd = in_array('all', $sel_pages) ? 'checked' : '';
// $pages_html = '<label><input type="checkbox" name="wpages_all" ' . $chkd . '> ' . qa_lang_html('admin/widget_all_pages') . '</label><br><br>';
$pages_html = '';
foreach ($this->templatelangkeys as $tmpl => $langkey) {
$chkd = in_array($tmpl, $sel_pages) ? 'checked' : '';
$pages_html .= '<label><input type="checkbox" name="wpages_' . $tmpl . '" ' . $chkd . '> ' . qa_lang_html($langkey) . '</label><br>';
}
$qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'ok' => $saved_msg, 'fields' => array('title' => array('label' => 'Title', 'tags' => 'NAME="wtitle"', 'value' => qa_html($widget['title'])), 'position' => array('type' => 'select', 'label' => 'Position', 'tags' => 'NAME="wposition"', 'options' => $this->positionlangs, 'value' => $sel_position), 'all_pages' => array('type' => 'checkbox', 'id' => 'tb_pages_all', 'label' => qa_lang_html('admin/widget_all_pages'), 'tags' => 'NAME="wpages_all" ID="wpages_all"', 'value' => in_array('all', $sel_pages)), 'pages' => array('type' => 'custom', 'id' => 'tb_pages_list', 'label' => qa_lang_html('admin/widget_pages_explanation'), 'html' => $pages_html), 'show_custom_pages' => array('type' => 'checkbox', 'id' => 'tb_show_custom_pages', 'label' => 'Show on custom page(s)', 'tags' => 'NAME="cb_custom_pages" ID="cb_custom_pages"', 'value' => count($custom_pages) > 0), 'custom_pages' => array('id' => 'tb_custom_pages', 'label' => 'Page slugs', 'tags' => 'NAME="wpages_custom"', 'value' => qa_html(implode(',', $custom_pages)), 'note' => 'Separate multiple page slugs (URL fragments) with commas, e.g. <code>custom-page,other-page</code>'), 'ordering' => array('type' => 'number', 'label' => 'Order', 'tags' => 'NAME="wordering"', 'value' => qa_html($widget['ordering'])), 'content' => array('type' => 'textarea', 'label' => 'Content (HTML)', 'tags' => 'NAME="wcontent"', 'value' => qa_html($widget['content']), 'rows' => 12)), 'hidden' => array('wid' => $widget['id']), 'buttons' => array('save' => array('tags' => 'NAME="save_button"', 'label' => 'Save widget', 'value' => '1'), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))));
if ($widget['id'] > 0) {
$qa_content['form']['fields']['delete'] = array('tags' => 'NAME="dodelete"', 'label' => 'Delete widget', 'value' => 0, 'type' => 'checkbox');
}
qa_set_display_rules($qa_content, array('tb_pages_list' => '!wpages_all', 'tb_show_custom_pages' => '!wpages_all', 'tb_custom_pages' => 'cb_custom_pages && !wpages_all'));
return $qa_content;
}
开发者ID:siddiquinoor,项目名称:q2a-widget-anywhere,代码行数:60,代码来源:qa-widget-anywhere.php
示例3: process_request
public function process_request($request)
{
require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
// smiley replacement regexes
$rxSearch = '<(img|a)([^>]+)(src|href)="([^"]+)/wysiwyg-editor/plugins/smiley/images/([^"]+)"';
$rxReplace = '<$1$2$3="$4/wysiwyg-editor/ckeditor/plugins/smiley/images/$5"';
qa_suspend_event_reports(true);
// avoid infinite loop
// prevent race conditions
$locks = array('posts', 'categories', 'users', 'users AS lastusers', 'userpoints', 'words', 'titlewords', 'contentwords', 'tagwords', 'words AS x', 'posttags', 'options');
foreach ($locks as &$tbl) {
$tbl = '^' . $tbl . ' WRITE';
}
qa_db_query_sub('LOCK TABLES ' . implode(',', $locks));
$sql = 'SELECT postid, title, content FROM ^posts WHERE format="html" ' . 'AND content LIKE "%/wysiwyg-editor/plugins/smiley/images/%" ' . 'AND content RLIKE \'' . $rxSearch . '\' ' . 'LIMIT 5';
$result = qa_db_query_sub($sql);
$numPosts = 0;
while (($post = qa_db_read_one_assoc($result, true)) !== null) {
$newcontent = preg_replace("#{$rxSearch}#", $rxReplace, $post['content']);
qa_post_set_content($post['postid'], $post['title'], $newcontent);
$numPosts++;
}
qa_db_query_raw('UNLOCK TABLES');
qa_suspend_event_reports(false);
echo $numPosts;
}
开发者ID:swuit,项目名称:swuit-q2a,代码行数:26,代码来源:qa-wysiwyg-ajax.php
示例4: qa_priv_notification
function qa_priv_notification($uid, $oid, $badge_slug)
{
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
if (QA_FINAL_EXTERNAL_USERS) {
$publictohandle = qa_get_public_from_userids(array($uid));
$handle = @$publictohandle[$uid];
} else {
$user = qa_db_single_select(qa_db_user_account_selectspec($uid, true));
$handle = @$user['handle'];
}
$subject = qa_opt('badge_email_subject');
$body = qa_opt('badge_email_body');
$body = preg_replace('/\\^if_post_text="([^"]*)"/', $oid ? '$1' : '', $body);
// if post text
$site_url = qa_opt('site_url');
$profile_url = qa_path_html('user/' . $handle, null, $site_url);
if ($oid) {
$post = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $oid), true);
if ($post['parentid']) {
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $post['parentid']), true);
}
if (isset($parent)) {
$anchor = urlencode(qa_anchor($post['basetype'], $oid));
$post_title = $parent['title'];
$post_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
} else {
$post_title = $post['title'];
$post_url = qa_path_html(qa_q_request($post['postid'], $post['title']), null, qa_opt('site_url'));
}
}
$subs = array('^badge_name' => qa_opt('badge_' . $badge_slug . '_name'), '^post_title' => @$post_title, '^post_url' => @$post_url, '^profile_url' => $profile_url, '^site_url' => $site_url);
qa_send_notification($uid, '@', $handle, $subject, $body, $subs);
}
开发者ID:NoahY,项目名称:q2a-privileges,代码行数:34,代码来源:qa-plugin.php
示例5: mp_get_categoryinfo
function mp_get_categoryinfo($categoryid)
{
/*
* Returns all the information for $categoryid
*
*/
return qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^categories WHERE categoryid = #', $categoryid), true);
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:8,代码来源:mp-db-users.php
示例6: qa_db_blob_read
function qa_db_blob_read($blobid)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
return qa_db_read_one_assoc(qa_db_query_sub('SELECT content, format, filename FROM ^blobs WHERE blobid=#', $blobid), true);
}
开发者ID:netham91,项目名称:question2answer,代码行数:8,代码来源:qa-db-blobs.php
示例7: custom_badges_rebuild
function custom_badges_rebuild()
{
$awarded = 0;
$userq = qa_db_query_sub('SELECT user_id, meta_value FROM ^usermeta WHERE meta_key=$', 'max_bookmarks');
while (($user = qa_db_read_one_assoc($userq, true)) !== null) {
$badges = array('bookmarker', 'bookkeeper', 'bookworm');
$awarded += count(qa_badge_award_check($badges, (int) $user['meta_value'], $user['user_id'], null, 2));
}
return $awarded;
}
开发者ID:NoahY,项目名称:q2a-bookmarks,代码行数:10,代码来源:qa-bookmarks-admin.php
示例8: custom_badges_rebuild
function custom_badges_rebuild()
{
$awarded = 0;
$posts = qa_db_query_sub('SELECT userid, postid, netvotes FROM ^posts WHERE type=$ AND netvotes>0', 'C');
while (($post = qa_db_read_one_assoc($posts, true)) !== null) {
$badges = array('nice_comment', 'good_comment', 'excellent_comment');
$awarded += count(qa_badge_award_check($badges, (int) $post['netvotes'], $post['userid'], $post['postid'], 2));
}
return $awarded;
}
开发者ID:neil-zeng,项目名称:q2a-comment-voting,代码行数:10,代码来源:qa-comment-voting-admin.php
示例9: mp_get_contribution_points_by_userid
function mp_get_contribution_points_by_userid($userid, $categoryid)
{
// retrieve raw points data
$Qpoints = qa_db_read_one_assoc(qa_db_query_sub('SELECT 500 * COUNT(P.postid) points, 100 * COALESCE(SUM(P.upvotes),0) upvotes, 100 * COALESCE(SUM(P.downvotes),0) downvotes
FROM ^posts P
WHERE type = "Q" and categoryid = # and userid = #', $categoryid, $userid));
$Apoints = qa_db_read_one_assoc(qa_db_query_sub('SELECT 500 * COUNT(P.postid) points, 100 * COALESCE(SUM(P.upvotes),0) upvotes, 100 * COALESCE(SUM(P.downvotes),0) downvotes
FROM ^posts P
WHERE type = "A" AND categoryid = # AND userid = #', $categoryid, $userid));
return $Apoints['points'] + $Apoints['upvotes'] - $Apoints['downvotes'];
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:11,代码来源:mp-db-points.php
示例10: getUsername
/**
*通过用户的id找到提问者的用户名
*/
function getUsername($userid)
{
$query = "SELECT * FROM ^users WHERE userid=\$";
$arr = qa_db_query_sub($query, $userid);
$result = qa_db_read_one_assoc($arr);
if (count($result)) {
return $result['handle'];
} else {
return null;
}
}
开发者ID:GitFuture,项目名称:bmf,代码行数:14,代码来源:qa_base.php
示例11: qa_db_category_child_depth
function qa_db_category_child_depth($categoryid)
{
// This is potentially a very slow query since it counts all the multi-generational offspring of a particular category
// But it's only used for admin purposes when moving a category around so I don't think it's worth making more efficient
// (Incidentally, this could be done by keeping a count for every category of how many generations of offspring it has.)
$result = qa_db_read_one_assoc(qa_db_query_sub('SELECT COUNT(child1.categoryid) AS count1, COUNT(child2.categoryid) AS count2, COUNT(child3.categoryid) AS count3 FROM ^categories AS child1 LEFT JOIN ^categories AS child2 ON child2.parentid=child1.categoryid LEFT JOIN ^categories AS child3 ON child3.parentid=child2.categoryid WHERE child1.parentid=#;', $categoryid));
for ($depth = QA_CATEGORY_DEPTH - 1; $depth >= 1; $depth--) {
if ($result['count' . $depth]) {
return $depth;
}
}
return 0;
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:13,代码来源:qa-db-admin.php
示例12: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
$temp = qa_db_query_sub('SELECT BINARY title as title, postid, netvotes, acount FROM ^posts WHERE type=$', 'Q');
$max = mysqli_num_rows($temp);
if (!$max) {
return;
}
$themeobject->output('<h2>' . qa_opt('random_question_title') . '</h2>');
for ($i = 0; $i < qa_opt('random_question_number'); $i++) {
$rand = rand() / getrandmax() * $max;
$check = mysqli_data_seek($temp, $rand);
if (!$check) {
$i--;
} else {
$random_question = qa_db_read_one_assoc($temp, true);
}
if (is_array($random_question)) {
$votes = (int) $random_question['netvotes'];
if ($votes > 0) {
if ($votes > 1) {
$votes = str_replace('^', '+' . $votes, qa_lang('main/x_votes'));
} else {
$votes = str_replace('1', '+1', qa_lang('main/1_vote'));
}
} else {
if ($votes < 0) {
if ($votes < -1) {
$votes = str_replace('^', $votes, qa_lang('main/x_votes'));
} else {
$votes = str_replace('1', '-1', qa_lang('main/1_vote'));
}
} else {
$votes = '';
}
}
$answers = (int) $random_question['acount'];
if ($answers > 0) {
if ($answers > 1) {
$answers = str_replace('^', '+' . $answers, qa_lang('main/x_answers'));
} else {
$answers = qa_lang('main/1_answer');
}
} else {
$answers = '';
}
$themeobject->output('<div class="random-question" style="padding-bottom:4px;"><a href="' . qa_path_html(qa_q_request($random_question['postid'], $random_question['title'])) . '">' . $random_question['title'] . '</a></div><div class="random-question-meta" style="padding-bottom:4px; border-bottom:1px solid; margin-bottom:2px;">' . $votes . ($votes && $answers ? ', ' : '') . $answers . '</div>');
}
}
}
开发者ID:luchenn,项目名称:qa-random-question,代码行数:49,代码来源:qa-random-question.php
示例13: sendEmail
function sendEmail($event, $userid, $handle, $params)
{
$email = $this->getEmail($userid);
if ($email == qa_opt('feedback_email')) {
return;
}
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $params['parentid']), true);
if ($parent['type'] == 'A') {
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $parent['parentid']), true);
}
$url = qa_q_path($parent['postid'], $parent['title'], true, $event == 'a_post' ? 'A' : 'C', $params['postid']);
$title = $parent['title'];
$type = $event == 'a_post' ? 'answer' : 'comment';
$subs = array();
qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('admin_plus/posted_subject'), qa_lang('admin_plus/posted_body'), array('^post_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^post_type' => $type, '^post_title' => $title, '^post_content' => $params['content'], '^site_url' => qa_opt('site_url'), '^url' => $url));
}
开发者ID:NoahY,项目名称:q2a-admin-plus,代码行数:16,代码来源:qa-admin-check.php
示例14: doctype
function doctype()
{
if (@$this->content['error'] == qa_lang_html('main/page_not_found') && preg_match('/^[0-9]+\\//', $this->request) !== false) {
$pid = preg_replace('/\\/.*/', '', $this->request);
$merged = qa_db_read_one_assoc(qa_db_query_sub("SELECT ^posts.postid as postid,^posts.title as title FROM ^postmeta, ^posts WHERE ^postmeta.meta_key='merged_with' AND ^postmeta.post_id=# AND ^posts.postid=^postmeta.meta_value", $pid), true);
if ($merged) {
qa_redirect(qa_q_request($merged['postid'], $merged['title']), array('merged' => $pid));
}
} else {
if (qa_get('merged')) {
$this->content['error'] = str_replace('^post', qa_get('merged'), qa_opt('merge_question_merged'));
}
}
if (qa_post_text('ajax_merge_get_from')) {
return;
}
qa_html_theme_base::doctype();
}
开发者ID:NoahY,项目名称:q2a-post-merge,代码行数:18,代码来源:qa-merge-layer.php
示例15: get_next_q
function get_next_q()
{
$myurl = $this->request;
$myurlpieces = explode("/", $myurl);
$myurl = $myurlpieces[0];
if (is_numeric($myurl)) {
$query_n = "SELECT ^posts.*,^categories.position\n\tFROM ^posts INNER JOIN ^categories ON ^posts.categoryid = ^categories.categoryid\n\tWHERE postid = {$myurl}\n\tAND type='Q'\n\tLIMIT 1";
$current_q = qa_db_query_sub($query_n);
while ($current_link = qa_db_read_one_assoc($current_q, true)) {
$categoryid = $current_link['categoryid'];
$categoryposition = $current_link['position'];
}
$combinedid = $categoryposition * 1000000 - $myurl;
$query_n = "SELECT ^posts.* \n\tFROM ^posts INNER JOIN ^categories ON ^posts.categoryid = ^categories.categoryid\n\tWHERE position*1000000-postid > {$combinedid} \n\tAND type='Q'\n\tORDER BY position*1000000-postid ASC\n\tLIMIT 1";
$next_q = qa_db_query_sub($query_n);
while ($next_link = qa_db_read_one_assoc($next_q, true)) {
$title = $next_link['title'];
$pid = $next_link['postid'];
$this->output('
<A HREF="' . qa_q_path_html($pid, $title) . '" title="' . $title . '" STYLE="float:right;padding-right:20px">Next Action <img style="border:0px;width:50px" src="../qa-theme/GreenTheme-CATO/next.png"/></A>', '');
}
}
}
开发者ID:ruuttt,项目名称:question2answer,代码行数:23,代码来源:qa-theme.php
示例16: init_page
/**
* save category meta data if category is updated
*/
function init_page()
{
if (qa_clicked('dosavecategory') && !qa_clicked('docancel')) {
require_once QA_INCLUDE_DIR . 'qa-db-metas.php';
$categoryid = qa_post_text('edit');
if (!empty($categoryid)) {
// update admin/category form to save form's category meta data
$et_category['et_cat_title'] = qa_post_text('et_category_link_title');
if (!isset($et_category['et_cat_title'])) {
$et_category['et_cat_title'] = '';
}
$et_category['et_cat_desc'] = qa_post_text('et_category_description');
if (!isset($et_category['et_cat_desc'])) {
$et_category['et_cat_desc'] = '';
}
$et_category['et_cat_icon48'] = qa_post_text('et_category_icon_48');
if (!isset($et_category['et_cat_icon48'])) {
$et_category['et_cat_icon48'] = '';
}
$et_category['et_cat_icon64'] = qa_post_text('et_category_icon_64');
if (!isset($et_category['et_cat_icon64'])) {
$et_category['et_cat_icon64'] = '';
}
qa_db_categorymeta_set($categoryid, 'et_category', json_encode($et_category));
}
}
// when loading question page after edit if category is updated, Q2A will attempt to Re-Update question category based on "q_category_X" field.
// this happens when category already exists, and we attempt to change it while editing question.
// here we will set category id to "q_category_1" field, so it wont change it to null after question is updated
$questionid = qa_request_part(0);
$num_questionid = (int) $questionid;
if (qa_clicked('q_dosave') && $questionid == $num_questionid) {
$result = qa_db_read_one_assoc(qa_db_query_sub('SELECT categoryid FROM ^posts WHERE postid=$', $num_questionid), true);
$_POST['q_category_1'] = $result['categoryid'];
}
}
开发者ID:swuit,项目名称:swuit-q2a,代码行数:39,代码来源:it-process.php
示例17: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
if (!qa_opt('event_logger_to_database')) {
return;
}
$badges = qa_db_query_sub('SELECT event,handle,params, UNIX_TIMESTAMP(datetime) AS datetime FROM ^eventlog WHERE event=$' . (qa_opt('badge_widget_date_max') ? ' AND DATE_SUB(CURDATE(),INTERVAL ' . (int) qa_opt('badge_widget_date_max') . ' DAY) <= datetime' : '') . ' ORDER BY datetime DESC' . (qa_opt('badge_widget_list_max') ? ' LIMIT ' . (int) qa_opt('badge_widget_list_max') : ''), 'badge_awarded');
$first = true;
while (($badge = qa_db_read_one_assoc($badges, true)) !== null) {
$params = array();
$paramsa = explode("\t", $badge['params']);
foreach ($paramsa as $param) {
$parama = explode('=', $param);
$params[$parama[0]] = $parama[1];
}
$slug = $params['badge_slug'];
$typea = qa_get_badge_type_by_slug($slug);
if (!$typea) {
continue;
}
$types = $typea['slug'];
$typed = $typea['name'];
$badge_name = qa_badge_name($slug);
if (!qa_opt('badge_' . $slug . '_name')) {
qa_opt('badge_' . $slug . '_name', $badge_name);
}
$var = qa_opt('badge_' . $slug . '_var');
$name = qa_opt('badge_' . $slug . '_name');
$desc = qa_badge_desc_replace($slug, $var, false);
$string = '<span class="badge-' . $types . '" title="' . $desc . ' (' . $typed . ')">' . qa_html($name) . '<br/>- ' . $badge['handle'] . ' -</span>';
if ($first) {
$themeobject->output('<h2>' . qa_lang('badges/badge_widget_title') . '</h2>');
$first = false;
}
$themeobject->output('<div class="badge-widget-entry" style="padding-top:8px;">', $string, '</div>');
}
}
开发者ID:architbakliwal,项目名称:Q2A,代码行数:36,代码来源:qa-badge-widget.php
示例18: process_request
public function process_request($request)
{
@ini_set('display_errors', 0);
// we don't want to show PHP errors inside XML
header('Content-type: text/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
// Question pages
if (qa_opt('xml_sitemap_show_questions')) {
$hotstats = qa_db_read_one_assoc(qa_db_query_sub("SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'"));
$nextpostid = 0;
while (1) {
$questions = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid, title, hotness FROM ^posts WHERE postid>=# AND type='Q' ORDER BY postid LIMIT 100", $nextpostid));
if (!count($questions)) {
break;
}
foreach ($questions as $question) {
$this->sitemap_output(qa_q_request($question['postid'], $question['title']), 0.1 + 0.9 * ($question['hotness'] - $hotstats['base']) / (1 + $hotstats['spread']));
$nextpostid = max($nextpostid, $question['postid'] + 1);
}
}
}
// User pages
if (!QA_FINAL_EXTERNAL_USERS && qa_opt('xml_sitemap_show_users')) {
$nextuserid = 0;
while (1) {
$users = qa_db_read_all_assoc(qa_db_query_sub("SELECT userid, handle FROM ^users WHERE userid>=# ORDER BY userid LIMIT 100", $nextuserid));
if (!count($users)) {
break;
}
foreach ($users as $user) {
$this->sitemap_output('user/' . $user['handle'], 0.25);
$nextuserid = max($nextuserid, $user['userid'] + 1);
}
}
}
// Tag pages
if (qa_using_tags() && qa_opt('xml_sitemap_show_tag_qs')) {
$nextwordid = 0;
while (1) {
$tagwords = qa_db_read_all_assoc(qa_db_query_sub("SELECT wordid, word, tagcount FROM ^words WHERE wordid>=# AND tagcount>0 ORDER BY wordid LIMIT 100", $nextwordid));
if (!count($tagwords)) {
break;
}
foreach ($tagwords as $tagword) {
$this->sitemap_output('tag/' . $tagword['word'], 0.5 / (1 + 1 / $tagword['tagcount']));
// priority between 0.25 and 0.5 depending on tag frequency
$nextwordid = max($nextwordid, $tagword['wordid'] + 1);
}
}
}
// Question list for each category
if (qa_using_categories() && qa_opt('xml_sitemap_show_category_qs')) {
$nextcategoryid = 0;
while (1) {
$categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT categoryid, backpath FROM ^categories WHERE categoryid>=# AND qcount>0 ORDER BY categoryid LIMIT 2", $nextcategoryid));
if (!count($categories)) {
break;
}
foreach ($categories as $category) {
$this->sitemap_output('questions/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1);
}
}
}
// Pages in category browser
if (qa_using_categories() && qa_opt('xml_sitemap_show_categories')) {
$this->sitemap_output('categories', 0.5);
$nextcategoryid = 0;
while (1) {
// only find categories with a child
$categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT parent.categoryid, parent.backpath FROM ^categories AS parent " . "JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100", $nextcategoryid));
if (!count($categories)) {
break;
}
foreach ($categories as $category) {
$this->sitemap_output('categories/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
$nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1);
}
}
}
echo "</urlset>\n";
return null;
}
开发者ID:kosmoluna,项目名称:question2answer,代码行数:84,代码来源:qa-xml-sitemap.php
示例19: post
function post($event, $userid, $handle, $params, $type)
{
// remove mentions
if (!qa_opt('buddypress_mentions')) {
remove_filter('bp_activity_after_save', 'bp_activity_at_name_filter_updates');
}
switch ($type) {
case 'Q':
$suffix = ' question ';
break;
case 'A':
$suffix = 'n %answer% to the question ';
break;
case 'C':
$suffix = ' %comment% on the question ';
break;
}
// poll integration
if (qa_post_text('is_poll')) {
if ($type == 'A') {
return;
}
if ($type == 'Q') {
$suffix = str_replace('question', 'poll', $suffix);
} else {
$suffix = str_replace('question', 'poll', $suffix);
}
}
$content = $params['content'];
// activity post
if ($event != 'q_post') {
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $params['parentid']), true);
if ($parent['type'] == 'A') {
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $parent['parentid']), true);
}
$anchor = qa_anchor($event == 'a_post' ? 'A' : 'C', $params['postid']);
$suffix = preg_replace('/%([^%]+)%/', '<a href="' . qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor) . '">$1</a>', $suffix);
$activity_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'));
$context = $suffix . '"<a href="' . $activity_url . '">' . $parent['title'] . '</a>"';
} else {
$activity_url = qa_path_html(qa_q_request($params['postid'], $params['title']), null, qa_opt('site_url'));
$context = $suffix . '"<a href="' . $activity_url . '">' . $params['title'] . '</a>"';
}
if (qa_opt('buddypress_display_names')) {
$name = bp_core_get_user_displayname($handle) ? bp_core_get_user_displayname($handle) : $handle;
} else {
$name = $handle;
}
$action = '<a href="' . bp_core_get_user_domain($userid) . '" rel="nofollow">' . $name . '</a> posted a' . $context . ' at <a href="' . qa_opt('site_url') . '">' . qa_opt('site_title') . '</a>';
if (qa_opt('buddypress_integration_include_content')) {
$informat = $params['format'];
$viewer = qa_load_viewer($content, $informat);
if (qa_opt('buddypress_integration_max_post_length') && strlen($content) > (int) qa_opt('buddypress_integration_max_post_length')) {
$content = substr($content, 0, (int) qa_opt('buddypress_integration_max_post_length'));
$content = $content . ' ...';
}
$content = $viewer->get_html($content, $informat, array());
} else {
$content = null;
}
global $phpmailer;
if (class_exists('PHPMailer') && !is_object($phpmailer)) {
$phpmailer = new PHPMailer(true);
}
$act_id = qa_buddypress_activity_post(array('action' => $action, 'content' => $content, 'primary_link' => $activity_url, 'component' => 'bp-qa', 'type' => 'activity_qa_' . $type, 'user_id' => $userid, 'item_id' => null));
}
开发者ID:NoahY,项目名称:q2a-buddypress,代码行数:66,代码来源:qa-bp-check.php
示例20: doctype
function doctype()
{
qa_html_theme_base::doctype();
if (qa_opt('badge_active')) {
// tabs
if ($this->template == 'user' && !qa_opt('badge_admin_user_field_no_tab')) {
if (!isset($this->content['navigation']['sub'])) {
$this->content['navigation']['sub'] = array('profile' => array('url' => qa_path_html('user/' . $this->_user_handle(), null, qa_opt('site_url')), 'label' => $this->_user_handle(), 'selected' => !qa_get('tab') ? true : false), 'badges' => array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => 'badges'), qa_opt('site_url')), 'label' => qa_lang('badges/badges'), 'selected' => qa_get('tab') == 'badges' ? true : false));
} else {
$this->content['navigation']['sub']['badges'] = array('url' => qa_path_html('user/' . $this->_user_handle(), array('tab' => 'badges'), qa_opt('site_url')), 'label' => qa_lang('badges/badges'), 'selected' => qa_get('tab') == 'badges' ? true : false);
}
}
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
$userid = qa_get_logged_in_userid();
if (!$userid) {
return;
}
// not logged in? die.
// first visit check
$user = @qa_db_read_one_assoc(qa_db_query_sub('SELECT ^achievements.user_id AS uid,^achievements.oldest_consec_visit AS ocv,^achievements.longest_consec_visit AS lcv,^achievements.total_days_visited AS tdv,^achievements.last_visit AS lv,^achievements.first_visit AS fv, ^userpoints.points as points FROM ^achievements, ^userpoints WHERE ^achievements.user_id=# AND ^userpoints.userid=#', $userid, $userid), true);
if (!$user['uid']) {
qa_db_query_sub('INSERT INTO ^achievements (user_id, first_visit, oldest_consec_visit, longest_consec_visit, last_visit, total_days_visited, questions_read, posts_edited) VALUES (#, NOW(), NOW(), #, NOW(), #, #, #) ON DUPLICATE KEY UPDATE first_visit=NOW(), oldest_consec_visit=NOW(), longest_consec_visit=#, last_visit=NOW(), total_days_visited=#, questions_read=#, posts_edited=#', $userid, 1, 1, 0, 0, 1, 1, 0, 0);
return;
}
// check lapse in days since last visit
// using julian days
$todayj = GregorianToJD(date('n'), date('j'), date('Y'));
$last_visit = strtotime($user['lv']);
$lastj = GregorianToJD(date('n', $last_visit), date('j', $last_visit), date('Y', $last_visit));
$last_diff = $todayj - $lastj;
$oldest_consec = strtotime($user['ocv']);
$oldest_consecj = GregorianToJD(date('n', $oldest_consec), date('j', $oldest_consec), date('Y', $oldest_consec));
$oldest_consec_diff = $todayj - $oldest_consecj + 1;
// include the first day
$first_visit = strtotime($user['fv']);
$first_visitj = GregorianToJD(date('n', $first_visit), date('j', $first_visit), date('Y', $first_visit));
$first_visit_diff = $todayj - $first_visitj;
if ($last_diff < 0) {
return;
}
// error
if ($last_diff < 2) {
// one day or less, update last visit
if ($oldest_consec_diff > $user['lcv']) {
$user['lcv'] = $oldest_consec_diff;
qa_db_query_sub('UPDATE ^achievements SET last_visit=NOW(), longest_consec_visit=#, total_days_visited=total_days_visited+# WHERE user_id=#', $oldest_consec_diff, $last_diff, $userid);
} else {
qa_db_query_sub('UPDATE ^achievements SET last_visit=NOW(), total_days_visited=total_days_visited+# WHERE user_id=#', $last_diff, $userid);
}
$badges = array('dedicated', 'devoted', 'zealous');
qa_badge_award_check($badges, $user['lcv'], $userid, null, 2);
} else {
// 2+ days, reset consecutive days due to lapse
qa_db_query_sub('UPDATE ^achievements SET last_visit=NOW(), oldest_consec_visit=NOW(), total_days_visited=total_days_visited+1 WHERE user_id=#', $userid);
}
$badges = array('visitor', 'trouper', 'veteran');
qa_badge_award_check($badges, $user['tdv'], $userid, null, 2);
$badges = array('regular', 'old_timer', 'ancestor');
qa_badge_award_check($badges, $first_visit_diff, $userid, null, 2);
// check points
if (isset($user['points'])) {
$badges = array('100_club', '1000_club', '10000_club');
qa_badge_award_check($badges, $user['points'], $userid, null, 2);
}
}
}
开发者ID:architbakliwal,项目名称:Q2A,代码行数:66,代码来源:qa-badge-layer.php
注:本文中的qa_db_read_one_assoc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论