Setting user limits in WHMCS
You can limit operations rate with the ostor-limits
service and the following parameters: emailAddress
specifying the email address, default=
, get=
, put=
, list=
, or delete=
specifying the limit value.
Similarly, you can limit outgoing bandwidth of a response with the following parameters: emailAddress
specifying the email address, out=
specifying the limit value. WHMCS configures user limits in an S3 cluster when you click the Set button. Create a file S3_setLimitsForUser.php with the following contents:
<?php // Load configuration and libraries. require('../../includes/staas_scripts/S3_getClient.php'); require('../../includes/staas_scripts/S3_getConfig.php'); require('../../includes/staas_scripts/S3_requestCurl.php'); require('../../init.php'); // Set s3 user limits. function S3_setLimitsForUser($vars) { // Load configuration. $s3_config = s3_getConfig(); // Get whmcs user email. $s3_whmcs = S3_getClient($vars['userid'], $s3_config['whmcs_username']); // Set only if value specified. if (!empty($vars['ops-value'])) { // Set s3 bucket limits (ops). S3_requestCurl( $s3_config['s3_key'], $s3_config['s3_secret'], $s3_config['s3_gateway'], "/?ostor-limits&emailAddress=" . $s3_whmcs['email'] . "&limit-type=ops&limit-resource=" . $vars['ops-name'] . '&limit-value=' . $vars['ops-value'], "PUT" ); } // Set only if value specified. if (!empty($vars['bandwidth-value'])) { // Set s3 bucket limits (bandwidth). S3_requestCurl( $s3_config['s3_key'], $s3_config['s3_secret'], $s3_config['s3_gateway'], "/?ostor-limits&emailAddress=" . $s3_whmcs['email'] . "&limit-type=bandwidth&limit-resource=" . $vars['bandwidth-name'] . '&limit-value=' . $vars['bandwidth-value'], "PUT" ); } // Redirect back. header('Location: ' . $_SERVER['HTTP_REFERER']); } // Call function. S3_setLimitsForUser($_GET); ?>