Commit fd392d05 by Scott

Check title and content for duplicates

parent f7e0e020
...@@ -144,12 +144,16 @@ if (qa_clicked('doask')) { ...@@ -144,12 +144,16 @@ if (qa_clicked('doask')) {
if (empty($errors)) { if (empty($errors)) {
// check if the question is already posted // check if the question is already posted
$testwords = implode(' ', qa_string_to_words($in['content'])); $testTitleWords = implode(' ', qa_string_to_words($in['title']));
$recent_questions = qa_db_select_with_pending(qa_db_qs_selectspec(null, 'created', 0, null, null, false, true, 5)); $testContentWords = implode(' ', qa_string_to_words($in['content']));
$recentQuestions = qa_db_select_with_pending(qa_db_qs_selectspec(null, 'created', 0, null, null, false, true, 5));
foreach ($recent_questions as $question) { foreach ($recentQuestions as $question) {
if (!$question['hidden']) { if (!$question['hidden']) {
if (implode(' ', qa_string_to_words($question['content'])) == $testwords) { $qTitleWords = implode(' ', qa_string_to_words($question['title']));
$qContentWords = implode(' ', qa_string_to_words($question['content']));
if ($qTitleWords == $testTitleWords && $qContentWords == $testContentWords) {
$errors['page'] = qa_lang_html('question/duplicate_content'); $errors['page'] = qa_lang_html('question/duplicate_content');
break; break;
} }
......
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