diff --git a/Globye.php b/Globye.php index bb16017..cb6ad0d 100644 --- a/Globye.php +++ b/Globye.php @@ -5,6 +5,8 @@ * @package tools * @copyright 2013 René-Gilles Deberdt, wedge.org * @license MIT + * + * Modifications 2015 by Feline, portamx.com */ /* @@ -13,9 +15,32 @@ - Remove quotes from tests, so we don't find false positives in commented-out code. */ +/* + Modifications by Feline + - if no additional option is given, only the help screen is shown. + - added option ?scan to scan all files in the current folder and his subfolder. + - added option ?file=filename to scan only the given file. + - added option ?path=path_to_scan to scan all files in the given folder and his subfolder. + - added option ?fixme to allow the script to fix all found problems exept false-positives. + In this case a backup (filename.php.timestamp) is created if any changed. + - added option ?nobackup .. uhm .. I think, you don't use this until you love high risk *g* + - added a function to stripout inline Javascript functions +*/ + $script_name = basename(__FILE__); -$root = dirname(__FILE__); +$root = $dir = $_SERVER['DOCUMENT_ROOT']; +if (isset($_GET['path'])) +{ + if (substr($_GET['path'], 0, 1) == '/') + $dir = $root . substr($_GET['path'], 1); + else + $dir = $_GET['path']; +} +$dir = $basedir = str_replace('\\', '/', $dir); +$file = (isset($_GET['file']) ? $_GET['file'] : ''); $problems = 0; +$fixes = 0; + @ini_set('xdebug.max_nesting_level', 300); if (function_exists('set_time_limit') && is_callable('set_time_limit')) // Can't be too careful with this one... @set_time_limit(300); @@ -42,6 +67,14 @@ '$scripturl', '$board_info', '$action_list', + '$language', // for SMF (forks or mainline) + '$sourcedir', // for SMF (forks or mainline) + '$themedir', // for SMF (forks or mainline) + '$themeurl', // for SMF (forks or mainline) + '$user_info', // for SMF (forks or mainline) + '$smcFunc', // for SMF (forks or mainline) + '$cachedir', // for SMF (forks or mainline) + '$maintenance', // for SMF (forks or mainline) ); echo ' @@ -55,49 +88,79 @@ .new { margin-top: 8px; } em { color: #c30; } li { padding: 3px 0 3px 8px; } - - .duplicates { background: linear-gradient(to right, #fcc, #fff 30px); } - .undeclared { background: linear-gradient(to right, #ccf, #fff 30px); } - .unused { background: linear-gradient(to right, #bea, #fff 30px); } + kbd { font-size: 17px; font-weight: bold; } + samp { font-size: 17px; font-weight: bold; } + h1 { font-size: 18px; font-weight: bold; } + .duplicates { background: linear-gradient(to right, #fcc, #fff 80px); } + .undeclared { background: linear-gradient(to right, #ccf, #fff 90px); } + .unused { background: linear-gradient(to right, #bea, #fff 65px); }
This script will list all PHP files in the ', $root, ' folder that have duplicate, unneeded global declarations or undeclared globals. +
-
- Add ?noclean to view a quick, dirty list of results that may generate more false positives.
-
- Add ?ignorefp to list only strong suspects; potential false positives will be ignored.
+ Add ?path=/relative or ?path=absolute to scan only the given path and his subfolder.
+ (Base path for relative: ' . $_SERVER['DOCUMENT_ROOT'] . ').
+ Add ?file=your_phpfile.php to allow the script to scan only the given file.
+ Add ?noclean to view a quick, dirty list of results that may generate more false positives.
+ (Ignored, if the fixme option is used).
+ Add ?ignorefp to list only strong suspects; potential false positives will be ignored.
+ Add ?fixme to allow the script to fix all files, except for potential false-positives. A backup (*.php.timestamp) is created if a file is modified.
+ Add ?nobackup if you don\'t make a backup if any changed during "fixme". Use this at your own risk !!!
+ If you use more then one option, use the ampersand (&) for the additional option, like path=/Sources&file=Subs.php
+ If you don\'t use any option, add ?scan to allow the script to scan all files in the current folder and all subfolder.