/
al.anatolyev
/
web4stud
Обзор
Документация
Войти
/
al.anatolyev
/
web4stud
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
tools/highlightcode.php
39 строк
1 KB
aag
%1
19 май 2026, 12:36
19 май 2026, 12:36
1775bad
Код
Авторство
О чём код?
<?php if (empty($_GET)) { echo " <pre>USAGE: highlightcode.php?dir=relative/path/to/files/ highlightcode.php?file=(relative/path/to/file/filename.ext | URL) </pre>"; exit; }; if (isset($_GET["file"])) { echo "<p class=\"listing\">Листинг _._. Файл ".basename($_GET["file"]).": </p>\n"."<pre><code>".htmlspecialchars(file_get_contents($_GET["file"]), ENT_QUOTES)."</code></pre>\n\n"; exit; } // by GEMINI function glob_recursive($pattern, $flags = 0) { $files = glob($pattern, $flags); // Iterate over all directories in the current path foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { // Recursively call the function for the new directory and merge the results $files = array_merge($files, glob_recursive($dir . '/' . basename($pattern), $flags)); } return $files; } // get list of files $files = glob_recursive("$_GET[dir]/*"); $o = ""; $i = 1; foreach ($files as $f) { if (is_file($f)) { $o .= "<p>Листинг _.$i. Файл ".basename($f).": </p>\n"."<pre><code>".htmlspecialchars(file_get_contents($f), ENT_QUOTES)."</code></pre>\n\n"; $i++; } }; echo $o;