Commit 936231ab by Scott

Coding style (ajax pages)

parent 4fb68aa6
...@@ -20,26 +20,23 @@ ...@@ -20,26 +20,23 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
$categoryid=qa_post_text('categoryid'); $categoryid = qa_post_text('categoryid');
if (!strlen($categoryid)) if (!strlen($categoryid))
$categoryid=null; $categoryid = null;
list($fullcategory, $categories)=qa_db_select_with_pending( list($fullcategory, $categories) = qa_db_select_with_pending(
qa_db_full_category_selectspec($categoryid, true), qa_db_full_category_selectspec($categoryid, true),
qa_db_category_sub_selectspec($categoryid) qa_db_category_sub_selectspec($categoryid)
); );
echo "QA_AJAX_RESPONSE\n1\n"; echo "QA_AJAX_RESPONSE\n1\n";
echo qa_html(strtr(@$fullcategory['content'], "\r\n", ' ')); // category description echo qa_html(strtr(@$fullcategory['content'], "\r\n", ' ')); // category description
foreach ($categories as $category) foreach ($categories as $category) {
echo "\n".$category['categoryid'].'/'.$category['title']; // subcategory information // subcategory information
echo "\n" . $category['categoryid'] . '/' . $category['title'];
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,22 +20,17 @@ ...@@ -20,22 +20,17 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/cookies.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
$entityid=qa_post_text('entityid'); $entityid = qa_post_text('entityid');
$action=qa_post_text('action'); $action = qa_post_text('action');
if (!qa_check_form_security_code('admin/click', qa_post_text('code'))) if (!qa_check_form_security_code('admin/click', qa_post_text('code')))
echo "QA_AJAX_RESPONSE\n0\n".qa_lang('misc/form_security_reload'); echo "QA_AJAX_RESPONSE\n0\n" . qa_lang('misc/form_security_reload');
elseif (qa_admin_single_click($entityid, $action)) // permission check happens in here elseif (qa_admin_single_click($entityid, $action)) // permission check happens in here
echo "QA_AJAX_RESPONSE\n1\n"; echo "QA_AJAX_RESPONSE\n1\n";
else else
echo "QA_AJAX_RESPONSE\n0\n".qa_lang('main/general_error'); echo "QA_AJAX_RESPONSE\n0\n" . qa_lang('main/general_error');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,60 +20,57 @@ ...@@ -20,60 +20,57 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/cookies.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'pages/question-view.php'; require_once QA_INCLUDE_DIR . 'pages/question-view.php';
require_once QA_INCLUDE_DIR.'pages/question-submit.php'; require_once QA_INCLUDE_DIR . 'pages/question-submit.php';
// Load relevant information about this comment // Load relevant information about this comment
$commentid=qa_post_text('commentid'); $commentid = qa_post_text('commentid');
$questionid=qa_post_text('questionid'); $questionid = qa_post_text('questionid');
$parentid=qa_post_text('parentid'); $parentid = qa_post_text('parentid');
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($comment, $question, $parent, $children)=qa_db_select_with_pending( list($comment, $question, $parent, $children) = qa_db_select_with_pending(
qa_db_full_post_selectspec($userid, $commentid), qa_db_full_post_selectspec($userid, $commentid),
qa_db_full_post_selectspec($userid, $questionid), qa_db_full_post_selectspec($userid, $questionid),
qa_db_full_post_selectspec($userid, $parentid), qa_db_full_post_selectspec($userid, $parentid),
qa_db_full_child_posts_selectspec($userid, $parentid) qa_db_full_child_posts_selectspec($userid, $parentid)
); );
// Check if there was an operation that succeeded // Check if there was an operation that succeeded
if ( if (
(@$comment['basetype']=='C') && @$comment['basetype'] == 'C' && @$question['basetype'] == 'Q' &&
(@$question['basetype']=='Q') && (@$parent['basetype'] == 'Q' || @$parent['basetype'] == 'A')
((@$parent['basetype']=='Q') || (@$parent['basetype']=='A')) ) {
) { $comment = $comment + qa_page_q_post_rules($comment, $parent, $children, null); // array union
$comment=$comment+qa_page_q_post_rules($comment, $parent, $children, null); // array union
if (qa_page_q_single_click_c($comment, $question, $parent, $error)) { if (qa_page_q_single_click_c($comment, $question, $parent, $error)) {
$comment=qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $commentid)); $comment = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $commentid));
// If so, page content to be updated via Ajax // If so, page content to be updated via Ajax
echo "QA_AJAX_RESPONSE\n1"; echo "QA_AJAX_RESPONSE\n1";
// If the comment was not deleted... // If the comment was not deleted...
if (isset($comment)) { if (isset($comment)) {
$parent=$parent+qa_page_q_post_rules($parent, ($questionid==$parentid) ? null : $question, null, $children); $parent = $parent + qa_page_q_post_rules($parent, ($questionid == $parentid) ? null : $question, null, $children);
// in theory we should retrieve the parent's siblings for the above, but they're not going to be relevant // in theory we should retrieve the parent's siblings for the above, but they're not going to be relevant
$comment=$comment+qa_page_q_post_rules($comment, $parent, $children, null); $comment = $comment + qa_page_q_post_rules($comment, $parent, $children, null);
$usershtml=qa_userids_handles_html(array($comment), true); $usershtml = qa_userids_handles_html(array($comment), true);
$c_view=qa_page_q_comment_view($question, $parent, $comment, $usershtml, false); $c_view = qa_page_q_comment_view($question, $parent, $comment, $usershtml, false);
$themeclass=qa_load_theme_class(qa_get_site_theme(), 'ajax-comment', null, null); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-comment', null, null);
$themeclass->initialize(); $themeclass->initialize();
...@@ -86,12 +83,7 @@ ...@@ -86,12 +83,7 @@
return; return;
} }
} }
echo "QA_AJAX_RESPONSE\n0\n"; // fall back to non-Ajax submission if something failed
echo "QA_AJAX_RESPONSE\n0\n"; // fall back to non-Ajax submission if something failed
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,38 +20,38 @@ ...@@ -20,38 +20,38 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/messages.php'; require_once QA_INCLUDE_DIR . 'app/messages.php';
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/cookies.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.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();
$fromhandle = qa_post_text('handle'); $fromhandle = qa_post_text('handle');
$start = (int) qa_post_text('start'); $start = (int)qa_post_text('start');
$box = qa_post_text('box'); $box = qa_post_text('box');
$pagesize = qa_opt('page_size_pms'); $pagesize = qa_opt('page_size_pms');
if ( !isset($loginUserId) || $loginUserHandle !== $fromhandle || !in_array($box, array('inbox', 'outbox')) ) { if (!isset($loginUserId) || $loginUserHandle !== $fromhandle || !in_array($box, array('inbox', 'outbox'))) {
echo "QA_AJAX_RESPONSE\n0\n"; echo "QA_AJAX_RESPONSE\n0\n";
return; return;
} }
$func = 'qa_db_messages_'.$box.'_selectspec'; $func = 'qa_db_messages_' . $box . '_selectspec';
$pmSpec = $func('private', $loginUserId, true, $start, $pagesize); $pmSpec = $func('private', $loginUserId, true, $start, $pagesize);
$userMessages = qa_db_select_with_pending($pmSpec); $userMessages = qa_db_select_with_pending($pmSpec);
foreach ($userMessages as $message) { foreach ($userMessages as $message) {
if (qa_clicked('m'.$message['messageid'].'_dodelete')) { if (qa_clicked('m' . $message['messageid'] . '_dodelete')) {
if (qa_check_form_security_code('pm-'.$fromhandle, qa_post_text('code'))) { if (qa_check_form_security_code('pm-' . $fromhandle, qa_post_text('code'))) {
qa_pm_delete($loginUserId, qa_get_logged_in_handle(), qa_cookie_get(), $message, $box); qa_pm_delete($loginUserId, qa_get_logged_in_handle(), qa_cookie_get(), $message, $box);
echo "QA_AJAX_RESPONSE\n1\n"; echo "QA_AJAX_RESPONSE\n1\n";
return; return;
} }
} }
} }
echo "QA_AJAX_RESPONSE\n0\n"; echo "QA_AJAX_RESPONSE\n0\n";
...@@ -20,28 +20,26 @@ ...@@ -20,28 +20,26 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/messages.php'; require_once QA_INCLUDE_DIR . 'app/messages.php';
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/cookies.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
$tohandle=qa_post_text('handle'); $tohandle = qa_post_text('handle');
$start=(int)qa_post_text('start'); $start = (int)qa_post_text('start');
$usermessages=qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $tohandle, false, null, $start)); $usermessages = qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $tohandle, false, null, $start));
$usermessages=qa_wall_posts_add_rules($usermessages, $start); $usermessages = qa_wall_posts_add_rules($usermessages, $start);
foreach ($usermessages as $message) foreach ($usermessages as $message) {
if (qa_clicked('m'.$message['messageid'].'_dodelete') && $message['deleteable']) if (qa_clicked('m' . $message['messageid'] . '_dodelete') && $message['deleteable']) {
if (qa_check_form_security_code('wall-'.$tohandle, qa_post_text('code'))) { if (qa_check_form_security_code('wall-' . $tohandle, qa_post_text('code'))) {
qa_wall_delete_post(qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), $message); qa_wall_delete_post(qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), $message);
echo "QA_AJAX_RESPONSE\n1\n"; echo "QA_AJAX_RESPONSE\n1\n";
return; return;
} }
}
}
echo "QA_AJAX_RESPONSE\n0\n"; echo "QA_AJAX_RESPONSE\n0\n";
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,85 +20,78 @@ ...@@ -20,85 +20,78 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/limits.php'; require_once QA_INCLUDE_DIR . 'app/limits.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
// Load relevant information about this question and the comment parent // Load relevant information about this question and the comment parent
$questionid=qa_post_text('c_questionid'); $questionid = qa_post_text('c_questionid');
$parentid=qa_post_text('c_parentid'); $parentid = qa_post_text('c_parentid');
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($question, $parent, $children)=qa_db_select_with_pending( list($question, $parent, $children) = qa_db_select_with_pending(
qa_db_full_post_selectspec($userid, $questionid), qa_db_full_post_selectspec($userid, $questionid),
qa_db_full_post_selectspec($userid, $parentid), qa_db_full_post_selectspec($userid, $parentid),
qa_db_full_child_posts_selectspec($userid, $parentid) qa_db_full_child_posts_selectspec($userid, $parentid)
); );
// Check if the question and parent exist, and whether the user has permission to do this // Check if the question and parent exist, and whether the user has permission to do this
if ( if (
(@$question['basetype']=='Q') && @$question['basetype'] == 'Q' && (@$parent['basetype'] == 'Q' || @$parent['basetype'] == 'A') &&
((@$parent['basetype']=='Q') || (@$parent['basetype']=='A')) && !qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)
!qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) ) {
{ require_once QA_INCLUDE_DIR . 'app/captcha.php';
require_once QA_INCLUDE_DIR.'app/captcha.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/post-create.php';
require_once QA_INCLUDE_DIR.'app/post-create.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR.'app/cookies.php'; require_once QA_INCLUDE_DIR . 'pages/question-view.php';
require_once QA_INCLUDE_DIR.'pages/question-view.php'; require_once QA_INCLUDE_DIR . 'pages/question-submit.php';
require_once QA_INCLUDE_DIR.'pages/question-submit.php'; require_once QA_INCLUDE_DIR . 'util/sort.php';
require_once QA_INCLUDE_DIR.'util/sort.php';
// Try to create the new comment // Try to create the new comment
$usecaptcha=qa_user_use_captcha(qa_user_level_for_post($question)); $usecaptcha = qa_user_use_captcha(qa_user_level_for_post($question));
$commentid=qa_page_q_add_c_submit($question, $parent, $children, $usecaptcha, $in, $errors); $commentid = qa_page_q_add_c_submit($question, $parent, $children, $usecaptcha, $in, $errors);
// If successful, page content will be updated via Ajax // If successful, page content will be updated via Ajax
if (isset($commentid)) { if (isset($commentid)) {
$children=qa_db_select_with_pending(qa_db_full_child_posts_selectspec($userid, $parentid)); $children = qa_db_select_with_pending(qa_db_full_child_posts_selectspec($userid, $parentid));
$parent=$parent+qa_page_q_post_rules($parent, ($questionid==$parentid) ? null : $question, null, $children); $parent = $parent + qa_page_q_post_rules($parent, ($questionid == $parentid) ? null : $question, null, $children);
// in theory we should retrieve the parent's siblings for the above, but they're not going to be relevant // in theory we should retrieve the parent's siblings for the above, but they're not going to be relevant
foreach ($children as $key => $child) foreach ($children as $key => $child) {
$children[$key]=$child+qa_page_q_post_rules($child, $parent, $children, null); $children[$key] = $child + qa_page_q_post_rules($child, $parent, $children, null);
}
$usershtml=qa_userids_handles_html($children, true); $usershtml = qa_userids_handles_html($children, true);
qa_sort_by($children, 'created'); qa_sort_by($children, 'created');
$c_list=qa_page_q_comment_follow_list($question, $parent, $children, true, $usershtml, false, null); $c_list = qa_page_q_comment_follow_list($question, $parent, $children, true, $usershtml, false, null);
$themeclass=qa_load_theme_class(qa_get_site_theme(), 'ajax-comments', null, null); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-comments', null, null);
$themeclass->initialize(); $themeclass->initialize();
echo "QA_AJAX_RESPONSE\n1\n"; echo "QA_AJAX_RESPONSE\n1\n";
// Send back the ID of the new comment // send back the ID of the new comment
echo qa_anchor('C', $commentid) . "\n";
echo qa_anchor('C', $commentid)."\n";
// Send back the HTML // send back the HTML
$themeclass->c_list_items($c_list['cs']); $themeclass->c_list_items($c_list['cs']);
return; return;
} }
} }
echo "QA_AJAX_RESPONSE\n0\n"; // fall back to non-Ajax submission if there were any problems echo "QA_AJAX_RESPONSE\n0\n"; // fall back to non-Ajax submission if there were any problems
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,37 +20,31 @@ ...@@ -20,37 +20,31 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/cookies.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR.'app/favorites.php'; require_once QA_INCLUDE_DIR . 'app/favorites.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
$entitytype=qa_post_text('entitytype'); $entitytype = qa_post_text('entitytype');
$entityid=qa_post_text('entityid'); $entityid = qa_post_text('entityid');
$setfavorite=qa_post_text('favorite'); $setfavorite = qa_post_text('favorite');
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if (!qa_check_form_security_code('favorite-'.$entitytype.'-'.$entityid, qa_post_text('code'))) if (!qa_check_form_security_code('favorite-' . $entitytype . '-' . $entityid, qa_post_text('code'))) {
echo "QA_AJAX_RESPONSE\n0\n".qa_lang('misc/form_security_reload'); echo "QA_AJAX_RESPONSE\n0\n" . qa_lang('misc/form_security_reload');
} elseif (isset($userid)) {
elseif (isset($userid)) { $cookieid = qa_cookie_get();
$cookieid=qa_cookie_get();
qa_user_favorite_set($userid, qa_get_logged_in_handle(), $cookieid, $entitytype, $entityid, $setfavorite); qa_user_favorite_set($userid, qa_get_logged_in_handle(), $cookieid, $entitytype, $entityid, $setfavorite);
$favoriteform=qa_favorite_form($entitytype, $entityid, $setfavorite, qa_lang($setfavorite ? 'main/remove_favorites' : 'main/add_favorites')); $favoriteform = qa_favorite_form($entitytype, $entityid, $setfavorite, qa_lang($setfavorite ? 'main/remove_favorites' : 'main/add_favorites'));
$themeclass=qa_load_theme_class(qa_get_site_theme(), 'ajax-favorite', null, null); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-favorite', null, null);
$themeclass->initialize(); $themeclass->initialize();
echo "QA_AJAX_RESPONSE\n1\n"; echo "QA_AJAX_RESPONSE\n1\n";
$themeclass->favorite_inner_html($favoriteform); $themeclass->favorite_inner_html($favoriteform);
} }
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,34 +20,29 @@ ...@@ -20,34 +20,29 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/mailing.php'; require_once QA_INCLUDE_DIR . 'app/mailing.php';
$continue=false; $continue = false;
if (qa_get_logged_in_level()>=QA_USER_LEVEL_ADMIN) { if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
$starttime=time(); $starttime = time();
qa_mailing_perform_step(); qa_mailing_perform_step();
if ($starttime==time()) if ($starttime == time())
sleep(1); // make sure at least one second has passed sleep(1); // make sure at least one second has passed
$message=qa_mailing_progress_message(); $message = qa_mailing_progress_message();
if (isset($message)) if (isset($message))
$continue=true; $continue = true;
else else
$message=qa_lang('admin/mailing_complete'); $message = qa_lang('admin/mailing_complete');
} else } else
$message=qa_lang('admin/no_privileges'); $message = qa_lang('admin/no_privileges');
echo "QA_AJAX_RESPONSE\n".(int)$continue."\n".qa_html($message); echo "QA_AJAX_RESPONSE\n" . (int)$continue . "\n" . qa_html($message);
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,24 +20,24 @@ ...@@ -20,24 +20,24 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'db/notices.php'; require_once QA_INCLUDE_DIR . 'db/notices.php';
require_once QA_INCLUDE_DIR.'db/users.php'; require_once QA_INCLUDE_DIR . 'db/users.php';
$noticeid=qa_post_text('noticeid'); $noticeid = qa_post_text('noticeid');
if (!qa_check_form_security_code('notice-'.$noticeid, qa_post_text('code'))) if (!qa_check_form_security_code('notice-' . $noticeid, qa_post_text('code')))
echo "QA_AJAX_RESPONSE\n0\n".qa_lang('misc/form_security_reload'); echo "QA_AJAX_RESPONSE\n0\n" . qa_lang('misc/form_security_reload');
else { else {
if ($noticeid=='visitor') if ($noticeid == 'visitor')
setcookie('qa_noticed', 1, time()+86400*3650, '/', QA_COOKIE_DOMAIN, (bool)ini_get('session.cookie_secure'), true); setcookie('qa_noticed', 1, time() + 86400 * 3650, '/', QA_COOKIE_DOMAIN, (bool)ini_get('session.cookie_secure'), true);
else { else {
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
if ($noticeid=='welcome') if ($noticeid == 'welcome')
qa_db_user_set_flag($userid, QA_USER_FLAGS_WELCOME_NOTICE, false); qa_db_user_set_flag($userid, QA_USER_FLAGS_WELCOME_NOTICE, false);
else else
qa_db_usernotice_delete($userid, $noticeid); qa_db_usernotice_delete($userid, $noticeid);
...@@ -45,9 +45,4 @@ ...@@ -45,9 +45,4 @@
echo "QA_AJAX_RESPONSE\n1"; echo "QA_AJAX_RESPONSE\n1";
} }
/*
Omit PHP closing tag to help avoid accidental output
*/
...@@ -20,35 +20,30 @@ ...@@ -20,35 +20,30 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/recalc.php'; require_once QA_INCLUDE_DIR . 'app/recalc.php';
if (qa_get_logged_in_level()>=QA_USER_LEVEL_ADMIN) { if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
if (!qa_check_form_security_code('admin/recalc', qa_post_text('code'))) { if (!qa_check_form_security_code('admin/recalc', qa_post_text('code'))) {
$state=''; $state = '';
$message=qa_lang('misc/form_security_reload'); $message = qa_lang('misc/form_security_reload');
} else { } else {
$state=qa_post_text('state'); $state = qa_post_text('state');
$stoptime=time()+3; $stoptime = time() + 3;
while ( qa_recalc_perform_step($state) && (time()<$stoptime) ) while (qa_recalc_perform_step($state) && (time() < $stoptime))
; ;
$message=qa_recalc_get_message($state); $message = qa_recalc_get_message($state);
}
} else {
$state='';
$message=qa_lang('admin/no_privileges');
} }
} else {
$state = '';
$message = qa_lang('admin/no_privileges');
}
echo "QA_AJAX_RESPONSE\n1\n".$state."\n".qa_html($message);
echo "QA_AJAX_RESPONSE\n1\n" . $state . "\n" . qa_html($message);
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,45 +20,46 @@ ...@@ -20,45 +20,46 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
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/cookies.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'pages/question-view.php'; require_once QA_INCLUDE_DIR . 'pages/question-view.php';
require_once QA_INCLUDE_DIR.'util/sort.php'; require_once QA_INCLUDE_DIR . 'util/sort.php';
// Load relevant information about this question and check it exists // Load relevant information about this question and check it exists
$questionid=qa_post_text('c_questionid'); $questionid = qa_post_text('c_questionid');
$parentid=qa_post_text('c_parentid'); $parentid = qa_post_text('c_parentid');
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($question, $parent, $children, $duplicateposts) = qa_db_select_with_pending( list($question, $parent, $children, $duplicateposts) = qa_db_select_with_pending(
qa_db_full_post_selectspec($userid, $questionid), qa_db_full_post_selectspec($userid, $questionid),
qa_db_full_post_selectspec($userid, $parentid), qa_db_full_post_selectspec($userid, $parentid),
qa_db_full_child_posts_selectspec($userid, $parentid), qa_db_full_child_posts_selectspec($userid, $parentid),
qa_db_post_duplicates_selectspec($questionid) qa_db_post_duplicates_selectspec($questionid)
); );
if (isset($parent)) { if (isset($parent)) {
$parent = $parent + qa_page_q_post_rules($parent, null, null, $children+$duplicateposts); $parent = $parent + qa_page_q_post_rules($parent, null, null, $children + $duplicateposts);
// in theory we should retrieve the parent's parent and siblings for the above, but they're not going to be relevant // in theory we should retrieve the parent's parent and siblings for the above, but they're not going to be relevant
foreach ($children as $key => $child) foreach ($children as $key => $child) {
$children[$key]=$child+qa_page_q_post_rules($child, $parent, $children, null); $children[$key] = $child + qa_page_q_post_rules($child, $parent, $children, null);
}
$commentsfollows = $questionid == $parentid $commentsfollows = $questionid == $parentid
? qa_page_q_load_c_follows($question, $children, array(), $duplicateposts) ? qa_page_q_load_c_follows($question, $children, array(), $duplicateposts)
: qa_page_q_load_c_follows($question, array(), $children); : qa_page_q_load_c_follows($question, array(), $children);
$usershtml=qa_userids_handles_html($commentsfollows, true); $usershtml = qa_userids_handles_html($commentsfollows, true);
qa_sort_by($commentsfollows, 'created'); qa_sort_by($commentsfollows, 'created');
$c_list=qa_page_q_comment_follow_list($question, $parent, $commentsfollows, true, $usershtml, false, null); $c_list = qa_page_q_comment_follow_list($question, $parent, $commentsfollows, true, $usershtml, false, null);
$themeclass=qa_load_theme_class(qa_get_site_theme(), 'ajax-comments', null, null); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-comments', null, null);
$themeclass->initialize(); $themeclass->initialize();
echo "QA_AJAX_RESPONSE\n1\n"; echo "QA_AJAX_RESPONSE\n1\n";
...@@ -69,12 +70,7 @@ ...@@ -69,12 +70,7 @@
$themeclass->c_list_items($c_list['cs']); $themeclass->c_list_items($c_list['cs']);
return; return;
} }
echo "QA_AJAX_RESPONSE\n0\n";
echo "QA_AJAX_RESPONSE\n0\n";
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,19 +20,19 @@ ...@@ -20,19 +20,19 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) { if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
echo "QA_AJAX_RESPONSE\n0\n" . qa_lang_html('admin/no_privileges'); echo "QA_AJAX_RESPONSE\n0\n" . qa_lang_html('admin/no_privileges');
return; return;
} }
$uri = qa_post_text('uri'); $uri = qa_post_text('uri');
$version = qa_post_text('version'); $version = qa_post_text('version');
$isCore = qa_post_text('isCore') === "true"; $isCore = qa_post_text('isCore') === "true";
if ($isCore) { if ($isCore) {
$contents = qa_retrieve_url($uri); $contents = qa_retrieve_url($uri);
if (strlen($contents) > 0) { if (strlen($contents) > 0) {
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
} else { } else {
$response = qa_lang_html('admin/version_latest_unknown'); $response = qa_lang_html('admin/version_latest_unknown');
} }
} else { } else {
$metadataUtil = new Q2A_Util_Metadata(); $metadataUtil = new Q2A_Util_Metadata();
$metadata = $metadataUtil->fetchFromUrl($uri); $metadata = $metadataUtil->fetchFromUrl($uri);
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
} else { } else {
$response = qa_lang_html_sub('admin/version_get_x', qa_html('v' . $metadata['version'])); $response = qa_lang_html_sub('admin/version_get_x', qa_html('v' . $metadata['version']));
if (strlen(@$metadata['uri'])){ if (strlen(@$metadata['uri'])) {
$response = '<a href="' . qa_html($metadata['uri']) . '" style="color:#d00;">' . $response . '</a>'; $response = '<a href="' . qa_html($metadata['uri']) . '" style="color:#d00;">' . $response . '</a>';
} }
} }
...@@ -76,12 +76,6 @@ ...@@ -76,12 +76,6 @@
} else { } else {
$response = qa_lang_html('admin/version_latest_unknown'); $response = qa_lang_html('admin/version_latest_unknown');
} }
} }
echo "QA_AJAX_RESPONSE\n1\n".$response;
echo "QA_AJAX_RESPONSE\n1\n" . $response;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,48 +20,46 @@ ...@@ -20,48 +20,46 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/cookies.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR.'app/votes.php'; require_once QA_INCLUDE_DIR . 'app/votes.php';
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.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
$postid=qa_post_text('postid'); $postid = qa_post_text('postid');
$vote=qa_post_text('vote'); $vote = qa_post_text('vote');
$code=qa_post_text('code'); $code = qa_post_text('code');
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
$cookieid=qa_cookie_get(); $cookieid = qa_cookie_get();
if (!qa_check_form_security_code('vote', $code)) if (!qa_check_form_security_code('vote', $code))
$voteerror=qa_lang_html('misc/form_security_reload'); $voteerror = qa_lang_html('misc/form_security_reload');
else { else {
$post=qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $postid)); $post = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $postid));
$voteerror=qa_vote_error_html($post, $vote, $userid, qa_request()); $voteerror = qa_vote_error_html($post, $vote, $userid, qa_request());
} }
if ($voteerror===false) { if ($voteerror === false) {
qa_vote_set($post, $userid, qa_get_logged_in_handle(), $cookieid, $vote); qa_vote_set($post, $userid, qa_get_logged_in_handle(), $cookieid, $vote);
$post=qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $postid)); $post = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $postid));
$fields=qa_post_html_fields($post, $userid, $cookieid, array(), null, array( $fields = qa_post_html_fields($post, $userid, $cookieid, array(), null, array(
'voteview' => qa_get_vote_view($post, true), // behave as if on question page since the vote succeeded 'voteview' => qa_get_vote_view($post, true), // behave as if on question page since the vote succeeded
)); ));
$themeclass=qa_load_theme_class(qa_get_site_theme(), 'voting', null, null); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'voting', null, null);
$themeclass->initialize(); $themeclass->initialize();
echo "QA_AJAX_RESPONSE\n1\n"; echo "QA_AJAX_RESPONSE\n1\n";
$themeclass->voting_inner_html($fields); $themeclass->voting_inner_html($fields);
} else return;
echo "QA_AJAX_RESPONSE\n0\n".$voteerror;
}
/* echo "QA_AJAX_RESPONSE\n0\n" . $voteerror;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,47 +20,42 @@ ...@@ -20,47 +20,42 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
require_once QA_INCLUDE_DIR.'app/messages.php'; require_once QA_INCLUDE_DIR . 'app/messages.php';
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR . 'app/users.php';
require_once QA_INCLUDE_DIR.'app/cookies.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
$message=qa_post_text('message'); $message = qa_post_text('message');
$tohandle=qa_post_text('handle'); $tohandle = qa_post_text('handle');
$morelink=qa_post_text('morelink'); $morelink = qa_post_text('morelink');
$touseraccount=qa_db_select_with_pending(qa_db_user_account_selectspec($tohandle, false)); $touseraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($tohandle, false));
$loginuserid=qa_get_logged_in_userid(); $loginuserid = qa_get_logged_in_userid();
$errorhtml=qa_wall_error_html($loginuserid, $touseraccount['userid'], $touseraccount['flags']); $errorhtml = qa_wall_error_html($loginuserid, $touseraccount['userid'], $touseraccount['flags']);
if ($errorhtml || (!strlen($message)) || !qa_check_form_security_code('wall-'.$tohandle, qa_post_text('code')) ) if ($errorhtml || !strlen($message) || !qa_check_form_security_code('wall-' . $tohandle, qa_post_text('code'))) {
echo "QA_AJAX_RESPONSE\n0"; // if there's an error, process in non-Ajax way echo "QA_AJAX_RESPONSE\n0"; // if there's an error, process in non-Ajax way
} else {
else { $messageid = qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(),
$messageid=qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(),
$touseraccount['userid'], $touseraccount['handle'], $message, ''); $touseraccount['userid'], $touseraccount['handle'], $message, '');
$touseraccount['wallposts']++; // won't have been updated $touseraccount['wallposts']++; // won't have been updated
$usermessages=qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $touseraccount['userid'], true, qa_opt('page_size_wall'))); $usermessages = qa_db_select_with_pending(qa_db_recent_messages_selectspec(null, null, $touseraccount['userid'], true, qa_opt('page_size_wall')));
$usermessages=qa_wall_posts_add_rules($usermessages, 0); $usermessages = qa_wall_posts_add_rules($usermessages, 0);
$themeclass=qa_load_theme_class(qa_get_site_theme(), 'wall', null, null); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'wall', null, null);
$themeclass->initialize(); $themeclass->initialize();
echo "QA_AJAX_RESPONSE\n1\n"; echo "QA_AJAX_RESPONSE\n1\n";
echo 'm'.$messageid."\n"; // element in list to be revealed echo 'm' . $messageid . "\n"; // element in list to be revealed
foreach ($usermessages as $message) foreach ($usermessages as $message) {
$themeclass->message_item(qa_wall_post_view($message)); $themeclass->message_item(qa_wall_post_view($message));
if ($morelink && ($touseraccount['wallposts']>count($usermessages)))
$themeclass->message_item(qa_wall_view_more_link($tohandle, count($usermessages)));
} }
if ($morelink && ($touseraccount['wallposts'] > count($usermessages)))
/* $themeclass->message_item(qa_wall_view_more_link($tohandle, count($usermessages)));
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