Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
8b5b5866
Commit
8b5b5866
authored
Dec 03, 2016
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style (AJAX pages)
parent
b86d4256
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
197 additions
and
221 deletions
+197
-221
answer.php
qa-include/ajax/answer.php
+45
-51
asktitle.php
qa-include/ajax/asktitle.php
+52
-56
click-answer.php
qa-include/ajax/click-answer.php
+57
-65
qa-ajax.php
qa-include/qa-ajax.php
+43
-49
No files found.
qa-include/ajax/answer.php
View file @
8b5b5866
...
@@ -20,84 +20,79 @@
...
@@ -20,84 +20,79 @@
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
//
Load relevant information about this question
$questionid
=
qa_post_text
(
'a_questionid'
);
$questionid
=
qa_post_text
(
'a_questionid'
);
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
list
(
$question
,
$childposts
)
=
qa_db_select_with_pending
(
list
(
$question
,
$childposts
)
=
qa_db_select_with_pending
(
qa_db_full_post_selectspec
(
$userid
,
$questionid
),
qa_db_full_post_selectspec
(
$userid
,
$questionid
),
qa_db_full_child_posts_selectspec
(
$userid
,
$questionid
)
qa_db_full_child_posts_selectspec
(
$userid
,
$questionid
)
);
);
//
Check if the question exists, is not closed, and whether the user has permission to do this
//
Check if the question exists, is not closed, and whether the user has permission to do this
if
((
@
$question
[
'basetype'
]
==
'Q'
)
&&
(
!
isset
(
$question
[
'closedbyid'
])
)
&&
!
qa_user_post_permit_error
(
'permit_post_a'
,
$question
,
QA_LIMIT_ANSWERS
))
{
if
(
@
$question
[
'basetype'
]
==
'Q'
&&
!
isset
(
$question
[
'closedbyid'
]
)
&&
!
qa_user_post_permit_error
(
'permit_post_a'
,
$question
,
QA_LIMIT_ANSWERS
))
{
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'
;
//
Try to create the new answer
//
Try to create the new answer
$usecaptcha
=
qa_user_use_captcha
(
qa_user_level_for_post
(
$question
));
$usecaptcha
=
qa_user_use_captcha
(
qa_user_level_for_post
(
$question
));
$answers
=
qa_page_q_load_as
(
$question
,
$childposts
);
$answers
=
qa_page_q_load_as
(
$question
,
$childposts
);
$answerid
=
qa_page_q_add_a_submit
(
$question
,
$answers
,
$usecaptcha
,
$in
,
$errors
);
$answerid
=
qa_page_q_add_a_submit
(
$question
,
$answers
,
$usecaptcha
,
$in
,
$errors
);
//
If successful, page content will be updated via Ajax
//
If successful, page content will be updated via Ajax
if
(
isset
(
$answerid
))
{
if
(
isset
(
$answerid
))
{
$answer
=
qa_db_select_with_pending
(
qa_db_full_post_selectspec
(
$userid
,
$answerid
));
$answer
=
qa_db_select_with_pending
(
qa_db_full_post_selectspec
(
$userid
,
$answerid
));
$question
=
$question
+
qa_page_q_post_rules
(
$question
,
null
,
null
,
$childposts
);
// array union
$question
=
$question
+
qa_page_q_post_rules
(
$question
,
null
,
null
,
$childposts
);
// array union
$answer
=
$answer
+
qa_page_q_post_rules
(
$answer
,
$question
,
$answers
,
null
);
$answer
=
$answer
+
qa_page_q_post_rules
(
$answer
,
$question
,
$answers
,
null
);
$usershtml
=
qa_userids_handles_html
(
array
(
$answer
),
true
);
$usershtml
=
qa_userids_handles_html
(
array
(
$answer
),
true
);
$a_view
=
qa_page_q_answer_view
(
$question
,
$answer
,
false
,
$usershtml
,
false
);
$a_view
=
qa_page_q_answer_view
(
$question
,
$answer
,
false
,
$usershtml
,
false
);
$themeclass
=
qa_load_theme_class
(
qa_get_site_theme
(),
'ajax-answer'
,
null
,
null
);
$themeclass
=
qa_load_theme_class
(
qa_get_site_theme
(),
'ajax-answer'
,
null
,
null
);
$themeclass
->
initialize
();
$themeclass
->
initialize
();
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
;
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
;
//
Send back whether the 'answer' button should still be visible
//
Send back whether the 'answer' button should still be visible
echo
(
int
)
qa_opt
(
'allow_multi_answers'
)
.
"
\n
"
;
echo
(
int
)
qa_opt
(
'allow_multi_answers'
)
.
"
\n
"
;
//
Send back the count of answers
//
Send back the count of answers
$countanswers
=
$question
[
'acount'
]
+
1
;
$countanswers
=
$question
[
'acount'
]
+
1
;
if
(
$countanswers
==
1
)
if
(
$countanswers
==
1
)
echo
qa_lang_html
(
'question/1_answer_title'
)
.
"
\n
"
;
echo
qa_lang_html
(
'question/1_answer_title'
)
.
"
\n
"
;
else
else
echo
qa_lang_html_sub
(
'question/x_answers_title'
,
$countanswers
)
.
"
\n
"
;
echo
qa_lang_html_sub
(
'question/x_answers_title'
,
$countanswers
)
.
"
\n
"
;
//
Send back the HTML
//
Send back the HTML
$themeclass
->
a_list_item
(
$a_view
);
$themeclass
->
a_list_item
(
$a_view
);
return
;
return
;
}
}
}
}
echo
"QA_AJAX_RESPONSE
\n
0
\n
"
;
// fall back to non-Ajax submission if there were any problems
echo
"QA_AJAX_RESPONSE
\n
0
\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
qa-include/ajax/asktitle.php
View file @
8b5b5866
...
@@ -20,86 +20,82 @@
...
@@ -20,86 +20,82 @@
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
.
'util/string.php'
;
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
//
Collect the information we need from the database
//
Collect the information we need from the database
$intitle
=
qa_post_text
(
'title'
);
$intitle
=
qa_post_text
(
'title'
);
$doaskcheck
=
qa_opt
(
'do_ask_check_qs'
);
$doaskcheck
=
qa_opt
(
'do_ask_check_qs'
);
$doexampletags
=
qa_using_tags
()
&&
qa_opt
(
'do_example_tags'
);
$doexampletags
=
qa_using_tags
()
&&
qa_opt
(
'do_example_tags'
);
if
(
$doaskcheck
||
$doexampletags
)
{
if
(
$doaskcheck
||
$doexampletags
)
{
$countqs
=
max
(
$doexampletags
?
QA_DB_RETRIEVE_ASK_TAG_QS
:
0
,
$doaskcheck
?
qa_opt
(
'page_size_ask_check_qs'
)
:
0
);
$countqs
=
max
(
$doexampletags
?
QA_DB_RETRIEVE_ASK_TAG_QS
:
0
,
$doaskcheck
?
qa_opt
(
'page_size_ask_check_qs'
)
:
0
);
$relatedquestions
=
qa_db_select_with_pending
(
$relatedquestions
=
qa_db_select_with_pending
(
qa_db_search_posts_selectspec
(
null
,
qa_string_to_words
(
$intitle
),
null
,
null
,
null
,
null
,
0
,
false
,
$countqs
)
qa_db_search_posts_selectspec
(
null
,
qa_string_to_words
(
$intitle
),
null
,
null
,
null
,
null
,
0
,
false
,
$countqs
)
);
);
}
}
//
Collect example tags if appropriate
//
Collect example tags if appropriate
if
(
$doexampletags
)
{
if
(
$doexampletags
)
{
$tagweight
=
array
();
$tagweight
=
array
();
foreach
(
$relatedquestions
as
$question
)
{
foreach
(
$relatedquestions
as
$question
)
{
$tags
=
qa_tagstring_to_tags
(
$question
[
'tags'
]);
$tags
=
qa_tagstring_to_tags
(
$question
[
'tags'
]);
foreach
(
$tags
as
$tag
)
foreach
(
$tags
as
$tag
)
{
@
$tagweight
[
$tag
]
+=
exp
(
$question
[
'score'
]);
@
$tagweight
[
$tag
]
+=
exp
(
$question
[
'score'
]);
}
}
}
arsort
(
$tagweight
,
SORT_NUMERIC
);
arsort
(
$tagweight
,
SORT_NUMERIC
);
$exampletags
=
array
();
$exampletags
=
array
();
$minweight
=
exp
(
qa_match_to_min_score
(
qa_opt
(
'match_example_tags'
)));
$minweight
=
exp
(
qa_match_to_min_score
(
qa_opt
(
'match_example_tags'
)));
$maxcount
=
qa_opt
(
'page_size_ask_tags'
);
$maxcount
=
qa_opt
(
'page_size_ask_tags'
);
foreach
(
$tagweight
as
$tag
=>
$weight
)
{
foreach
(
$tagweight
as
$tag
=>
$weight
)
{
if
(
$weight
<
$minweight
)
if
(
$weight
<
$minweight
)
break
;
break
;
$exampletags
[]
=
$tag
;
$exampletags
[]
=
$tag
;
if
(
count
(
$exampletags
)
>=
$maxcount
)
if
(
count
(
$exampletags
)
>=
$maxcount
)
break
;
break
;
}
}
}
else
}
else
{
$exampletags
=
array
();
$exampletags
=
array
();
}
// Output the response header and example tags
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
;
// Output the response header and example tags
echo
strtr
(
qa_html
(
implode
(
','
,
$exampletags
)),
"
\r\n
"
,
' '
)
.
"
\n
"
;
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
;
echo
strtr
(
qa_html
(
implode
(
','
,
$exampletags
)),
"
\r\n
"
,
' '
)
.
"
\n
"
;
// Collect and output the list of related questions
if
(
$doaskcheck
)
{
// Collect and output the list of related questions
$minscore
=
qa_match_to_min_score
(
qa_opt
(
'match_ask_check_qs'
));
$maxcount
=
qa_opt
(
'page_size_ask_check_qs'
);
$relatedquestions
=
array_slice
(
$relatedquestions
,
0
,
$maxcount
);
if
(
$doaskcheck
)
{
$limitedquestions
=
array
();
$minscore
=
qa_match_to_min_score
(
qa_opt
(
'match_ask_check_qs'
));
$maxcount
=
qa_opt
(
'page_size_ask_check_qs'
);
foreach
(
$relatedquestions
as
$question
)
{
$relatedquestions
=
array_slice
(
$relatedquestions
,
0
,
$maxcount
);
if
(
$question
[
'score'
]
<
$minscore
)
$limitedquestions
=
array
();
break
;
$limitedquestions
[]
=
$question
;
foreach
(
$relatedquestions
as
$question
)
{
}
if
(
$question
[
'score'
]
<
$minscore
)
break
;
$themeclass
=
qa_load_theme_class
(
qa_get_site_theme
(),
'ajax-asktitle'
,
null
,
null
);
$limitedquestions
[]
=
$question
;
$themeclass
->
initialize
();
$themeclass
->
q_ask_similar
(
$limitedquestions
,
qa_lang_html
(
'question/ask_same_q'
));
}
}
$themeclass
=
qa_load_theme_class
(
qa_get_site_theme
(),
'ajax-asktitle'
,
null
,
null
);
/*
$themeclass
->
initialize
();
Omit PHP closing tag to help avoid accidental output
$themeclass
->
q_ask_similar
(
$limitedquestions
,
qa_lang_html
(
'question/ask_same_q'
));
*/
}
qa-include/ajax/click-answer.php
View file @
8b5b5866
...
@@ -20,101 +20,94 @@
...
@@ -20,101 +20,94 @@
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'
;
require_once
QA_INCLUDE_DIR
.
'util/sort.php'
;
require_once
QA_INCLUDE_DIR
.
'util/sort.php'
;
//
Load relevant information about this answer
//
Load relevant information about this answer
$answerid
=
qa_post_text
(
'answerid'
);
$answerid
=
qa_post_text
(
'answerid'
);
$questionid
=
qa_post_text
(
'questionid'
);
$questionid
=
qa_post_text
(
'questionid'
);
$userid
=
qa_get_logged_in_userid
();
$userid
=
qa_get_logged_in_userid
();
list
(
$answer
,
$question
,
$qchildposts
,
$achildposts
)
=
qa_db_select_with_pending
(
list
(
$answer
,
$question
,
$qchildposts
,
$achildposts
)
=
qa_db_select_with_pending
(
qa_db_full_post_selectspec
(
$userid
,
$answerid
),
qa_db_full_post_selectspec
(
$userid
,
$answerid
),
qa_db_full_post_selectspec
(
$userid
,
$questionid
),
qa_db_full_post_selectspec
(
$userid
,
$questionid
),
qa_db_full_child_posts_selectspec
(
$userid
,
$questionid
),
qa_db_full_child_posts_selectspec
(
$userid
,
$questionid
),
qa_db_full_child_posts_selectspec
(
$userid
,
$answerid
)
qa_db_full_child_posts_selectspec
(
$userid
,
$answerid
)
);
);
//
Check if there was an operation that succeeded
//
Check if there was an operation that succeeded
if
(
if
(
@
$answer
[
'basetype'
]
==
'A'
&&
@
$question
[
'basetype'
]
==
'Q'
)
{
(
@
$answer
[
'basetype'
]
==
'A'
)
&&
$answers
=
qa_page_q_load_as
(
$question
,
$qchildposts
);
(
@
$question
[
'basetype'
]
==
'Q'
)
)
{
$answers
=
qa_page_q_load_as
(
$question
,
$qchildposts
);
$question
=
$question
+
qa_page_q_post_rules
(
$question
,
null
,
null
,
$qchildposts
);
// array union
$question
=
$question
+
qa_page_q_post_rules
(
$question
,
null
,
null
,
$qchildposts
);
// array union
$answer
=
$answer
+
qa_page_q_post_rules
(
$answer
,
$question
,
$qchildposts
,
$achildposts
);
$answer
=
$answer
+
qa_page_q_post_rules
(
$answer
,
$question
,
$qchildposts
,
$achildposts
);
if
(
qa_page_q_single_click_a
(
$answer
,
$question
,
$answers
,
$achildposts
,
false
,
$error
))
{
if
(
qa_page_q_single_click_a
(
$answer
,
$question
,
$answers
,
$achildposts
,
false
,
$error
))
{
list
(
$answer
,
$question
)
=
qa_db_select_with_pending
(
list
(
$answer
,
$question
)
=
qa_db_select_with_pending
(
qa_db_full_post_selectspec
(
$userid
,
$answerid
),
qa_db_full_post_selectspec
(
$userid
,
$answerid
),
qa_db_full_post_selectspec
(
$userid
,
$questionid
)
qa_db_full_post_selectspec
(
$userid
,
$questionid
)
);
);
//
If so, page content to be updated via Ajax
//
If so, page content to be updated via Ajax
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
;
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
;
//
Send back new count of answers
//
Send back new count of answers
$countanswers
=
$question
[
'acount'
];
$countanswers
=
$question
[
'acount'
];
if
(
$countanswers
==
1
)
if
(
$countanswers
==
1
)
echo
qa_lang_html
(
'question/1_answer_title'
);
echo
qa_lang_html
(
'question/1_answer_title'
);
else
else
echo
qa_lang_html_sub
(
'question/x_answers_title'
,
$countanswers
);
echo
qa_lang_html_sub
(
'question/x_answers_title'
,
$countanswers
);
//
If the answer was not deleted....
//
If the answer was not deleted....
if
(
isset
(
$answer
))
{
if
(
isset
(
$answer
))
{
$question
=
$question
+
qa_page_q_post_rules
(
$question
,
null
,
null
,
$qchildposts
);
// array union
$question
=
$question
+
qa_page_q_post_rules
(
$question
,
null
,
null
,
$qchildposts
);
// array union
$answer
=
$answer
+
qa_page_q_post_rules
(
$answer
,
$question
,
$qchildposts
,
$achildposts
);
$answer
=
$answer
+
qa_page_q_post_rules
(
$answer
,
$question
,
$qchildposts
,
$achildposts
);
$commentsfollows
=
qa_page_q_load_c_follows
(
$question
,
$qchildposts
,
$achildposts
);
$commentsfollows
=
qa_page_q_load_c_follows
(
$question
,
$qchildposts
,
$achildposts
);
foreach
(
$commentsfollows
as
$key
=>
$commentfollow
)
foreach
(
$commentsfollows
as
$key
=>
$commentfollow
)
{
$commentsfollows
[
$key
]
=
$commentfollow
+
qa_page_q_post_rules
(
$commentfollow
,
$answer
,
$commentsfollows
,
null
);
$commentsfollows
[
$key
]
=
$commentfollow
+
qa_page_q_post_rules
(
$commentfollow
,
$answer
,
$commentsfollows
,
null
);
}
$usershtml
=
qa_userids_handles_html
(
array_merge
(
array
(
$answer
),
$commentsfollows
),
true
);
qa_sort_by
(
$commentsfollows
,
'created'
);
$a_view
=
qa_page_q_answer_view
(
$question
,
$answer
,
(
$answer
[
'postid'
]
==
$question
[
'selchildid'
])
&&
(
$answer
[
'type'
]
==
'A'
),
$usershtml
=
qa_userids_handles_html
(
array_merge
(
array
(
$answer
),
$commentsfollows
),
true
);
$usershtml
,
false
);
qa_sort_by
(
$commentsfollows
,
'created'
);
$a_view
[
'c_list'
]
=
qa_page_q_comment_follow_list
(
$question
,
$answer
,
$commentsfollows
,
false
,
$usershtml
,
false
,
null
);
$a_view
=
qa_page_q_answer_view
(
$question
,
$answer
,
(
$answer
[
'postid'
]
==
$question
[
'selchildid'
]
&&
$answer
[
'type'
]
==
'A'
),
$usershtml
,
false
);
$themeclass
=
qa_load_theme_class
(
qa_get_site_theme
(),
'ajax-answer'
,
null
,
null
);
$a_view
[
'c_list'
]
=
qa_page_q_comment_follow_list
(
$question
,
$answer
,
$commentsfollows
,
false
,
$usershtml
,
false
,
null
);
$themeclass
->
initialize
();
$themeclass
=
qa_load_theme_class
(
qa_get_site_theme
(),
'ajax-answer'
,
null
,
null
);
$themeclass
->
initialize
();
// ... send back the HTML for it
echo
"
\n
"
;
// ... send back the HTML for it
$themeclass
->
a_list_item
(
$a_view
);
echo
"
\n
"
;
}
return
;
$themeclass
->
a_list_item
(
$a_view
)
;
}
}
}
return
;
echo
"QA_AJAX_RESPONSE
\n
0
\n
"
;
// fall back to non-Ajax submission if something failed
}
}
/*
echo
"QA_AJAX_RESPONSE
\n
0
\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
qa-include/qa-ajax.php
View file @
8b5b5866
...
@@ -20,73 +20,68 @@
...
@@ -20,73 +20,68 @@
More about this license: http://www.question2answer.org/license.php
More about this license: http://www.question2answer.org/license.php
*/
*/
//
Output this header as early as possible
//
Output this header as early as possible
header
(
'Content-Type: text/plain; charset=utf-8'
);
header
(
'Content-Type: text/plain; charset=utf-8'
);
//
Ensure no PHP errors are shown in the Ajax response
//
Ensure no PHP errors are shown in the Ajax response
@
ini_set
(
'display_errors'
,
0
);
@
ini_set
(
'display_errors'
,
0
);
//
Load the Q2A base file which sets up a bunch of crucial functions
//
Load the Q2A base file which sets up a bunch of crucial functions
require
'qa-base.php'
;
require
'qa-base.php'
;
qa_report_process_stage
(
'init_ajax'
);
qa_report_process_stage
(
'init_ajax'
);
//
Get general Ajax parameters from the POST payload, and clear $_GET
//
Get general Ajax parameters from the POST payload, and clear $_GET
qa_set_request
(
qa_post_text
(
'qa_request'
),
qa_post_text
(
'qa_root'
));
qa_set_request
(
qa_post_text
(
'qa_request'
),
qa_post_text
(
'qa_root'
));
$_GET
=
array
();
// for qa_self_html()
$_GET
=
array
();
// for qa_self_html()
//
Database failure handler
//
Database failure handler
function
qa_ajax_db_fail_handler
()
function
qa_ajax_db_fail_handler
()
{
{
echo
"QA_AJAX_RESPONSE
\n
0
\n
A database error occurred."
;
echo
"QA_AJAX_RESPONSE
\n
0
\n
A database error occurred."
;
qa_exit
(
'error'
);
qa_exit
(
'error'
);
}
}
//
Perform the appropriate Ajax operation
//
Perform the appropriate Ajax operation
$routing
=
array
(
$routing
=
array
(
'notice'
=>
'notice.php'
,
'notice'
=>
'notice.php'
,
'favorite'
=>
'favorite.php'
,
'favorite'
=>
'favorite.php'
,
'vote'
=>
'vote.php'
,
'vote'
=>
'vote.php'
,
'recalc'
=>
'recalc.php'
,
'recalc'
=>
'recalc.php'
,
'mailing'
=>
'mailing.php'
,
'mailing'
=>
'mailing.php'
,
'version'
=>
'version.php'
,
'version'
=>
'version.php'
,
'category'
=>
'category.php'
,
'category'
=>
'category.php'
,
'asktitle'
=>
'asktitle.php'
,
'asktitle'
=>
'asktitle.php'
,
'answer'
=>
'answer.php'
,
'answer'
=>
'answer.php'
,
'comment'
=>
'comment.php'
,
'comment'
=>
'comment.php'
,
'click_a'
=>
'click-answer.php'
,
'click_a'
=>
'click-answer.php'
,
'click_c'
=>
'click-comment.php'
,
'click_c'
=>
'click-comment.php'
,
'click_admin'
=>
'click-admin.php'
,
'click_admin'
=>
'click-admin.php'
,
'show_cs'
=>
'show-comments.php'
,
'show_cs'
=>
'show-comments.php'
,
'wallpost'
=>
'wallpost.php'
,
'wallpost'
=>
'wallpost.php'
,
'click_wall'
=>
'click-wall.php'
,
'click_wall'
=>
'click-wall.php'
,
'click_pm'
=>
'click-pm.php'
,
'click_pm'
=>
'click-pm.php'
,
);
);
$operation
=
qa_post_text
(
'qa_operation'
);
$operation
=
qa_post_text
(
'qa_operation'
);
if
(
isset
(
$routing
[
$operation
]))
{
if
(
isset
(
$routing
[
$operation
]))
{
qa_db_connect
(
'qa_ajax_db_fail_handler'
);
qa_db_connect
(
'qa_ajax_db_fail_handler'
);
qa_initialize_buffering
();
qa_initialize_buffering
();
require
QA_INCLUDE_DIR
.
'ajax/'
.
$routing
[
$operation
];
require
QA_INCLUDE_DIR
.
'ajax/'
.
$routing
[
$operation
];
qa_db_disconnect
();
qa_db_disconnect
();
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment