%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 18.222.120.131 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/clouds/classes/general/ |
Upload File : |
<?php class CCloudFileHash { public static function getFileHashAgent($bucket_id, $step_size = 1000) { $bucket_id = intval($bucket_id); if ($bucket_id <= 0) { return ''; } $bucket = new CCloudStorageBucket($bucket_id); if (!$bucket->Init()) { return ''; } $last_key = \Bitrix\Clouds\FileHashTable::getLastKey($bucket_id); $step_size = intval($step_size); if ($step_size <= 0) { $step_size = 1000; } $files = $bucket->ListFiles('/', true, $step_size, $last_key); if ($files && $files["file"]) { \Bitrix\Clouds\FileHashTable::addList($bucket_id, $files); } if (!$files || count($files["file"]) < $step_size) { //We have done with the listing proceed to save hashes to b_file_hash table. return "CCloudFileHash::setFileHashAgent($bucket_id, 0, $step_size);"; } //Continue to read cloud hashes to the database. return "CCloudFileHash::getFileHashAgent($bucket_id, $step_size);"; } public static function setFileHashAgent($bucket_id, $last_file_id, $step_size = 1000) { global $DB; $bucket_id = intval($bucket_id); $last_file_id = intval($last_file_id); $step_size = intval($step_size); if ($step_size <= 0) { $step_size = 1000; } $rs = $DB->Query(" select f.ID, concat(f.SUBDIR, '/', f.FILE_NAME) FILE_PATH, f.FILE_SIZE from b_file f LEFT JOIN b_file_hash h on h.FILE_ID = f.ID where f.HANDLER_ID = $bucket_id and h.FILE_ID is null and f.ID > $last_file_id ORDER BY f.ID limit $step_size "); $files = array(); while ($ar = $rs->Fetch()) { $files[$ar["FILE_PATH"]] = $ar["ID"]; $last_file_id = $ar["ID"]; } if (!$files) { return ''; } $rs = \Bitrix\Clouds\FileHashTable::getList(array( "filter" => array( "=BUCKET_ID" => $bucket_id, "=FILE_PATH" => array_keys($files), ), )); $values = array(); while ($ar = $rs->fetch()) { if (isset($files[$ar["FILE_PATH"]])) { $file_id = intval($files[$ar["FILE_PATH"]]); $file_size = intval($ar["FILE_SIZE"]); $file_hash = $DB->ForSql($ar["FILE_HASH"]); $values[] = "($file_id,$file_size,'$file_hash')"; } } if ($values) { $DB->Query(" INSERT INTO b_file_hash (FILE_ID, FILE_SIZE, FILE_HASH) values ".implode(",\n", $values)." ON DUPLICATE KEY UPDATE FILE_SIZE=values(FILE_SIZE), FILE_HASH=values(FILE_HASH) "); } return "CCloudFileHash::setFileHashAgent($bucket_id, $last_file_id, $step_size);"; } }