Created
August 25, 2017 19:09
Преобразование upd в модуль
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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