Changeset 1576

Show
Ignore:
Timestamp:
03/29/08 13:09:18 (5 months ago)
Author:
Neal
Message:

Added code to actually enforce the long implemented search flood group setting.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/punbb-1.3-dev/extras/db_update.php

    r1575 r1576  
    768768                $db->add_field($db->prefix.'users', 'date_format', 'INT(10)', false, 0, 'dst'); 
    769769 
     770                // Add the last_search column to the users table 
     771                $db->add_field($db->prefix.'users', 'last_search', 'INT(10)', true, null, 'last_post'); 
     772 
    770773                // Add the last_email_sent column to the users table and the g_send_email and 
    771774                // g_email_flood columns to the groups table 
    772                 $db->add_field($db->prefix.'users', 'last_email_sent', 'INT(10)', true, null, 'last_post'); 
     775                $db->add_field($db->prefix.'users', 'last_email_sent', 'INT(10)', true, null, 'last_search'); 
    773776                $db->add_field($db->prefix.'groups', 'g_send_email', 'TINYINT(1)', false, 1, 'g_search_users'); 
    774777                $db->add_field($db->prefix.'groups', 'g_email_flood', 'INT(10)', false, 60, 'g_search_flood'); 
  • branches/punbb-1.3-dev/upload/install.php

    r1575 r1576  
    12651265                                        num_posts INT(10) UNSIGNED NOT NULL DEFAULT 0, 
    12661266                                        last_post INT(10) UNSIGNED, 
     1267                                        last_search INT(10) UNSIGNED, 
    12671268                                        last_email_sent INT(10) UNSIGNED, 
    12681269                                        registered INT(10) UNSIGNED NOT NULL DEFAULT 0, 
     
    13141315                                        num_posts INT NOT NULL DEFAULT 0, 
    13151316                                        last_post INT, 
     1317                                        last_search INT 
    13161318                                        last_email_sent INT, 
    13171319                                        registered INT NOT NULL DEFAULT 0, 
     
    13631365                                        num_posts INTEGER NOT NULL DEFAULT 0, 
    13641366                                        last_post INTEGER, 
     1367                                        last_search INTEGER, 
    13651368                                        last_email_sent INTEGER, 
    13661369                                        registered INTEGER NOT NULL DEFAULT 0, 
  • branches/punbb-1.3-dev/upload/lang/English/search.php

    r1241 r1576  
    77'No search permission'          =>      'You do not have permission to use the search feature.', 
    88'Search heading'                        =>      'Search forums using your own criteria or predefined searches', 
     9'Search flood'                          =>      'At least %s seconds have to pass between searches. Please wait a while and try searching again.', 
    910'Predefined searches'           =>      'Predefined searches', 
    1011'Using criteria'                        =>      'Using your own criteria', 
  • branches/punbb-1.3-dev/upload/search.php

    r1569 r1576  
    9595                        message($lang_common['Bad request']); 
    9696        } 
     97 
     98        // Flood protection 
     99        if (!$pun_user['is_guest'] && $pun_user['last_search'] != '' && (time() - $pun_user['last_search']) < $pun_user['g_search_flood'] && (time() - $pun_user['last_search']) >= 0) 
     100                message(sprintf($lang_search['Search flood'], $pun_user['g_search_flood'])); 
    97101 
    98102        // First of all lets find out if we need to cache the results, we only need to do this for detailed queries, not quicksearches or for mysql(i) 
     
    697701        else 
    698702                $result = $db->query($query) or error(__FILE__, __LINE__); 
     703 
     704        if (!$pun_user['is_guest']) 
     705        { 
     706                // Set the user's last_search time 
     707                $query = array( 
     708                        'UPDATE'        => 'users', 
     709                        'SET'           => 'last_search='.time(), 
     710                        'WHERE'         => 'id='.$pun_user['id'], 
     711                        'PARAMS'        => array( 
     712                                'LOW_PRIORITY'  => 1    // MySQL only 
     713                        ) 
     714                ); 
     715 
     716                ($hook = get_hook('se_qr_update_last_search_time')) ? eval($hook) : null; 
     717                $db->query_build($query) or error(__FILE__, __LINE__); 
     718        } 
    699719 
    700720        // Make sure we actually have some results