Ignore:
Timestamp:
Jun 24, 2012, 3:24:55 AM (8 years ago)
Author:
mistic100
Message:

bug 2660: check guest IP on insert_user_comment (same system as rate_picture)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_comment.inc.php

    r13800 r15983  
    127127    $_POST['cr'][] = 'key'; // rvelices: I use this outside to see how spam robots work
    128128  }
     129 
     130  // anonymous id = ip address
     131  $ip_components = explode('.', $comm['ip']);
     132  if (count($ip_components) > 3)
     133  {
     134    array_pop($ip_components);
     135  }
     136  $comm['anonymous_id'] = implode('.', $ip_components);
    129137
    130138  if ($comment_action!='reject' and $conf['anti-flood_time']>0 and !is_admin())
     
    136144  WHERE date > '.$reference_date.'
    137145    AND author_id = '.$comm['author_id'];
     146    if (!is_classic_user())
     147    {
     148      $query.= '
     149      AND anonymous_id = "'.$comm['anonymous_id'].'"';
     150    }
     151    $query.= '
     152;';
     153
    138154    list($counter) = pwg_db_fetch_row(pwg_query($query));
    139155    if ( $counter > 0 )
     
    153169    $query = '
    154170INSERT INTO '.COMMENTS_TABLE.'
    155   (author, author_id, content, date, validated, validation_date, image_id)
     171  (author, author_id, anonymous_id, content, date, validated, validation_date, image_id)
    156172  VALUES (
    157173    \''.$comm['author'].'\',
    158174    '.$comm['author_id'].',
     175    \''.$comm['anonymous_id'].'\',
    159176    \''.$comm['content'].'\',
    160177    NOW(),
Note: See TracChangeset for help on using the changeset viewer.