[1793] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | function get_php_files($path, $to_ignore=array(), $recursive=true ) |
---|
| 5 | { |
---|
| 6 | $files = array(); |
---|
| 7 | if (is_dir($path)) |
---|
| 8 | { |
---|
| 9 | if ($contents = opendir($path)) |
---|
| 10 | { |
---|
| 11 | while (($node = readdir($contents)) !== false) |
---|
| 12 | { |
---|
| 13 | if ($node != '.' and $node != '..' and $node != '.svn' |
---|
| 14 | and !in_array($node, $to_ignore) ) |
---|
| 15 | { |
---|
| 16 | if ( $recursive and is_dir($path.'/'.$node) ) |
---|
| 17 | { |
---|
| 18 | $files = array_merge($files, get_php_files($path.'/'.$node, $to_ignore)); |
---|
[2757] | 19 | |
---|
[1793] | 20 | } |
---|
| 21 | if ( is_file($path.'/'.$node) ) |
---|
| 22 | { |
---|
| 23 | $files[] = $path.'/'.$node; |
---|
| 24 | } |
---|
| 25 | } |
---|
| 26 | } |
---|
| 27 | closedir($contents); |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | return $files; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | $files = array(); |
---|
| 34 | $files = array_merge( $files, get_php_files('.', array(), false) ); |
---|
| 35 | $files = array_merge( $files, get_php_files('./include') ); |
---|
| 36 | $files = array_merge( $files, get_php_files('./admin') ); |
---|
| 37 | $files = array_unique($files); |
---|
| 38 | |
---|
| 39 | $events = array(); |
---|
| 40 | foreach ($files as $file) |
---|
| 41 | { |
---|
| 42 | $code = file_get_contents($file); |
---|
| 43 | $code = preg_replace( '#\?'.'>.*<\?php#m', '', $code); |
---|
| 44 | $code = preg_replace( '#\/\*.*\*\/#m', '', $code); |
---|
| 45 | $code = preg_replace( '#\/\/.*#', '', $code); |
---|
[2757] | 46 | |
---|
[1793] | 47 | $count = preg_match_all( |
---|
[30183] | 48 | '#[^a-zA-Z_$-]trigger_(change|notify)\s*\(\s*([^,)]+)#m', |
---|
[1793] | 49 | $code, $matches |
---|
| 50 | ); |
---|
| 51 | |
---|
| 52 | for ($i=0; $i<$count; $i++) |
---|
| 53 | { |
---|
| 54 | $type = $matches[1][$i]; |
---|
| 55 | $name = preg_replace( '#^[\'"]?([^\'"]*)[\'"]?$#', '$1', $matches[2][$i]); |
---|
| 56 | array_push($events, array($type,$name,$file) ); |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | |
---|
[2757] | 60 | $sort= isset($_GET['sort']) ? (int)$_GET['sort'] : 1; |
---|
[1793] | 61 | usort( |
---|
| 62 | $events, |
---|
| 63 | create_function( '$a,$b', 'return $a['.$sort.']>$b['.$sort.'];' ) |
---|
| 64 | ); |
---|
| 65 | |
---|
| 66 | global $template; |
---|
| 67 | |
---|
| 68 | $url = get_admin_plugin_menu_link(__FILE__); |
---|
| 69 | |
---|
[2254] | 70 | $template->assign( array( |
---|
[1793] | 71 | 'NB_EVENTS' => count($events), |
---|
| 72 | 'U_SORT0' => add_url_params($url, array('sort'=>0) ), |
---|
| 73 | 'U_SORT1' => add_url_params($url, array('sort'=>1) ), |
---|
| 74 | 'U_SORT2' => add_url_params($url, array('sort'=>2) ), |
---|
| 75 | ) ); |
---|
| 76 | |
---|
[2254] | 77 | $template->assign('events', array()); |
---|
[1793] | 78 | foreach ($events as $e) |
---|
| 79 | { |
---|
[2254] | 80 | $template->append( 'events', array( |
---|
[1793] | 81 | 'TYPE' => $e[0], |
---|
| 82 | 'NAME' => $e[1], |
---|
| 83 | 'FILE' => $e[2], |
---|
| 84 | ) |
---|
| 85 | ); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | $template->set_filenames( array('event_list' => dirname(__FILE__).'/event_list.tpl' ) ); |
---|
| 89 | $template->assign_var_from_handle( 'ADMIN_CONTENT', 'event_list'); |
---|
| 90 | ?> |
---|