function qa_cookie_get_create() { require_once QA_INCLUDE_DIR . 'qa-db-cookies.php'; $cookieid = qa_cookie_get(); if (isset($cookieid) && qa_db_cookie_exists($cookieid)) { } else { $cookieid = qa_db_cookie_create(qa_remote_ip_address()); } setcookie('qa_id', $cookieid, time() + 86400 * 365, '/', QA_COOKIE_DOMAIN); return $cookieid; }
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'app/updates.php'; $userid = qa_get_logged_in_userid(); // Chop down to size, get user information for display if (isset($pagesize)) { $questions = array_slice($questions, 0, $pagesize); } $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); // Prepare content for theme $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid))); $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $qa_content['q_list']['qs'] = array(); if (count($questions)) { $qa_content['title'] = $sometitle; $defaults = qa_post_html_defaults('Q'); if (isset($categorypathprefix)) { $defaults['categorypathprefix'] = $categorypathprefix; } foreach ($questions as $question) { $fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults)); if (!empty($fields['raw']['closedbyid'])) { $fields['closed'] = array('state' => qa_lang_html('main/closed')); } $qa_content['q_list']['qs'][] = $fields; } } else { $qa_content['title'] = $nonetitle; } if (isset($userid) && isset($categoryid)) { $favoritemap = qa_get_favorite_non_qs_map(); $categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']]; $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite, qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title'])); } if (isset($count) && isset($pagesize)) { $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams); } if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = $suggest; } if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) { $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams); } if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle)); } return $qa_content; }
function qa_favorite_q_list_view($questions, $usershtml) { $q_list = array('qs' => array()); if (count($questions) === 0) { return $q_list; } $q_list['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $defaults = qa_post_html_defaults('Q'); foreach ($questions as $question) { $q_list['qs'][] = qa_post_html_fields($question, qa_get_logged_in_userid(), qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults)); } return $q_list; }
function qa_cookie_get_create() { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'qa-db-cookies.php'; $cookieid = qa_cookie_get(); if (isset($cookieid) && qa_db_cookie_exists($cookieid)) { } else { $cookieid = qa_db_cookie_create(qa_remote_ip_address()); } setcookie('qa_id', $cookieid, time() + 86400 * 365, '/', QA_COOKIE_DOMAIN); $_COOKIE['qa_id'] = $cookieid; return $cookieid; }
function qa_complete_reset_user($userid) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; require_once QA_INCLUDE_DIR . 'qa-app-cookies.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; $password = qa_random_alphanum(max(QA_MIN_PASSWORD_LEN, QA_NEW_PASSWORD_LEN)); $userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true)); if (!qw_send_notification($userid, $userinfo['email'], $userinfo['handle'], qa_lang('emails/new_password_subject'), nl2br(qa_lang('emails/new_password_body')), array('^password' => $password, '^url' => qa_opt('site_url')))) { qa_fatal_error('Could not send new password - password not reset'); } qa_db_user_set_password($userid, $password); // do this last, to be safe qa_db_user_set($userid, 'emailcode', ''); // so can't be reused qa_report_event('u_reset', $userid, $userinfo['handle'], qa_cookie_get(), array('email' => $userinfo['email'])); }
function get_user_activity($handle, $limit = 10) { $userid = qa_handle_to_userid($handle); require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_recent_qs_selectspec($userid, $identifier, $limit), qa_db_user_recent_a_qs_selectspec($userid, $identifier), qa_db_user_recent_c_qs_selectspec($userid, $identifier), qa_db_user_recent_edit_qs_selectspec($userid, $identifier)); if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) { // check the user exists return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Get information on user references $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = array_slice($questions, 0, $limit); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false); $htmldefaults = qa_post_html_defaults('Q'); $htmldefaults['whoview'] = false; $htmldefaults['voteview'] = false; $htmldefaults['avatarsize'] = 0; foreach ($questions as $question) { $qa_content[] = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults)); } $output = '<div class="user-activities">'; $output .= '<ul>'; if (isset($qa_content)) { foreach ($qa_content as $qs) { $icon = 'icon-time undefined'; $output .= '<li class="activity-item">'; $output .= '<div class="list-right">'; $output .= '<div class="type pull-left ' . $icon . '"></div>'; $output .= '<div class="what"><a class="what-task" href="' . @$qs['url'] . '">' . $qs['what'] . '</a>'; $output .= '<a href="' . $qs['url'] . '">' . $qs['title'] . '</a> </div>'; $output .= '<strong class="when">' . implode(' ', $qs['when']) . '</strong>'; $output .= '</div>'; $output .= '</li>'; } } else { $output .= '<li>' . qa_lang('cleanstrap/no_activity_yet') . '</li>'; } $output .= '</ul>'; $output .= '</div>'; return $output; }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { $widget_opt = @$themeobject->current_widget['param']['options']; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; if (@$qa_content['q_view']['raw']['type'] != 'Q') { // question might not be visible, etc... return; } $questionid = $qa_content['q_view']['raw']['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $questions = qa_db_single_select(qa_db_related_qs_selectspec($userid, $questionid, (int) $widget_opt['count'])); $minscore = qa_match_to_min_score(qa_opt('match_related_qs')); foreach ($questions as $key => $question) { if ($question['score'] < $minscore) { unset($questions[$key]); } } $titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title'); if (@$themeobject->current_widget['param']['locations']['show_title']) { $themeobject->output('<h3 class="widget-title">' . qa_lang('cleanstrap/related_questions') . '</h3>'); } $themeobject->output('<div class="ra-rq-widget">'); $themeobject->output('<ul>'); foreach ($questions as $p) { $timeCode = qa_when_to_html($p['created'], 7); $when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix']; $themeobject->output('<li>' . cs_get_post_avatar($p, $p['userid'], 30, true)); $themeobject->output('<div class="post-content">'); $themeobject->output('<a class="title" href="' . qa_q_path_html($p['postid'], $p['title']) . '">' . qa_html($p['title']) . '</a>'); $themeobject->output('<div class="meta">'); $themeobject->output('<span>' . qa_lang_sub('cleanstrap/x_answers', $p['acount']) . '</span>'); $themeobject->output('<span class="time icon-time">' . $when . '</span>'); $themeobject->output('<span class="vote-count icon-thumbs-up2">' . qa_lang_sub('cleanstrap/x_votes', $p['netvotes']) . '</span>'); $themeobject->output('</div>'); $themeobject->output('</div>'); $themeobject->output('</li>'); } $themeobject->output('</ul>'); $themeobject->output('</div>'); }
function process_request($request) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; require_once QA_INCLUDE_DIR . 'qa-db-post-create.php'; require_once QA_INCLUDE_DIR . 'mp-db-users.php'; // 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'])); // create the editor and update its content qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext); $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$incontent, @$informat, $editorname); // retrieve variable data $innotify = qa_post_text('notify') ? true : false; // handle creation of annoucement if (qa_post_text('docreate')) { //retrieve data $title = qa_post_text('title'); $content = $incontent; $format = $informat; // validate data // handle create work // actual create process is in file mp-app-posts.php $postid = qa_post_create('AN', null, $title, $content, $format, mp_get_categoryid(), null, qa_get_logged_in_userid(), $innotify); // redirect page qa_redirect('mp-announcements-page'); // our work is done here } $qa_content = qa_content_prepare(); // if the user is not logged in, request user to login if (!qa_get_logged_in_userid()) { $qa_content['error'] = qa_insert_login_links('Please ^1log in^2 or ^3register^4 first.', $request); return $qa_content; } $qa_content['title'] = 'Create Announcement'; $qa_content['form_newannouncement'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang_html('announcements/a_title_label'), 'tags' => 'NAME="title"', 'value' => qa_html(qa_post_text('title')), 'error' => qa_html(@$errors['title'])), 'content' => array_merge($editor->get_field($qa_content, @$incontent, @$informat, 'content', 12, false), array('label' => qa_lang_html('announcements/a_content_label'), 'error' => qa_html(@$errors['content']))), 'notify' => array('label' => 'Send email notification to all registered students', 'tags' => 'NAME="notify"', 'type' => 'checkbox', 'value' => qa_html($innotify))), 'buttons' => array('ok' => array('tags' => 'NAME="docreate"', 'label' => 'Create Announcement', 'value' => '1')), 'hidden' => array('hiddenfield' => '1', 'editor' => qa_html($editorname))); // create the sub menu for navigation $qa_content['navigation']['sub'] = mp_announcements_sub_navigation(); $qa_content['navigation']['sub']['create']['selected'] = true; return $qa_content; }
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { require_once QA_INCLUDE_DIR . 'db/selects.php'; if (!isset($qa_content['q_view']['raw']['type']) || $qa_content['q_view']['raw']['type'] != 'Q') { // question might not be visible, etc... return; } $questionid = $qa_content['q_view']['raw']['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $questions = qa_db_single_select(qa_db_related_qs_selectspec($userid, $questionid, qa_opt('page_size_related_qs'))); $minscore = qa_match_to_min_score(qa_opt('match_related_qs')); foreach ($questions as $key => $question) { if ($question['score'] < $minscore) { unset($questions[$key]); } } $titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title'); if ($region == 'side') { $themeobject->output('<div class="qa-related-qs">', '<h2 style="margin-top:0; padding-top:0;">', $titlehtml, '</h2>'); $themeobject->output('<ul class="qa-related-q-list">'); foreach ($questions as $question) { $themeobject->output('<li class="qa-related-q-item">' . '<a href="' . qa_q_path_html($question['postid'], $question['title']) . '">' . qa_html($question['title']) . '</a>' . '</li>'); } $themeobject->output('</ul>', '</div>'); } else { $themeobject->output('<h2>', $titlehtml, '</h2>'); $q_list = array('form' => array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))), 'qs' => array()); $defaults = qa_post_html_defaults('Q'); $usershtml = qa_userids_handles_html($questions); foreach ($questions as $question) { $q_list['qs'][] = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, qa_post_html_options($question, $defaults)); } $themeobject->q_list_and_form($q_list); } }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; if (@$qa_content['q_view']['raw']['type'] != 'Q') { // question might not be visible, etc... return; } $questionid = $qa_content['q_view']['raw']['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $questions = qa_db_single_select(qa_db_related_qs_selectspec($userid, $questionid, qa_opt('page_size_related_qs'))); $minscore = qa_match_to_min_score(qa_opt('match_related_qs')); foreach ($questions as $key => $question) { if ($question['score'] < $minscore) { unset($questions[$key]); } } $titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title'); if ($region == 'side') { $themeobject->output('<DIV CLASS="qa-related-qs">', '<H2 STYLE="margin-top:0; padding-top:0;">', $titlehtml, '</H2>'); $themeobject->output('<UL CLASS="qa-related-q-list">'); foreach ($questions as $question) { $themeobject->output('<LI CLASS="qa-related-q-item"><A HREF="' . qa_q_path_html($question['postid'], $question['title']) . '">' . qa_html($question['title']) . '</A></LI>'); } $themeobject->output('</UL>', '</DIV>'); } else { $themeobject->output('<H2>', $titlehtml, '</H2>'); $q_list = array('form' => array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"'), 'qs' => array()); $options = qa_post_html_defaults('Q'); $usershtml = qa_userids_handles_html($questions); foreach ($questions as $question) { $q_list['qs'][] = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $options); } $themeobject->q_list_and_form($q_list); } }
function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, &$in, &$errors) { $parentid = $parent['postid']; $prefix = 'c' . $parentid . '_'; $in = array('name' => qa_post_text($prefix . 'name'), 'notify' => qa_post_text($prefix . 'notify') !== null, 'email' => qa_post_text($prefix . 'email'), 'queued' => qa_user_moderation_reason(qa_user_level_for_post($parent)) !== false); qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $errors = array(); if (!qa_check_form_security_code('comment-' . $parent['postid'], qa_post_text($prefix . 'code'))) { $errors['content'] = qa_lang_html('misc/form_security_again'); } else { $filtermodules = qa_load_modules_with('filter', 'filter_comment'); foreach ($filtermodules as $filtermodule) { $oldin = $in; $filtermodule->filter_comment($in, $errors, $question, $parent, null); qa_update_post_text($in, $oldin); } if ($usecaptcha) { qa_captcha_validate_post($errors); } if (empty($errors)) { $testwords = implode(' ', qa_string_to_words($in['content'])); foreach ($commentsfollows as $comment) { if ($comment['basetype'] == 'C' && $comment['parentid'] == $parentid && !$comment['hidden']) { if (implode(' ', qa_string_to_words($comment['content'])) == $testwords) { $errors['content'] = qa_lang_html('question/duplicate_content'); } } } } if (empty($errors)) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary $commentid = qa_comment_create($userid, $handle, $cookieid, $in['content'], $in['format'], $in['text'], $in['notify'], $in['email'], $question, $parent, $commentsfollows, $in['queued'], $in['name']); return $commentid; } } return null; }
$qa_content['title'] = qa_lang_html('admin/recent_hidden_title'); $qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error(); $qa_content['q_list'] = array('form' => array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('admin/click'))), 'qs' => array()); if (count($questions)) { foreach ($questions as $key => $question) { $elementid = 'p' . $qhiddenpostid[$key]; $htmloptions = qa_post_html_options($question); $htmloptions['voteview'] = false; $htmloptions['tagsview'] = !isset($question['opostid']); $htmloptions['answersview'] = false; $htmloptions['viewsview'] = false; $htmloptions['updateview'] = false; $htmloptions['contentview'] = true; $htmloptions['flagsview'] = true; $htmloptions['elementid'] = $elementid; $htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions); if (isset($htmlfields['what_url'])) { // link directly to relevant content $htmlfields['url'] = $htmlfields['what_url']; } $htmlfields['what_2'] = qa_lang_html('main/hidden'); if (@$htmloptions['whenview']) { $updated = @$question[isset($question['opostid']) ? 'oupdated' : 'updated']; if (isset($updated)) { $htmlfields['when_2'] = qa_when_to_html($updated, @$htmloptions['fulldatedays']); } } $buttons = array(); $posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']); if (!qa_user_post_permit_error('permit_hide_show', $question)) { // Possible values for popup: reshow_q_popup, reshow_a_popup, reshow_c_popup
} $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $qa_content['q_list']['qs'] = array(); $qdefaults = qa_post_html_defaults('Q'); foreach ($results as $result) { if (!isset($result['question'])) { // if we have any non-question results, display with less statistics $qdefaults['voteview'] = false; $qdefaults['answersview'] = false; $qdefaults['viewsview'] = false; break; } } foreach ($results as $result) { if (isset($result['question'])) { $fields = qa_post_html_fields($result['question'], $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($result['question'], $qdefaults)); } elseif (isset($result['url'])) { $fields = array('what' => qa_html($result['url']), 'meta_order' => qa_lang_html('main/meta_order')); } else { continue; } // nothing to show here if (isset($qdefaults['blockwordspreg'])) { $result['title'] = qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']); } $fields['title'] = qa_html($result['title']); $fields['url'] = qa_html($result['url']); $qa_content['q_list']['qs'][] = $fields; } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount, qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count); if (qa_opt('feed_for_search')) {
More about this license: http://www.question2answer.org/license.php */ require_once QA_INCLUDE_DIR . 'app/messages.php'; require_once QA_INCLUDE_DIR . 'app/users.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php'; require_once QA_INCLUDE_DIR . 'db/selects.php'; $message = qa_post_text('message'); $tohandle = qa_post_text('handle'); $morelink = qa_post_text('morelink'); $touseraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($tohandle, false)); $loginuserid = qa_get_logged_in_userid(); $errorhtml = qa_wall_error_html($loginuserid, $touseraccount['userid'], $touseraccount['flags']); if ($errorhtml || !strlen($message) || !qa_check_form_security_code('wall-' . $tohandle, qa_post_text('code'))) { echo "QA_AJAX_RESPONSE\n0"; } else { $messageid = qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $touseraccount['userid'], $touseraccount['handle'], $message, ''); $touseraccount['wallposts']++; // won't have been updated $usermessages = qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $touseraccount['userid'], true, qa_opt('page_size_wall'))); $usermessages = qa_wall_posts_add_rules($usermessages, 0); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'wall', null, null); echo "QA_AJAX_RESPONSE\n1\n"; echo 'm' . $messageid . "\n"; // element in list to be revealed foreach ($usermessages as $message) { $themeclass->message_item(qa_wall_post_view($message)); } if ($morelink && $touseraccount['wallposts'] > count($usermessages)) { $themeclass->message_item(qa_wall_view_more_link($tohandle, count($usermessages))); } }
of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. More about this license: http://www.question2answer.org/license.php */ 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'; // Get popular tags $populartags = qa_db_select_with_pending(qa_db_popular_tags_selectspec($qa_start)); $tagcount = qa_opt('cache_tagcount'); $pagesize = qa_opt('page_size_tags'); // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('main/popular_tags'); $qa_content['ranking'] = array('items' => array(), 'rows' => ceil($pagesize / qa_opt('columns_tags')), 'type' => 'tags'); if (count($populartags)) { $output = 0; foreach ($populartags as $word => $count) { $qa_content['ranking']['items'][] = array('label' => qa_tag_html($word), 'count' => number_format($count)); if (++$output >= $pagesize) {
list($questions, $tagword) = qa_db_select_with_pending(qa_db_tag_recent_qs_selectspec($userid, $tag, $start, false, qa_opt_if_loaded('page_size_tag_qs')), qa_db_tag_word_selectspec($tag)); $pagesize = qa_opt('page_size_tag_qs'); $questions = array_slice($questions, 0, $pagesize); $usershtml = qa_userids_handles_html($questions); // Prepare content for theme $qa_content = qa_content_prepare(true); $qa_content['title'] = qa_lang_html_sub('main/questions_tagged_x', qa_html($tag)); if (isset($userid) && isset($tagword)) { $favoritemap = qa_get_favorite_non_qs_map(); $favorite = @$favoritemap['tag'][qa_strtolower($tagword['word'])]; $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite, qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word'])); } if (!count($questions)) { $qa_content['q_list']['title'] = qa_lang_html('main/no_questions_found'); } $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $qa_content['q_list']['qs'] = array(); foreach ($questions as $postid => $question) { $qa_content['q_list']['qs'][] = qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question)); } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagword['tagcount'], qa_opt('pages_prev_next')); if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = qa_html_suggest_qs_tags(true); } if (qa_opt('feed_for_tag_qs')) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request('tag/' . $tag)), 'label' => qa_lang_html_sub('main/questions_tagged_x', qa_html($tag))); } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
function qa_set_logged_in_user($userid, $handle = '', $remember = false, $source = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'app/cookies.php'; qa_start_session(); if (isset($userid)) { qa_set_session_user($userid, $source); // PHP sessions time out too quickly on the server side, so we also set a cookie as backup. // Logging in from a second browser will make the previous browser's 'Remember me' no longer // work - I'm not sure if this is the right behavior - could see it either way. require_once QA_INCLUDE_DIR . 'db/selects.php'; $userinfo = qa_db_single_select(qa_db_user_account_selectspec($userid, true)); // if we have logged in before, and are logging in the same way as before, we don't need to change the sessioncode/source // this means it will be possible to automatically log in (via cookies) to the same account from more than one browser if (empty($userinfo['sessioncode']) || $source !== $userinfo['sessionsource']) { $sessioncode = qa_db_user_rand_sessioncode(); qa_db_user_set($userid, 'sessioncode', $sessioncode); qa_db_user_set($userid, 'sessionsource', $source); } else { $sessioncode = $userinfo['sessioncode']; } qa_db_user_logged_in($userid, qa_remote_ip_address()); qa_set_session_cookie($handle, $sessioncode, $remember); qa_report_event('u_login', $userid, $userinfo['handle'], qa_cookie_get()); } else { $olduserid = qa_get_logged_in_userid(); $oldhandle = qa_get_logged_in_handle(); qa_clear_session_cookie(); qa_clear_session_user(); qa_report_event('u_logout', $olduserid, $oldhandle, qa_cookie_get()); } }
require_once QA_INCLUDE_DIR . 'qa-app-emails.php'; if (qa_opt('show_message_history')) { $messageid = qa_db_message_create($loginuserid, $toaccount['userid'], $inmessage, '', false); } else { $messageid = null; } $fromhandle = qa_get_logged_in_handle(); $canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES); $more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array('^f_handle' => $fromhandle, '^url' => qa_path_absolute($canreply ? 'message/' . $fromhandle : 'user/' . $fromhandle))); $subs = array('^message' => $inmessage, '^f_handle' => $fromhandle, '^f_url' => qa_path_absolute('user/' . $fromhandle), '^more' => $more, '^a_url' => qa_path_absolute('account')); if (qa_send_notification($toaccount['userid'], $toaccount['email'], $toaccount['handle'], qa_lang('emails/private_message_subject'), qa_lang('emails/private_message_body'), $subs)) { $messagesent = true; } else { $pageerror = qa_lang_html('main/general_error'); } qa_report_event('u_message', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array('userid' => $toaccount['userid'], 'handle' => $toaccount['handle'], 'messageid' => $messageid, 'message' => $inmessage)); if ($messagesent && qa_opt('show_message_history')) { // show message as part of general history qa_redirect(qa_request(), array('state' => 'message-sent')); } } } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('misc/private_message_title'); $qa_content['error'] = @$pageerror; $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', 'code' => qa_get_form_security_code('message-' . $handle))); $qa_content['focusid'] = 'message'; if ($messagesent) { $qa_content['form_message']['ok'] = qa_lang_html('misc/message_sent');
as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. More about this license: http://www.question2answer.org/license.php */ require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-app-cookies.php'; require_once QA_INCLUDE_DIR . 'qa-app-favorites.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $entitytype = qa_post_text('entitytype'); $entityid = qa_post_text('entityid'); $setfavorite = qa_post_text('favorite'); $userid = qa_get_logged_in_userid(); if (!qa_check_form_security_code('favorite-' . $entitytype . '-' . $entityid, qa_post_text('code'))) { echo "QA_AJAX_RESPONSE\n0\n" . qa_lang('misc/form_security_reload'); } elseif (isset($userid)) { $cookieid = qa_cookie_get(); qa_user_favorite_set($userid, qa_get_logged_in_handle(), $cookieid, $entitytype, $entityid, $setfavorite); $favoriteform = qa_favorite_form($entitytype, $entityid, $setfavorite, qa_lang($setfavorite ? 'main/remove_favorites' : 'main/add_favorites')); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-favorite', null, null); echo "QA_AJAX_RESPONSE\n1\n"; $themeclass->favorite_inner_html($favoriteform); } /* Omit PHP closing tag to help avoid accidental output */
function qa_complete_reset_user($userid) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'util/string.php'; require_once QA_INCLUDE_DIR . 'app/options.php'; require_once QA_INCLUDE_DIR . 'app/emails.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php'; require_once QA_INCLUDE_DIR . 'db/selects.php'; $password = qa_random_alphanum(max(QA_MIN_PASSWORD_LEN, QA_NEW_PASSWORD_LEN)); $userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true)); if (!qa_send_notification($userid, $userinfo['email'], $userinfo['handle'], qa_lang('emails/new_password_subject'), qa_lang('emails/new_password_body'), array('^password' => $password, '^url' => qa_opt('site_url')))) { qa_fatal_error('Could not send new password - password not reset'); } qa_db_user_set_password($userid, $password); // do this last, to be safe qa_db_user_set($userid, 'emailcode', ''); // so can't be reused qa_report_event('u_reset', $userid, $userinfo['handle'], qa_cookie_get(), array('email' => $userinfo['email'])); }
function qa_page_q_comment_follow_list($parent, $commentsfollows, $alwaysfull, $usershtml, $formrequested, $formpostid) { $parentid = $parent['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $commentlist = array('tags' => 'ID="c' . qa_html($parentid) . '_list"', 'cs' => array()); $showcomments = array(); foreach ($commentsfollows as $commentfollowid => $commentfollow) { if ($commentfollow['parentid'] == $parentid && $commentfollow['viewable'] && $commentfollowid != $formpostid) { $showcomments[$commentfollowid] = $commentfollow; } } $countshowcomments = count($showcomments); if (!$alwaysfull && $countshowcomments > qa_opt('show_fewer_cs_from')) { $skipfirst = $countshowcomments - qa_opt('show_fewer_cs_count'); } else { $skipfirst = 0; } if ($skipfirst == $countshowcomments) { // showing none if ($skipfirst == 1) { $expandtitle = qa_lang_html('question/show_1_comment'); } else { $expandtitle = qa_lang_html_sub('question/show_x_comments', $skipfirst); } } else { if ($skipfirst == 1) { $expandtitle = qa_lang_html('question/show_1_previous_comment'); } else { $expandtitle = qa_lang_html_sub('question/show_x_previous_comments', $skipfirst); } } if ($skipfirst > 0) { $commentlist['cs'][$parentid] = array('url' => qa_html('?state=showcomments-' . $parentid . '&show=' . $parentid . '#' . urlencode(qa_anchor($parent['basetype'], $parentid))), 'expand_tags' => 'onClick="return qa_show_comments(' . qa_js($parentid) . ', this);"', 'title' => $expandtitle); } foreach ($showcomments as $commentfollowid => $commentfollow) { if ($skipfirst > 0) { $skipfirst--; } elseif ($commentfollow['basetype'] == 'C') { $commentlist['cs'][$commentfollowid] = qa_page_q_comment_view($parent, $commentfollow, $usershtml, $formrequested); } elseif ($commentfollow['basetype'] == 'Q') { $htmloptions = qa_post_html_defaults('Q'); $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size'); $commentlist['cs'][$commentfollowid] = qa_post_html_fields($commentfollow, $userid, $cookieid, $usershtml, null, $htmloptions); } } if (!count($commentlist['cs'])) { $commentlist['hidden'] = true; } return $commentlist; }
if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) { // check the user exists return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Get information on user references $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = array_slice($questions, 0, qa_opt('page_size_activity')); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false); // Prepare content for theme $qa_content = qa_content_prepare(true); if (count($questions)) { $qa_content['title'] = qa_lang_html_sub('profile/recent_activity_by_x', $userhtml); } else { $qa_content['title'] = qa_lang_html_sub('profile/no_posts_by_x', $userhtml); } // Recent activity by this user $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $qa_content['q_list']['qs'] = array(); $htmldefaults = qa_post_html_defaults('Q'); $htmldefaults['whoview'] = false; $htmldefaults['voteview'] = false; $htmldefaults['avatarsize'] = 0; foreach ($questions as $question) { $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults)); } // Sub menu for navigation in user pages $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'activity', isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid'])); return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
/** * Outputs cache to the user */ private function get_cache() { qa_report_process_stage('init_page'); qa_db_connect('qa_page_db_fail_handler'); qa_page_queue_pending(); qa_load_state(); qa_check_login_modules(); if (QA_DEBUG_PERFORMANCE) { if (qa_qa_version_below('1.7')) { qa_usage_mark('setup'); } else { //global $qa_usage; //$qa_usage->mark('setup'); null; } } qa_check_page_clicks(); qa_set_form_security_key(); if (!QA_CACHING_FILE) { $contents = $this->get_cache_db(); } else { $contents = $this->get_cache_file(); } $qa_content = array(); // Dummy contents $userid = qa_get_logged_in_userid(); $questionid = qa_request_part(0); $cookieid = qa_cookie_get(true); if (is_numeric($questionid)) { $question = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid)); if (is_numeric($questionid) && qa_opt('do_count_q_views') && !preg_match("/^(?:POST|PUT)\$/i", $_SERVER["REQUEST_METHOD"]) && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $userid || !isset($question['userid'])) && ($question['cookieid'] != $cookieid || !isset($question['cookieid'])))) { $qa_content['inc_views_postid'] = $questionid; } else { $qa_content['inc_views_postid'] = null; } qa_do_content_stats($qa_content); } if (QA_DEBUG_PERFORMANCE) { ob_start(); if (qa_qa_version_below('1.7')) { qa_usage_output(); } else { global $qa_usage; $qa_usage->output(); } $contents .= ob_get_contents(); ob_end_clean(); } qa_db_disconnect(); header('Content-type: ' . strtr('^type/^format; charset=utf-8', array('^type' => 'text', '^format' => $this->get_cache_file_extension()))); exit($contents); }
function qa_check_page_clicks() { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } global $qa_page_error_html; if (qa_is_http_post()) { foreach ($_POST as $field => $value) { if (strpos($field, 'vote_') === 0) { // voting... @(list($dummy, $postid, $vote, $anchor) = explode('_', $field)); if (isset($postid) && isset($vote)) { if (!qa_check_form_security_code('vote', qa_post_text('code'))) { $qa_page_error_html = qa_lang_html('misc/form_security_again'); } else { require_once QA_INCLUDE_DIR . 'app/votes.php'; require_once QA_INCLUDE_DIR . 'db/selects.php'; $userid = qa_get_logged_in_userid(); $post = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $postid)); $qa_page_error_html = qa_vote_error_html($post, $vote, $userid, qa_request()); if (!$qa_page_error_html) { qa_vote_set($post, $userid, qa_get_logged_in_handle(), qa_cookie_get(), $vote); qa_redirect(qa_request(), $_GET, null, null, $anchor); } break; } } } elseif (strpos($field, 'favorite_') === 0) { // favorites... @(list($dummy, $entitytype, $entityid, $favorite) = explode('_', $field)); if (isset($entitytype) && isset($entityid) && isset($favorite)) { if (!qa_check_form_security_code('favorite-' . $entitytype . '-' . $entityid, qa_post_text('code'))) { $qa_page_error_html = qa_lang_html('misc/form_security_again'); } else { require_once QA_INCLUDE_DIR . 'app/favorites.php'; qa_user_favorite_set(qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), $entitytype, $entityid, $favorite); qa_redirect(qa_request(), $_GET); } } } elseif (strpos($field, 'notice_') === 0) { // notices... @(list($dummy, $noticeid) = explode('_', $field)); if (isset($noticeid)) { if (!qa_check_form_security_code('notice-' . $noticeid, qa_post_text('code'))) { $qa_page_error_html = qa_lang_html('misc/form_security_again'); } else { if ($noticeid == 'visitor') { setcookie('qa_noticed', 1, time() + 86400 * 3650, '/', QA_COOKIE_DOMAIN); } elseif ($noticeid == 'welcome') { require_once QA_INCLUDE_DIR . 'db/users.php'; qa_db_user_set_flag(qa_get_logged_in_userid(), QA_USER_FLAGS_WELCOME_NOTICE, false); } else { require_once QA_INCLUDE_DIR . 'db/notices.php'; qa_db_usernotice_delete(qa_get_logged_in_userid(), $noticeid); } qa_redirect(qa_request(), $_GET); } } } } } }
function qa_page_q_edit_c_submit($comment, $question, $parent, &$in, &$errors) { $commentid = $comment['postid']; $prefix = 'c' . $commentid . '_'; $in = array(); if ($comment['isbyuser']) { $in['name'] = qa_post_text($prefix . 'name'); $in['notify'] = qa_post_text($prefix . 'notify') ? true : false; $in['email'] = qa_post_text($prefix . 'email'); } if (!qa_user_post_permit_error('permit_edit_silent', $comment)) { $in['silent'] = qa_post_text($prefix . 'silent'); } qa_get_post_content($prefix . 'editor', $prefix . 'content', $in['editor'], $in['content'], $in['format'], $in['text']); // here the $in array only contains values for parts of the form that were displayed, so those are only ones checked by filters $errors = array(); if (!qa_check_form_security_code('edit-' . $commentid, qa_post_text($prefix . 'code'))) { $errors['content'] = qa_lang_html('misc/form_security_again'); } else { $in['queued'] = qa_opt('moderate_edited_again') && qa_user_moderation_reason(qa_user_level_for_post($comment)); $filtermodules = qa_load_modules_with('filter', 'filter_comment'); foreach ($filtermodules as $filtermodule) { $oldin = $in; $filtermodule->filter_comment($in, $errors, $question, $parent, $comment); qa_update_post_text($in, $oldin); } if (empty($errors)) { $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); if (!isset($in['silent'])) { $in['silent'] = false; } $setnotify = $comment['isbyuser'] ? qa_combine_notify_email($comment['userid'], $in['notify'], $in['email']) : $comment['notify']; qa_comment_set_content($comment, $in['content'], $in['format'], $in['text'], $setnotify, $userid, $handle, $cookieid, $question, $parent, @$in['name'], $in['queued'], $in['silent']); return true; } } return false; }
if ($haspassword && strtolower(qa_db_calc_passcheck($inoldpassword, $useraccount['passsalt'])) != strtolower($useraccount['passcheck'])) { $errors['oldpassword'] = qa_lang('users/password_wrong'); } $useraccount['password'] = $inoldpassword; $errors = $errors + qa_password_validate($innewpassword1, $useraccount); // array union if ($innewpassword1 != $innewpassword2) { $errors['newpassword2'] = qa_lang('users/password_mismatch'); } if (empty($errors)) { qa_db_user_set_password($userid, $innewpassword1); qa_db_user_set($userid, 'sessioncode', ''); // stop old 'Remember me' style logins from still working qa_set_logged_in_user($userid, $useraccount['handle'], false, $useraccount['sessionsource']); // reinstate this specific session qa_report_event('u_password', $userid, $useraccount['handle'], qa_cookie_get()); qa_redirect('account', array('state' => 'password-changed')); } } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('profile/my_account_title'); $qa_content['error'] = @$errors['page']; $qa_content['form_profile'] = array('tags' => 'enctype="multipart/form-data" method="post" action="' . qa_self_html() . '"', 'style' => 'wide', 'fields' => array('duration' => array('type' => 'static', 'label' => qa_lang_html('users/member_for'), 'value' => qa_time_to_string(qa_opt('db_time') - $useraccount['created'])), 'type' => array('type' => 'static', 'label' => qa_lang_html('users/member_type'), 'value' => qa_html(qa_user_level_string($useraccount['level'])), 'note' => $isblocked ? qa_lang_html('users/user_blocked') : null), 'handle' => array('label' => qa_lang_html('users/handle_label'), 'tags' => 'name="handle"', 'value' => qa_html(isset($inhandle) ? $inhandle : $useraccount['handle']), 'error' => qa_html(@$errors['handle']), 'type' => $changehandle && !$isblocked ? 'text' : 'static'), 'email' => array('label' => qa_lang_html('users/email_label'), 'tags' => 'name="email"', 'value' => qa_html(isset($inemail) ? $inemail : $useraccount['email']), 'error' => isset($errors['email']) ? qa_html($errors['email']) : ($doconfirms && !$isconfirmed ? qa_insert_login_links(qa_lang_html('users/email_please_confirm')) : null), 'type' => $isblocked ? 'static' : 'text'), 'messages' => array('label' => qa_lang_html('users/private_messages'), 'tags' => 'name="messages"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES), 'note' => qa_lang_html('users/private_messages_explanation')), 'wall' => array('label' => qa_lang_html('users/wall_posts'), 'tags' => 'name="wall"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_WALL_POSTS), 'note' => qa_lang_html('users/wall_posts_explanation')), 'mailings' => array('label' => qa_lang_html('users/mass_mailings'), 'tags' => 'name="mailings"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_MAILINGS), 'note' => qa_lang_html('users/mass_mailings_explanation')), 'avatar' => null), 'buttons' => array('save' => array('tags' => 'onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('users/save_profile'))), 'hidden' => array('dosaveprofile' => '1', 'code' => qa_get_form_security_code('account'))); if (qa_get_state() == 'profile-saved') { $qa_content['form_profile']['ok'] = qa_lang_html('users/profile_saved'); } if (!qa_opt('allow_private_messages')) { unset($qa_content['form_profile']['fields']['messages']); }
as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. More about this license: http://www.question2answer.org/license.php */ require_once QA_INCLUDE_DIR . 'qa-app-messages.php'; require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-app-cookies.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; $tohandle = qa_post_text('handle'); $start = (int) qa_post_text('start'); $usermessages = qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $tohandle, false, null, $start)); $usermessages = qa_wall_posts_add_rules($usermessages, $start); foreach ($usermessages as $message) { if (qa_clicked('m' . $message['messageid'] . '_dodelete') && $message['deleteable']) { if (qa_check_form_security_code('wall-' . $tohandle, qa_post_text('code'))) { qa_wall_delete_post(qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), $message); echo "QA_AJAX_RESPONSE\n1\n"; return; } } } echo "QA_AJAX_RESPONSE\n0\n"; /* Omit PHP closing tag to help avoid accidental output */
function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $onlyimage = false, $imagemaxwidth = null, $imagemaxheight = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } $result = array(); // Check per-user upload limits require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-app-limits.php'; switch (qa_user_permit_error(null, QA_LIMIT_UPLOADS)) { case 'limit': $result['error'] = qa_lang('main/upload_limit'); return $result; case false: qa_limits_increment(qa_get_logged_in_userid(), QA_LIMIT_UPLOADS); break; default: $result['error'] = qa_lang('users/no_permission'); return $result; } // Check the uploaded file is not too large $filesize = filesize($localfilename); if (isset($maxfilesize)) { $maxfilesize = min($maxfilesize, qa_get_max_upload_size()); } else { $maxfilesize = qa_get_max_upload_size(); } if ($filesize <= 0 || $filesize > $maxfilesize) { // if file was too big for PHP, $filesize will be zero $result['error'] = qa_lang_sub('main/max_upload_size_x', number_format($maxfilesize / 1048576, 1) . 'MB'); return $result; } // Find out what type of source file was uploaded and if appropriate, check it's an image and get preliminary size measure $pathinfo = pathinfo($sourcefilename); $format = strtolower(@$pathinfo['extension']); $isimage = $format == 'png' || $format == 'gif' || $format == 'jpeg' || $format == 'jpg'; // allowed image extensions if ($isimage) { $imagesize = @getimagesize($localfilename); if (is_array($imagesize)) { $result['width'] = $imagesize[0]; $result['height'] = $imagesize[1]; switch ($imagesize['2']) { // reassign format based on actual content, if we can case IMAGETYPE_GIF: $format = 'gif'; break; case IMAGETYPE_JPEG: $format = 'jpeg'; break; case IMAGETYPE_PNG: $format = 'png'; break; } } } $result['format'] = $format; if ($onlyimage) { if (!$isimage || !is_array($imagesize)) { $result['error'] = qa_lang_sub('main/image_not_read', 'GIF, JPG, PNG'); return $result; } } // Read in the raw file contents $content = file_get_contents($localfilename); // If appropriate, get more accurate image size and apply constraints to it require_once QA_INCLUDE_DIR . 'qa-util-image.php'; if ($isimage && qa_has_gd_image()) { $image = @imagecreatefromstring($content); if (is_resource($image)) { $result['width'] = $width = imagesx($image); $result['height'] = $height = imagesy($image); if (isset($imagemaxwidth) || isset($imagemaxheight)) { if (qa_image_constrain($width, $height, isset($imagemaxwidth) ? $imagemaxwidth : $width, isset($imagemaxheight) ? $imagemaxheight : $height)) { qa_gd_image_resize($image, $width, $height); if (is_resource($image)) { $content = qa_gd_image_jpeg($image); $result['format'] = $format = 'jpeg'; $result['width'] = $width; $result['height'] = $height; } } } if (is_resource($image)) { // might have been lost imagedestroy($image); } } } // Create the blob and return require_once QA_INCLUDE_DIR . 'qa-app-blobs.php'; $userid = qa_get_logged_in_userid(); $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); $result['blobid'] = qa_create_blob($content, $format, $sourcefilename, $userid, $cookieid, qa_remote_ip_address()); if (!isset($result['blobid'])) { $result['error'] = qa_lang('main/general_error'); return $result; } $result['bloburl'] = qa_get_blob_url($result['blobid'], true); return $result; }
foreach ($filtermodules as $filtermodule) { $oldin = $in; $filtermodule->filter_question($in, $errors, null); qa_update_post_text($in, $oldin); } if (qa_using_categories() && count($categories) && !qa_opt('allow_no_category') && !isset($in['categoryid'])) { $errors['categoryid'] = qa_lang_html('question/category_required'); } elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) { $errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed'); } if ($captchareason) { require_once 'qa-app-captcha.php'; qa_captcha_validate_post($errors); } if (empty($errors)) { $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary $questionid = qa_question_create($followanswer, $userid, qa_get_logged_in_handle(), $cookieid, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $in['notify'], $in['email'], $in['categoryid'], $in['extra'], $in['queued'], $in['name']); qa_redirect(qa_q_request($questionid, $in['title'])); // our work is done here } } } // Prepare content for theme $qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, @$in['categoryid']))); $qa_content['title'] = qa_lang_html(isset($followanswer) ? 'question/ask_follow_title' : 'question/ask_title'); $qa_content['error'] = @$errors['page']; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); $field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false); $field['label'] = qa_lang_html('question/q_content_label');
if (@$userpoints['aselects']) { $qa_content['form_activity']['fields']['questions']['value'] .= $userpoints['aselects'] == 1 ? qa_lang_html_sub('profile/1_with_best_chosen', '<SPAN CLASS="qa-uf-user-q-selects">1</SPAN>', '1') : qa_lang_html_sub('profile/x_with_best_chosen', '<SPAN CLASS="qa-uf-user-q-selects">' . number_format($userpoints['aselects']) . '</SPAN>'); } if (@$userpoints['aselecteds']) { $qa_content['form_activity']['fields']['answers']['value'] .= $userpoints['aselecteds'] == 1 ? qa_lang_html_sub('profile/1_chosen_as_best', '<SPAN CLASS="qa-uf-user-a-selecteds">1</SPAN>', '1') : qa_lang_html_sub('profile/x_chosen_as_best', '<SPAN CLASS="qa-uf-user-a-selecteds">' . number_format($userpoints['aselecteds']) . '</SPAN>'); } // For plugin layers to access $qa_content['raw']['userid'] = $userid; $qa_content['raw']['points'] = $userpoints; $qa_content['raw']['rank'] = $userrank; // Recent posts by this user if ($pagesize > 0) { if (count($questions)) { $qa_content['q_list']['title'] = qa_lang_html_sub('profile/recent_activity_by_x', $userhtml); } else { $qa_content['q_list']['title'] = qa_lang_html_sub('profile/no_posts_by_x', $userhtml); } $qa_content['q_list']['form_profile'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"'); $qa_content['q_list']['qs'] = array(); $htmloptions = qa_post_html_defaults('Q'); $htmloptions['whoview'] = true; //false; $htmloptions['avatarsize'] = 0; foreach ($questions as $question) { $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, $htmloptions); } } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */