validate.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:6k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: validate.php,v $
- // | $Date: 2004/02/10 01:34:26 $
- // | $Revision: 1.25 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - FAQ article submissions validation.
- // +-------------------------------------------------------------+
- error_reporting(E_ALL ^ E_NOTICE);
- include "./../global.php";
- tech_nav('faq');
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "navigate";
- }
- include ('./faq_include.php');
- ############################### VALIDATE ARTICLES ###############################
- if ($_REQUEST['do'] == "validate") {
- // delete articles
- if (is_array($_REQUEST['do_delete'])) {
- foreach($_REQUEST['do_delete'] AS $key => $var) {
-
- if ($var) {
- if ($_REQUEST['do_email'][$key]) {
-
- $article = $db->query_return("
- SELECT faq_articles.*
- FROM faq_articles
- WHERE faq_articles.id = '$key'
- ");
- $user_details = $db->query_return("
- SELECT *
- FROM user
- WHERE id = '$article[userid]'
- ");
- $user_details = update_user_details($user_details);
- eval(makeemaileval('message', 'BODY_article_deleted', $subject));
- dp_mail($user_details['email'], $subject, $message);
-
- }
- $db->query("DELETE FROM faq_articles WHERE id = '$key'");
- $del++;
- }
- }
- }
- // validate articles
- if (is_array($_REQUEST['do_validated'])) {
- foreach($_REQUEST['do_validated'] AS $key => $var) {
- $checks = xss_check(
- array(
- $_REQUEST['do_question'][$key],
- $_REQUEST['do_title'][$key],
- $_REQUEST['do_answer'][$key],
- $_REQUEST['do_category'][$key]
- ), 'user');
- $db->query("
- UPDATE faq_articles SET
- to_validate = '0',
- question = '" . mysql_escape_string($checks[0]) . "',
- title = '" . mysql_escape_string($checks[1]) . "',
- answer = '" . mysql_escape_string($checks[2]) . "',
- category = '" . mysql_escape_string($checks[3]) . "'
- WHERE id = '$key'
- ");
-
- $result = $db->query_return("
- SELECT parentlist
- FROM faq_cats
- WHERE id = '$checks[4]'
- ");
- // update parents
- if ($result['parentlist']) {
- $db->query("UPDATE faq_cats SET
- totalarticles = (totalarticles + 1)
- newdate = '" . mktime() . "'
- WHERE id IN ($result[parentlist])
- ");
- }
- // update category
- $db->query("UPDATE faq_cats SET
- totalarticles = (totalarticles + 1),
- articles = (articles + 1),
- newdate = '" . mktime() . "'
- WHERE id = '$checks[3]'
- ");
-
- if ($_REQUEST[do_email][$key]) {
-
- $article = $db->query_return("
- SELECT faq_articles.*
- FROM faq_articles
- WHERE faq_articles.id = '$key'
- ");
- $user_details = $db->query_return("
- SELECT *
- FROM user
- WHERE id = '$article[userid]'
- ");
- $user_details = update_user_details($user_details);
- eval(makeemaileval('message', 'BODY_article_accepted', $subject));
- dp_mail($user_details['email'], $subject, $message);
- unset($message);
- }
- $val++;
- }
- }
-
- if ($val) {
- $message .= "$val articles validated";
- }
- if ($del) {
- if ($val) {
- $message .= '/n';
- }
- $message .= "$del articles deleted";
- }
- if ($message) {
- alert($message);
- }
- $_REQUEST['do'] = 'navigate';
- }
- ############################### LIST ELEMENTS ###############################
- if ($_REQUEST['do'] == 'navigate') {
- $catarray = faq_categoryjump();
- unset($catarray[0]);
- ############################### VALIDATE ARTICLES ###############################
- // select the articles
- $db->query("
- SELECT * FROM faq_articles
- WHERE to_validate
- ORDER BY show_order
- ");
-
- new_db_class(2);
- while ($article = $db->row_array()) {
-
- $table[] = array(
- htmlspecialchars($article[title]),
- form_select($article['id'], $catarray, 'do_category', $article['category']),
- form_checkbox_single($article['id'], '1', '', 'do_delete'),
- form_checkbox_single($article['id'], '1', $article['validated'], 'do_validated'),
- form_checkbox_single($article['id'], '1', 1, 'do_email')
- );
- $entry = "<table width="100%" cellpadding="0" cellspacing="0" class="table_midheader"><tr><td><table cellspacing="1" cellpadding="3" width="100%"><tr><td bgcolor="FFFFFF">";
- if ($article['userid']) {
- $userdata = $db2->query_return("SELECT * FROM user WHERE id = '$article[userid]'");
- $entry .= "From user '$userdata[username]' ($userdata[email])";
- } else {
- $entry .= "From an anonymous user.";
- }
- $entry .= "<BR><b>Title:</b><br />" .
- form_input($article['id'], $article['title'], '30', 'do_title') . "<br /><br /><b>Question:</b><br />" .
- form_textarea($article['id'], 100, 10, $article['question'], 'do_question') . "<br /><br /><b>Answer:</b><br />" .
- form_textarea($article['id'], 100, 10, $article['answer'], 'do_answer') . "</td></tr></table></td></tr></table>";
- $faq_entry[] = $entry;
- }
- $columns = array('Title', 'Category', 'Delete', 'Validate', 'Send Email');
- table_header('Articles Awaiting Validation', 'validate.php', array('do' => 'validate'));
- table_content($columns, $table, $extra, '', '', $faq_entry, '', '', 100);
- table_footer('Validate Articles');
- }
- tech_footer();
- ?>