Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ASDAFF/6406cb9f52a7538b2666ed24376dcbcc to your computer and use it in GitHub Desktop.
Save ASDAFF/6406cb9f52a7538b2666ed24376dcbcc to your computer and use it in GitHub Desktop.
Преобразование upd в модуль
<?php
//Полный путь к папке, в которой лежат "UPD" Последний слеш не нужен!
$dir = '/home/bitrix.dev/www/bitrix/your.upd.folder';
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if($entry == "." || $entry == ".."){continue;}
$string = file_get_contents($dir."/".$entry);
$matches = array();
if (preg_match_all("#(\d+)\s{2,}(\d+)\|([^\|]+)\|(\w{8})(.*?)#s", $string, $matches, PREG_SET_ORDER)){
foreach ($matches as $match){
//echo "\n{$match[3]}\n";
$file = "{$match[3]}";
//echo ($dir.dirname($file));
mkdir($dir.dirname($file), 0775, true);
$file = fopen($dir.$file, "w+b");
$code = substr($string, strpos($string, "|".$match[4])+9, $match[2]); //9 потому что CRC32 + папйп
fputs($file, $code);
fclose($file);
}
}
}
closedir($handle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment