Changeset 6605


Ignore:
Timestamp:
06/25/10 21:45:19 (10 years ago)
Author:
nikrou
Message:

Bug 1744 fixed : Incorrect use of timezone with SQLite
Fixed anti-flood system.

Merge from trunk

Location:
branches/2.1
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2.1/admin/intro.php

    r6364 r6605  
    127127$php_current_timestamp = date("Y-m-d H:i:s"); 
    128128$db_version = pwg_get_db_version(); 
    129 list($db_current_timestamp) = pwg_db_fetch_row(pwg_query('SELECT CURRENT_TIMESTAMP;')); 
     129list($db_current_date) = pwg_db_fetch_row(pwg_query('SELECT now();')); 
    130130 
    131131$query = ' 
     
    216216    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo', 
    217217    'PHP_DATATIME' => $php_current_timestamp, 
    218     'DB_DATATIME' => $db_current_timestamp, 
     218    'DB_DATATIME' => $db_current_date, 
    219219    ) 
    220220  ); 
  • branches/2.1/include/dblayer/functions_mysql.inc.php

    r6579 r6605  
    561561 */ 
    562562 
    563  
    564563function pwg_db_get_recent_period_expression($period, $date='CURRENT_DATE') 
    565564{ 
     
    581580} 
    582581 
     582function pwg_db_get_flood_period_expression($seconds) 
     583{ 
     584  return 'SUBDATE(now(), INTERVAL '.$seconds.' SECOND)'; 
     585} 
     586 
    583587function pwg_db_get_hour($date)  
    584588{ 
  • branches/2.1/include/dblayer/functions_pdo-sqlite.inc.php

    r6581 r6605  
    500500} 
    501501 
     502function pwg_db_get_flood_period_expression($seconds) 
     503{ 
     504  return 'datetime(\'now\', \'localtime\', \''.-$seconds.' seconds\')'; 
     505} 
     506 
    502507function pwg_db_get_hour($date) 
    503508{ 
  • branches/2.1/include/dblayer/functions_pgsql.inc.php

    r6592 r6605  
    547547} 
    548548 
     549function pwg_db_get_flood_period_expression($seconds) 
     550{ 
     551  return 'now() - \''.$seconds.' SECOND\'::interval'; 
     552} 
     553 
    549554function pwg_db_get_hour($date) 
    550555{ 
  • branches/2.1/include/dblayer/functions_sqlite.inc.php

    r6581 r6605  
    512512} 
    513513 
     514function pwg_db_get_flood_period_expression($seconds) 
     515{ 
     516  return 'datetime(\'now\', \'localtime\', \''.-$seconds.' seconds\')'; 
     517} 
     518 
    514519function pwg_db_get_hour($date) 
    515520{ 
  • branches/2.1/include/functions_comment.inc.php

    r6602 r6605  
    134134  if ($comment_action!='reject' and $conf['anti-flood_time']>0 ) 
    135135  { // anti-flood system 
    136     $reference_date = date('c', time() - $conf['anti-flood_time']); 
     136    $reference_date = pwg_db_get_flood_period_expression($conf['anti-flood_time']); 
     137 
    137138    $query = ' 
    138 SELECT id FROM '.COMMENTS_TABLE.' 
    139   WHERE date > \''.$reference_date.'\' 
     139SELECT count(1) FROM '.COMMENTS_TABLE.' 
     140  WHERE date > '.$reference_date.' 
    140141    AND author_id = '.$comm['author_id']; 
    141     if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 ) 
     142    list($counter) = pwg_db_fetch_row(pwg_query($query)); 
     143    if ( $counter > 0 ) 
    142144    { 
    143145      array_push( $infos, l10n('Anti-flood system : please wait for a moment before trying to post another comment') ); 
Note: See TracChangeset for help on using the changeset viewer.