Skip to content

Commit

Permalink
Issue techjoomla#62,techjoomla#122 and Joomla 4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinayak Patil committed Feb 22, 2023
1 parent 7042d40 commit 0c85b39
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
5 changes: 3 additions & 2 deletions code/admin/controllers/keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Factory;
use Joomla\Utilities\ArrayHelper;

/**
* Keys list controller class.
Expand Down Expand Up @@ -52,8 +53,8 @@ public function saveOrderAjax()
$order = $input->post->get('order', array(), 'array');

// Sanitize the input
JArrayHelper::toInteger($pks);
JArrayHelper::toInteger($order);
ArrayHelper::toInteger($pks);
ArrayHelper::toInteger($order);

// Get the model
$model = $this->getModel();
Expand Down
2 changes: 1 addition & 1 deletion code/admin/language/en-GB/en-GB.com_api.ini
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ COM_API_CONFIG_ALLOW_HEADER_DESC="Add comma separated values for Access-Control-
COM_API_FILTER_DESC="Searches in User name, hash, Request URL, POST Data. <br />uid:number searches logs for a particular user"
UNASSIGNED_HASH="No user for this API Key"

COM_API_CONFIG_IPS_DESC="Ristrict APIs to specific IP address"
COM_API_CONFIG_IPS_DESC="List of IPs for which to allow API access. Put an asterisk (*) to allow API access from all IPs. Alternately put a comma separated list of IPs Ex. 192.168.1.1, 192.168.1.10 or IP Range Ex. 192.168.1.1-192.168.1.10 or CIDR Block Ex. 192.168.1.1/24"
COM_API_CONFIG_IPS_LBL="IP Address/IP Range/CIDR Block"
COM_API_CONFIG_REQ_LT_LBL="Rate Frequency"
COM_API_CONFIG_REQ_LT_DESC="Request limit frequency"
Expand Down
3 changes: 2 additions & 1 deletion code/admin/tables/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\Factory;
use Joomla\Registry\Registry;
use Joomla\CMS\Access\Access;
use Joomla\Utilities\ArrayHelper;

/**
* Log Table class
Expand Down Expand Up @@ -138,7 +139,7 @@ public function store($updateNulls = false)
{
if (is_array($this->post_data))
{
$this->post_data = JArrayHelper::toString($this->post_data, '=', '&');
$this->post_data = ArrayHelper::toString($this->post_data, '=', '&');
}

return parent::store($updateNulls = false);
Expand Down
3 changes: 1 addition & 2 deletions code/site/libraries/authentication/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public function authenticate()
//$username = Factory::getApplication()->input->get( 'username' );
//$password = Factory::getApplication()->input->get( 'password' );

$user = $this->loadUserByCredentials( $username, $password );

$user = $this->loadUserByCredentials( $username, $password );
// Remove username and password from request for when it gets logged
$uri = Factory::getURI();
$uri->delVar('username');
Expand Down
16 changes: 5 additions & 11 deletions code/site/libraries/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,32 +377,26 @@ final private function checkRequestLimit()
return true;
}

$hash = $app->input->get('key', '', 'STRING');
$ip_address = $app->input->server->get('REMOTE_ADDR', '', 'STRING');

$hash = $app->input->get('key', '', 'STRING');
$time = $this->params->get('request_limit_time', 'hour');
$now = Factory::getDate();
switch ($time)
{
case 'day':
$offset = 60 * 60 * 24;
case 'day':
$now->modify('-1 day');
break;

case 'minute':
$offset = 60;
case 'minute':
$now->modify('-1 minute');
break;

case 'hour':
default:
$offset = 60 * 60;
default:
$now->modify('-1 hour');
break;
}

$query_time = $now->toSql();

$query_time = $now->toSql();
$db = Factory::getDBO();
$query = $db->getQuery(true);
$query->select('COUNT(*)');
Expand Down

0 comments on commit 0c85b39

Please sign in to comment.