diff options
Diffstat (limited to 'Neutron-trunk/replace.php')
-rw-r--r-- | Neutron-trunk/replace.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Neutron-trunk/replace.php b/Neutron-trunk/replace.php new file mode 100644 index 0000000..2908207 --- /dev/null +++ b/Neutron-trunk/replace.php @@ -0,0 +1,35 @@ +<?php + +$cwd = getcwd(); +$found = 0; +$size = 0; + +function crawl(string $dir) { + global $found; + global $size; + echo("(DIR) " . $dir . "\n"); + $files = scandir($dir); + foreach ($files as $file) { + if (is_dir($dir . "/" . $file)) { + if ($file == "." || $file == "..") {} else { + crawl($dir . "/" . $file); + } + } else { + if (is_link($dir . "/" . $file)) {} else { + echo("(DOC) " . $dir . "/" . $file . "\n"); + file_put_contents($dir . "/" . $file, str_replace('<?php echo("<!--\n\n" . file_get_contents($_SERVER[\'DOCUMENT_ROOT\'] . "/resources/private/license") . "\n\n-->") ?>', '<?php ob_start();echo("<!--\n\n" . file_get_contents($_SERVER[\'DOCUMENT_ROOT\'] . "/resources/private/license") . "\n\n-->") ?>', file_get_contents($dir . "/" . $file))); + $size = $size + filesize($dir . "/" . $file); + $found = $found + count(file($dir . "/" . $file)); + } + } + } + return $found; +} + +if (PHP_SAPI === 'cli') +{ + echo("Couting lines..."); + crawl($cwd); + echo("\nDONE!\n\nTotal code is " . $found . " lines long."); + echo("({$size} bytes)"); +} |