Mercurial > ec-dotfiles
view bin/ed2k @ 746:6b7f6f09b8d1 default tip
[vimrc] fix php syntax highlight
Example file: https://github.com/ppy/osu-web/blob/e23658f45ac2e85d78bd339947e0d1cee57629c6/app/Libraries/BBCodeFromDB.php
(around the end)
| author | nanaya <me@nanaya.net> |
|---|---|
| date | Wed, 29 Oct 2025 12:28:45 +0900 |
| parents | 8d3ad5ae1ce4 |
| children |
line wrap: on
line source
#!/usr/bin/env php <?php function ed2k_hash(string $path): string { // ed2k hash is an md4 hash of concatenated binary md4 hashes of 9500 KiB file chunks. static $bs = 9500 * 1024; $hash = ''; $fp = fopen($path, 'rb'); while (!feof($fp)) { $hash .= hash('md4', fread($fp, $bs), true); } fclose($fp); return hash('md4', $hash); } function main(): void { $files = $_SERVER['argv']; array_shift($files); foreach ($files as $path) { $hash = ed2k_hash($path); $filename = basename($path); $filesize = filesize($path); echo "ed2k://|file|{$filename}|{$filesize}|{$hash}|", PHP_EOL; } } main();
