function doctype() { if ($this->request == 'admin/emails') { if (qa_post_text('option_notify_admin_a_post')) { qa_opt('notify_admin_a_post', (bool) qa_post_text('option_notify_admin_a_post')); qa_opt('notify_admin_c_post', (bool) qa_post_text('option_notify_admin_c_post')); } foreach ($this->content['form']['fields'] as $key => $val) { $arr[$key] = $val; if ($key == 'notify_admin_q_post') { $arr['notify_admin_a_post'] = array('id' => 'notify_admin_a_post', 'label' => 'Email this address when an answer is posted', 'tags' => 'NAME="option_notify_admin_a_post" ID="option_notify_admin_a_post"', 'value' => qa_opt('notify_admin_a_post'), 'type' => 'checkbox', 'error' => ''); $arr['notify_admin_c_post'] = array('id' => 'notify_admin_a_post', 'label' => 'Email this address when a comment is posted', 'tags' => 'NAME="option_notify_admin_c_post" ID="option_notify_admin_c_post"', 'value' => qa_opt('notify_admin_c_post'), 'type' => 'checkbox', 'error' => ''); } $this->content['form']['fields'] = $arr; } } if (qa_opt('admin_plus_notify') && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN && (time() - (int) qa_opt('admin_plus_notify_checked')) / 3600 > qa_opt('admin_plus_notify_hours')) { qa_opt('admin_plus_notify_checked', time()); $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php'); if (count($pluginfiles)) { require_once QA_INCLUDE_DIR . 'qa-app-admin.php'; $cnt = 0; foreach ($pluginfiles as $pluginfile) { $plugindirectory = dirname($pluginfile) . '/'; $contents = file_get_contents($pluginfile); $metadata = qa_admin_addon_metadata($contents, array('version' => 'Plugin Version', 'update' => 'Plugin Update Check URI')); if (@$metadata['version'] && @$metadata['update']) { $newdata = qa_admin_addon_metadata(qa_retrieve_url($metadata['update']), array('version' => 'Plugin Version', 'uri' => 'Plugin URI')); if (strlen(@$newdata['version']) && strcmp($newdata['version'], $metadata['version'])) { $this->content['notices'][] = qa_notice_form('updates', qa_viewer_html(qa_opt('admin_plus_notify_text'), 'html')); $this->content['script'][] = "<script type=\"text/javascript\">jQuery(document).ready(function(){qa_reveal(document.getElementById('notice_updates'), 'notice');});</script>"; break; } } } } } qa_html_theme_base::doctype(); }
$lines[] = '<link>' . qa_xml(qa_path($linkrequest, $linkparams, $siteurl)) . '</link>'; $lines[] = '<description>Powered by Question2Answer</description>'; foreach ($questions as $question) { // Determine whether this is a question, answer or comment, and act accordingly $options = array('blockwordspreg' => @$blockwordspreg, 'showurllinks' => $showurllinks); $time = null; $htmlcontent = null; if (isset($question['opostid'])) { $time = $question['otime']; if ($full) { $htmlcontent = qa_viewer_html($question['ocontent'], $question['oformat'], $options); } } elseif (isset($question['postid'])) { $time = $question['created']; if ($full) { $htmlcontent = qa_viewer_html($question['content'], $question['format'], $options); } } if ($feedtype == 'search') { $titleprefix = ''; $urlxml = qa_xml($question['url']); } else { switch (@$question['obasetype'] . '-' . @$question['oupdatetype']) { case 'Q-': case '-': $langstring = null; break; case 'Q-' . QA_UPDATE_VISIBLE: $langstring = $question['hidden'] ? 'misc/feed_hidden_prefix' : 'misc/feed_reshown_prefix'; break; case 'Q-' . QA_UPDATE_CLOSED:
function qa_get_request_content() { $qa_content = qa_get_request_content_base(); // displays signature form in user profile $qa_request = strtolower(qa_request()); $reqs = explode('/', $qa_request); if ($reqs[0] == 'user') { // permissions if (isset($qa_content['form_profile']['fields']['permits'])) { $ov = $qa_content['form_profile']['fields']['permits']['value']; $ov = str_replace('[profile/signature_allow]', qa_lang('signature_plugin/signature_allow'), $ov); $ov = str_replace('[profile/signature_edit_allow]', qa_lang('signature_plugin/signature_edit_allow'), $ov); $qa_content['form_profile']['fields']['permits']['value'] = $ov; } $qa_content['user_signature_form'] = array(); $userid = @$qa_content['raw']['userid']; if (!$userid) { return $qa_content; } $handles = qa_userids_to_handles(array($userid)); $handle = $handles[$userid]; if (qa_get_logged_in_handle() == $handle && !qa_user_permit_error('signature_allow') || !qa_user_permit_error('signature_edit_allow')) { $ok = null; $formats = qa_list_modules('editor'); $format = qa_opt('signatures_format'); $editorname = $formats[$format]; if (!strlen($editorname)) { $editorname = qa_lang_html('admin/basic_editor'); } $editor = qa_load_editor('', '', $editorname); qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^usersignatures (' . 'userid INT(11) NOT NULL,' . 'signature VARCHAR (1000) DEFAULT \'\',' . 'format VARCHAR (20) DEFAULT \'\',' . 'id INT(11) NOT NULL AUTO_INCREMENT,' . 'UNIQUE (userid),' . 'PRIMARY KEY (id)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8'); if (qa_clicked('signature_save')) { if (strlen(qa_post_text('signature_text')) > qa_opt('signatures_length')) { $error = 'Max possible signature length is 1000 characters'; } else { $readdata = $editor->read_post('signature_text'); $informat = $readdata['format']; $incontent = qa_post_text('signature_text'); qa_db_query_sub('INSERT INTO ^usersignatures (userid,signature,format) VALUES (#,$,$) ON DUPLICATE KEY UPDATE signature=$,format=$', $userid, $incontent, $informat, $incontent, $informat); $ok = 'Signature Saved.'; } } $content = qa_db_read_one_assoc(qa_db_query_sub('SELECT BINARY signature AS signature,format FROM ^usersignatures WHERE userid=#', $userid), true); $field = qa_editor_load_field($editor, $qa_content, $content['signature'], $content['format'], 'signature_text', 12, false); $field['label'] = qa_lang_html('signature_plugin/signature'); $fields['content'] = $field; if (!$editorname || $editorname == 'Markdown Editor') { $fields['elCount'] = array('label' => '<div id="elCount">' . qa_opt('signatures_length') . '</div>', 'type' => 'static'); } $form = array('ok' => $ok && !isset($error) ? $ok : null, 'error' => @$error, 'style' => 'tall', 'title' => '<a name="signature_text"></a>' . qa_lang_html('signature_plugin/signature'), 'tags' => 'action="' . qa_self_html() . '#signature_text" method="POST"', 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="signature_save"')), 'hidden' => array('editor' => qa_html($editorname), 'dosavesig' => '1')); $qa_content['user_signature_form'] = $form; } else { if (qa_opt('signatures_profile_enable')) { $content = qa_db_read_one_assoc(qa_db_query_sub('SELECT BINARY signature as signature, format FROM ^usersignatures WHERE userid=#', $userid), true); if (!$content) { return $qa_content; } $informat = $content['format']; $viewer = qa_load_viewer($content['signature'], $informat); global $options; $signature = qa_viewer_html($content['signature'], $informat, array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow'])); $fields[] = array('label' => qa_opt('signatures_header') . $signature . qa_opt('signatures_footer'), 'type' => 'static'); $qa_content['user_signature_form'] = array('title' => 'Signature', 'fields' => $fields, 'style' => 'tall'); } } } return $qa_content; }
} } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('misc/private_message_title'); $qa_content['error'] = @$page_error; $qa_content['form_message'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('message' => array('type' => $messagesent ? 'static' : '', 'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)), 'tags' => 'NAME="message" ID="message"', 'value' => qa_html(@$inmessage, $messagesent), 'rows' => 8, 'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))), 'error' => qa_html(@$errors['message']))), 'buttons' => array('send' => array('tags' => 'onClick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('main/send_button'))), 'hidden' => array('domessage' => '1')); $qa_content['focusid'] = 'message'; if ($messagesent) { $qa_content['form_message']['ok'] = qa_lang_html('misc/message_sent'); unset($qa_content['form_message']['fields']['message']['note']); unset($qa_content['form_message']['buttons']); } // If relevant, show recent message history if (qa_opt('show_message_history')) { $recent = array_merge($torecent, $fromrecent); qa_sort_by($recent, 'created'); $showmessages = array_slice(array_reverse($recent, true), 0, QA_DB_RETRIEVE_MESSAGES); if (count($showmessages)) { $qa_content['form_recent'] = array('title' => qa_lang_html_sub('misc/message_recent_history', qa_html($toaccount['handle'])), 'style' => 'tall', 'fields' => array()); foreach ($showmessages as $message) { $qa_content['form_recent']['fields'][] = array('label' => qa_lang_html_sub($message['touserid'] == $toaccount['userid'] ? 'misc/message_sent_x_ago' : 'misc/message_received_x_ago', qa_html(qa_time_to_string(qa_opt('db_time') - $message['created']))), 'type' => 'static', 'value' => qa_viewer_html($message['content'], $message['format'])); } } } $qa_content['raw']['account'] = $toaccount; // for plugin layers to access return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
function qa_content_prepare($voting = false, $categoryids = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } global $qa_template, $qa_page_error_html; if (QA_DEBUG_PERFORMANCE) { global $qa_usage; $qa_usage->mark('control'); } $request = qa_request(); $requestlower = qa_request(); $navpages = qa_db_get_pending_result('navpages'); $widgets = qa_db_get_pending_result('widgets'); if (isset($categoryids) && !is_array($categoryids)) { // accept old-style parameter $categoryids = array($categoryids); } $lastcategoryid = count($categoryids) ? end($categoryids) : null; $charset = 'utf-8'; $qa_content = array('content_type' => 'text/html; charset=' . $charset, 'charset' => $charset, 'direction' => qa_opt('site_text_direction'), 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array()); if (qa_opt('show_custom_in_head')) { $qa_content['head_lines'][] = qa_opt('custom_in_head'); } if (qa_opt('show_custom_header')) { $qa_content['body_header'] = qa_opt('custom_header'); } if (qa_opt('show_custom_footer')) { $qa_content['body_footer'] = qa_opt('custom_footer'); } if (isset($categoryids)) { $qa_content['categoryids'] = $categoryids; } foreach ($navpages as $page) { if ($page['nav'] == 'B') { qa_navigation_add_page($qa_content['navigation']['main'], $page); } } if (qa_opt('nav_home') && qa_opt('show_custom_home')) { $qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home')); } if (qa_opt('nav_activity')) { $qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity')); } $hascustomhome = qa_has_custom_home(); if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) { $qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa')); } if (qa_opt('nav_questions')) { $qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs')); } if (qa_opt('nav_hot')) { $qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot')); } if (qa_opt('nav_unanswered')) { $qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered')); } if (qa_using_tags() && qa_opt('nav_tags')) { $qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags'), 'selected_on' => array('tags$', 'tag/')); } if (qa_using_categories() && qa_opt('nav_categories')) { $qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories'), 'selected_on' => array('categories$', 'categories/')); } if (qa_opt('nav_users')) { $qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users'), 'selected_on' => array('users$', 'users/', 'user/')); } // Only the 'level' permission error prevents the menu option being shown - others reported on qa-page-ask.php if (qa_opt('nav_ask') && qa_user_maximum_permit_error('permit_post_q') != 'level') { $qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask')); } if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN || !qa_user_maximum_permit_error('permit_moderate') || !qa_user_maximum_permit_error('permit_hide_show') || !qa_user_maximum_permit_error('permit_delete_hidden')) { $qa_content['navigation']['main']['admin'] = array('url' => qa_path_html('admin'), 'label' => qa_lang_html('main/nav_admin'), 'selected_on' => array('admin/')); } $qa_content['search'] = array('form_tags' => 'method="get" action="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'name="q"', 'button_label' => qa_lang_html('main/search_button')); if (!qa_opt('feedback_enabled')) { unset($qa_content['navigation']['footer']['feedback']); } foreach ($navpages as $page) { if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') { qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page); } } $regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side'); $placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom'); foreach ($widgets as $widget) { if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) { // see if it has been selected for display on this template $region = @$regioncodes[substr($widget['place'], 0, 1)]; $place = @$placecodes[substr($widget['place'], 1, 2)]; if (isset($region) && isset($place)) { // check region/place codes recognized $module = qa_load_module('widget', $widget['title']); if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template(substr($qa_template, 0, 7) == 'custom-' ? 'custom' : $qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) { $qa_content['widgets'][$region][$place][] = $module; } // if module loaded and happy to be displayed here, tell theme about it } } } $logoshow = qa_opt('logo_show'); $logourl = qa_opt('logo_url'); $logowidth = qa_opt('logo_width'); $logoheight = qa_opt('logo_height'); if ($logoshow) { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link" title="' . qa_html(qa_opt('site_title')) . '">' . '<img src="' . qa_html(is_numeric(strpos($logourl, '://')) ? $logourl : qa_path_to_root() . $logourl) . '"' . ($logowidth ? ' width="' . $logowidth . '"' : '') . ($logoheight ? ' height="' . $logoheight . '"' : '') . ' border="0" alt="' . qa_html(qa_opt('site_title')) . '"/></a>'; } else { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link">' . qa_html(qa_opt('site_title')) . '</a>'; } $topath = qa_get('to'); // lets user switch between login and register without losing destination page $userlinks = qa_get_login_links(qa_path_to_root(), isset($topath) ? $topath : qa_path($request, $_GET, '')); $qa_content['navigation']['user'] = array(); if (qa_is_logged_in()) { $qa_content['loggedin'] = qa_lang_html_sub_split('main/logged_in_x', QA_FINAL_EXTERNAL_USERS ? qa_get_logged_in_user_html(qa_get_logged_in_user_cache(), qa_path_to_root(), false) : qa_get_one_user_html(qa_get_logged_in_handle(), false)); $qa_content['navigation']['user']['updates'] = array('url' => qa_path_html('updates'), 'label' => qa_lang_html('main/nav_updates')); if (!empty($userlinks['logout'])) { $qa_content['navigation']['user']['logout'] = array('url' => qa_html(@$userlinks['logout']), 'label' => qa_lang_html('main/nav_logout')); } if (!QA_FINAL_EXTERNAL_USERS) { $source = qa_get_logged_in_source(); if (strlen($source)) { $loginmodules = qa_load_modules_with('login', 'match_source'); foreach ($loginmodules as $module) { if ($module->match_source($source) && method_exists($module, 'logout_html')) { ob_start(); $module->logout_html(qa_path('logout', array(), qa_opt('site_url'))); $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean()); } } } } $notices = qa_db_get_pending_result('notices'); foreach ($notices as $notice) { $qa_content['notices'][] = qa_notice_form($notice['noticeid'], qa_viewer_html($notice['content'], $notice['format']), $notice); } } else { require_once QA_INCLUDE_DIR . 'util/string.php'; if (!QA_FINAL_EXTERNAL_USERS) { $loginmodules = qa_load_modules_with('login', 'login_html'); foreach ($loginmodules as $tryname => $module) { ob_start(); $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($request, $_GET, qa_opt('site_url')), 'menu'); $label = ob_get_clean(); if (strlen($label)) { $qa_content['navigation']['user'][implode('-', qa_string_to_words($tryname))] = array('label' => $label); } } } if (!empty($userlinks['login'])) { $qa_content['navigation']['user']['login'] = array('url' => qa_html(@$userlinks['login']), 'label' => qa_lang_html('main/nav_login')); } if (!empty($userlinks['register'])) { $qa_content['navigation']['user']['register'] = array('url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register')); } } if (QA_FINAL_EXTERNAL_USERS || !qa_is_logged_in()) { if (qa_opt('show_notice_visitor') && !isset($topath) && !isset($_COOKIE['qa_noticed'])) { $qa_content['notices'][] = qa_notice_form('visitor', qa_opt('notice_visitor')); } } else { setcookie('qa_noticed', 1, time() + 86400 * 3650, '/', QA_COOKIE_DOMAIN); // don't show first-time notice if a user has logged in if (qa_opt('show_notice_welcome') && qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE) { if ($requestlower != 'confirm' && $requestlower != 'account') { // let people finish registering in peace $qa_content['notices'][] = qa_notice_form('welcome', qa_opt('notice_welcome')); } } } $qa_content['script_rel'] = array('qa-content/jquery-1.11.2.min.js'); $qa_content['script_rel'][] = 'qa-content/qa-page.js?' . QA_VERSION; if ($voting) { $qa_content['error'] = @$qa_page_error_html; } $qa_content['script_var'] = array('qa_root' => qa_path_to_root(), 'qa_request' => $request); return $qa_content; }
function process_request($request) { // get all variables preg_match($this->reqmatch, $request, $matches); $post_type = $matches[1]; $handle = $matches[2]; $start = (int) qa_get('start'); $pagesize = qa_opt('page_size_qs'); $hidecss = qa_opt($this->cssopt) === '1'; // regular page request $qa_content = qa_content_prepare(); require_once QA_INCLUDE_DIR . 'qa-util-string.php'; // display CSS for stat summary if (!$hidecss) { $qa_content['custom'] = "<style>\n" . ".qa-useract-page-links { margin: 16px 0; color: #555753; font-size: 16px; text-align: center; }\n" . ".qa-useract-page-links > a { font-weight: bold; }\n" . ".qa-useract-stats { margin: 8px 0; text-align: center; }\n" . ".qa-useract-stat { display: inline-block; margin: 0 16px 8px; }\n" . ".qa-useract-count { font-size: 18px; font-weight: bold; }\n" . ".qa-useract-wrapper .qa-q-item-main { width: 658px; }\n" . ".qa-useract-wrapper .qa-a-count { height: auto; border: 1px solid #ebeaca; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius:8px; }\n" . ".qa-useract-wrapper .qa-a-snippet { margin-top: 2px; color: #555753; }\n" . ".qa-useract-wrapper .qa-q-item-meta { float: none; }\n" . "</style>\n\n"; } // list of questions by this user if ($post_type === 'questions') { $qa_content['title'] = qa_lang_html_sub('useractivity/questions_by', $handle); list($userid, $count, $sel_count) = $this->_questions_stats($handle); // get questions $columns = 'postid, categoryid, type, LEFT(type,1) AS basetype, INSTR(type,"_HIDDEN")>0 AS hidden, acount, selchildid, closedbyid, upvotes, downvotes, netvotes, hotness, flagcount, BINARY title AS title, BINARY tags AS tags, UNIX_TIMESTAMP(created) AS created'; $sql_questions = 'SELECT ' . $columns . ' FROM ^posts WHERE type="Q" AND userid=# ORDER BY created DESC LIMIT #,#'; $result = qa_db_query_sub($sql_questions, $userid, $start, $pagesize); $questions = qa_db_read_all_assoc($result); $htmloptions = qa_post_html_defaults('Q'); $htmloptions['whoview'] = false; $htmloptions['avatarsize'] = 0; // html for stats $qa_content['custom'] .= '<div class="qa-useract-stats">' . ' <div class="qa-useract-stat"><span class="qa-useract-count">' . $count . '</span><br>' . ($count == 1 ? qa_lang_html('useractivity/question') : qa_lang_html('useractivity/questions')) . '</div>' . ' <div class="qa-useract-stat"><span class="qa-useract-count">' . $sel_count . '</span><br>' . ($sel_count == 1 ? qa_lang_html('useractivity/best_answer_given') : qa_lang_html('useractivity/best_answers_given')) . '</div>' . '</div>'; // create html for question list $qa_content['q_list']['qs'] = array(); foreach ($questions as $question) { $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, qa_get_logged_in_userid(), qa_cookie_get(), null, null, $htmloptions); } // pagination $qa_content['page_links'] = qa_html_page_links($request, $start, $pagesize, $count, qa_opt('pages_prev_next'), null); return $qa_content; } else { if ($post_type === 'answers') { $qa_content['title'] = qa_lang_html_sub('useractivity/answers_by', $handle); // userid and answer count $sql_count = 'SELECT u.userid, count(a.postid) AS qs, sum(q.selchildid=a.postid) AS selected ' . 'FROM ^posts a, ^posts q, ^users u ' . 'WHERE a.parentid=q.postid AND u.userid=a.userid AND a.type="A" AND q.type="Q" AND u.handle=$'; $result = qa_db_query_sub($sql_count, $handle); $row = qa_db_read_one_assoc($result); $userid = $row['userid']; $count = $row['qs']; $sel_count = $row['selected']; // get answers $columns = 'q.postid AS qpostid, BINARY q.title AS qtitle, q.selchildid AS qselid, q.netvotes AS qvotes, a.postid AS apostid, BINARY a.content AS acontent, a.netvotes AS avotes, UNIX_TIMESTAMP(a.created) AS acreated, a.format'; $sql_answers = 'SELECT ' . $columns . ' FROM ^posts a, ^posts q WHERE a.parentid=q.postid AND a.type="A" AND q.type="Q" AND a.userid=# ORDER BY a.created DESC LIMIT #,#'; $result = qa_db_query_sub($sql_answers, $userid, $start, $pagesize); $answers = qa_db_read_all_assoc($result); $qa_content['custom'] .= '<div class="qa-useract-stats">' . ' <div class="qa-useract-stat"><span class="qa-useract-count">' . $count . '</span><br>' . ($count == 1 ? qa_lang_html('useractivity/answer') : qa_lang_html('useractivity/answers')) . '</div>' . ' <div class="qa-useract-stat"><span class="qa-useract-count">' . $sel_count . '</span><br>' . ($sel_count == 1 ? qa_lang_html('useractivity/best_answer_received') : qa_lang_html('useractivity/best_answers_received')) . '</div>' . '</div>'; $qa_content['custom_2'] = '<div class="qa-useract-wrapper">'; foreach ($answers as $ans) { // to avoid ugly content, convert answer to HTML then strip the tags and remove any URLs $ans['acontent'] = qa_viewer_html($ans['acontent'], $ans['format']); $ans['acontent'] = strip_tags($ans['acontent']); $ans['acontent'] = preg_replace('#\\shttp://[^\\s]+#', '', $ans['acontent']); $ans['acontent'] = qa_substr($ans['acontent'], 0, 100); if (strlen($ans['acontent']) == 100) { $ans['acontent'] .= '...'; } // question url $ans['qurl'] = qa_path_html(qa_q_request($ans['qpostid'], $ans['qtitle'])); // answer date $ans['acreated'] = qa_when_to_html($ans['acreated'], qa_opt('show_full_date_days')); // html content $qa_content['custom_2'] .= $this->_answer_tmpl($ans); } $qa_content['custom_2'] .= '</div>'; // pagination $qa_content['page_links'] = qa_html_page_links($request, $start, $pagesize, $count, qa_opt('pages_prev_next'), null); return $qa_content; } } }
public function process_request($request) { $category_1 = qa_opt('qa_blog_cat_1'); $category_2 = qa_opt('qa_blog_cat_2'); $category_3 = qa_opt('qa_blog_cat_3'); $category_4 = qa_opt('qa_blog_cat_4'); $category_5 = qa_opt('qa_blog_cat_5'); $qa_content = qa_content_prepare(); $cat = -1; if (isset($_GET['category'])) { $cat = $_GET['category']; } $qa_content['navigation']['sub'] = array(); $qa_content['navigation']['sub']['all'] = array('label' => qa_lang('qa_blog_lang/nav_all'), 'url' => qa_path_to_root() . '/blog', 'selected' => isset($_GET['category']) ? 0 : 1); $qa_content['navigation']['sub']['cat1'] = array('label' => $category_1, 'url' => qa_path_to_root() . '/blog?category=1', 'selected' => $cat == 1 ? 1 : 0); $qa_content['navigation']['sub']['cat2'] = array('label' => $category_2, 'url' => qa_path_to_root() . '/blog?category=2', 'selected' => $cat == 2 ? 1 : 0); $qa_content['navigation']['sub']['cat3'] = array('label' => $category_3, 'url' => qa_path_to_root() . '/blog?category=3', 'selected' => $cat == 3 ? 1 : 0); $qa_content['navigation']['sub']['cat4'] = array('label' => $category_4, 'url' => qa_path_to_root() . '/blog?category=4', 'selected' => $cat == 4 ? 1 : 0); $qa_content['navigation']['sub']['cat5'] = array('label' => $category_5, 'url' => qa_path_to_root() . '/blog?category=5', 'selected' => $cat == 5 ? 1 : 0); $qa_content['navigation']['sub']['post'] = array('label' => qa_lang('qa_blog_lang/nav_post'), 'url' => qa_path_to_root() . '/articles'); $qa_content['title'] = qa_opt('qa_blog_title'); $postid = qa_request_part(1); if (isset($postid)) { $result = qa_db_query_sub('SELECT * FROM ^blog_posts WHERE `postid` LIKE #', $postid); if ($row = mysqli_fetch_array($result)) { qa_db_query_sub('UPDATE ^blog_posts SET Views = Views + 1 WHERE `postid` LIKE #', $postid); $qa_content['title'] = $row['title']; $qa_content['custom'] = ""; $html = qa_viewer_html($row['content'], $row['format'], array('showurllinks' => 1)); $strviews = qa_lang('qa_blog_lang/post_views'); $views = $row['views']; if ($row['views'] == 1) { $strviews = qa_lang('qa_blog_lang/post_views'); } $author = handleLinkForID($row['userid']); if ($row['userid'] == 0) { $author = qa_lang('qa_blog_lang/userid_null'); } $user = $row['userid']; $date = $row['posted']; $date = new DateTime($date); $on = $date->format('Y.m.d'); $at = $date->format('H:i'); $parentid = $postid; $result = qa_db_query_sub("SELECT COUNT(*) as total FROM ^blog_comments WHERE `parentid` LIKE #", $parentid); $countdata = mysqli_fetch_assoc($result); $count = $countdata['total']; $delete = "<a href='" . qa_path_to_root() . "/edit/" . $postid . "'/>\n\t\t\t<img src='" . qa_opt('site_url') . "qa-plugin/blog-post/images/delete.png'> Delete </a>"; $edit = "<a href='" . qa_path_to_root() . "/edit/" . $postid . "'/>\n\t\t\t<img src='" . qa_opt('site_url') . "qa-plugin/blog-post/images/edit.png'> Edit </a>"; $flag = "<a href='#'/>\n\t\t\t<img src='" . qa_opt('site_url') . "qa-plugin/blog-post/images/edit.png'> Flag </a>"; $comments = qa_lang('qa_blog_lang/post_comments'); $queryName = qa_db_read_one_assoc(qa_db_query_sub('SELECT content FROM `^userprofile` WHERE `userid`=' . $user . ' AND title="name" LIMIT 0,#;', $user), true); $name = isset($queryName['content']) && trim($queryName['content']) != '' ? $queryName['content'] : $author; $result = qa_db_query_sub('SELECT * FROM ^users WHERE userid=#', $user); if ($row = mysqli_fetch_array($result)) { $fullname = '<a href="/user/' . $row['handle'] . '">' . $name . '</a>'; } if (qa_is_logged_in()) { $html .= "<hr>\n\t\t\t\t\t<span style='float:left;padding-left:10px'>\n\t\t\t\t\t" . qa_lang('qa_blog_lang/posted_by') . " " . $fullname . " " . qa_lang('qa_blog_lang/on') . "\n\t\t\t\t\t" . $on . " " . qa_lang('qa_blog_lang/at') . " " . $at . "</span>\n\t\t\t\t\t<span style='float:right;padding-right:10px;'>\n\t\t\t\t\t" . $edit . " . " . $delete . " |\n\t\t\t\t\t<img src='" . qa_path_to_root() . "/qa-plugin/blog-post/images/comment.png'>" . $count . " " . $comments . "\n\t\t\t\t\t<img src='" . qa_path_to_root() . "/qa-plugin/blog-post/images/hits.jpg'>" . $views . " " . $strviews . "</span>\n\t\t\t\t\t<br>"; } else { $html .= "<hr>\n\t\t\t\t\t<span style='float:left;padding-left:10px'>\n\t\t\t\t\t" . qa_lang('qa_blog_lang/posted_by') . " " . $fullname . " " . qa_lang('qa_blog_lang/on') . "\n\t\t\t\t\t" . $on . " " . qa_lang('qa_blog_lang/at') . " " . $at . "</span>\n\t\t\t\t\t<span style='float:right;padding-right:10px;'>" . $count . " " . $comments . " | " . $row['views'] . " " . $strviews . "</span>\n\t\t\t\t\t<br>"; } # $html .= "<h2>Comments features is not available in free version</h2>"; $parentid = qa_request_part(1); $result = qa_db_query_sub("SELECT * FROM ^blog_comments WHERE parentid = '{$parentid}' "); $i = 0; while ($blob = mysqli_fetch_array($result)) { $i++; $html .= "<p> " . $blob['comment'] . "</span><br>" . qa_lang('qa_blog_lang/comment') . "\n\t\t\t\t\t" . $author . " " . qa_lang('qa_blog_lang/on') . " " . $on . " " . qa_lang('qa_blog_lang/at') . "\n\t\t\t\t\t" . $at . "</p>"; } if ($i == 0) { $html .= '<h3>No Comments yet</h3>'; } } else { $html = qa_lang('qa_blog_lang/post_null'); } } else { $cat = -1; if (isset($_GET['category'])) { $cat = $_GET['category']; } $qa_content['navigation']['sub'] = array(); $qa_content['navigation']['sub']['all'] = array('label' => qa_lang('qa_blog_lang/nav_all'), 'url' => './blog', 'selected' => isset($_GET['category']) ? 0 : 1); $qa_content['navigation']['sub']['cat1'] = array('label' => $category_1, 'url' => './blog?category=1', 'selected' => $cat == 1 ? 1 : 0); $qa_content['navigation']['sub']['cat2'] = array('label' => $category_2, 'url' => './blog?category=2', 'selected' => $cat == 2 ? 1 : 0); $qa_content['navigation']['sub']['cat3'] = array('label' => $category_3, 'url' => './blog?category=3', 'selected' => $cat == 3 ? 1 : 0); $qa_content['navigation']['sub']['cat4'] = array('label' => $category_4, 'url' => './blog?category=4', 'selected' => $cat == 4 ? 1 : 0); $qa_content['navigation']['sub']['cat5'] = array('label' => $category_5, 'url' => './blog?category=5', 'selected' => $cat == 5 ? 1 : 0); $qa_content['navigation']['sub']['post'] = array('label' => qa_lang('qa_blog_lang/nav_post'), 'url' => './articles'); $html = qa_opt('qa_blog_tagline') . '<hr>'; $page = 1; if (isset($_GET['page'])) { $page = $_GET['page']; } $limit = 10; if (isset($_GET['category'])) { $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE type=# and format='markdown'\n\t\tORDER BY posted DESC LIMIT #,#", $cat, ($page - 1) * $limit, $limit); } else { $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE format='markdown' ORDER BY posted DESC LIMIT #,#", ($page - 1) * $limit, $limit); } $i = 0; while ($article = mysqli_fetch_array($result)) { $i++; $author = $article['userid']; if ($article['userid'] == 0) { $author = qa_lang('qa_blog_lang/userid_null'); } $html .= article_item_with_author($article['title'], '' . qa_path_to_root() . '/blog/' . $article['postid'] . '/' . seoUrl($article['title']) . '/', $article['content'], $author, $article['posted'], $article['views'], $article['type'], $article['postid']); } if ($i == 0) { $html = "<h4>" . qa_lang('qa_blog_lang/posts_null') . "</h4>"; } else { if (isset($_GET['category'])) { $result = qa_db_query_sub("SELECT COUNT(*) as total FROM ^blog_posts WHERE type=#", $cat); } else { $result = qa_db_query_sub("SELECT COUNT(*) as total FROM ^blog_posts"); } $countdata = mysqli_fetch_assoc($result); $count = $countdata['total']; if ($count / $limit > 1) { $html .= '<br><br><div class="qa-page-links"> <span class="qa-page-links-label">Page: </span><ul class="qa-page-links-list">'; if ($page > 1) { $html .= '<li class="qa-page-links-item"> <a href="./questions?page=' . ($page - 1) . '" class="qa-page-prev">« prev</a> </li>'; } for ($i = 0; $i < $count / $limit; $i++) { if ($page - 1 == $i) { $html .= '<li class="qa-page-links-item"><span class="qa-page-selected">' . ($i + 1) . '</span></li>'; } else { $html .= '<li class="qa-page-links-item"><a href="./blog?page=' . ($i + 1) . '" class="qa-page-link">' . ($i + 1) . '</a></li>'; } } if ($page < $count / $limit) { $html .= '<li class="qa-page-links-item"> <a href="./blog?page=' . ($page + 1) . '" class="qa-page-next">next »</a> </li></ul></div>'; } else { $html .= '</ul></div>'; } } } $this->content['custom'] = $html; } $qa_content['custom'] = $html; //print_r($qa_content['site_title']); return $qa_content; }