1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-06 15:45:34 +02:00

[ticket/11924] Do not use globals :(

PHPBB3-11924
This commit is contained in:
Joas Schilling 2013-10-26 18:03:46 +02:00
parent 91eeebfb07
commit 35dff79cd8

View File

@ -24,9 +24,8 @@ function usage()
exit(2); exit(2);
} }
function export_from_eventsmd($filter) function export_from_eventsmd($phpbb_root_path, $filter)
{ {
global $phpbb_root_path;
$file_content = file_get_contents($phpbb_root_path . 'docs/events.md'); $file_content = file_get_contents($phpbb_root_path . 'docs/events.md');
$events = explode("\n\n", $file_content); $events = explode("\n\n", $file_content);
@ -73,15 +72,13 @@ function export_from_eventsmd($filter)
} }
} }
function export_from_php() function export_from_php($phpbb_root_path)
{ {
global $phpbb_root_path;
$files = get_file_list($phpbb_root_path); $files = get_file_list($phpbb_root_path);
$events = array(); $events = array();
foreach ($files as $file) foreach ($files as $file)
{ {
$file_events = check_for_events($file); $file_events = check_for_events($phpbb_root_path, $file);
if (!empty($file_events)) if (!empty($file_events))
{ {
$events = array_merge($events, $file_events); $events = array_merge($events, $file_events);
@ -97,10 +94,8 @@ function export_from_php()
} }
} }
function check_for_events($file) function check_for_events($phpbb_root_path, $file)
{ {
global $phpbb_root_path;
$events = array(); $events = array();
$content = file_get_contents($phpbb_root_path . $file); $content = file_get_contents($phpbb_root_path . $file);
@ -276,32 +271,30 @@ function get_file_list($dir, $path = '')
return $files; return $files;
} }
function validate_argument_count($count) function validate_argument_count($arguments, $count)
{ {
global $argv; if ($arguments <= $count)
if (count($argv) <= $count)
{ {
usage(); usage();
} }
} }
validate_argument_count(1); validate_argument_count($argc, 1);
$action = $argv[1]; $action = $argv[1];
switch ($action) switch ($action)
{ {
case 'acp': case 'acp':
export_from_eventsmd('acp'); export_from_eventsmd($phpbb_root_path, 'acp');
break; break;
case 'styles': case 'styles':
export_from_eventsmd('styles'); export_from_eventsmd($phpbb_root_path, 'styles');
break; break;
case 'php': case 'php':
export_from_php(); export_from_php($phpbb_root_path);
break; break;
default: default: