Plugin Directory

Changeset 2503496


Ignore:
Timestamp:
03/25/2021 06:10:22 PM (5 years ago)
Author:
dsky
Message:

prevent too many api requests

Location:
site-search-360/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • site-search-360/trunk/class-sitesearch360-plugin.php

    r2482287 r2503496  
    394394    }
    395395
     396    private function checkRate() {
     397        $current = get_option('ss360_rate_checker', true);
     398        $minuteStamp = strval(floor(time() / 60));
     399        if ($current == NULL) {
     400            update_option('ss360_rate_checker', $minuteStamp . '<#>1');
     401            return true;
     402        } else {
     403            $parts = explode('<#>', $current);
     404            $minutePart = $parts[0];
     405            if ($minutePart != $minuteStamp) {
     406                update_option('ss360_rate_checker', $minuteStamp . '<#>1');
     407                return true;
     408            }
     409            $count = intval($parts[1]);
     410            if ($count > 300) {
     411                return false;
     412            }
     413            update_option('ss360_rate_checker', $minuteStamp . '<#>' . ($count + 1));
     414            return true;
     415        }               
     416    }
     417
    396418    /**
    397419     * Sends a request to the Site Search 360 API index a specific post in the server-side search engine.
     
    402424    {
    403425        try {
    404             $indexer = new SiteSearch360Indexer(1,0,'');
    405             $indexer->indexSingle($postId);
     426            if ($this->checkRate()) {
     427                $indexer = new SiteSearch360Indexer(1,0,'');
     428                $indexer->indexSingle($postId);
     429            }
    406430        } catch (Error $e) {
    407431            return;
     
    664688                    }
    665689                    ?>
    666                     <!-- Site Search 360 WP v<?php $ss360_v = defined('SITESEARCH360_VERSION') ? SITESEARCH360_VERSION : '1.1.23'; echo $ss360_v; ?> -->
     690                    <!-- Site Search 360 WP v<?php $ss360_v = defined('SITESEARCH360_VERSION') ? SITESEARCH360_VERSION : '1.1.24'; echo $ss360_v; ?> -->
    667691                    <script type="text/javascript">
    668692                        var ss360Config = <?php echo json_encode($configuration); ?>;
  • site-search-360/trunk/class-sitesearch360-tracker.php

    r2482287 r2503496  
    8383        }
    8484
    85         $data['version'] = defined('SITESEARCH360_VERSION') ? SITESEARCH360_VERSION : '1.1.23';
     85        $data['version'] = defined('SITESEARCH360_VERSION') ? SITESEARCH360_VERSION : '1.1.24';
    8686
    8787        $args = array(
  • site-search-360/trunk/readme.txt

    r2482287 r2503496  
    66Requires at least: 4.0.0
    77Tested up to: 5.5
    8 Stable tag: 1.1.23
     8Stable tag: 1.1.24
    99Requires PHP: 5.2.4
    1010License: GPLv2
     
    7878
    7979== Changelog ==
     80= 1.1.24 =
     81* Automatic re-indexing rate checking.
     82
    8083= 1.1.23 =
    8184* Major fix.
  • site-search-360/trunk/sitesearch360.php

    r2482287 r2503496  
    66Description: Site Search 360 enhances and improves your standard WordPress search with search suggests, autocompletion, semantic search, and a whole lot of customization. Also, you'll be amazed of how much faster you get relevant search results.
    77Author: SEMKNOX GmbH
    8 Version: 1.1.23
     8Version: 1.1.24
    99Author URI: https://sitesearch360.com
    1010Text Domain: site-search-360
     
    1212*/
    1313
    14 define( 'SITESEARCH360_VERSION', '1.1.23' );
     14define( 'SITESEARCH360_VERSION', '1.1.24' );
    1515
    1616require_once 'class-sitesearch360-widget.php';
Note: See TracChangeset for help on using the changeset viewer.