Commit 2be2b6bb by Scott

Coding style (misc. pages)

parent d057c557
...@@ -20,99 +20,94 @@ ...@@ -20,99 +20,94 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
$categoryslugs=qa_request_parts(1); $categoryslugs = qa_request_parts(1);
$countslugs=count($categoryslugs); $countslugs = count($categoryslugs);
// Get information about appropriate categories and redirect to questions page if category has no sub-categories // Get information about appropriate categories and redirect to questions page if category has no sub-categories
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($categories, $categoryid, $favoritecats)=qa_db_select_with_pending( list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending(
qa_db_category_nav_selectspec($categoryslugs, false, false, true), qa_db_category_nav_selectspec($categoryslugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null,
isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null
); );
if ($countslugs && !isset($categoryid)) if ($countslugs && !isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Function for recursive display of categories // Function for recursive display of categories
function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap) function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap)
{ {
foreach ($navigation as $key => $navlink) { foreach ($navigation as $key => $navlink) {
$category=$categories[$navlink['categoryid']]; $category = $categories[$navlink['categoryid']];
if (!$category['childcount']) if (!$category['childcount'])
unset($navigation[$key]['url']); unset($navigation[$key]['url']);
elseif ($navlink['selected']) { elseif ($navlink['selected']) {
$navigation[$key]['state']='open'; $navigation[$key]['state'] = 'open';
$navigation[$key]['url']=qa_path_html('categories/'.qa_category_path_request($categories, $category['parentid'])); $navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid']));
} else } else
$navigation[$key]['state']='closed'; $navigation[$key]['state'] = 'closed';
if (@$favoritemap[$navlink['categoryid']]) if (@$favoritemap[$navlink['categoryid']])
$navigation[$key]['favorited']=true; $navigation[$key]['favorited'] = true;
$navigation[$key]['note']=''; $navigation[$key]['note'] = '';
$navigation[$key]['note'].= $navigation[$key]['note'] .=
' - <a href="'.qa_path_html('questions/'.implode('/', array_reverse(explode('/', $category['backpath'])))).'">'.( ($category['qcount']==1) ' - <a href="' . qa_path_html('questions/' . implode('/', array_reverse(explode('/', $category['backpath'])))) . '">' . (($category['qcount'] == 1)
? qa_lang_html_sub('main/1_question', '1', '1') ? qa_lang_html_sub('main/1_question', '1', '1')
: qa_lang_html_sub('main/x_questions', qa_format_number($category['qcount'], 0, true)) : qa_lang_html_sub('main/x_questions', qa_format_number($category['qcount'], 0, true))
).'</a>'; ) . '</a>';
if (strlen($category['content'])) if (strlen($category['content']))
$navigation[$key]['note'].=qa_html(' - '.$category['content']); $navigation[$key]['note'] .= qa_html(' - ' . $category['content']);
if (isset($navlink['subnav'])) if (isset($navlink['subnav']))
qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap); qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap);
}
} }
}
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(false, array_keys(qa_category_path($categories, $categoryid))); $qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, $categoryid)));
$qa_content['title']=qa_lang_html('misc/browse_categories'); $qa_content['title'] = qa_lang_html('misc/browse_categories');
if (count($categories)) { if (count($categories)) {
$navigation=qa_category_navigation($categories, $categoryid, 'categories/', false); $navigation = qa_category_navigation($categories, $categoryid, 'categories/', false);
unset($navigation['all']); unset($navigation['all']);
$favoritemap=array(); $favoritemap = array();
if (isset($favoritecats)) if (isset($favoritecats))
foreach ($favoritecats as $category) foreach ($favoritecats as $category)
$favoritemap[$category['categoryid']]=true; $favoritemap[$category['categoryid']] = true;
qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap); qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap);
$qa_content['nav_list']=array(
'nav' => $navigation,
'type' => 'browse-cat',
);
} else {
$qa_content['title']=qa_lang_html('main/no_categories_found');
$qa_content['suggest_next']=qa_html_suggest_qs_tags(qa_using_tags());
}
$qa_content['nav_list'] = array(
'nav' => $navigation,
'type' => 'browse-cat',
);
return $qa_content; } else {
$qa_content['title'] = qa_lang_html('main/no_categories_found');
$qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
}
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,88 +20,84 @@ ...@@ -20,88 +20,84 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/favorites.php'; require_once QA_INCLUDE_DIR . 'app/favorites.php';
// Data for functions to run // Data for functions to run
$favswitch = array(
'questions' => array( $favswitch = array(
'page_opt' => 'page_size_qs', 'questions' => array(
'fn_spec' => 'qa_db_user_favorite_qs_selectspec', 'page_opt' => 'page_size_qs',
'fn_view' => 'qa_favorite_q_list_view', 'fn_spec' => 'qa_db_user_favorite_qs_selectspec',
'key' => 'q_list', 'fn_view' => 'qa_favorite_q_list_view',
), 'key' => 'q_list',
'users' => array( ),
'page_opt' => 'page_size_users', 'users' => array(
'fn_spec' => 'qa_db_user_favorite_users_selectspec', 'page_opt' => 'page_size_users',
'fn_view' => 'qa_favorite_users_view', 'fn_spec' => 'qa_db_user_favorite_users_selectspec',
'key' => 'ranking_users', 'fn_view' => 'qa_favorite_users_view',
), 'key' => 'ranking_users',
'tags' => array( ),
'page_opt' => 'page_size_tags', 'tags' => array(
'fn_spec' => 'qa_db_user_favorite_tags_selectspec', 'page_opt' => 'page_size_tags',
'fn_view' => 'qa_favorite_tags_view', 'fn_spec' => 'qa_db_user_favorite_tags_selectspec',
'key' => 'ranking_tags', 'fn_view' => 'qa_favorite_tags_view',
), 'key' => 'ranking_tags',
); ),
);
// Check that we're logged in // Check that we're logged in
$userid = qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if (!isset($userid)) if (!isset($userid))
qa_redirect('login'); qa_redirect('login');
// Get lists of favorites of this type // Get lists of favorites of this type
$favtype = qa_request_part(1); $favtype = qa_request_part(1);
$start = qa_get_start(); $start = qa_get_start();
if (!array_key_exists($favtype, $favswitch) || ($favtype === 'users' && QA_FINAL_EXTERNAL_USERS)) if (!array_key_exists($favtype, $favswitch) || ($favtype === 'users' && QA_FINAL_EXTERNAL_USERS))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
extract($favswitch[$favtype]); // get switch variables extract($favswitch[$favtype]); // get switch variables
$pagesize = qa_opt($page_opt); $pagesize = qa_opt($page_opt);
list($totalItems, $items) = qa_db_select_with_pending( list($totalItems, $items) = qa_db_select_with_pending(
qa_db_selectspec_count($fn_spec($userid)), qa_db_selectspec_count($fn_spec($userid)),
$fn_spec($userid, $pagesize, $start) $fn_spec($userid, $pagesize, $start)
); );
$count = $totalItems['count']; $count = $totalItems['count'];
$usershtml = qa_userids_handles_html($items); $usershtml = qa_userids_handles_html($items);
// Prepare and return content for theme // Prepare and return content for theme
$qa_content = qa_content_prepare(true); $qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html('misc/my_favorites_title'); $qa_content['title'] = qa_lang_html('misc/my_favorites_title');
$qa_content[$key] = $fn_view($items, $usershtml); $qa_content[$key] = $fn_view($items, $usershtml);
// Sub navigation for account pages and suggestion // Sub navigation for account pages and suggestion
$qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>'); $qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>');
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true); $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true);
return $qa_content;
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,105 +20,100 @@ ...@@ -20,105 +20,100 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/favorites.php'; require_once QA_INCLUDE_DIR . 'app/favorites.php';
// Check that we're logged in // Check that we're logged in
$userid = qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if (!isset($userid)) if (!isset($userid))
qa_redirect('login'); qa_redirect('login');
// Get lists of favorites for this user // Get lists of favorites for this user
$pagesize_qs = qa_opt('page_size_qs'); $pagesize_qs = qa_opt('page_size_qs');
$pagesize_users = qa_opt('page_size_users'); $pagesize_users = qa_opt('page_size_users');
$pagesize_tags = qa_opt('page_size_tags'); $pagesize_tags = qa_opt('page_size_tags');
list($numQs, $questions, $numUsers, $users, $numTags, $tags, $categories) = qa_db_select_with_pending( list($numQs, $questions, $numUsers, $users, $numTags, $tags, $categories) = qa_db_select_with_pending(
qa_db_selectspec_count( qa_db_user_favorite_qs_selectspec($userid) ), qa_db_selectspec_count(qa_db_user_favorite_qs_selectspec($userid)),
qa_db_user_favorite_qs_selectspec($userid, $pagesize_qs), qa_db_user_favorite_qs_selectspec($userid, $pagesize_qs),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_selectspec_count( qa_db_user_favorite_users_selectspec($userid) ), QA_FINAL_EXTERNAL_USERS ? null : qa_db_selectspec_count(qa_db_user_favorite_users_selectspec($userid)),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_favorite_users_selectspec($userid, $pagesize_users), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_favorite_users_selectspec($userid, $pagesize_users),
qa_db_selectspec_count( qa_db_user_favorite_tags_selectspec($userid) ), qa_db_selectspec_count(qa_db_user_favorite_tags_selectspec($userid)),
qa_db_user_favorite_tags_selectspec($userid, $pagesize_tags), qa_db_user_favorite_tags_selectspec($userid, $pagesize_tags),
qa_db_user_favorite_categories_selectspec($userid) qa_db_user_favorite_categories_selectspec($userid)
); );
$usershtml = qa_userids_handles_html(QA_FINAL_EXTERNAL_USERS ? $questions : array_merge($questions, $users)); $usershtml = qa_userids_handles_html(QA_FINAL_EXTERNAL_USERS ? $questions : array_merge($questions, $users));
// Prepare and return content for theme // Prepare and return content for theme
$qa_content = qa_content_prepare(true); $qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html('misc/my_favorites_title'); $qa_content['title'] = qa_lang_html('misc/my_favorites_title');
// Favorite questions // Favorite questions
$qa_content['q_list'] = qa_favorite_q_list_view($questions, $usershtml); $qa_content['q_list'] = qa_favorite_q_list_view($questions, $usershtml);
$qa_content['q_list']['title'] = count($questions) ? qa_lang_html('main/nav_qs') : qa_lang_html('misc/no_favorite_qs'); $qa_content['q_list']['title'] = count($questions) ? qa_lang_html('main/nav_qs') : qa_lang_html('misc/no_favorite_qs');
if ($numQs['count'] > count($questions)) { if ($numQs['count'] > count($questions)) {
$url = qa_path_html('favorites/questions', array('start'=>$pagesize_qs)); $url = qa_path_html('favorites/questions', array('start' => $pagesize_qs));
$qa_content['q_list']['footer'] = '<p class="qa-link-next"><a href="'.$url.'">'.qa_lang_html('misc/more_favorite_qs').'</a></p>'; $qa_content['q_list']['footer'] = '<p class="qa-link-next"><a href="' . $url . '">' . qa_lang_html('misc/more_favorite_qs') . '</a></p>';
} }
// Favorite users // Favorite users
if (!QA_FINAL_EXTERNAL_USERS) { if (!QA_FINAL_EXTERNAL_USERS) {
$qa_content['ranking_users'] = qa_favorite_users_view($users, $usershtml); $qa_content['ranking_users'] = qa_favorite_users_view($users, $usershtml);
$qa_content['ranking_users']['title'] = count($users) ? qa_lang_html('main/nav_users') : qa_lang_html('misc/no_favorite_users'); $qa_content['ranking_users']['title'] = count($users) ? qa_lang_html('main/nav_users') : qa_lang_html('misc/no_favorite_users');
if ($numUsers['count'] > count($users)) { if ($numUsers['count'] > count($users)) {
$url = qa_path_html('favorites/users', array('start'=>$pagesize_users)); $url = qa_path_html('favorites/users', array('start' => $pagesize_users));
$qa_content['ranking_users']['footer'] = '<p class="qa-link-next"><a href="'.$url.'">'.qa_lang_html('misc/more_favorite_users').'</a></p>'; $qa_content['ranking_users']['footer'] = '<p class="qa-link-next"><a href="' . $url . '">' . qa_lang_html('misc/more_favorite_users') . '</a></p>';
}
} }
}
// Favorite tags // Favorite tags
if (qa_using_tags()) { if (qa_using_tags()) {
$qa_content['ranking_tags'] = qa_favorite_tags_view($tags); $qa_content['ranking_tags'] = qa_favorite_tags_view($tags);
$qa_content['ranking_tags']['title'] = count($tags) ? qa_lang_html('main/nav_tags') : qa_lang_html('misc/no_favorite_tags'); $qa_content['ranking_tags']['title'] = count($tags) ? qa_lang_html('main/nav_tags') : qa_lang_html('misc/no_favorite_tags');
if ($numTags['count'] > count($tags)) { if ($numTags['count'] > count($tags)) {
$url = qa_path_html('favorites/tags', array('start'=>$pagesize_tags)); $url = qa_path_html('favorites/tags', array('start' => $pagesize_tags));
$qa_content['ranking_tags']['footer'] = '<p class="qa-link-next"><a href="'.$url.'">'.qa_lang_html('misc/more_favorite_tags').'</a></p>'; $qa_content['ranking_tags']['footer'] = '<p class="qa-link-next"><a href="' . $url . '">' . qa_lang_html('misc/more_favorite_tags') . '</a></p>';
}
} }
}
// Favorite categories (no pagination) // Favorite categories (no pagination)
if (qa_using_categories()) { if (qa_using_categories()) {
$qa_content['nav_list_categories'] = qa_favorite_categories_view($categories); $qa_content['nav_list_categories'] = qa_favorite_categories_view($categories);
$qa_content['nav_list_categories']['title'] = count($categories) ? qa_lang_html('main/nav_categories') : qa_lang_html('misc/no_favorite_categories'); $qa_content['nav_list_categories']['title'] = count($categories) ? qa_lang_html('main/nav_categories') : qa_lang_html('misc/no_favorite_categories');
} }
// Sub navigation for account pages and suggestion // Sub navigation for account pages and suggestion
$qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>'); $qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>');
$qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true); $qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true);
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,166 +20,163 @@ ...@@ -20,166 +20,163 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/captcha.php'; require_once QA_INCLUDE_DIR . 'app/captcha.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
// Get useful information on the logged in user // Get useful information on the logged in user
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if (isset($userid) && !QA_FINAL_EXTERNAL_USERS) if (isset($userid) && !QA_FINAL_EXTERNAL_USERS) {
list($useraccount, $userprofile)=qa_db_select_with_pending( list($useraccount, $userprofile) = qa_db_select_with_pending(
qa_db_user_account_selectspec($userid, true), qa_db_user_account_selectspec($userid, true),
qa_db_user_profile_selectspec($userid, true) qa_db_user_profile_selectspec($userid, true)
); );
}
$usecaptcha=qa_opt('captcha_on_feedback') && qa_user_use_captcha(); $usecaptcha = qa_opt('captcha_on_feedback') && qa_user_use_captcha();
// Check feedback is enabled and the person isn't blocked // Check feedback is enabled and the person isn't blocked
if (!qa_opt('feedback_enabled')) if (!qa_opt('feedback_enabled'))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
if (qa_user_permit_error()) { if (qa_user_permit_error()) {
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content; return $qa_content;
} }
// Send the feedback form // Send the feedback form
$feedbacksent=false; $feedbacksent = false;
if (qa_clicked('dofeedback')) { if (qa_clicked('dofeedback')) {
require_once QA_INCLUDE_DIR.'app/emails.php'; require_once QA_INCLUDE_DIR . 'app/emails.php';
require_once QA_INCLUDE_DIR.'util/string.php'; require_once QA_INCLUDE_DIR . 'util/string.php';
$inmessage=qa_post_text('message'); $inmessage = qa_post_text('message');
$inname=qa_post_text('name'); $inname = qa_post_text('name');
$inemail=qa_post_text('email'); $inemail = qa_post_text('email');
$inreferer=qa_post_text('referer'); $inreferer = qa_post_text('referer');
if (!qa_check_form_security_code('feedback', qa_post_text('code'))) if (!qa_check_form_security_code('feedback', qa_post_text('code')))
$pageerror=qa_lang_html('misc/form_security_again'); $pageerror = qa_lang_html('misc/form_security_again');
else { else {
if (empty($inmessage)) if (empty($inmessage))
$errors['message']=qa_lang('misc/feedback_empty'); $errors['message'] = qa_lang('misc/feedback_empty');
if ($usecaptcha) if ($usecaptcha)
qa_captcha_validate_post($errors); qa_captcha_validate_post($errors);
if (empty($errors)) { if (empty($errors)) {
$subs=array( $subs = array(
'^message' => $inmessage, '^message' => $inmessage,
'^name' => empty($inname) ? '-' : $inname, '^name' => empty($inname) ? '-' : $inname,
'^email' => empty($inemail) ? '-' : $inemail, '^email' => empty($inemail) ? '-' : $inemail,
'^previous' => empty($inreferer) ? '-' : $inreferer, '^previous' => empty($inreferer) ? '-' : $inreferer,
'^url' => isset($userid) ? qa_path_absolute('user/'.qa_get_logged_in_handle()) : '-', '^url' => isset($userid) ? qa_path_absolute('user/' . qa_get_logged_in_handle()) : '-',
'^ip' => qa_remote_ip_address(), '^ip' => qa_remote_ip_address(),
'^browser' => @$_SERVER['HTTP_USER_AGENT'], '^browser' => @$_SERVER['HTTP_USER_AGENT'],
); );
if (qa_send_email(array( if (qa_send_email(array(
'fromemail' => qa_email_validate(@$inemail) ? $inemail : qa_opt('from_email'), 'fromemail' => qa_email_validate(@$inemail) ? $inemail : qa_opt('from_email'),
'fromname' => $inname, 'fromname' => $inname,
'toemail' => qa_opt('feedback_email'), 'toemail' => qa_opt('feedback_email'),
'toname' => qa_opt('site_title'), 'toname' => qa_opt('site_title'),
'subject' => qa_lang_sub('emails/feedback_subject', qa_opt('site_title')), 'subject' => qa_lang_sub('emails/feedback_subject', qa_opt('site_title')),
'body' => strtr(qa_lang('emails/feedback_body'), $subs), 'body' => strtr(qa_lang('emails/feedback_body'), $subs),
'html' => false, 'html' => false,
))) ))) {
$feedbacksent=true; $feedbacksent = true;
else } else {
$pageerror=qa_lang_html('main/general_error'); $pageerror = qa_lang_html('main/general_error');
qa_report_event('feedback', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'email' => $inemail,
'name' => $inname,
'message' => $inmessage,
'previous' => $inreferer,
'browser' => @$_SERVER['HTTP_USER_AGENT'],
));
} }
qa_report_event('feedback', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'email' => $inemail,
'name' => $inname,
'message' => $inmessage,
'previous' => $inreferer,
'browser' => @$_SERVER['HTTP_USER_AGENT'],
));
} }
} }
}
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('misc/feedback_title'); $qa_content['title'] = qa_lang_html('misc/feedback_title');
$qa_content['error']=@$pageerror; $qa_content['error'] = @$pageerror;
$qa_content['form']=array( $qa_content['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'tall', 'style' => 'tall',
'fields' => array( 'fields' => array(
'message' => array( 'message' => array(
'type' => $feedbacksent ? 'static' : '', 'type' => $feedbacksent ? 'static' : '',
'label' => qa_lang_html_sub('misc/feedback_message', qa_opt('site_title')), 'label' => qa_lang_html_sub('misc/feedback_message', qa_opt('site_title')),
'tags' => 'name="message" id="message"', 'tags' => 'name="message" id="message"',
'value' => qa_html(@$inmessage), 'value' => qa_html(@$inmessage),
'rows' => 8, 'rows' => 8,
'error' => qa_html(@$errors['message']), 'error' => qa_html(@$errors['message']),
),
'name' => array(
'type' => $feedbacksent ? 'static' : '',
'label' => qa_lang_html('misc/feedback_name'),
'tags' => 'name="name"',
'value' => qa_html(isset($inname) ? $inname : @$userprofile['name']),
),
'email' => array(
'type' => $feedbacksent ? 'static' : '',
'label' => qa_lang_html('misc/feedback_email'),
'tags' => 'name="email"',
'value' => qa_html(isset($inemail) ? $inemail : qa_get_logged_in_email()),
'note' => $feedbacksent ? null : qa_opt('email_privacy'),
),
), ),
'buttons' => array( 'name' => array(
'send' => array( 'type' => $feedbacksent ? 'static' : '',
'label' => qa_lang_html('main/send_button'), 'label' => qa_lang_html('misc/feedback_name'),
), 'tags' => 'name="name"',
'value' => qa_html(isset($inname) ? $inname : @$userprofile['name']),
), ),
'hidden' => array( 'email' => array(
'dofeedback' => '1', 'type' => $feedbacksent ? 'static' : '',
'code' => qa_get_form_security_code('feedback'), 'label' => qa_lang_html('misc/feedback_email'),
'referer' => qa_html(isset($inreferer) ? $inreferer : @$_SERVER['HTTP_REFERER']), 'tags' => 'name="email"',
'value' => qa_html(isset($inemail) ? $inemail : qa_get_logged_in_email()),
'note' => $feedbacksent ? null : qa_opt('email_privacy'),
), ),
); ),
if ($usecaptcha && !$feedbacksent) 'buttons' => array(
qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors); 'send' => array(
'label' => qa_lang_html('main/send_button'),
),
),
'hidden' => array(
'dofeedback' => '1',
'code' => qa_get_form_security_code('feedback'),
'referer' => qa_html(isset($inreferer) ? $inreferer : @$_SERVER['HTTP_REFERER']),
),
);
$qa_content['focusid']='message'; if ($usecaptcha && !$feedbacksent)
qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors);
if ($feedbacksent) {
$qa_content['form']['ok']=qa_lang_html('misc/feedback_sent');
unset($qa_content['form']['buttons']);
}
$qa_content['focusid'] = 'message';
return $qa_content; if ($feedbacksent) {
$qa_content['form']['ok'] = qa_lang_html('misc/feedback_sent');
unset($qa_content['form']['buttons']);
}
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,106 +20,101 @@ ...@@ -20,106 +20,101 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/users.php'; require_once QA_INCLUDE_DIR . 'db/users.php';
require_once QA_INCLUDE_DIR.'app/captcha.php'; require_once QA_INCLUDE_DIR . 'app/captcha.php';
// Check we're not using single-sign on integration and that we're not logged in // Check we're not using single-sign on integration and that we're not logged in
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User login is handled by external code'); qa_fatal_error('User login is handled by external code');
if (qa_is_logged_in()) if (qa_is_logged_in())
qa_redirect(''); qa_redirect('');
// Start the 'I forgot my password' process, sending email if appropriate // Start the 'I forgot my password' process, sending email if appropriate
if (qa_clicked('doforgot')) { if (qa_clicked('doforgot')) {
require_once QA_INCLUDE_DIR.'app/users-edit.php'; require_once QA_INCLUDE_DIR . 'app/users-edit.php';
$inemailhandle=qa_post_text('emailhandle'); $inemailhandle = qa_post_text('emailhandle');
$errors=array(); $errors = array();
if (!qa_check_form_security_code('forgot', qa_post_text('code'))) if (!qa_check_form_security_code('forgot', qa_post_text('code')))
$errors['page']=qa_lang_html('misc/form_security_again'); $errors['page'] = qa_lang_html('misc/form_security_again');
else { else {
if (strpos($inemailhandle, '@')===false) { // handles can't contain @ symbols if (strpos($inemailhandle, '@') === false) { // handles can't contain @ symbols
$matchusers=qa_db_user_find_by_handle($inemailhandle); $matchusers = qa_db_user_find_by_handle($inemailhandle);
$passemailhandle=!qa_opt('allow_login_email_only'); $passemailhandle = !qa_opt('allow_login_email_only');
} else { } else {
$matchusers=qa_db_user_find_by_email($inemailhandle); $matchusers = qa_db_user_find_by_email($inemailhandle);
$passemailhandle=true; $passemailhandle = true;
} }
if (count($matchusers)!=1) // if we get more than one match (should be impossible) also give an error if (count($matchusers) != 1) // if we get more than one match (should be impossible) also give an error
$errors['emailhandle']=qa_lang('users/user_not_found'); $errors['emailhandle'] = qa_lang('users/user_not_found');
if (qa_opt('captcha_on_reset_password')) if (qa_opt('captcha_on_reset_password'))
qa_captcha_validate_post($errors); qa_captcha_validate_post($errors);
if (empty($errors)) { if (empty($errors)) {
$inuserid=$matchusers[0]; $inuserid = $matchusers[0];
qa_start_reset_user($inuserid); qa_start_reset_user($inuserid);
qa_redirect('reset', $passemailhandle ? array('e' => $inemailhandle) : null); // redirect to page where code is entered qa_redirect('reset', $passemailhandle ? array('e' => $inemailhandle) : null); // redirect to page where code is entered
}
} }
}
} else } else
$inemailhandle=qa_get('e'); $inemailhandle = qa_get('e');
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('users/reset_title'); $qa_content['title'] = qa_lang_html('users/reset_title');
$qa_content['error']=@$errors['page']; $qa_content['error'] = @$errors['page'];
$qa_content['form']=array( $qa_content['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'tall', 'style' => 'tall',
'fields' => array( 'fields' => array(
'email_handle' => array( 'email_handle' => array(
'label' => qa_lang_html('users/email_handle_label'), 'label' => qa_lang_html('users/email_handle_label'),
'tags' => 'name="emailhandle" id="emailhandle"', 'tags' => 'name="emailhandle" id="emailhandle"',
'value' => qa_html(@$inemailhandle), 'value' => qa_html(@$inemailhandle),
'error' => qa_html(@$errors['emailhandle']), 'error' => qa_html(@$errors['emailhandle']),
'note' => qa_lang_html('users/send_reset_note'), 'note' => qa_lang_html('users/send_reset_note'),
),
), ),
),
'buttons' => array( 'buttons' => array(
'send' => array( 'send' => array(
'label' => qa_lang_html('users/send_reset_button'), 'label' => qa_lang_html('users/send_reset_button'),
),
), ),
),
'hidden' => array( 'hidden' => array(
'doforgot' => '1', 'doforgot' => '1',
'code' => qa_get_form_security_code('forgot'), 'code' => qa_get_form_security_code('forgot'),
), ),
); );
if (qa_opt('captcha_on_reset_password')) if (qa_opt('captcha_on_reset_password'))
qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors); qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors);
$qa_content['focusid']='emailhandle'; $qa_content['focusid'] = 'emailhandle';
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,216 +20,214 @@ ...@@ -20,216 +20,214 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
$ip=qa_request_part(1); // picked up from qa-page.php $ip = qa_request_part(1); // picked up from qa-page.php
if (filter_var($ip, FILTER_VALIDATE_IP) === false) if (filter_var($ip, FILTER_VALIDATE_IP) === false)
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Find recently (hidden, queued or not) questions, answers, comments and edits for this IP // Find recently (hidden, queued or not) questions, answers, comments and edits for this IP
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($qs, $qs_queued, $qs_hidden, $a_qs, $a_queued_qs, $a_hidden_qs, $c_qs, $c_queued_qs, $c_hidden_qs, $edit_qs)= list($qs, $qs_queued, $qs_hidden, $a_qs, $a_queued_qs, $a_hidden_qs, $c_qs, $c_queued_qs, $c_hidden_qs, $edit_qs) =
qa_db_select_with_pending( qa_db_select_with_pending(
qa_db_qs_selectspec($userid, 'created', 0, null, $ip, false), qa_db_qs_selectspec($userid, 'created', 0, null, $ip, false),
qa_db_qs_selectspec($userid, 'created', 0, null, $ip, 'Q_QUEUED'), qa_db_qs_selectspec($userid, 'created', 0, null, $ip, 'Q_QUEUED'),
qa_db_qs_selectspec($userid, 'created', 0, null, $ip, 'Q_HIDDEN', true), qa_db_qs_selectspec($userid, 'created', 0, null, $ip, 'Q_HIDDEN', true),
qa_db_recent_a_qs_selectspec($userid, 0, null, $ip, false), qa_db_recent_a_qs_selectspec($userid, 0, null, $ip, false),
qa_db_recent_a_qs_selectspec($userid, 0, null, $ip, 'A_QUEUED'), qa_db_recent_a_qs_selectspec($userid, 0, null, $ip, 'A_QUEUED'),
qa_db_recent_a_qs_selectspec($userid, 0, null, $ip, 'A_HIDDEN', true), qa_db_recent_a_qs_selectspec($userid, 0, null, $ip, 'A_HIDDEN', true),
qa_db_recent_c_qs_selectspec($userid, 0, null, $ip, false), qa_db_recent_c_qs_selectspec($userid, 0, null, $ip, false),
qa_db_recent_c_qs_selectspec($userid, 0, null, $ip, 'C_QUEUED'), qa_db_recent_c_qs_selectspec($userid, 0, null, $ip, 'C_QUEUED'),
qa_db_recent_c_qs_selectspec($userid, 0, null, $ip, 'C_HIDDEN', true), qa_db_recent_c_qs_selectspec($userid, 0, null, $ip, 'C_HIDDEN', true),
qa_db_recent_edit_qs_selectspec($userid, 0, null, $ip, false) qa_db_recent_edit_qs_selectspec($userid, 0, null, $ip, false)
); );
// Check we have permission to view this page, and whether we can block or unblock IPs // Check we have permission to view this page, and whether we can block or unblock IPs
if (qa_user_maximum_permit_error('permit_anon_view_ips')) { if (qa_user_maximum_permit_error('permit_anon_view_ips')) {
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content; return $qa_content;
} }
$blockable=qa_user_level_maximum()>=QA_USER_LEVEL_MODERATOR; // allow moderator in one category to block across all categories $blockable = qa_user_level_maximum() >= QA_USER_LEVEL_MODERATOR; // allow moderator in one category to block across all categories
// Perform blocking or unblocking operations as appropriate // Perform blocking or unblocking operations as appropriate
if (qa_clicked('doblock') || qa_clicked('dounblock') || qa_clicked('dohideall')) { if (qa_clicked('doblock') || qa_clicked('dounblock') || qa_clicked('dohideall')) {
if (!qa_check_form_security_code('ip-'.$ip, qa_post_text('code'))) if (!qa_check_form_security_code('ip-' . $ip, qa_post_text('code')))
$pageerror=qa_lang_html('misc/form_security_again'); $pageerror = qa_lang_html('misc/form_security_again');
elseif ($blockable) { elseif ($blockable) {
if (qa_clicked('doblock')) { if (qa_clicked('doblock')) {
$oldblocked=qa_opt('block_ips_write'); $oldblocked = qa_opt('block_ips_write');
qa_set_option('block_ips_write', (strlen($oldblocked) ? ($oldblocked.' , ') : '').$ip); qa_set_option('block_ips_write', (strlen($oldblocked) ? ($oldblocked . ' , ') : '') . $ip);
qa_report_event('ip_block', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array( qa_report_event('ip_block', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'ip' => $ip, 'ip' => $ip,
)); ));
qa_redirect(qa_request()); qa_redirect(qa_request());
} }
if (qa_clicked('dounblock')) { if (qa_clicked('dounblock')) {
require_once QA_INCLUDE_DIR.'app/limits.php'; require_once QA_INCLUDE_DIR . 'app/limits.php';
$blockipclauses=qa_block_ips_explode(qa_opt('block_ips_write')); $blockipclauses = qa_block_ips_explode(qa_opt('block_ips_write'));
foreach ($blockipclauses as $key => $blockipclause) foreach ($blockipclauses as $key => $blockipclause) {
if (qa_block_ip_match($ip, $blockipclause)) if (qa_block_ip_match($ip, $blockipclause))
unset($blockipclauses[$key]); unset($blockipclauses[$key]);
}
qa_set_option('block_ips_write', implode(' , ', $blockipclauses)); qa_set_option('block_ips_write', implode(' , ', $blockipclauses));
qa_report_event('ip_unblock', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array( qa_report_event('ip_unblock', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'ip' => $ip, 'ip' => $ip,
)); ));
qa_redirect(qa_request()); qa_redirect(qa_request());
} }
if (qa_clicked('dohideall') && !qa_user_maximum_permit_error('permit_hide_show')) { if (qa_clicked('dohideall') && !qa_user_maximum_permit_error('permit_hide_show')) {
// allow moderator in one category to hide posts across all categories if they are identified via IP page // allow moderator in one category to hide posts across all categories if they are identified via IP page
require_once QA_INCLUDE_DIR.'db/admin.php'; require_once QA_INCLUDE_DIR . 'db/admin.php';
require_once QA_INCLUDE_DIR.'app/posts.php'; require_once QA_INCLUDE_DIR . 'app/posts.php';
$postids=qa_db_get_ip_visible_postids($ip); $postids = qa_db_get_ip_visible_postids($ip);
foreach ($postids as $postid) foreach ($postids as $postid)
qa_post_set_hidden($postid, true, $userid); qa_post_set_hidden($postid, true, $userid);
qa_redirect(qa_request()); qa_redirect(qa_request());
}
} }
} }
}
// Combine sets of questions and get information for users // Combine sets of questions and get information for users
$questions=qa_any_sort_by_date(array_merge($qs, $qs_queued, $qs_hidden, $a_qs, $a_queued_qs, $a_hidden_qs, $c_qs, $c_queued_qs, $c_hidden_qs, $edit_qs)); $questions = qa_any_sort_by_date(array_merge($qs, $qs_queued, $qs_hidden, $a_qs, $a_queued_qs, $a_hidden_qs, $c_qs, $c_queued_qs, $c_hidden_qs, $edit_qs));
$usershtml=qa_userids_handles_html(qa_any_get_userids_handles($questions)); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
$hostname=gethostbyaddr($ip); $hostname = gethostbyaddr($ip);
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html_sub('main/ip_address_x', qa_html($ip));
$qa_content['error']=@$pageerror;
$qa_content['form']=array( $qa_content['title'] = qa_lang_html_sub('main/ip_address_x', qa_html($ip));
'tags' => 'method="post" action="'.qa_self_html().'"', $qa_content['error'] = @$pageerror;
'style' => 'wide', $qa_content['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'fields' => array( 'style' => 'wide',
'host' => array(
'type' => 'static',
'label' => qa_lang_html('misc/host_name'),
'value' => qa_html($hostname),
),
),
'hidden' => array( 'fields' => array(
'code' => qa_get_form_security_code('ip-'.$ip), 'host' => array(
'type' => 'static',
'label' => qa_lang_html('misc/host_name'),
'value' => qa_html($hostname),
), ),
); ),
'hidden' => array(
'code' => qa_get_form_security_code('ip-' . $ip),
),
);
if ($blockable) {
require_once QA_INCLUDE_DIR.'app/limits.php';
$blockipclauses=qa_block_ips_explode(qa_opt('block_ips_write')); if ($blockable) {
$matchclauses=array(); require_once QA_INCLUDE_DIR . 'app/limits.php';
foreach ($blockipclauses as $blockipclause) $blockipclauses = qa_block_ips_explode(qa_opt('block_ips_write'));
if (qa_block_ip_match($ip, $blockipclause)) $matchclauses = array();
$matchclauses[]=$blockipclause;
if (count($matchclauses)) { foreach ($blockipclauses as $blockipclause) {
$qa_content['form']['fields']['status']=array( if (qa_block_ip_match($ip, $blockipclause))
'type' => 'static', $matchclauses[] = $blockipclause;
'label' => qa_lang_html('misc/matches_blocked_ips'), }
'value' => qa_html(implode("\n", $matchclauses), true),
);
$qa_content['form']['buttons']['unblock']=array( if (count($matchclauses)) {
'tags' => 'name="dounblock"', $qa_content['form']['fields']['status'] = array(
'label' => qa_lang_html('misc/unblock_ip_button'), 'type' => 'static',
); 'label' => qa_lang_html('misc/matches_blocked_ips'),
'value' => qa_html(implode("\n", $matchclauses), true),
);
if (count($questions) && !qa_user_maximum_permit_error('permit_hide_show')) $qa_content['form']['buttons']['unblock'] = array(
$qa_content['form']['buttons']['hideall']=array( 'tags' => 'name="dounblock"',
'tags' => 'name="dohideall" onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('misc/unblock_ip_button'),
'label' => qa_lang_html('misc/hide_all_ip_button'), );
);
} else if (count($questions) && !qa_user_maximum_permit_error('permit_hide_show'))
$qa_content['form']['buttons']['block']=array( $qa_content['form']['buttons']['hideall'] = array(
'tags' => 'name="doblock"', 'tags' => 'name="dohideall" onclick="qa_show_waiting_after(this, false);"',
'label' => qa_lang_html('misc/block_ip_button'), 'label' => qa_lang_html('misc/hide_all_ip_button'),
); );
} else {
$qa_content['form']['buttons']['block'] = array(
'tags' => 'name="doblock"',
'label' => qa_lang_html('misc/block_ip_button'),
);
} }
}
$qa_content['q_list']['qs']=array(); $qa_content['q_list']['qs'] = array();
if (count($questions)) { if (count($questions)) {
$qa_content['q_list']['title']=qa_lang_html_sub('misc/recent_activity_from_x', qa_html($ip)); $qa_content['q_list']['title'] = qa_lang_html_sub('misc/recent_activity_from_x', qa_html($ip));
foreach ($questions as $question) { foreach ($questions as $question) {
$htmloptions=qa_post_html_options($question); $htmloptions = qa_post_html_options($question);
$htmloptions['tagsview']=false; $htmloptions['tagsview'] = false;
$htmloptions['voteview']=false; $htmloptions['voteview'] = false;
$htmloptions['ipview']=false; $htmloptions['ipview'] = false;
$htmloptions['answersview']=false; $htmloptions['answersview'] = false;
$htmloptions['viewsview']=false; $htmloptions['viewsview'] = false;
$htmloptions['updateview']=false; $htmloptions['updateview'] = false;
$htmlfields=qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions); $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 if (isset($htmlfields['what_url'])) // link directly to relevant content
$htmlfields['url']=$htmlfields['what_url']; $htmlfields['url'] = $htmlfields['what_url'];
$hasother=isset($question['opostid']); $hasother = isset($question['opostid']);
if ($question[$hasother ? 'ohidden' : 'hidden'] && !isset($question[$hasother ? 'oupdatetype' : 'updatetype'])) { if ($question[$hasother ? 'ohidden' : 'hidden'] && !isset($question[$hasother ? 'oupdatetype' : 'updatetype'])) {
$htmlfields['what_2']=qa_lang_html('main/hidden'); $htmlfields['what_2'] = qa_lang_html('main/hidden');
if (@$htmloptions['whenview']) { if (@$htmloptions['whenview']) {
$updated=@$question[$hasother ? 'oupdated' : 'updated']; $updated = @$question[$hasother ? 'oupdated' : 'updated'];
if (isset($updated)) if (isset($updated))
$htmlfields['when_2']=qa_when_to_html($updated, @$htmloptions['fulldatedays']); $htmlfields['when_2'] = qa_when_to_html($updated, @$htmloptions['fulldatedays']);
}
} }
$qa_content['q_list']['qs'][]=$htmlfields;
} }
} else $qa_content['q_list']['qs'][] = $htmlfields;
$qa_content['q_list']['title']=qa_lang_html_sub('misc/no_activity_from_x', qa_html($ip)); }
return $qa_content; } else
$qa_content['q_list']['title'] = qa_lang_html_sub('misc/no_activity_from_x', qa_html($ip));
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,233 +20,228 @@ ...@@ -20,233 +20,228 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/limits.php'; require_once QA_INCLUDE_DIR . 'app/limits.php';
$handle = qa_request_part(1); $handle = qa_request_part(1);
$loginuserid = qa_get_logged_in_userid(); $loginuserid = qa_get_logged_in_userid();
$fromhandle = qa_get_logged_in_handle(); $fromhandle = qa_get_logged_in_handle();
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
// Check we have a handle, we're not using Q2A's single-sign on integration and that we're logged in // Check we have a handle, we're not using Q2A's single-sign on integration and that we're logged in
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code'); qa_fatal_error('User accounts are handled by external code');
if (!strlen($handle)) if (!strlen($handle))
qa_redirect('users'); qa_redirect('users');
if (!isset($loginuserid)) { if (!isset($loginuserid)) {
$qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request()); $qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request());
return $qa_content; return $qa_content;
} }
if ($handle === $fromhandle) { if ($handle === $fromhandle) {
// prevent users sending messages to themselves // prevent users sending messages to themselves
$qa_content['error'] = qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content; return $qa_content;
} }
// Find the user profile and their recent private messages // Find the user profile and their recent private messages
list($toaccount, $torecent, $fromrecent) = qa_db_select_with_pending( list($toaccount, $torecent, $fromrecent) = qa_db_select_with_pending(
qa_db_user_account_selectspec($handle, false), qa_db_user_account_selectspec($handle, false),
qa_db_recent_messages_selectspec($loginuserid, true, $handle, false), qa_db_recent_messages_selectspec($loginuserid, true, $handle, false),
qa_db_recent_messages_selectspec($handle, false, $loginuserid, true) qa_db_recent_messages_selectspec($handle, false, $loginuserid, true)
); );
// Check the user exists and work out what can and can't be set (if not using single sign-on) // Check the user exists and work out what can and can't be set (if not using single sign-on)
if (!qa_opt('allow_private_messages') || !is_array($toaccount)) if (!qa_opt('allow_private_messages') || !is_array($toaccount))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Check the target user has enabled private messages and inform the current user in case they haven't // Check the target user has enabled private messages and inform the current user in case they haven't
if ($toaccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) { if ($toaccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) {
$qa_content['error'] = qa_lang_html_sub( $qa_content['error'] = qa_lang_html_sub(
'profile/user_x_disabled_pms', 'profile/user_x_disabled_pms',
sprintf('<a href="%s">%s</a>', qa_path_html('user/' . $handle), qa_html($handle)) sprintf('<a href="%s">%s</a>', qa_path_html('user/' . $handle), qa_html($handle))
); );
return $qa_content; return $qa_content;
} }
// Check that we have permission and haven't reached the limit, but don't quit just yet // Check that we have permission and haven't reached the limit, but don't quit just yet
switch (qa_user_permit_error(null, QA_LIMIT_MESSAGES)) { switch (qa_user_permit_error(null, QA_LIMIT_MESSAGES)) {
case 'limit': case 'limit':
$pageerror = qa_lang_html('misc/message_limit'); $pageerror = qa_lang_html('misc/message_limit');
break; break;
case false: case false:
break; break;
default: default:
$pageerror = qa_lang_html('users/no_permission'); $pageerror = qa_lang_html('users/no_permission');
break; break;
} }
// Process sending a message to user // Process sending a message to user
// check for messages or errors // check for messages or errors
$state = qa_get_state(); $state = qa_get_state();
$messagesent = $state == 'message-sent'; $messagesent = $state == 'message-sent';
if ($state == 'email-error') if ($state == 'email-error')
$pageerror = qa_lang_html('main/email_error'); $pageerror = qa_lang_html('main/email_error');
if (qa_post_text('domessage')) { if (qa_post_text('domessage')) {
$inmessage = qa_post_text('message'); $inmessage = qa_post_text('message');
if (isset($pageerror)) { if (isset($pageerror)) {
// not permitted to post, so quit here // not permitted to post, so quit here
$qa_content['error'] = $pageerror; $qa_content['error'] = $pageerror;
return $qa_content; return $qa_content;
} }
if (!qa_check_form_security_code('message-' . $handle, qa_post_text('code')))
$pageerror = qa_lang_html('misc/form_security_again');
else {
if (empty($inmessage))
$errors['message'] = qa_lang('misc/message_empty');
if ( !qa_check_form_security_code('message-'.$handle, qa_post_text('code')) ) if (empty($errors)) {
$pageerror = qa_lang_html('misc/form_security_again'); require_once QA_INCLUDE_DIR . 'db/messages.php';
require_once QA_INCLUDE_DIR . 'app/emails.php';
else {
if (empty($inmessage)) if (qa_opt('show_message_history'))
$errors['message'] = qa_lang('misc/message_empty'); $messageid = qa_db_message_create($loginuserid, $toaccount['userid'], $inmessage, '', false);
else
if (empty($errors)) { $messageid = null;
require_once QA_INCLUDE_DIR.'db/messages.php';
require_once QA_INCLUDE_DIR.'app/emails.php'; $canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES);
if (qa_opt('show_message_history')) $more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array(
$messageid = qa_db_message_create($loginuserid, $toaccount['userid'], $inmessage, '', false); '^f_handle' => $fromhandle,
else '^url' => qa_path_absolute($canreply ? ('message/' . $fromhandle) : ('user/' . $fromhandle)),
$messageid = null; ));
$canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES); $subs = array(
'^message' => $inmessage,
$more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array( '^f_handle' => $fromhandle,
'^f_handle' => $fromhandle, '^f_url' => qa_path_absolute('user/' . $fromhandle),
'^url' => qa_path_absolute($canreply ? ('message/'.$fromhandle) : ('user/'.$fromhandle)), '^more' => $more,
)); '^a_url' => qa_path_absolute('account'),
);
$subs = array(
'^message' => $inmessage, if (qa_send_notification($toaccount['userid'], $toaccount['email'], $toaccount['handle'],
'^f_handle' => $fromhandle, qa_lang('emails/private_message_subject'), qa_lang('emails/private_message_body'), $subs))
'^f_url' => qa_path_absolute('user/'.$fromhandle), $messagesent = true;
'^more' => $more,
'^a_url' => qa_path_absolute('account'), qa_report_event('u_message', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array(
); 'userid' => $toaccount['userid'],
'handle' => $toaccount['handle'],
if (qa_send_notification($toaccount['userid'], $toaccount['email'], $toaccount['handle'], 'messageid' => $messageid,
qa_lang('emails/private_message_subject'), qa_lang('emails/private_message_body'), $subs)) 'message' => $inmessage,
$messagesent = true; ));
qa_report_event('u_message', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array( // show message as part of general history
'userid' => $toaccount['userid'], if (qa_opt('show_message_history'))
'handle' => $toaccount['handle'], qa_redirect(qa_request(), array('state' => ($messagesent ? 'message-sent' : 'email-error')));
'messageid' => $messageid,
'message' => $inmessage,
));
// show message as part of general history
if (qa_opt('show_message_history'))
qa_redirect(qa_request(), array('state' => ($messagesent ? 'message-sent' : 'email-error')));
}
} }
} }
}
// Prepare content for theme // Prepare content for theme
$hideForm = !empty($pageerror) || $messagesent; $hideForm = !empty($pageerror) || $messagesent;
$qa_content['title'] = qa_lang_html('misc/private_message_title'); $qa_content['title'] = qa_lang_html('misc/private_message_title');
$qa_content['error'] = @$pageerror; $qa_content['error'] = @$pageerror;
$qa_content['form_message'] = array( $qa_content['form_message'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'tall', 'style' => 'tall',
'ok' => $messagesent ? qa_lang_html('misc/message_sent') : null, 'ok' => $messagesent ? qa_lang_html('misc/message_sent') : null,
'fields' => array( 'fields' => array(
'message' => array( 'message' => array(
'type' => $hideForm ? 'static' : '', 'type' => $hideForm ? 'static' : '',
'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)), 'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)),
'tags' => 'name="message" id="message"', 'tags' => 'name="message" id="message"',
'value' => qa_html(@$inmessage, $messagesent), 'value' => qa_html(@$inmessage, $messagesent),
'rows' => 8, 'rows' => 8,
'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))), 'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))),
'error' => qa_html(@$errors['message']), 'error' => qa_html(@$errors['message']),
),
), ),
),
'buttons' => array( 'buttons' => array(
'send' => array( 'send' => array(
'tags' => 'onclick="qa_show_waiting_after(this, false);"', 'tags' => 'onclick="qa_show_waiting_after(this, false);"',
'label' => qa_lang_html('main/send_button'), 'label' => qa_lang_html('main/send_button'),
),
), ),
),
'hidden' => array( 'hidden' => array(
'domessage' => '1', 'domessage' => '1',
'code' => qa_get_form_security_code('message-'.$handle), 'code' => qa_get_form_security_code('message-' . $handle),
), ),
); );
$qa_content['focusid'] = 'message'; $qa_content['focusid'] = 'message';
if ($hideForm) { if ($hideForm) {
unset($qa_content['form_message']['buttons']); unset($qa_content['form_message']['buttons']);
if (qa_opt('show_message_history')) if (qa_opt('show_message_history'))
unset($qa_content['form_message']['fields']['message']); unset($qa_content['form_message']['fields']['message']);
else { else {
unset($qa_content['form_message']['fields']['message']['note']); unset($qa_content['form_message']['fields']['message']['note']);
unset($qa_content['form_message']['fields']['message']['label']); unset($qa_content['form_message']['fields']['message']['label']);
}
} }
}
// If relevant, show recent message history // If relevant, show recent message history
if (qa_opt('show_message_history')) { if (qa_opt('show_message_history')) {
$recent = array_merge($torecent, $fromrecent); $recent = array_merge($torecent, $fromrecent);
qa_sort_by($recent, 'created'); qa_sort_by($recent, 'created');
$showmessages = array_slice(array_reverse($recent, true), 0, QA_DB_RETRIEVE_MESSAGES); $showmessages = array_slice(array_reverse($recent, true), 0, QA_DB_RETRIEVE_MESSAGES);
if (count($showmessages)) { if (count($showmessages)) {
$qa_content['message_list'] = array( $qa_content['message_list'] = array(
'title' => qa_lang_html_sub('misc/message_recent_history', qa_html($toaccount['handle'])), 'title' => qa_lang_html_sub('misc/message_recent_history', qa_html($toaccount['handle'])),
); );
$options = qa_message_html_defaults(); $options = qa_message_html_defaults();
foreach ($showmessages as $message) foreach ($showmessages as $message)
$qa_content['message_list']['messages'][] = qa_message_html_fields($message, $options); $qa_content['message_list']['messages'][] = qa_message_html_fields($message, $options);
}
$qa_content['navigation']['sub'] = qa_messages_sub_navigation();
} }
$qa_content['navigation']['sub'] = qa_messages_sub_navigation();
}
$qa_content['raw']['account'] = $toaccount; // for plugin layers to access
return $qa_content;
$qa_content['raw']['account'] = $toaccount; // for plugin layers to access
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,106 +20,106 @@ ...@@ -20,106 +20,106 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/limits.php'; require_once QA_INCLUDE_DIR . 'app/limits.php';
$loginUserId = qa_get_logged_in_userid(); $loginUserId = qa_get_logged_in_userid();
$loginUserHandle = qa_get_logged_in_handle(); $loginUserHandle = qa_get_logged_in_handle();
// Check which box we're showing (inbox/sent), we're not using Q2A's single-sign on integration and that we're logged in // Check which box we're showing (inbox/sent), we're not using Q2A's single-sign on integration and that we're logged in
$req = qa_request_part(1); $req = qa_request_part(1);
if ($req === null) if ($req === null)
$showOutbox = false; $showOutbox = false;
elseif ($req === 'sent') elseif ($req === 'sent')
$showOutbox = true; $showOutbox = true;
else else
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code'); qa_fatal_error('User accounts are handled by external code');
if (!isset($loginUserId)) { if (!isset($loginUserId)) {
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request()); $qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request());
return $qa_content; return $qa_content;
} }
if (!qa_opt('allow_private_messages') || !qa_opt('show_message_history')) if (!qa_opt('allow_private_messages') || !qa_opt('show_message_history'))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Find the messages for this user // Find the messages for this user
$start = qa_get_start(); $start = qa_get_start();
$pagesize = qa_opt('page_size_pms'); $pagesize = qa_opt('page_size_pms');
// get number of messages then actual messages for this page // get number of messages then actual messages for this page
$func = $showOutbox ? 'qa_db_messages_outbox_selectspec' : 'qa_db_messages_inbox_selectspec'; $func = $showOutbox ? 'qa_db_messages_outbox_selectspec' : 'qa_db_messages_inbox_selectspec';
$pmSpecCount = qa_db_selectspec_count( $func('private', $loginUserId, true) ); $pmSpecCount = qa_db_selectspec_count($func('private', $loginUserId, true));
$pmSpec = $func('private', $loginUserId, true, $start, $pagesize); $pmSpec = $func('private', $loginUserId, true, $start, $pagesize);
list($numMessages, $userMessages) = qa_db_select_with_pending($pmSpecCount, $pmSpec); list($numMessages, $userMessages) = qa_db_select_with_pending($pmSpecCount, $pmSpec);
$count = $numMessages['count']; $count = $numMessages['count'];
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html( $showOutbox ? 'misc/pm_outbox_title' : 'misc/pm_inbox_title' ); $qa_content['title'] = qa_lang_html($showOutbox ? 'misc/pm_outbox_title' : 'misc/pm_inbox_title');
$qa_content['script_rel'][] = 'qa-content/qa-user.js?'.QA_VERSION; $qa_content['script_rel'][] = 'qa-content/qa-user.js?' . QA_VERSION;
$qa_content['message_list'] = array( $qa_content['message_list'] = array(
'tags' => 'id="privatemessages"', 'tags' => 'id="privatemessages"',
'messages' => array(), 'messages' => array(),
'form' => array( 'form' => array(
'tags' => 'name="pmessage" method="post" action="'.qa_self_html().'"', 'tags' => 'name="pmessage" method="post" action="' . qa_self_html() . '"',
'style' => 'tall', 'style' => 'tall',
'hidden' => array( 'hidden' => array(
'qa_click' => '', // for simulating clicks in Javascript 'qa_click' => '', // for simulating clicks in Javascript
'handle' => qa_html($loginUserHandle), 'handle' => qa_html($loginUserHandle),
'start' => qa_html($start), 'start' => qa_html($start),
'code' => qa_get_form_security_code('pm-'.$loginUserHandle), 'code' => qa_get_form_security_code('pm-' . $loginUserHandle),
),
),
);
$htmlDefaults = qa_message_html_defaults();
if ($showOutbox)
$htmlDefaults['towhomview'] = true;
foreach ($userMessages as $message) {
$msgFormat = qa_message_html_fields($message, $htmlDefaults);
$replyHandle = $showOutbox ? $message['tohandle'] : $message['fromhandle'];
$msgFormat['form'] = array(
'style' => 'light',
'buttons' => array(
'reply' => array(
'tags' => 'onclick="window.location.href=\'' . qa_path_html('message/' . $replyHandle) . '\';return false"',
'label' => qa_lang_html('question/reply_button'),
),
'delete' => array(
'tags' => 'name="m' . qa_html($message['messageid']) . '_dodelete" onclick="return qa_pm_click(' . qa_js($message['messageid']) . ', this, ' . qa_js($showOutbox ? 'outbox' : 'inbox') . ');"',
'label' => qa_lang_html('question/delete_button'),
'popup' => qa_lang_html('profile/delete_pm_popup'),
), ),
), ),
); );
$htmlDefaults = qa_message_html_defaults(); $qa_content['message_list']['messages'][] = $msgFormat;
if ($showOutbox) }
$htmlDefaults['towhomview'] = true;
foreach ($userMessages as $message) {
$msgFormat = qa_message_html_fields($message, $htmlDefaults);
$replyHandle = $showOutbox ? $message['tohandle'] : $message['fromhandle'];
$msgFormat['form'] = array(
'style' => 'light',
'buttons' => array(
'reply' => array(
'tags' => 'onclick="window.location.href=\''.qa_path_html('message/'.$replyHandle).'\';return false"',
'label' => qa_lang_html('question/reply_button'),
),
'delete' => array(
'tags' => 'name="m'.qa_html($message['messageid']).'_dodelete" onclick="return qa_pm_click('.qa_js($message['messageid']).', this, '.qa_js($showOutbox ? 'outbox' : 'inbox').');"',
'label' => qa_lang_html('question/delete_button'),
'popup' => qa_lang_html('profile/delete_pm_popup'),
),
),
);
$qa_content['message_list']['messages'][] = $msgFormat;
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next')); $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_messages_sub_navigation($showOutbox ? 'outbox' : 'inbox'); $qa_content['navigation']['sub'] = qa_messages_sub_navigation($showOutbox ? 'outbox' : 'inbox');
return $qa_content; return $qa_content;
...@@ -20,134 +20,130 @@ ...@@ -20,134 +20,130 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/options.php'; require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR.'app/search.php'; require_once QA_INCLUDE_DIR . 'app/search.php';
// Perform the search if appropriate // Perform the search if appropriate
if (strlen(qa_get('q'))) { if (strlen(qa_get('q'))) {
// Pull in input parameters // Pull in input parameters
$inquery=trim(qa_get('q')); $inquery = trim(qa_get('q'));
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
$start=qa_get_start(); $start = qa_get_start();
$display=qa_opt_if_loaded('page_size_search'); $display = qa_opt_if_loaded('page_size_search');
$count=2*(isset($display) ? $display : QA_DB_RETRIEVE_QS_AS)+1; $count = 2 * (isset($display) ? $display : QA_DB_RETRIEVE_QS_AS) + 1;
// get enough results to be able to give some idea of how many pages of search results there are // get enough results to be able to give some idea of how many pages of search results there are
// Perform the search using appropriate module // Perform the search using appropriate module
$results=qa_get_search_results($inquery, $start, $count, $userid, false, false); $results = qa_get_search_results($inquery, $start, $count, $userid, false, false);
// Count and truncate results // Count and truncate results
$pagesize=qa_opt('page_size_search'); $pagesize = qa_opt('page_size_search');
$gotcount=count($results); $gotcount = count($results);
$results=array_slice($results, 0, $pagesize); $results = array_slice($results, 0, $pagesize);
// Retrieve extra information on users // Retrieve extra information on users
$fullquestions=array(); $fullquestions = array();
foreach ($results as $result) foreach ($results as $result) {
if (isset($result['question'])) if (isset($result['question']))
$fullquestions[]=$result['question']; $fullquestions[] = $result['question'];
}
$usershtml=qa_userids_handles_html($fullquestions); $usershtml = qa_userids_handles_html($fullquestions);
// Report the search event // Report the search event
qa_report_event('search', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array( qa_report_event('search', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'query' => $inquery, 'query' => $inquery,
'start' => $start, 'start' => $start,
)); ));
} }
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(true); $qa_content = qa_content_prepare(true);
if (strlen(qa_get('q'))) {
$qa_content['search']['value']=qa_html($inquery);
if (count($results))
$qa_content['title']=qa_lang_html_sub('main/results_for_x', qa_html($inquery));
else
$qa_content['title']=qa_lang_html_sub('main/no_results_for_x', qa_html($inquery));
$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'); if (strlen(qa_get('q'))) {
$qa_content['search']['value'] = qa_html($inquery);
foreach ($results as $result) if (count($results))
if (!isset($result['question'])) { // if we have any non-question results, display with less statistics $qa_content['title'] = qa_lang_html_sub('main/results_for_x', qa_html($inquery));
$qdefaults['voteview']=false; else
$qdefaults['answersview']=false; $qa_content['title'] = qa_lang_html_sub('main/no_results_for_x', qa_html($inquery));
$qdefaults['viewsview']=false;
break;
}
foreach ($results as $result) { $qa_content['q_list']['form'] = array(
if (isset($result['question'])) 'tags' => 'method="post" action="' . qa_self_html() . '"',
$fields=qa_post_html_fields($result['question'], $userid, qa_cookie_get(),
$usershtml, null, qa_post_html_options($result['question'], $qdefaults));
elseif (isset($result['url'])) 'hidden' => array(
$fields=array( 'code' => qa_get_form_security_code('vote'),
'what' => qa_html($result['url']), ),
'meta_order' => qa_lang_html('main/meta_order'), );
);
else $qa_content['q_list']['qs'] = array();
continue; // nothing to show here
if (isset($qdefaults['blockwordspreg'])) $qdefaults = qa_post_html_defaults('Q');
$result['title']=qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']);
$fields['title']=qa_html($result['title']); foreach ($results as $result) {
$fields['url']=qa_html($result['url']); 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;
}
}
$qa_content['q_list']['qs'][]=$fields; 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
} }
$qa_content['page_links']=qa_html_page_links(qa_request(), $start, $pagesize, $start+$gotcount, if (isset($qdefaults['blockwordspreg']))
qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount>=$count); $result['title'] = qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']);
if (qa_opt('feed_for_search')) $fields['title'] = qa_html($result['title']);
$qa_content['feed']=array( $fields['url'] = qa_html($result['url']);
'url' => qa_path_html(qa_feed_request('search/'.$inquery)),
'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery)),
);
if (empty($qa_content['page_links'])) $qa_content['q_list']['qs'][] = $fields;
$qa_content['suggest_next']=qa_html_suggest_qs_tags(qa_using_tags()); }
} else $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount,
$qa_content['error']=qa_lang_html('main/search_explanation'); qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count);
if (qa_opt('feed_for_search')) {
$qa_content['feed'] = array(
'url' => qa_path_html(qa_feed_request('search/' . $inquery)),
'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery)),
);
}
if (empty($qa_content['page_links']))
$qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
return $qa_content; } else
$qa_content['error'] = qa_lang_html('main/search_explanation');
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,79 +20,77 @@ ...@@ -20,79 +20,77 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/updates.php'; require_once QA_INCLUDE_DIR . 'app/updates.php';
$tag=qa_request_part(1); // picked up from qa-page.php $tag = qa_request_part(1); // picked up from qa-page.php
$start=qa_get_start(); $start = qa_get_start();
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
// Find the questions with this tag // Find the questions with this tag
if (!strlen($tag)) if (!strlen($tag))
qa_redirect('tags'); qa_redirect('tags');
list($questions, $tagword)=qa_db_select_with_pending( 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_recent_qs_selectspec($userid, $tag, $start, false, qa_opt_if_loaded('page_size_tag_qs')),
qa_db_tag_word_selectspec($tag) qa_db_tag_word_selectspec($tag)
); );
$pagesize=qa_opt('page_size_tag_qs'); $pagesize = qa_opt('page_size_tag_qs');
$questions=array_slice($questions, 0, $pagesize); $questions = array_slice($questions, 0, $pagesize);
$usershtml=qa_userids_handles_html($questions); $usershtml = qa_userids_handles_html($questions);
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(true); $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_content['title'] = qa_lang_html_sub('main/questions_tagged_x', qa_html($tag));
qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word']));
}
if (!count($questions)) if (isset($userid) && isset($tagword)) {
$qa_content['q_list']['title']=qa_lang_html('main/no_questions_found'); $favoritemap = qa_get_favorite_non_qs_map();
$favorite = @$favoritemap['tag'][qa_strtolower($tagword['word'])];
$qa_content['q_list']['form']=array( $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite,
'tags' => 'method="post" action="'.qa_self_html().'"', qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word']));
}
'hidden' => array( if (!count($questions))
'code' => qa_get_form_security_code('vote'), $qa_content['q_list']['title'] = qa_lang_html('main/no_questions_found');
),
);
$qa_content['q_list']['qs']=array(); $qa_content['q_list']['form'] = array(
foreach ($questions as $postid => $question) 'tags' => 'method="post" action="' . qa_self_html() . '"',
$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')); 'hidden' => array(
'code' => qa_get_form_security_code('vote'),
),
);
if (empty($qa_content['page_links'])) $qa_content['q_list']['qs'] = array();
$qa_content['suggest_next']=qa_html_suggest_qs_tags(true); 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));
}
if (qa_opt('feed_for_tag_qs')) $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagword['tagcount'], qa_opt('pages_prev_next'));
$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)),
);
if (empty($qa_content['page_links']))
$qa_content['suggest_next'] = qa_html_suggest_qs_tags(true);
return $qa_content; 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
*/
\ No newline at end of file
...@@ -20,65 +20,60 @@ ...@@ -20,65 +20,60 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
// Get popular tags // Get popular tags
$start = qa_get_start(); $start = qa_get_start();
$userid = qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
$populartags = qa_db_select_with_pending( $populartags = qa_db_select_with_pending(
qa_db_popular_tags_selectspec($start, qa_opt_if_loaded('page_size_tags')) qa_db_popular_tags_selectspec($start, qa_opt_if_loaded('page_size_tags'))
); );
$tagcount = qa_opt('cache_tagcount'); $tagcount = qa_opt('cache_tagcount');
$pagesize = qa_opt('page_size_tags'); $pagesize = qa_opt('page_size_tags');
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(); $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)) { $qa_content['title'] = qa_lang_html('main/popular_tags');
$favoritemap = qa_get_favorite_non_qs_map();
$output = 0; $qa_content['ranking'] = array(
foreach ($populartags as $word => $count) { 'items' => array(),
$qa_content['ranking']['items'][] = array( 'rows' => ceil($pagesize / qa_opt('columns_tags')),
'label' => qa_tag_html($word, false, @$favoritemap['tag'][qa_strtolower($word)]), 'type' => 'tags'
'count' => qa_format_number($count, 0, true), );
);
if ((++$output) >= $pagesize) if (count($populartags)) {
break; $favoritemap = qa_get_favorite_non_qs_map();
}
} else $output = 0;
$qa_content['title'] = qa_lang_html('main/no_tags_found'); foreach ($populartags as $word => $count) {
$qa_content['ranking']['items'][] = array(
'label' => qa_tag_html($word, false, @$favoritemap['tag'][qa_strtolower($word)]),
'count' => qa_format_number($count, 0, true),
);
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagcount, qa_opt('pages_prev_next')); if ((++$output) >= $pagesize)
break;
}
if (empty($qa_content['page_links'])) } else
$qa_content['suggest_next'] = qa_html_suggest_ask(); $qa_content['title'] = qa_lang_html('main/no_tags_found');
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagcount, qa_opt('pages_prev_next'));
return $qa_content; if (empty($qa_content['page_links']))
$qa_content['suggest_next'] = qa_html_suggest_ask();
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,62 +20,58 @@ ...@@ -20,62 +20,58 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/users.php'; require_once QA_INCLUDE_DIR . 'db/users.php';
// Check we're not using single-sign on integration // Check we're not using single-sign on integration
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User login is handled by external code'); qa_fatal_error('User login is handled by external code');
// Check the code and unsubscribe the user if appropriate // Check the code and unsubscribe the user if appropriate
$unsubscribed=false; $unsubscribed = false;
$loginuserid=qa_get_logged_in_userid(); $loginuserid = qa_get_logged_in_userid();
$incode=trim(qa_get('c')); // trim to prevent passing in blank values to match uninitiated DB rows $incode = trim(qa_get('c')); // trim to prevent passing in blank values to match uninitiated DB rows
$inhandle=qa_get('u'); $inhandle = qa_get('u');
if (!empty($inhandle)) { // match based on code and handle provided on URL if (!empty($inhandle)) { // match based on code and handle provided on URL
$userinfo=qa_db_select_with_pending(qa_db_user_account_selectspec($inhandle, false)); $userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($inhandle, false));
if (strtolower(trim(@$userinfo['emailcode']))==strtolower($incode)) { if (strtolower(trim(@$userinfo['emailcode'])) == strtolower($incode)) {
qa_db_user_set_flag($userinfo['userid'], QA_USER_FLAGS_NO_MAILINGS, true); qa_db_user_set_flag($userinfo['userid'], QA_USER_FLAGS_NO_MAILINGS, true);
$unsubscribed=true; $unsubscribed = true;
}
} }
}
if ( (!$unsubscribed) && isset($loginuserid)) { // as a backup, also unsubscribe logged in user if ((!$unsubscribed) && isset($loginuserid)) { // as a backup, also unsubscribe logged in user
qa_db_user_set_flag($loginuserid, QA_USER_FLAGS_NO_MAILINGS, true); qa_db_user_set_flag($loginuserid, QA_USER_FLAGS_NO_MAILINGS, true);
$unsubscribed=true; $unsubscribed = true;
} }
// Prepare content for theme // Prepare content for theme
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('users/unsubscribe_title');
if ($unsubscribed) $qa_content['title'] = qa_lang_html('users/unsubscribe_title');
$qa_content['error']=strtr(qa_lang_html('users/unsubscribe_complete'), array(
'^0' => qa_html(qa_opt('site_title')),
'^1' => '<a href="'.qa_path_html('account').'">',
'^2' => '</a>',
));
else
$qa_content['error']=qa_insert_login_links(qa_lang_html('users/unsubscribe_wrong_log_in'), 'unsubscribe');
if ($unsubscribed) {
$qa_content['error'] = strtr(qa_lang_html('users/unsubscribe_complete'), array(
'^0' => qa_html(qa_opt('site_title')),
'^1' => '<a href="' . qa_path_html('account') . '">',
'^2' => '</a>',
));
} else {
$qa_content['error'] = qa_insert_login_links(qa_lang_html('users/unsubscribe_wrong_log_in'), 'unsubscribe');
}
return $qa_content;
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,96 +20,91 @@ ...@@ -20,96 +20,91 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/q-list.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php';
// Check that we're logged in // Check that we're logged in
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if (!isset($userid)) if (!isset($userid))
qa_redirect('login'); qa_redirect('login');
// Find out which updates to show // Find out which updates to show
$forfavorites=qa_get('show')!='content'; $forfavorites = qa_get('show') != 'content';
$forcontent=qa_get('show')!='favorites'; $forcontent = qa_get('show') != 'favorites';
// Get lists of recent updates for this user // Get lists of recent updates for this user
$questions=qa_db_select_with_pending( $questions = qa_db_select_with_pending(
qa_db_user_updates_selectspec($userid, $forfavorites, $forcontent) qa_db_user_updates_selectspec($userid, $forfavorites, $forcontent)
); );
if ($forfavorites) {
if ($forcontent) {
$sometitle=qa_lang_html('misc/recent_updates_title');
$nonetitle=qa_lang_html('misc/no_recent_updates');
} else { if ($forfavorites) {
$sometitle=qa_lang_html('misc/recent_updates_favorites'); if ($forcontent) {
$nonetitle=qa_lang_html('misc/no_updates_favorites'); $sometitle = qa_lang_html('misc/recent_updates_title');
} $nonetitle = qa_lang_html('misc/no_recent_updates');
} else { } else {
$sometitle=qa_lang_html('misc/recent_updates_content'); $sometitle = qa_lang_html('misc/recent_updates_favorites');
$nonetitle=qa_lang_html('misc/no_updates_content'); $nonetitle = qa_lang_html('misc/no_updates_favorites');
} }
} else {
$sometitle = qa_lang_html('misc/recent_updates_content');
$nonetitle = qa_lang_html('misc/no_updates_content');
}
// Prepare and return content for theme
$qa_content=qa_q_list_page_content(
qa_any_sort_and_dedupe($questions),
null, // questions per page
0, // start offset
null, // total count (null to hide page links)
$sometitle, // title if some questions
$nonetitle, // title if no questions
null, // categories for navigation
null, // selected category id
null, // show question counts in category navigation
null, // prefix for links in category navigation
null, // prefix for RSS feed paths (null to hide)
$forfavorites ? strtr(qa_lang_html('misc/suggest_update_favorites'), array(
'^1' => '<a href="'.qa_path_html('favorites').'">',
'^2' => '</a>',
)) : null // suggest what to do next
);
$qa_content['navigation']['sub']=array(
'all' => array(
'label' => qa_lang_html('misc/nav_all_my_updates'),
'url' => qa_path_html('updates'),
'selected' => $forfavorites && $forcontent,
),
'favorites' => array(
'label' => qa_lang_html('misc/nav_my_favorites'),
'url' => qa_path_html('updates', array('show' => 'favorites')),
'selected' => $forfavorites && !$forcontent,
),
'myposts' => array(
'label' => qa_lang_html('misc/nav_my_content'),
'url' => qa_path_html('updates', array('show' => 'content')),
'selected' => $forcontent && !$forfavorites,
),
);
return $qa_content;
// Prepare and return content for theme
/* $qa_content = qa_q_list_page_content(
Omit PHP closing tag to help avoid accidental output qa_any_sort_and_dedupe($questions),
*/ null, // questions per page
\ No newline at end of file 0, // start offset
null, // total count (null to hide page links)
$sometitle, // title if some questions
$nonetitle, // title if no questions
null, // categories for navigation
null, // selected category id
null, // show question counts in category navigation
null, // prefix for links in category navigation
null, // prefix for RSS feed paths (null to hide)
$forfavorites ? strtr(qa_lang_html('misc/suggest_update_favorites'), array(
'^1' => '<a href="' . qa_path_html('favorites') . '">',
'^2' => '</a>',
)) : null // suggest what to do next
);
$qa_content['navigation']['sub'] = array(
'all' => array(
'label' => qa_lang_html('misc/nav_all_my_updates'),
'url' => qa_path_html('updates'),
'selected' => $forfavorites && $forcontent,
),
'favorites' => array(
'label' => qa_lang_html('misc/nav_my_favorites'),
'url' => qa_path_html('updates', array('show' => 'favorites')),
'selected' => $forfavorites && !$forcontent,
),
'myposts' => array(
'label' => qa_lang_html('misc/nav_my_content'),
'url' => qa_path_html('updates', array('show' => 'content')),
'selected' => $forcontent && !$forfavorites,
),
);
return $qa_content;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment