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( $qa_content['nav_list'] = array(
'nav' => $navigation, 'nav' => $navigation,
'type' => 'browse-cat', 'type' => 'browse-cat',
); );
} else { } else {
$qa_content['title']=qa_lang_html('main/no_categories_found'); $qa_content['title'] = qa_lang_html('main/no_categories_found');
$qa_content['suggest_next']=qa_html_suggest_qs_tags(qa_using_tags()); $qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
} }
return $qa_content;
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,18 +20,19 @@ ...@@ -20,18 +20,19 @@
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(
$favswitch = array(
'questions' => array( 'questions' => array(
'page_opt' => 'page_size_qs', 'page_opt' => 'page_size_qs',
'fn_spec' => 'qa_db_user_favorite_qs_selectspec', 'fn_spec' => 'qa_db_user_favorite_qs_selectspec',
...@@ -50,58 +51,53 @@ ...@@ -50,58 +51,53 @@
'fn_view' => 'qa_favorite_tags_view', 'fn_view' => 'qa_favorite_tags_view',
'key' => 'ranking_tags', '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'));
return $qa_content; $qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true);
/* 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,70 +20,71 @@ ...@@ -20,70 +20,71 @@
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'],
); );
...@@ -96,10 +97,11 @@ ...@@ -96,10 +97,11 @@
'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( qa_report_event('feedback', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'email' => $inemail, 'email' => $inemail,
...@@ -110,19 +112,19 @@ ...@@ -110,19 +112,19 @@
)); ));
} }
} }
} }
// 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',
...@@ -163,23 +165,18 @@ ...@@ -163,23 +165,18 @@
'code' => qa_get_form_security_code('feedback'), 'code' => qa_get_form_security_code('feedback'),
'referer' => qa_html(isset($inreferer) ? $inreferer : @$_SERVER['HTTP_REFERER']), 'referer' => qa_html(isset($inreferer) ? $inreferer : @$_SERVER['HTTP_REFERER']),
), ),
); );
if ($usecaptcha && !$feedbacksent) if ($usecaptcha && !$feedbacksent)
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']='message'; $qa_content['focusid'] = 'message';
if ($feedbacksent) { if ($feedbacksent) {
$qa_content['form']['ok']=qa_lang_html('misc/feedback_sent'); $qa_content['form']['ok'] = qa_lang_html('misc/feedback_sent');
unset($qa_content['form']['buttons']); unset($qa_content['form']['buttons']);
} }
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,72 +20,72 @@ ...@@ -20,72 +20,72 @@
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',
...@@ -109,17 +109,12 @@ ...@@ -109,17 +109,12 @@
'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,25 +20,25 @@ ...@@ -20,25 +20,25 @@
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'),
...@@ -55,26 +55,26 @@ ...@@ -55,26 +55,26 @@
// 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,
...@@ -84,13 +84,14 @@ ...@@ -84,13 +84,14 @@
} }
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));
...@@ -104,10 +105,10 @@ ...@@ -104,10 +105,10 @@
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);
...@@ -115,27 +116,27 @@ ...@@ -115,27 +116,27 @@
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['title'] = qa_lang_html_sub('main/ip_address_x', qa_html($ip));
$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' => 'wide', 'style' => 'wide',
...@@ -148,88 +149,85 @@ ...@@ -148,88 +149,85 @@
), ),
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('ip-'.$ip), 'code' => qa_get_form_security_code('ip-' . $ip),
), ),
); );
if ($blockable) { if ($blockable) {
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'));
$matchclauses=array(); $matchclauses = array();
foreach ($blockipclauses as $blockipclause) foreach ($blockipclauses as $blockipclause) {
if (qa_block_ip_match($ip, $blockipclause)) if (qa_block_ip_match($ip, $blockipclause))
$matchclauses[]=$blockipclause; $matchclauses[] = $blockipclause;
}
if (count($matchclauses)) { if (count($matchclauses)) {
$qa_content['form']['fields']['status']=array( $qa_content['form']['fields']['status'] = array(
'type' => 'static', 'type' => 'static',
'label' => qa_lang_html('misc/matches_blocked_ips'), 'label' => qa_lang_html('misc/matches_blocked_ips'),
'value' => qa_html(implode("\n", $matchclauses), true), 'value' => qa_html(implode("\n", $matchclauses), true),
); );
$qa_content['form']['buttons']['unblock']=array( $qa_content['form']['buttons']['unblock'] = array(
'tags' => 'name="dounblock"', 'tags' => 'name="dounblock"',
'label' => qa_lang_html('misc/unblock_ip_button'), 'label' => qa_lang_html('misc/unblock_ip_button'),
); );
if (count($questions) && !qa_user_maximum_permit_error('permit_hide_show')) if (count($questions) && !qa_user_maximum_permit_error('permit_hide_show'))
$qa_content['form']['buttons']['hideall']=array( $qa_content['form']['buttons']['hideall'] = array(
'tags' => 'name="dohideall" onclick="qa_show_waiting_after(this, false);"', 'tags' => 'name="dohideall" onclick="qa_show_waiting_after(this, false);"',
'label' => qa_lang_html('misc/hide_all_ip_button'), 'label' => qa_lang_html('misc/hide_all_ip_button'),
); );
} else } else {
$qa_content['form']['buttons']['block']=array( $qa_content['form']['buttons']['block'] = array(
'tags' => 'name="doblock"', 'tags' => 'name="doblock"',
'label' => qa_lang_html('misc/block_ip_button'), '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; $qa_content['q_list']['qs'][] = $htmlfields;
} }
} else } else
$qa_content['q_list']['title']=qa_lang_html_sub('misc/no_activity_from_x', qa_html($ip)); $qa_content['q_list']['title'] = qa_lang_html_sub('misc/no_activity_from_x', qa_html($ip));
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,70 +20,70 @@ ...@@ -20,70 +20,70 @@
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;
...@@ -94,18 +94,18 @@ ...@@ -94,18 +94,18 @@
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)) {
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
return $qa_content; return $qa_content;
} }
if ( !qa_check_form_security_code('message-'.$handle, qa_post_text('code')) ) if (!qa_check_form_security_code('message-' . $handle, qa_post_text('code')))
$pageerror = qa_lang_html('misc/form_security_again'); $pageerror = qa_lang_html('misc/form_security_again');
else { else {
...@@ -122,8 +122,8 @@ ...@@ -122,8 +122,8 @@
$errors['message'] = qa_lang('misc/message_empty'); $errors['message'] = qa_lang('misc/message_empty');
if (empty($errors)) { if (empty($errors)) {
require_once QA_INCLUDE_DIR.'db/messages.php'; require_once QA_INCLUDE_DIR . 'db/messages.php';
require_once QA_INCLUDE_DIR.'app/emails.php'; require_once QA_INCLUDE_DIR . 'app/emails.php';
if (qa_opt('show_message_history')) if (qa_opt('show_message_history'))
$messageid = qa_db_message_create($loginuserid, $toaccount['userid'], $inmessage, '', false); $messageid = qa_db_message_create($loginuserid, $toaccount['userid'], $inmessage, '', false);
...@@ -134,13 +134,13 @@ ...@@ -134,13 +134,13 @@
$more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array( $more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array(
'^f_handle' => $fromhandle, '^f_handle' => $fromhandle,
'^url' => qa_path_absolute($canreply ? ('message/'.$fromhandle) : ('user/'.$fromhandle)), '^url' => qa_path_absolute($canreply ? ('message/' . $fromhandle) : ('user/' . $fromhandle)),
)); ));
$subs = array( $subs = array(
'^message' => $inmessage, '^message' => $inmessage,
'^f_handle' => $fromhandle, '^f_handle' => $fromhandle,
'^f_url' => qa_path_absolute('user/'.$fromhandle), '^f_url' => qa_path_absolute('user/' . $fromhandle),
'^more' => $more, '^more' => $more,
'^a_url' => qa_path_absolute('account'), '^a_url' => qa_path_absolute('account'),
); );
...@@ -161,19 +161,19 @@ ...@@ -161,19 +161,19 @@
qa_redirect(qa_request(), array('state' => ($messagesent ? 'message-sent' : 'email-error'))); 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',
...@@ -200,13 +200,13 @@ ...@@ -200,13 +200,13 @@
'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'))
...@@ -215,12 +215,12 @@ ...@@ -215,12 +215,12 @@
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');
...@@ -239,14 +239,9 @@ ...@@ -239,14 +239,9 @@
} }
$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 $qa_content['raw']['account'] = $toaccount; // for plugin layers to access
return $qa_content;
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,83 +20,83 @@ ...@@ -20,83 +20,83 @@
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(); $htmlDefaults = qa_message_html_defaults();
if ($showOutbox) if ($showOutbox)
$htmlDefaults['towhomview'] = true; $htmlDefaults['towhomview'] = true;
foreach ($userMessages as $message) { foreach ($userMessages as $message) {
$msgFormat = qa_message_html_fields($message, $htmlDefaults); $msgFormat = qa_message_html_fields($message, $htmlDefaults);
$replyHandle = $showOutbox ? $message['tohandle'] : $message['fromhandle']; $replyHandle = $showOutbox ? $message['tohandle'] : $message['fromhandle'];
...@@ -104,11 +104,11 @@ ...@@ -104,11 +104,11 @@
'style' => 'light', 'style' => 'light',
'buttons' => array( 'buttons' => array(
'reply' => array( 'reply' => array(
'tags' => 'onclick="window.location.href=\''.qa_path_html('message/'.$replyHandle).'\';return false"', 'tags' => 'onclick="window.location.href=\'' . qa_path_html('message/' . $replyHandle) . '\';return false"',
'label' => qa_lang_html('question/reply_button'), 'label' => qa_lang_html('question/reply_button'),
), ),
'delete' => array( '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').');"', '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'), 'label' => qa_lang_html('question/delete_button'),
'popup' => qa_lang_html('profile/delete_pm_popup'), 'popup' => qa_lang_html('profile/delete_pm_popup'),
), ),
...@@ -116,10 +116,10 @@ ...@@ -116,10 +116,10 @@
); );
$qa_content['message_list']['messages'][] = $msgFormat; $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,49 +20,50 @@ ...@@ -20,49 +20,50 @@
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
...@@ -70,84 +71,79 @@ ...@@ -70,84 +71,79 @@
'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'))) { if (strlen(qa_get('q'))) {
$qa_content['search']['value']=qa_html($inquery); $qa_content['search']['value'] = qa_html($inquery);
if (count($results)) if (count($results))
$qa_content['title']=qa_lang_html_sub('main/results_for_x', qa_html($inquery)); $qa_content['title'] = qa_lang_html_sub('main/results_for_x', qa_html($inquery));
else else
$qa_content['title']=qa_lang_html_sub('main/no_results_for_x', qa_html($inquery)); $qa_content['title'] = qa_lang_html_sub('main/no_results_for_x', qa_html($inquery));
$qa_content['q_list']['form']=array( $qa_content['q_list']['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('vote'), 'code' => qa_get_form_security_code('vote'),
), ),
); );
$qa_content['q_list']['qs']=array(); $qa_content['q_list']['qs'] = array();
$qdefaults=qa_post_html_defaults('Q'); $qdefaults = qa_post_html_defaults('Q');
foreach ($results as $result) foreach ($results as $result) {
if (!isset($result['question'])) { // if we have any non-question results, display with less statistics if (!isset($result['question'])) { // if we have any non-question results, display with less statistics
$qdefaults['voteview']=false; $qdefaults['voteview'] = false;
$qdefaults['answersview']=false; $qdefaults['answersview'] = false;
$qdefaults['viewsview']=false; $qdefaults['viewsview'] = false;
break; break;
} }
}
foreach ($results as $result) { foreach ($results as $result) {
if (isset($result['question'])) if (isset($result['question'])) {
$fields=qa_post_html_fields($result['question'], $userid, qa_cookie_get(), $fields = qa_post_html_fields($result['question'], $userid, qa_cookie_get(),
$usershtml, null, qa_post_html_options($result['question'], $qdefaults)); $usershtml, null, qa_post_html_options($result['question'], $qdefaults));
} elseif (isset($result['url'])) {
elseif (isset($result['url'])) $fields = array(
$fields=array(
'what' => qa_html($result['url']), 'what' => qa_html($result['url']),
'meta_order' => qa_lang_html('main/meta_order'), 'meta_order' => qa_lang_html('main/meta_order'),
); );
} else {
else
continue; // nothing to show here continue; // nothing to show here
}
if (isset($qdefaults['blockwordspreg'])) if (isset($qdefaults['blockwordspreg']))
$result['title']=qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']); $result['title'] = qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']);
$fields['title']=qa_html($result['title']); $fields['title'] = qa_html($result['title']);
$fields['url']=qa_html($result['url']); $fields['url'] = qa_html($result['url']);
$qa_content['q_list']['qs'][]=$fields; $qa_content['q_list']['qs'][] = $fields;
} }
$qa_content['page_links']=qa_html_page_links(qa_request(), $start, $pagesize, $start+$gotcount, $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount,
qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount>=$count); qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count);
if (qa_opt('feed_for_search')) if (qa_opt('feed_for_search')) {
$qa_content['feed']=array( $qa_content['feed'] = array(
'url' => qa_path_html(qa_feed_request('search/'.$inquery)), 'url' => qa_path_html(qa_feed_request('search/' . $inquery)),
'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery)), 'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery)),
); );
}
if (empty($qa_content['page_links'])) if (empty($qa_content['page_links']))
$qa_content['suggest_next']=qa_html_suggest_qs_tags(qa_using_tags()); $qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
} else
$qa_content['error']=qa_lang_html('main/search_explanation');
} else
$qa_content['error'] = qa_lang_html('main/search_explanation');
return $qa_content; 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)); $qa_content['title'] = qa_lang_html_sub('main/questions_tagged_x', qa_html($tag));
if (isset($userid) && isset($tagword)) { if (isset($userid) && isset($tagword)) {
$favoritemap=qa_get_favorite_non_qs_map(); $favoritemap = qa_get_favorite_non_qs_map();
$favorite=@$favoritemap['tag'][qa_strtolower($tagword['word'])]; $favorite = @$favoritemap['tag'][qa_strtolower($tagword['word'])];
$qa_content['favorite']=qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite, $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'])); qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word']));
} }
if (!count($questions)) if (!count($questions))
$qa_content['q_list']['title']=qa_lang_html('main/no_questions_found'); $qa_content['q_list']['title'] = qa_lang_html('main/no_questions_found');
$qa_content['q_list']['form']=array( $qa_content['q_list']['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('vote'), 'code' => qa_get_form_security_code('vote'),
), ),
); );
$qa_content['q_list']['qs']=array(); $qa_content['q_list']['qs'] = array();
foreach ($questions as $postid => $question) 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['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')); $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'])) if (empty($qa_content['page_links']))
$qa_content['suggest_next']=qa_html_suggest_qs_tags(true); $qa_content['suggest_next'] = qa_html_suggest_qs_tags(true);
if (qa_opt('feed_for_tag_qs')) if (qa_opt('feed_for_tag_qs')) {
$qa_content['feed']=array( $qa_content['feed'] = array(
'url' => qa_path_html(qa_feed_request('tag/'.$tag)), 'url' => qa_path_html(qa_feed_request('tag/' . $tag)),
'label' => qa_lang_html_sub('main/questions_tagged_x', qa_html($tag)), 'label' => qa_lang_html_sub('main/questions_tagged_x', qa_html($tag)),
); );
}
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,40 +20,40 @@ ...@@ -20,40 +20,40 @@
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['title'] = qa_lang_html('main/popular_tags');
$qa_content['ranking'] = array( $qa_content['ranking'] = array(
'items' => array(), 'items' => array(),
'rows' => ceil($pagesize/qa_opt('columns_tags')), 'rows' => ceil($pagesize / qa_opt('columns_tags')),
'type' => 'tags' 'type' => 'tags'
); );
if (count($populartags)) { if (count($populartags)) {
$favoritemap = qa_get_favorite_non_qs_map(); $favoritemap = qa_get_favorite_non_qs_map();
$output = 0; $output = 0;
...@@ -67,18 +67,13 @@ ...@@ -67,18 +67,13 @@
break; break;
} }
} else } else
$qa_content['title'] = qa_lang_html('main/no_tags_found'); $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')); $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagcount, qa_opt('pages_prev_next'));
if (empty($qa_content['page_links'])) if (empty($qa_content['page_links']))
$qa_content['suggest_next'] = qa_html_suggest_ask(); $qa_content['suggest_next'] = qa_html_suggest_ask();
return $qa_content; 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'); $qa_content['title'] = qa_lang_html('users/unsubscribe_title');
if ($unsubscribed) if ($unsubscribed) {
$qa_content['error']=strtr(qa_lang_html('users/unsubscribe_complete'), array( $qa_content['error'] = strtr(qa_lang_html('users/unsubscribe_complete'), array(
'^0' => qa_html(qa_opt('site_title')), '^0' => qa_html(qa_opt('site_title')),
'^1' => '<a href="'.qa_path_html('account').'">', '^1' => '<a href="' . qa_path_html('account') . '">',
'^2' => '</a>', '^2' => '</a>',
)); ));
else } else {
$qa_content['error']=qa_insert_login_links(qa_lang_html('users/unsubscribe_wrong_log_in'), 'unsubscribe'); $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,55 +20,55 @@ ...@@ -20,55 +20,55 @@
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 ($forfavorites) {
if ($forcontent) { if ($forcontent) {
$sometitle=qa_lang_html('misc/recent_updates_title'); $sometitle = qa_lang_html('misc/recent_updates_title');
$nonetitle=qa_lang_html('misc/no_recent_updates'); $nonetitle = qa_lang_html('misc/no_recent_updates');
} else { } else {
$sometitle=qa_lang_html('misc/recent_updates_favorites'); $sometitle = qa_lang_html('misc/recent_updates_favorites');
$nonetitle=qa_lang_html('misc/no_updates_favorites'); $nonetitle = qa_lang_html('misc/no_updates_favorites');
} }
} else { } else {
$sometitle=qa_lang_html('misc/recent_updates_content'); $sometitle = qa_lang_html('misc/recent_updates_content');
$nonetitle=qa_lang_html('misc/no_updates_content'); $nonetitle = qa_lang_html('misc/no_updates_content');
} }
// Prepare and return content for theme // Prepare and return content for theme
$qa_content=qa_q_list_page_content( $qa_content = qa_q_list_page_content(
qa_any_sort_and_dedupe($questions), qa_any_sort_and_dedupe($questions),
null, // questions per page null, // questions per page
0, // start offset 0, // start offset
...@@ -81,12 +81,12 @@ ...@@ -81,12 +81,12 @@
null, // prefix for links in category navigation null, // prefix for links in category navigation
null, // prefix for RSS feed paths (null to hide) null, // prefix for RSS feed paths (null to hide)
$forfavorites ? strtr(qa_lang_html('misc/suggest_update_favorites'), array( $forfavorites ? strtr(qa_lang_html('misc/suggest_update_favorites'), array(
'^1' => '<a href="'.qa_path_html('favorites').'">', '^1' => '<a href="' . qa_path_html('favorites') . '">',
'^2' => '</a>', '^2' => '</a>',
)) : null // suggest what to do next )) : null // suggest what to do next
); );
$qa_content['navigation']['sub']=array( $qa_content['navigation']['sub'] = array(
'all' => array( 'all' => array(
'label' => qa_lang_html('misc/nav_all_my_updates'), 'label' => qa_lang_html('misc/nav_all_my_updates'),
'url' => qa_path_html('updates'), 'url' => qa_path_html('updates'),
...@@ -104,12 +104,7 @@ ...@@ -104,12 +104,7 @@
'url' => qa_path_html('updates', array('show' => 'content')), 'url' => qa_path_html('updates', array('show' => 'content')),
'selected' => $forcontent && !$forfavorites, 'selected' => $forcontent && !$forfavorites,
), ),
); );
return $qa_content;
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
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