Make WordPress Core


Ignore:
Timestamp:
10/03/2003 10:31:47 PM (22 years ago)
Author:
saxmatt
Message:

Some general comment code cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2comments.post.php

    r357 r407  
    2222}
    2323
    24 $author = trim($HTTP_POST_VARS['author']);
    25 $email = trim($HTTP_POST_VARS['email']);
    26 $url = trim($HTTP_POST_VARS['url']);
     24$author = trim(strip_tags($HTTP_POST_VARS['author']));
     25
     26$email = trim(strip_tags($HTTP_POST_VARS['email']));
     27if (strlen($email) < 6)
     28    $email = '';
     29
     30$url = trim(strip_tags($HTTP_POST_VARS['url']));
     31$url = ((!stristr($url, '://')) && ($url != '')) ? 'http://'.$url : $url;
     32if (strlen($url) < 7)
     33    $url = '';
     34
    2735$comment = trim($HTTP_POST_VARS['comment']);
    2836$original_comment = $comment;
    29 $comment_autobr = $HTTP_POST_VARS['comment_autobr'];
    30 $comment_post_ID = $HTTP_POST_VARS['comment_post_ID'];
     37$comment_post_ID = intval($HTTP_POST_VARS['comment_post_ID']);
     38$user_ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
     39$user_domain = gethostbyaddr($user_ip);
    3140
    3241$commentstatus = $wpdb->get_var("SELECT comment_status FROM $tableposts WHERE ID = $comment_post_ID");
     
    4453}
    4554
    46 $user_ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
    47 $user_domain = gethostbyaddr($user_ip);
    4855$time_difference = get_settings('time_difference');
    4956$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
    5057
    51 $author = trim(strip_tags($author));
    52 $email = trim(strip_tags($email));
    53 if (strlen($email) < 6)
    54     $email = '';
    55 
    56 $url = trim(strip_tags($url));
    57 $url = ((!stristr($url, '://')) && ($url != '')) ? 'http://'.$url : $url;
    58 if (strlen($url) < 7)
    59     $url = '';
    60 
    61 $comment = trim(strip_tags($comment, $comment_allowed_tags));
     58$comment = strip_tags($comment, $comment_allowed_tags);
    6259$comment = balanceTags($comment, 1);
    6360$comment = convert_chars($comment);
     
    7471/* flood-protection */
    7572$lasttime = $wpdb->get_var("SELECT comment_date FROM $tablecomments WHERE comment_author_IP = '$user_ip' ORDER BY comment_date DESC LIMIT 1");
    76 $ok = 1;
     73$ok = true;
    7774if (!empty($lasttime)) {
    7875    $time_lastcomment= mysql2date('U', $lasttime);
    7976    $time_newcomment= mysql2date('U', "$now");
    8077    if (($time_newcomment - $time_lastcomment) < 10)
    81         $ok = 0;
     78        $ok = false;
    8279}
    8380/* end flood-protection */
     
    8784if ($ok) { // if there was no comment from this IP in the last 10 seconds
    8885
    89     $wpdb->query("INSERT INTO $tablecomments VALUES ('0','$comment_post_ID','$author','$email','$url','$user_ip','$now','$comment','0')");
     86    $wpdb->query("INSERT INTO $tablecomments VALUES ('0', '$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$comment', '0')");
    9087
    9188    if ($comments_notify) {
Note: See TracChangeset for help on using the changeset viewer.