/** Рекурсивное копирование из $path_from в $path_to **/ public static function __CopyDirFiles($path_from, $path_to, &$strError, $bSkipUpdater = True) { $strError_tmp = ""; while (strlen($path_from) > 1 && $path_from[strlen($path_from) - 1] == "/") { $path_from = substr($path_from, 0, strlen($path_from) - 1); } while (strlen($path_to) > 1 && $path_to[strlen($path_to) - 1] == "/") { $path_to = substr($path_to, 0, strlen($path_to) - 1); } if (strpos($path_to . "/", $path_from . "/") === 0) { $strError_tmp .= "[UCDF01] " . GetMessage("SUPP_CDF_SELF_COPY") . ". "; } if (strlen($strError_tmp) <= 0) { if (!file_exists($path_from)) { $strError_tmp .= "[UCDF02] " . str_replace("#FILE#", $path_from, GetMessage("SUPP_CDF_NO_PATH")) . ". "; } } if (strlen($strError_tmp) <= 0) { $strongUpdateCheck = COption::GetOptionString("main", "strong_update_check", "Y"); if (is_dir($path_from)) { CUpdateClientPartner::__CheckDirPath($path_to . "/"); if (!file_exists($path_to) || !is_dir($path_to)) { $strError_tmp .= "[UCDF03] " . str_replace("#FILE#", $path_to, GetMessage("SUPP_CDF_CANT_CREATE")) . ". "; } elseif (!is_writable($path_to)) { $strError_tmp .= "[UCDF04] " . str_replace("#FILE#", $path_to, GetMessage("SUPP_CDF_CANT_WRITE")) . ". "; } if (strlen($strError_tmp) <= 0) { if ($handle = @opendir($path_from)) { while (($file = readdir($handle)) !== false) { if ($file == "." || $file == "..") { continue; } if ($bSkipUpdater && substr($file, 0, strlen("updater")) == "updater") { continue; } if (is_dir($path_from . "/" . $file)) { CUpdateClientPartner::__CopyDirFiles($path_from . "/" . $file, $path_to . "/" . $file, $strError_tmp); } elseif (is_file($path_from . "/" . $file)) { if (file_exists($path_to . "/" . $file) && !is_writable($path_to . "/" . $file)) { $strError_tmp .= "[UCDF05] " . str_replace("#FILE#", $path_to . "/" . $file, GetMessage("SUPP_CDF_CANT_FILE")) . ". "; } else { if ($strongUpdateCheck == "Y") { $crc32_old = dechex(crc32(file_get_contents($path_from . "/" . $file))); } @copy($path_from . "/" . $file, $path_to . "/" . $file); @chmod($path_to . "/" . $file, BX_FILE_PERMISSIONS); if ($strongUpdateCheck == "Y") { $crc32_new = dechex(crc32(file_get_contents($path_to . "/" . $file))); if ($crc32_new != $crc32_old) { $strError_tmp .= "[UCDF061] " . str_replace("#FILE#", $path_to . "/" . $file, GetMessage("SUPP_UGA_FILE_CRUSH")) . ". "; } } } } } @closedir($handle); } } } else { $p = CUpdateClientPartner::__bxstrrpos($path_to, "/"); $path_to_dir = substr($path_to, 0, $p); CUpdateClientPartner::__CheckDirPath($path_to_dir . "/"); if (!file_exists($path_to_dir) || !is_dir($path_to_dir)) { $strError_tmp .= "[UCDF06] " . str_replace("#FILE#", $path_to_dir, GetMessage("SUPP_CDF_CANT_FOLDER")) . ". "; } elseif (!is_writable($path_to_dir)) { $strError_tmp .= "[UCDF07] " . str_replace("#FILE#", $path_to_dir, GetMessage("SUPP_CDF_CANT_FOLDER_WR")) . ". "; } if (strlen($strError_tmp) <= 0) { if ($strongUpdateCheck == "Y") { $crc32_old = dechex(crc32(file_get_contents($path_from))); } @copy($path_from, $path_to); @chmod($path_to, BX_FILE_PERMISSIONS); if ($strongUpdateCheck == "Y") { $crc32_new = dechex(crc32(file_get_contents($path_to))); if ($crc32_new != $crc32_old) { $strError_tmp .= "[UCDF0611] " . str_replace("#FILE#", $path_to, GetMessage("SUPP_UGA_FILE_CRUSH")) . ". "; } } } } } if (strlen($strError_tmp) > 0) { CUpdateClientPartner::AddMessage2Log($strError_tmp, "CUCDF"); $strError .= $strError_tmp; return False; } else { return True; } }