|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
-
- <?php
-
- chdir(dirname(__FILE__));
- require_once 'common.php';
- require_once '../tests/path2class.func.php';
- require_once '../library/HTMLPurifier/Bootstrap.php';
- assertCli();
-
-
-
- chdir(dirname(__FILE__) . '/../library/');
- $FS = new FSTools();
-
- $exclude_dirs = array(
- 'HTMLPurifier/Language/',
- 'HTMLPurifier/ConfigSchema/',
- 'HTMLPurifier/Filter/',
- 'HTMLPurifier/Printer/',
-
-
- );
- $exclude_files = array(
- 'HTMLPurifier/Lexer/PEARSax3.php',
- 'HTMLPurifier/Lexer/PH5P.php',
- 'HTMLPurifier/Printer.php',
- );
-
-
- echo 'Scanning for files... ';
- $raw_files = $FS->globr('.', '*.php');
- if (!$raw_files) throw new Exception('Did not find any PHP source files');
- $files = array();
- foreach ($raw_files as $file) {
- $file = substr($file, 2);
- if (strncmp('standalone/', $file, 11) === 0) continue;
- if (substr_count($file, '.') > 1) continue;
- $ok = true;
- foreach ($exclude_dirs as $dir) {
- if (strncmp($dir, $file, strlen($dir)) === 0) {
- $ok = false;
- break;
- }
- }
- if (!$ok) continue;
- if (in_array($file, $exclude_files)) continue;
- $files[] = $file;
- }
- echo "done!\n";
-
-
-
-
- function get_dependency_lookup($file)
- {
- static $cache = array();
- if (isset($cache[$file])) return $cache[$file];
- if (!file_exists($file)) {
- echo "File doesn't exist: $file\n";
- return array();
- }
- $fh = fopen($file, 'r');
- $deps = array();
- while (!feof($fh)) {
- $line = fgets($fh);
- if (strncmp('class', $line, 5) === 0) {
-
-
- $arr = explode(' extends ', trim($line, ' {'."\n\r"), 2);
- if (count($arr) < 2) break;
- $parent = $arr[1];
- $dep_file = HTMLPurifier_Bootstrap::getPath($parent);
- if (!$dep_file) break;
- $deps[$dep_file] = true;
- break;
- }
- }
- fclose($fh);
- foreach (array_keys($deps) as $file) {
-
- $deps = get_dependency_lookup($file) + $deps;
- }
- $cache[$file] = $deps;
- return $deps;
- }
-
-
- function dep_sort($files)
- {
- $ret = array();
- $cache = array();
- foreach ($files as $file) {
- if (isset($cache[$file])) continue;
- $deps = get_dependency_lookup($file);
- foreach (array_keys($deps) as $dep) {
- if (!isset($cache[$dep])) {
- $ret[] = $dep;
- $cache[$dep] = true;
- }
- }
- $cache[$file] = true;
- $ret[] = $file;
- }
- return $ret;
- }
-
- $files = dep_sort($files);
-
-
-
- $version = trim(file_get_contents('../VERSION'));
-
-
- $php = "<?php
-
- /**
- * @file
- * This file was auto-generated by generate-includes.php and includes all of
- * the core files required by HTML Purifier. Use this if performance is a
- * primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS
- * FILE, changes will be overwritten the next time the script is run.
- *
- * @version $version
- *
- * @warning
- * You must *not* include any other HTML Purifier files before this file,
- * because 'require' not 'require_once' is used.
- *
- * @warning
- * This file requires that the include path contains the HTML Purifier
- * library directory; this is not auto-set.
- */
-
- ";
-
- foreach ($files as $file) {
- $php .= "require '$file';" . PHP_EOL;
- }
-
- echo "Writing HTMLPurifier.includes.php... ";
- file_put_contents('HTMLPurifier.includes.php', $php);
- echo "done!\n";
-
- $php = "<?php
-
- /**
- * @file
- * This file was auto-generated by generate-includes.php and includes all of
- * the core files required by HTML Purifier. This is a convenience stub that
- * includes all files using dirname(__FILE__) and require_once. PLEASE DO NOT
- * EDIT THIS FILE, changes will be overwritten the next time the script is run.
- *
- * Changes to include_path are not necessary.
- */
-
- \$__dir = dirname(__FILE__);
-
- ";
-
- foreach ($files as $file) {
- $php .= "require_once \$__dir . '/$file';" . PHP_EOL;
- }
-
- echo "Writing HTMLPurifier.safe-includes.php... ";
- file_put_contents('HTMLPurifier.safe-includes.php', $php);
- echo "done!\n";
-
-
|