Commit 2be2b6bb by Scott

Coding style (misc. pages)

parent d057c557
......@@ -20,99 +20,94 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
$categoryslugs=qa_request_parts(1);
$countslugs=count($categoryslugs);
$categoryslugs = qa_request_parts(1);
$countslugs = count($categoryslugs);
// Get information about appropriate categories and redirect to questions page if category has no sub-categories
$userid=qa_get_logged_in_userid();
list($categories, $categoryid, $favoritecats)=qa_db_select_with_pending(
$userid = qa_get_logged_in_userid();
list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending(
qa_db_category_nav_selectspec($categoryslugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null,
isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null
);
);
if ($countslugs && !isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
if ($countslugs && !isset($categoryid))
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// 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) {
$category=$categories[$navlink['categoryid']];
$category = $categories[$navlink['categoryid']];
if (!$category['childcount'])
unset($navigation[$key]['url']);
elseif ($navlink['selected']) {
$navigation[$key]['state']='open';
$navigation[$key]['url']=qa_path_html('categories/'.qa_category_path_request($categories, $category['parentid']));
$navigation[$key]['state'] = 'open';
$navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid']));
} else
$navigation[$key]['state']='closed';
$navigation[$key]['state'] = 'closed';
if (@$favoritemap[$navlink['categoryid']])
$navigation[$key]['favorited']=true;
$navigation[$key]['favorited'] = true;
$navigation[$key]['note']='';
$navigation[$key]['note'] = '';
$navigation[$key]['note'].=
' - <a href="'.qa_path_html('questions/'.implode('/', array_reverse(explode('/', $category['backpath'])))).'">'.( ($category['qcount']==1)
$navigation[$key]['note'] .=
' - <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/x_questions', qa_format_number($category['qcount'], 0, true))
).'</a>';
) . '</a>';
if (strlen($category['content']))
$navigation[$key]['note'].=qa_html(' - '.$category['content']);
$navigation[$key]['note'] .= qa_html(' - ' . $category['content']);
if (isset($navlink['subnav']))
qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap);
}
}
}
// 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)) {
$navigation=qa_category_navigation($categories, $categoryid, 'categories/', false);
if (count($categories)) {
$navigation = qa_category_navigation($categories, $categoryid, 'categories/', false);
unset($navigation['all']);
$favoritemap=array();
$favoritemap = array();
if (isset($favoritecats))
foreach ($favoritecats as $category)
$favoritemap[$category['categoryid']]=true;
$favoritemap[$category['categoryid']] = true;
qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap);
$qa_content['nav_list']=array(
$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());
}
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());
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,18 +20,19 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR.'app/favorites.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/favorites.php';
// Data for functions to run
$favswitch = array(
$favswitch = array(
'questions' => array(
'page_opt' => 'page_size_qs',
'fn_spec' => 'qa_db_user_favorite_qs_selectspec',
......@@ -50,58 +51,53 @@
'fn_view' => 'qa_favorite_tags_view',
'key' => 'ranking_tags',
),
);
);
// 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');
// Get lists of favorites of this type
$favtype = qa_request_part(1);
$start = qa_get_start();
$favtype = qa_request_part(1);
$start = qa_get_start();
if (!array_key_exists($favtype, $favswitch) || ($favtype === 'users' && QA_FINAL_EXTERNAL_USERS))
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
if (!array_key_exists($favtype, $favswitch) || ($favtype === 'users' && QA_FINAL_EXTERNAL_USERS))
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);
list($totalItems, $items) = qa_db_select_with_pending(
$pagesize = qa_opt($page_opt);
list($totalItems, $items) = qa_db_select_with_pending(
qa_db_selectspec_count($fn_spec($userid)),
$fn_spec($userid, $pagesize, $start)
);
);
$count = $totalItems['count'];
$usershtml = qa_userids_handles_html($items);
$count = $totalItems['count'];
$usershtml = qa_userids_handles_html($items);
// 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
$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['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'));
return $qa_content;
$qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true);
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,105 +20,100 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR.'app/favorites.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/favorites.php';
// 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');
// Get lists of favorites for this user
$pagesize_qs = qa_opt('page_size_qs');
$pagesize_users = qa_opt('page_size_users');
$pagesize_tags = qa_opt('page_size_tags');
$pagesize_qs = qa_opt('page_size_qs');
$pagesize_users = qa_opt('page_size_users');
$pagesize_tags = qa_opt('page_size_tags');
list($numQs, $questions, $numUsers, $users, $numTags, $tags, $categories) = qa_db_select_with_pending(
qa_db_selectspec_count( qa_db_user_favorite_qs_selectspec($userid) ),
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_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_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_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
$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
$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');
if ($numQs['count'] > count($questions)) {
$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'] = 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');
if ($numQs['count'] > count($questions)) {
$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>';
}
// 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']['title'] = count($users) ? qa_lang_html('main/nav_users') : qa_lang_html('misc/no_favorite_users');
if ($numUsers['count'] > count($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>';
}
$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>';
}
}
// Favorite tags
if (qa_using_tags()) {
if (qa_using_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');
if ($numTags['count'] > count($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>';
}
$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>';
}
}
// 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']['title'] = count($categories) ? qa_lang_html('main/nav_categories') : qa_lang_html('misc/no_favorite_categories');
}
}
// 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;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,70 +20,71 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'app/captcha.php';
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/captcha.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
// 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)
list($useraccount, $userprofile)=qa_db_select_with_pending(
if (isset($userid) && !QA_FINAL_EXTERNAL_USERS) {
list($useraccount, $userprofile) = qa_db_select_with_pending(
qa_db_user_account_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
if (!qa_opt('feedback_enabled'))
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
if (!qa_opt('feedback_enabled'))
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
if (qa_user_permit_error()) {
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission');
if (qa_user_permit_error()) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
}
// Send the feedback form
$feedbacksent=false;
$feedbacksent = false;
if (qa_clicked('dofeedback')) {
require_once QA_INCLUDE_DIR.'app/emails.php';
require_once QA_INCLUDE_DIR.'util/string.php';
if (qa_clicked('dofeedback')) {
require_once QA_INCLUDE_DIR . 'app/emails.php';
require_once QA_INCLUDE_DIR . 'util/string.php';
$inmessage=qa_post_text('message');
$inname=qa_post_text('name');
$inemail=qa_post_text('email');
$inreferer=qa_post_text('referer');
$inmessage = qa_post_text('message');
$inname = qa_post_text('name');
$inemail = qa_post_text('email');
$inreferer = qa_post_text('referer');
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 {
if (empty($inmessage))
$errors['message']=qa_lang('misc/feedback_empty');
$errors['message'] = qa_lang('misc/feedback_empty');
if ($usecaptcha)
qa_captcha_validate_post($errors);
if (empty($errors)) {
$subs=array(
$subs = array(
'^message' => $inmessage,
'^name' => empty($inname) ? '-' : $inname,
'^email' => empty($inemail) ? '-' : $inemail,
'^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(),
'^browser' => @$_SERVER['HTTP_USER_AGENT'],
);
......@@ -96,10 +97,11 @@
'subject' => qa_lang_sub('emails/feedback_subject', qa_opt('site_title')),
'body' => strtr(qa_lang('emails/feedback_body'), $subs),
'html' => false,
)))
$feedbacksent=true;
else
$pageerror=qa_lang_html('main/general_error');
))) {
$feedbacksent = true;
} else {
$pageerror = qa_lang_html('main/general_error');
}
qa_report_event('feedback', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array(
'email' => $inemail,
......@@ -110,19 +112,19 @@
));
}
}
}
}
// 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(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'tall',
......@@ -163,23 +165,18 @@
'code' => qa_get_form_security_code('feedback'),
'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_content['focusid']='message';
$qa_content['focusid'] = 'message';
if ($feedbacksent) {
$qa_content['form']['ok']=qa_lang_html('misc/feedback_sent');
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
return $qa_content;
......@@ -20,72 +20,72 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/users.php';
require_once QA_INCLUDE_DIR.'app/captcha.php';
require_once QA_INCLUDE_DIR . 'db/users.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
if (QA_FINAL_EXTERNAL_USERS)
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User login is handled by external code');
if (qa_is_logged_in())
if (qa_is_logged_in())
qa_redirect('');
// Start the 'I forgot my password' process, sending email if appropriate
if (qa_clicked('doforgot')) {
require_once QA_INCLUDE_DIR.'app/users-edit.php';
if (qa_clicked('doforgot')) {
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')))
$errors['page']=qa_lang_html('misc/form_security_again');
$errors['page'] = qa_lang_html('misc/form_security_again');
else {
if (strpos($inemailhandle, '@')===false) { // handles can't contain @ symbols
$matchusers=qa_db_user_find_by_handle($inemailhandle);
$passemailhandle=!qa_opt('allow_login_email_only');
if (strpos($inemailhandle, '@') === false) { // handles can't contain @ symbols
$matchusers = qa_db_user_find_by_handle($inemailhandle);
$passemailhandle = !qa_opt('allow_login_email_only');
} else {
$matchusers=qa_db_user_find_by_email($inemailhandle);
$passemailhandle=true;
$matchusers = qa_db_user_find_by_email($inemailhandle);
$passemailhandle = true;
}
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');
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');
if (qa_opt('captcha_on_reset_password'))
qa_captcha_validate_post($errors);
if (empty($errors)) {
$inuserid=$matchusers[0];
$inuserid = $matchusers[0];
qa_start_reset_user($inuserid);
qa_redirect('reset', $passemailhandle ? array('e' => $inemailhandle) : null); // redirect to page where code is entered
}
}
} else
$inemailhandle=qa_get('e');
} else
$inemailhandle = qa_get('e');
// 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['error']=@$errors['page'];
$qa_content['title'] = qa_lang_html('users/reset_title');
$qa_content['error'] = @$errors['page'];
$qa_content['form']=array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'tall',
......@@ -109,17 +109,12 @@
'doforgot' => '1',
'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_content['focusid']='emailhandle';
$qa_content['focusid'] = 'emailhandle';
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,25 +20,25 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
$ip=qa_request_part(1); // picked up from qa-page.php
if (filter_var($ip, FILTER_VALIDATE_IP) === false)
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
$ip = qa_request_part(1); // picked up from qa-page.php
if (filter_var($ip, FILTER_VALIDATE_IP) === false)
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// 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_qs_selectspec($userid, 'created', 0, null, $ip, false),
qa_db_qs_selectspec($userid, 'created', 0, null, $ip, 'Q_QUEUED'),
......@@ -55,26 +55,26 @@
// 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')) {
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission');
if (qa_user_maximum_permit_error('permit_anon_view_ips')) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
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
if (qa_clicked('doblock') || qa_clicked('dounblock') || qa_clicked('dohideall')) {
if (!qa_check_form_security_code('ip-'.$ip, qa_post_text('code')))
$pageerror=qa_lang_html('misc/form_security_again');
if (qa_clicked('doblock') || qa_clicked('dounblock') || qa_clicked('dohideall')) {
if (!qa_check_form_security_code('ip-' . $ip, qa_post_text('code')))
$pageerror = qa_lang_html('misc/form_security_again');
elseif ($blockable) {
if (qa_clicked('doblock')) {
$oldblocked=qa_opt('block_ips_write');
qa_set_option('block_ips_write', (strlen($oldblocked) ? ($oldblocked.' , ') : '').$ip);
$oldblocked = qa_opt('block_ips_write');
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(
'ip' => $ip,
......@@ -84,13 +84,14 @@
}
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))
unset($blockipclauses[$key]);
}
qa_set_option('block_ips_write', implode(' , ', $blockipclauses));
......@@ -104,10 +105,10 @@
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
require_once QA_INCLUDE_DIR.'db/admin.php';
require_once QA_INCLUDE_DIR.'app/posts.php';
require_once QA_INCLUDE_DIR . 'db/admin.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)
qa_post_set_hidden($postid, true, $userid);
......@@ -115,27 +116,27 @@
qa_redirect(qa_request());
}
}
}
}
// 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
$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['title'] = qa_lang_html_sub('main/ip_address_x', qa_html($ip));
$qa_content['error'] = @$pageerror;
$qa_content['form']=array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'wide',
......@@ -148,88 +149,85 @@
),
'hidden' => array(
'code' => qa_get_form_security_code('ip-'.$ip),
'code' => qa_get_form_security_code('ip-' . $ip),
),
);
);
if ($blockable) {
require_once QA_INCLUDE_DIR.'app/limits.php';
if ($blockable) {
require_once QA_INCLUDE_DIR . 'app/limits.php';
$blockipclauses=qa_block_ips_explode(qa_opt('block_ips_write'));
$matchclauses=array();
$blockipclauses = qa_block_ips_explode(qa_opt('block_ips_write'));
$matchclauses = array();
foreach ($blockipclauses as $blockipclause)
foreach ($blockipclauses as $blockipclause) {
if (qa_block_ip_match($ip, $blockipclause))
$matchclauses[]=$blockipclause;
$matchclauses[] = $blockipclause;
}
if (count($matchclauses)) {
$qa_content['form']['fields']['status']=array(
$qa_content['form']['fields']['status'] = array(
'type' => 'static',
'label' => qa_lang_html('misc/matches_blocked_ips'),
'value' => qa_html(implode("\n", $matchclauses), true),
);
$qa_content['form']['buttons']['unblock']=array(
$qa_content['form']['buttons']['unblock'] = array(
'tags' => 'name="dounblock"',
'label' => qa_lang_html('misc/unblock_ip_button'),
);
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);"',
'label' => qa_lang_html('misc/hide_all_ip_button'),
);
} else
$qa_content['form']['buttons']['block']=array(
} 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)) {
$qa_content['q_list']['title']=qa_lang_html_sub('misc/recent_activity_from_x', qa_html($ip));
if (count($questions)) {
$qa_content['q_list']['title'] = qa_lang_html_sub('misc/recent_activity_from_x', qa_html($ip));
foreach ($questions as $question) {
$htmloptions=qa_post_html_options($question);
$htmloptions['tagsview']=false;
$htmloptions['voteview']=false;
$htmloptions['ipview']=false;
$htmloptions['answersview']=false;
$htmloptions['viewsview']=false;
$htmloptions['updateview']=false;
$htmloptions = qa_post_html_options($question);
$htmloptions['tagsview'] = false;
$htmloptions['voteview'] = false;
$htmloptions['ipview'] = false;
$htmloptions['answersview'] = false;
$htmloptions['viewsview'] = 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
$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'])) {
$htmlfields['what_2']=qa_lang_html('main/hidden');
$htmlfields['what_2'] = qa_lang_html('main/hidden');
if (@$htmloptions['whenview']) {
$updated=@$question[$hasother ? 'oupdated' : 'updated'];
$updated = @$question[$hasother ? 'oupdated' : '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
$qa_content['q_list']['title']=qa_lang_html_sub('misc/no_activity_from_x', qa_html($ip));
} 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
return $qa_content;
......@@ -20,70 +20,70 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/users.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR.'app/limits.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/limits.php';
$handle = qa_request_part(1);
$loginuserid = qa_get_logged_in_userid();
$fromhandle = qa_get_logged_in_handle();
$handle = qa_request_part(1);
$loginuserid = qa_get_logged_in_userid();
$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
if (QA_FINAL_EXTERNAL_USERS)
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code');
if (!strlen($handle))
if (!strlen($handle))
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());
return $qa_content;
}
}
if ($handle === $fromhandle) {
if ($handle === $fromhandle) {
// prevent users sending messages to themselves
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
}
// 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_recent_messages_selectspec($loginuserid, true, $handle, false),
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)
if (!qa_opt('allow_private_messages') || !is_array($toaccount))
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
if (!qa_opt('allow_private_messages') || !is_array($toaccount))
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
if ($toaccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) {
if ($toaccount['flags'] & QA_USER_FLAGS_NO_MESSAGES) {
$qa_content['error'] = qa_lang_html_sub(
'profile/user_x_disabled_pms',
sprintf('<a href="%s">%s</a>', qa_path_html('user/' . $handle), qa_html($handle))
);
return $qa_content;
}
}
// 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':
$pageerror = qa_lang_html('misc/message_limit');
break;
......@@ -94,18 +94,18 @@
default:
$pageerror = qa_lang_html('users/no_permission');
break;
}
}
// Process sending a message to user
// check for messages or errors
$state = qa_get_state();
$messagesent = $state == 'message-sent';
if ($state == 'email-error')
// check for messages or errors
$state = qa_get_state();
$messagesent = $state == 'message-sent';
if ($state == 'email-error')
$pageerror = qa_lang_html('main/email_error');
if (qa_post_text('domessage')) {
if (qa_post_text('domessage')) {
$inmessage = qa_post_text('message');
if (isset($pageerror)) {
......@@ -114,7 +114,7 @@
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');
else {
......@@ -122,8 +122,8 @@
$errors['message'] = qa_lang('misc/message_empty');
if (empty($errors)) {
require_once QA_INCLUDE_DIR.'db/messages.php';
require_once QA_INCLUDE_DIR.'app/emails.php';
require_once QA_INCLUDE_DIR . 'db/messages.php';
require_once QA_INCLUDE_DIR . 'app/emails.php';
if (qa_opt('show_message_history'))
$messageid = qa_db_message_create($loginuserid, $toaccount['userid'], $inmessage, '', false);
......@@ -134,13 +134,13 @@
$more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array(
'^f_handle' => $fromhandle,
'^url' => qa_path_absolute($canreply ? ('message/'.$fromhandle) : ('user/'.$fromhandle)),
'^url' => qa_path_absolute($canreply ? ('message/' . $fromhandle) : ('user/' . $fromhandle)),
));
$subs = array(
'^message' => $inmessage,
'^f_handle' => $fromhandle,
'^f_url' => qa_path_absolute('user/'.$fromhandle),
'^f_url' => qa_path_absolute('user/' . $fromhandle),
'^more' => $more,
'^a_url' => qa_path_absolute('account'),
);
......@@ -161,19 +161,19 @@
qa_redirect(qa_request(), array('state' => ($messagesent ? 'message-sent' : 'email-error')));
}
}
}
}
// 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(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['form_message'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'tall',
......@@ -200,13 +200,13 @@
'hidden' => array(
'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']);
if (qa_opt('show_message_history'))
......@@ -215,12 +215,12 @@
unset($qa_content['form_message']['fields']['message']['note']);
unset($qa_content['form_message']['fields']['message']['label']);
}
}
}
// If relevant, show recent message history
if (qa_opt('show_message_history')) {
if (qa_opt('show_message_history')) {
$recent = array_merge($torecent, $fromrecent);
qa_sort_by($recent, 'created');
......@@ -239,14 +239,9 @@
}
$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
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,83 +20,83 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/users.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR.'app/limits.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/limits.php';
$loginUserId = qa_get_logged_in_userid();
$loginUserHandle = qa_get_logged_in_handle();
$loginUserId = qa_get_logged_in_userid();
$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
$req = qa_request_part(1);
if ($req === null)
$req = qa_request_part(1);
if ($req === null)
$showOutbox = false;
elseif ($req === 'sent')
elseif ($req === 'sent')
$showOutbox = true;
else
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
else
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');
if (!isset($loginUserId)) {
if (!isset($loginUserId)) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request());
return $qa_content;
}
}
if (!qa_opt('allow_private_messages') || !qa_opt('show_message_history'))
return include QA_INCLUDE_DIR.'qa-page-not-found.php';
if (!qa_opt('allow_private_messages') || !qa_opt('show_message_history'))
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
// Find the messages for this user
$start = qa_get_start();
$pagesize = qa_opt('page_size_pms');
$start = qa_get_start();
$pagesize = qa_opt('page_size_pms');
// get number of messages then actual messages for this page
$func = $showOutbox ? 'qa_db_messages_outbox_selectspec' : 'qa_db_messages_inbox_selectspec';
$pmSpecCount = qa_db_selectspec_count( $func('private', $loginUserId, true) );
$pmSpec = $func('private', $loginUserId, true, $start, $pagesize);
// get number of messages then actual messages for this page
$func = $showOutbox ? 'qa_db_messages_outbox_selectspec' : 'qa_db_messages_inbox_selectspec';
$pmSpecCount = qa_db_selectspec_count($func('private', $loginUserId, true));
$pmSpec = $func('private', $loginUserId, true, $start, $pagesize);
list($numMessages, $userMessages) = qa_db_select_with_pending($pmSpecCount, $pmSpec);
$count = $numMessages['count'];
list($numMessages, $userMessages) = qa_db_select_with_pending($pmSpecCount, $pmSpec);
$count = $numMessages['count'];
// Prepare content for theme
$qa_content = qa_content_prepare();
$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 = qa_content_prepare();
$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['message_list'] = array(
$qa_content['message_list'] = array(
'tags' => 'id="privatemessages"',
'messages' => array(),
'form' => array(
'tags' => 'name="pmessage" method="post" action="'.qa_self_html().'"',
'tags' => 'name="pmessage" method="post" action="' . qa_self_html() . '"',
'style' => 'tall',
'hidden' => array(
'qa_click' => '', // for simulating clicks in Javascript
'handle' => qa_html($loginUserHandle),
'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 = qa_message_html_defaults();
if ($showOutbox)
$htmlDefaults['towhomview'] = true;
foreach ($userMessages as $message) {
foreach ($userMessages as $message) {
$msgFormat = qa_message_html_fields($message, $htmlDefaults);
$replyHandle = $showOutbox ? $message['tohandle'] : $message['fromhandle'];
......@@ -104,11 +104,11 @@
'style' => 'light',
'buttons' => 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'),
),
'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'),
'popup' => qa_lang_html('profile/delete_pm_popup'),
),
......@@ -116,10 +116,10 @@
);
$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 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR.'app/options.php';
require_once QA_INCLUDE_DIR.'app/search.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR . 'app/search.php';
// Perform the search if appropriate
if (strlen(qa_get('q'))) {
if (strlen(qa_get('q'))) {
// Pull in input parameters
$inquery=trim(qa_get('q'));
$userid=qa_get_logged_in_userid();
$start=qa_get_start();
$inquery = trim(qa_get('q'));
$userid = qa_get_logged_in_userid();
$start = qa_get_start();
$display=qa_opt_if_loaded('page_size_search');
$count=2*(isset($display) ? $display : QA_DB_RETRIEVE_QS_AS)+1;
$display = qa_opt_if_loaded('page_size_search');
$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
// 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
$pagesize=qa_opt('page_size_search');
$gotcount=count($results);
$results=array_slice($results, 0, $pagesize);
$pagesize = qa_opt('page_size_search');
$gotcount = count($results);
$results = array_slice($results, 0, $pagesize);
// Retrieve extra information on users
$fullquestions=array();
$fullquestions = array();
foreach ($results as $result)
foreach ($results as $result) {
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
......@@ -70,84 +71,79 @@
'query' => $inquery,
'start' => $start,
));
}
}
// 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 (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));
$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['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().'"',
$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();
$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
$qdefaults['voteview']=false;
$qdefaults['answersview']=false;
$qdefaults['viewsview']=false;
$qdefaults['voteview'] = false;
$qdefaults['answersview'] = false;
$qdefaults['viewsview'] = false;
break;
}
}
foreach ($results as $result) {
if (isset($result['question']))
$fields=qa_post_html_fields($result['question'], $userid, qa_cookie_get(),
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(
} elseif (isset($result['url'])) {
$fields = array(
'what' => qa_html($result['url']),
'meta_order' => qa_lang_html('main/meta_order'),
);
else
} else {
continue; // nothing to show here
}
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['url']=qa_html($result['url']);
$fields['title'] = qa_html($result['title']);
$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_opt('pages_prev_next'), array('q' => $inquery), $gotcount>=$count);
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount,
qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count);
if (qa_opt('feed_for_search'))
$qa_content['feed']=array(
'url' => qa_path_html(qa_feed_request('search/'.$inquery)),
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());
} else
$qa_content['error']=qa_lang_html('main/search_explanation');
$qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
} 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
return $qa_content;
......@@ -20,79 +20,77 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR.'app/updates.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/updates.php';
$tag=qa_request_part(1); // picked up from qa-page.php
$start=qa_get_start();
$userid=qa_get_logged_in_userid();
$tag = qa_request_part(1); // picked up from qa-page.php
$start = qa_get_start();
$userid = qa_get_logged_in_userid();
// Find the questions with this tag
if (!strlen($tag))
if (!strlen($tag))
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_word_selectspec($tag)
);
);
$pagesize=qa_opt('page_size_tag_qs');
$questions=array_slice($questions, 0, $pagesize);
$usershtml=qa_userids_handles_html($questions);
$pagesize = qa_opt('page_size_tag_qs');
$questions = array_slice($questions, 0, $pagesize);
$usershtml = qa_userids_handles_html($questions);
// Prepare content for theme
$qa_content=qa_content_prepare(true);
$qa_content = 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)) {
$favoritemap=qa_get_favorite_non_qs_map();
$favorite=@$favoritemap['tag'][qa_strtolower($tagword['word'])];
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['favorite'] = qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite,
qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word']));
}
}
if (!count($questions))
$qa_content['q_list']['title']=qa_lang_html('main/no_questions_found');
if (!count($questions))
$qa_content['q_list']['title'] = qa_lang_html('main/no_questions_found');
$qa_content['q_list']['form']=array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['q_list']['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array(
'code' => qa_get_form_security_code('vote'),
),
);
);
$qa_content['q_list']['qs']=array();
foreach ($questions as $postid => $question)
$qa_content['q_list']['qs'][]=qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question));
$qa_content['q_list']['qs'] = array();
foreach ($questions as $postid => $question) {
$qa_content['q_list']['qs'][] =
qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question));
}
$qa_content['page_links']=qa_html_page_links(qa_request(), $start, $pagesize, $tagword['tagcount'], qa_opt('pages_prev_next'));
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagword['tagcount'], qa_opt('pages_prev_next'));
if (empty($qa_content['page_links']))
$qa_content['suggest_next']=qa_html_suggest_qs_tags(true);
if (empty($qa_content['page_links']))
$qa_content['suggest_next'] = qa_html_suggest_qs_tags(true);
if (qa_opt('feed_for_tag_qs'))
$qa_content['feed']=array(
'url' => qa_path_html(qa_feed_request('tag/'.$tag)),
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
return $qa_content;
......@@ -20,40 +20,40 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
// Get popular tags
$start = qa_get_start();
$userid = qa_get_logged_in_userid();
$populartags = qa_db_select_with_pending(
$start = qa_get_start();
$userid = qa_get_logged_in_userid();
$populartags = qa_db_select_with_pending(
qa_db_popular_tags_selectspec($start, qa_opt_if_loaded('page_size_tags'))
);
);
$tagcount = qa_opt('cache_tagcount');
$pagesize = qa_opt('page_size_tags');
$tagcount = qa_opt('cache_tagcount');
$pagesize = qa_opt('page_size_tags');
// 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(),
'rows' => ceil($pagesize/qa_opt('columns_tags')),
'rows' => ceil($pagesize / qa_opt('columns_tags')),
'type' => 'tags'
);
);
if (count($populartags)) {
if (count($populartags)) {
$favoritemap = qa_get_favorite_non_qs_map();
$output = 0;
......@@ -67,18 +67,13 @@
break;
}
} else
} else
$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();
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,62 +20,58 @@
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: ../');
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
if (QA_FINAL_EXTERNAL_USERS)
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User login is handled by external code');
// Check the code and unsubscribe the user if appropriate
$unsubscribed=false;
$loginuserid=qa_get_logged_in_userid();
$unsubscribed = false;
$loginuserid = qa_get_logged_in_userid();
$incode=trim(qa_get('c')); // trim to prevent passing in blank values to match uninitiated DB rows
$inhandle=qa_get('u');
$incode = trim(qa_get('c')); // trim to prevent passing in blank values to match uninitiated DB rows
$inhandle = qa_get('u');
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));
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));
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);
$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);
$unsubscribed=true;
}
$unsubscribed = true;
}
// 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)
$qa_content['error']=strtr(qa_lang_html('users/unsubscribe_complete'), array(
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').'">',
'^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');
} else {
$qa_content['error'] = qa_insert_login_links(qa_lang_html('users/unsubscribe_wrong_log_in'), 'unsubscribe');
}
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,55 +20,55 @@
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: ../');
exit;
}
}
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR.'app/q-list.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/q-list.php';
// 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');
// Find out which updates to show
$forfavorites=qa_get('show')!='content';
$forcontent=qa_get('show')!='favorites';
$forfavorites = qa_get('show') != 'content';
$forcontent = qa_get('show') != 'favorites';
// 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)
);
);
if ($forfavorites) {
if ($forfavorites) {
if ($forcontent) {
$sometitle=qa_lang_html('misc/recent_updates_title');
$nonetitle=qa_lang_html('misc/no_recent_updates');
$sometitle = qa_lang_html('misc/recent_updates_title');
$nonetitle = qa_lang_html('misc/no_recent_updates');
} else {
$sometitle=qa_lang_html('misc/recent_updates_favorites');
$nonetitle=qa_lang_html('misc/no_updates_favorites');
$sometitle = qa_lang_html('misc/recent_updates_favorites');
$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');
}
} 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_content = qa_q_list_page_content(
qa_any_sort_and_dedupe($questions),
null, // questions per page
0, // start offset
......@@ -81,12 +81,12 @@
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').'">',
'^1' => '<a href="' . qa_path_html('favorites') . '">',
'^2' => '</a>',
)) : null // suggest what to do next
);
);
$qa_content['navigation']['sub']=array(
$qa_content['navigation']['sub'] = array(
'all' => array(
'label' => qa_lang_html('misc/nav_all_my_updates'),
'url' => qa_path_html('updates'),
......@@ -104,12 +104,7 @@
'url' => qa_path_html('updates', array('show' => 'content')),
'selected' => $forcontent && !$forfavorites,
),
);
);
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
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