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/ilovecveti.ru/bitrix/modules/socialservices/lib/encryptedtoken/ |
Upload File : |
<?php namespace Bitrix\Socialservices\EncryptedToken; use Bitrix\Main\Application; use Bitrix\Main\Config\Option; use Bitrix\Main\Entity\ReferenceField; use Bitrix\Socialservices\EncryptedToken\UserTable as EncryptedTokenUserTable; use Bitrix\Socialservices\UserTable; class Agent { public static function init() { Option::set("socialservices", "allow_encrypted_tokens", true); $interval = IsModuleInstalled('bitrix24') ? 600 : 0; \CAgent::AddAgent( __CLASS__.'::runAgent();', "socialservices", "N", 60, "", "Y", ConvertTimeStamp((time() + \CTimeZone::GetOffset() + $interval), 'FULL') ); } public static function runAgent() { if (self::run()) { return __CLASS__.'::runAgent();'; } UserTable::enableCrypto('OATOKEN'); UserTable::enableCrypto('OASECRET'); UserTable::enableCrypto('REFRESH_TOKEN'); return ''; } public static function run() { $limit = Option::get("socialservices", "encrypt_tokens_step_limit", 500); $lastEncryptedUserId = Option::get("socialservices", "last_encrypted_user_id", 0); $users = UserTable::getList([ 'order' => ['ID' => 'ASC'], 'select' => [ 'ID', 'OATOKEN', 'OASECRET', 'REFRESH_TOKEN' ], 'filter' => ['>ID' => $lastEncryptedUserId], 'limit' => $limit ]); $found = 0; while ($user = $users->fetch()) { $found++; UserTable::update($user['ID'], [ 'OATOKEN' => $user['OATOKEN'], 'OASECRET' => $user['OASECRET'], 'REFRESH_TOKEN' => $user['REFRESH_TOKEN'], ]); $lastEncryptedUserId = $user['ID']; } Option::set("socialservices", "last_encrypted_user_id", $lastEncryptedUserId); return ($found >= $limit); } }