Forked from anonymous/gist:e54c8a2951d6e8c03f25db60646061de
Created
November 30, 2017 21:32
-
-
Save ASDAFF/6406cb9f52a7538b2666ed24376dcbcc to your computer and use it in GitHub Desktop.
Преобразование 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