Changeset 1184 in ExiteCMS for trunk/includes/comments_include.php


Ignore:
Timestamp:
12/31/07 13:01:02 (4 years ago)
Author:
hverton
Message:

Added a captcha validation check to comment posts of guests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/comments_include.php

    r1071 r1184  
    2525 
    2626    $variables = array(); 
    27      
     27 
    2828    if ((iMEMBER || $settings['guestposts'] == "1") && isset($_POST['post_comment'])) { 
     29 
     30        $result = dbquery("DELETE FROM ".$db_prefix."captcha WHERE captcha_datestamp<'".(time()-900)."'"); 
     31 
    2932        $flood = false; 
    3033        if (dbrows(dbquery("SELECT $ccol FROM ".$db_prefix."$cdb WHERE $ccol='$comment_id'"))==0) { 
     
    3841            if (isNum($comment_name)) $comment_name=""; 
    3942        } 
     43         
     44        // captcha check for guest posts 
     45        $cic = (iGUEST && !check_captcha($_POST['captcha_encode'], $_POST['captcha_code'])) ? "&cic=1" : ""; 
     46 
    4047        $comment_message = trim(stripinput(censorwords($_POST['comment_message']))); 
    4148        $comment_smileys = isset($_POST['disable_smileys']) ? "0" : "1"; 
    42         if ($comment_name != "" && $comment_message != "") { 
     49        if ($comment_name != "" && $comment_message != "" && $cic == "") { 
    4350            $result = dbquery("SELECT MAX(comment_datestamp) AS last_comment FROM ".$db_prefix."comments WHERE comment_ip='".USER_IP."'"); 
    4451            if (!iSUPERADMIN || dbrows($result) > 0) { 
     
    5461            if (!$flood) $result = dbquery("INSERT INTO ".$db_prefix."comments (comment_item_id, comment_type, comment_name, comment_message, comment_smileys, comment_datestamp, comment_ip) VALUES ('$comment_id', '$comment_type', '$comment_name', '$comment_message', '$comment_smileys', '".time()."', '".USER_IP."')"); 
    5562        } 
    56         redirect($clink); 
     63        if ($cic != "") redirect($clink.$cic); 
    5764    } 
    5865 
     
    7784    $variables['comment_id'] = $comment_id; 
    7885    $variables['post_link'] = $clink; 
     86    $variables['cic'] = (isset($_GET['cic']) && !empty($_GET['cic'])) ? $_GET['cic'] : ""; 
    7987 
    8088    // define the body panel variables 
Note: See TracChangeset for help on using the changeset viewer.