本文整理汇总了PHP中qa_db_query_sub函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_db_query_sub函数的具体用法?PHP qa_db_query_sub怎么用?PHP qa_db_query_sub使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_db_query_sub函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
if (!qa_opt('event_logger_to_database')) {
return;
}
$badges = qa_db_read_all_assoc(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'));
if (empty($badges)) {
return;
}
$themeobject->output('<h2>' . qa_lang('badges/badge_widget_title') . '</h2>');
foreach ($badges as $badge) {
$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);
$types = $typea['slug'];
$typed = $typea['name'];
$badge_name = qa_lang('badges/' . $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, $name);
$string = '<span class="badge-' . $types . '" title="' . $desc . ' (' . $typed . ')">' . qa_html($name) . '<br/>- ' . $badge['handle'] . ' -</span>';
$themeobject->output('<div class="badge-widget-entry" style="padding-top:8px;">', $string, '</div>');
}
}
示例2: q_list
public function q_list($q_list)
{
if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (!empty($postids)) {
// Retrieve the content for these questions from the database and put into an array fetching
// the minimal amount of characters needed to determine the string should be shortened or not
$maxlength = qa_opt('mouseover_content_max_len');
$result = qa_db_query_sub('SELECT postid, LEFT(content, #) content, format FROM ^posts WHERE postid IN (#)', $maxlength + 1, $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
if (isset($postinfo[$question['raw']['postid']])) {
$thispost = $postinfo[$question['raw']['postid']];
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$title = isset($question['title']) ? $question['title'] : '';
$q_list['qs'][$index]['title'] = sprintf('<span title="%s">%s</span>', qa_html($text), $title);
}
}
}
}
qa_html_theme_base::q_list($q_list);
// call back through to the default function
}
示例3: admin_form
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('cp_save')) {
// Save
qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^postmeta (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_id bigint(20) unsigned NOT NULL,
meta_key varchar(255) DEFAULT \'\',
meta_value longtext,
PRIMARY KEY (meta_id),
KEY post_id (post_id),
KEY meta_key (meta_key)
) ENGINE=MyISAM DEFAULT CHARSET=utf8');
qa_opt('cp_enable', (bool) qa_post_text('cp_enable'));
$ok = qa_lang('admin/options_saved');
} else {
if (qa_clicked('cp_reset')) {
// Reset
foreach ($_POST as $i => $v) {
$def = $this->option_default($i);
if ($def !== null) {
qa_opt($i, $def);
}
}
qa_opt('cp_enable', true);
$ok = qa_lang('admin/options_reset');
}
}
// Create the form for display
$fields = array();
$fields[] = array('label' => qa_lang('cp/enable_community_posts'), 'tags' => 'NAME="cp_enable"', 'value' => qa_opt('cp_enable'), 'type' => 'checkbox');
return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="cp_save"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="cp_reset"')));
}
示例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);
}
示例5: qa_share_buttons
function qa_share_buttons($q_view)
{
if (qa_opt('expert_question_enable')) {
$qid = $q_view['raw']['postid'];
$expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE meta_key='is_expert_question' AND post_id=#", $qid), true);
if ($expert) {
return;
}
}
$url = qa_path_html(qa_q_request($q_view['raw']['postid'], $q_view['raw']['title']), null, qa_opt('site_url'));
$code = array('facebook' => '<iframe src="//www.facebook.com/plugins/like.php?href=' . qa_path_html(qa_q_request($this->content['q_view']['raw']['postid'], $this->content['q_view']['raw']['title']), null, qa_opt('site_url')) . '&send=false&layout=standard&width=53&layout=button_count&show_faces=false&action=like&colorscheme=light&font&height=20&appId=170382616390886" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:53px; height:20px;" allowTransparency="true"></iframe>', 'twitter' => '<a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a>', 'google' => '<g:plusone size="medium" count="false"></g:plusone>', 'linkedin' => '<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share"></script>', 'email' => '<a title="Share this question via email" id="share-button-email" href="mailto:?subject=' . rawurlencode('[' . qa_opt('site_title') . '] ' . $q_view['raw']['title']) . '&body=' . rawurlencode($url) . '"><img height="24" src="' . QA_HTML_THEME_LAYER_URLTOROOT . 'qa-share-mail.png' . '"/></a>');
// sort by weight
$weight = array('facebook' => qa_opt('share_plugin_facebook_weight'), 'twitter' => qa_opt('share_plugin_twitter_weight'), 'google' => qa_opt('share_plugin_google_weight'), 'linkedin' => qa_opt('share_plugin_linkedin_weight'), 'email' => qa_opt('share_plugin_email_weight'));
asort($weight);
// output
foreach ($weight as $key => $val) {
if (qa_opt('share_plugin_' . $key)) {
$shares[] = $code[$key];
}
}
if (empty($shares)) {
return null;
}
$output = implode(' ', $shares);
return $output;
}
示例6: init_queries
function init_queries($tableslc)
{
// check if the plugin is initialized
$ok = qa_opt('open_login_ok');
if ($ok == 3) {
return null;
}
$queries = array();
$columns = qa_db_read_all_values(qa_db_query_sub('describe ^userlogins'));
if (!in_array('oemail', $columns)) {
$queries[] = 'ALTER TABLE ^userlogins ADD `oemail` VARCHAR( 80 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL';
}
if (!in_array('ohandle', $columns)) {
$queries[] = 'ALTER TABLE ^userlogins ADD `ohandle` VARCHAR( 80 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL';
}
$columns = qa_db_read_all_values(qa_db_query_sub('describe ^users'));
if (!in_array('oemail', $columns)) {
$queries[] = 'ALTER TABLE ^users ADD `oemail` VARCHAR( 80 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL';
}
if (count($queries)) {
return $queries;
}
// we're already set up
qa_opt('open_login_ok', '3');
return null;
}
示例7: resync_question
function resync_question($postid, $voidparent)
{
if ($voidparent) {
qa_db_query_sub('REPLACE INTO ^homepage SELECT postid, NULL, created FROM ^posts WHERE type = "Q" AND postid = # LIMIT 1', $postid);
} else {
qa_db_query_sub('REPLACE INTO ^homepage SELECT postid, parentid, created FROM ^posts WHERE type = "Q" AND postid = # LIMIT 1', $postid);
}
$query = ' SELECT
question.postid,
Answers.postid AS answerid,
Answers.date AS answerid
FROM ^posts question
INNER JOIN
(
SELECT
parentid,
postid,
MAX(created) AS date
FROM ^posts
WHERE `type` = "A"
GROUP BY postid
) AS Answers ON Answers.parentid = question.postid
WHERE question.type = "Q" AND question.postid = #';
qa_db_query_sub('REPLACE INTO ^homepage ' . $query, $postid);
}
示例8: 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);
}
}
示例9: q_list
function q_list($q_list)
{
if (count(@$q_list['qs']) && qa_opt('mouseover_content_on')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (count($postids)) {
// Retrieve the content for these questions from the database and put into an array
$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
$maxlength = qa_opt('mouseover_content_max_len');
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
$thispost = @$postinfo[$question['raw']['postid']];
if (isset($thispost)) {
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$q_list['qs'][$index]['title'] = '<SPAN TITLE="' . qa_html($text) . '">' . @$question['title'] . '</SPAN>';
}
}
}
}
qa_html_theme_base::q_list($q_list);
// call back through to the default function
}
示例10: q_list
public function q_list($q_list)
{
if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (!empty($postids)) {
// Retrieve the content for these questions from the database
$maxlength = qa_opt('mouseover_content_max_len');
$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
if (isset($postinfo[$question['raw']['postid']])) {
$thispost = $postinfo[$question['raw']['postid']];
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = preg_replace('/\\s+/', ' ', $text);
// Remove duplicated blanks, new line characters, tabs, etc
$text = qa_shorten_string_line($text, $maxlength);
$title = isset($question['title']) ? $question['title'] : '';
$q_list['qs'][$index]['title'] = $this->getHtmlTitle(qa_html($text), $title);
}
}
}
}
parent::q_list($q_list);
// call back through to the default function
}
示例11: q2apro_save_most_viewed_questions
function q2apro_save_most_viewed_questions()
{
// save checktime of cache
qa_opt('q2apro_popularqu_checktime', time());
$maxquestions = qa_opt('q2apro_popularqu_maxqu');
$lastdays = qa_opt('q2apro_popularqu_lastdays');
$ourTopQuestions = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, title, acount FROM `^posts`
WHERE `created` > NOW() - INTERVAL # DAY
AND `type` = "Q"
AND `closedbyid` IS NULL
ORDER BY views DESC
LIMIT #;', $lastdays, $maxquestions));
$saveoutput = '';
foreach ($ourTopQuestions as $qu) {
$activity_url = qa_path_html(qa_q_request($qu['postid'], $qu['title']), null, qa_opt('site_url'), null, null);
$questionlink = '<a href="' . $activity_url . '">' . htmlspecialchars($qu['title']) . '</a>';
$answercnt = '';
if (qa_opt('q2apro_popularqu_answercount')) {
$acnttitle = $qu['acount'] == 1 ? qa_lang('q2apro_popularqu_lang/answer_one') : $qu['acount'] . ' ' . qa_lang('q2apro_popularqu_lang/answers');
$answercnt = ' <span title="' . $acnttitle . '">(' . $qu['acount'] . ')</span>';
}
$saveoutput .= '<li>
' . $questionlink . $answercnt . '
</li>
';
}
// save into cache
qa_opt('q2apro_popularqu_cached', $saveoutput);
}
示例12: 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;
}
示例13: cs_events
function cs_events($limit = 10, $events_type = false)
{
if (!$events_type) {
$events_type = array('q_post', 'a_post', 'c_post', 'a_select', 'badge_awarded');
}
// query last 3 events
$posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT datetime,ipaddress,handle,event,params FROM ^eventlog WHERE event IN ("q_post", "a_post", "c_post") ORDER BY datetime DESC LIMIT #', $limit));
if (empty($posts)) {
return;
}
$postids = '';
$i = 1;
foreach ($posts as $post) {
$params = preg_replace('/\\s+/', '&', $post['params']);
parse_str($params, $data);
$postids .= ($i != 1 ? ', ' : '') . $data['postid'];
$i++;
}
$posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT ^posts.* , ^users.handle FROM ^posts, ^users WHERE (^posts.userid=^users.userid AND ^posts.postid IN (' . $postids . ')) AND ^posts.type IN ("Q", "A", "C") ORDER BY ^posts.created DESC'));
$o = '<ul class="ra-activity">';
foreach ($posts as $p) {
$event_name = '';
$event_icon = '';
if ($p['type'] == 'Q') {
$event_name = qa_lang('cleanstrap/asked');
$event_icon = 'icon-question';
} else {
if ($p['type'] == 'A') {
$event_name = qa_lang('cleanstrap/answered');
$event_icon = 'icon-answer';
} else {
$event_name = qa_lang('cleanstrap/commented');
$event_icon = 'icon-chat';
}
}
$username = is_null($p['handle']) ? qa_lang('cleanstrap/anonymous') : htmlspecialchars($p['handle']);
$usernameLink = is_null($p['handle']) ? qa_lang('cleanstrap/anonymous') : '<a href="' . qa_path_html('user/' . $p['handle']) . '">' . $p['handle'] . '</a>';
$timeCode = qa_when_to_html(strtotime($p['created']), 7);
$time = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix'];
$o .= '<li class="event-item">';
$o .= '<div class="event-inner">';
$o .= '<div class="event-icon pull-left ' . $event_icon . '"></div>';
$o .= '<div class="event-content">';
$o .= '<p class="title"><strong class="avatar" data-handle="' . $p['handle'] . '" data-id="' . $p['userid'] . '">' . @$usernameLink . '</strong> <span class="what">' . $event_name . '</span></p>';
if ($p['type'] == 'Q') {
$o .= '<a class="event-title" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . cs_truncate($p['title'], 100) . '</a>';
} elseif ($p['type'] == 'A') {
$o .= '<a class="event-title" href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
} else {
$o .= '<a class="event-title" href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
}
$o .= '<span class="time">' . $time . '</span>';
$o .= '</div>';
$o .= '</div>';
$o .= '</li>';
}
$o .= '</ul>';
return $o;
}
示例14: mp_announcements_get_all
function mp_announcements_get_all($categoryid)
{
/*
Return all annoucement posts
*/
$results = qa_db_read_all_assoc(qa_db_query_sub('select p.*, u.handle from ^posts p, ^users u where p.type="AN" AND p.categoryid=# AND p.userid = u.userid ORDER BY p.created DESC', $categoryid), 'postid');
return $results;
}
示例15: qa_db_cache_get
function qa_db_cache_get($type, $cacheid)
{
$content = qa_db_read_one_value(qa_db_query_sub('SELECT content FROM ^cache WHERE type=$ AND cacheid=#', $type, $cacheid), true);
if (isset($content)) {
qa_db_query_sub('UPDATE ^cache SET lastread=NOW() WHERE type=$ AND cacheid=#', $type, $cacheid);
}
return $content;
}