Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo listvars();
- function listvars( $vars = 'vars' )
- {
- $vars = minus_reserved( dumpvars( $vars ) );
- $pagerow = '<p>{{key}} (x{{value}})</p>';
- $pagedata = '';
- foreach($vars as $key => $value )
- {
- $pagedata.= str_replace( '{{value}}', $value, str_replace( '{{key}}', $key, $pagerow ) );
- }
- return $pagedata;
- }
- function dumpvars( $filename = 'vars' )
- {
- $nen = nen_ini();
- $subject = file_get_contents( $nen[ 'root' ]. $filename. '.dat' );
- $v = array();
- $pattern = '/(?<var>(?<prefix>\$|)(?<name>[A-Za-z][A-Za-z0-9]*)(?<ext>[%&!#$]|))/m';
- if( preg_match_all( $pattern, $subject, $matches, PREG_UNMATCHED_AS_NULL ) )
- {
- foreach($matches as $group )
- {
- if( isset( $group[ 'var' ] ) )
- {
- trk_echo2('group',$group);
- if( !isset( $v[ $group[ 'var' ] ] ) )
- {
- $v[ $group[ 'var' ] ] = 0;
- }
- $v[ $group[ 'var' ] ]++;
- }
- }
- }
- return $v;
- }
- function minus_reserved( $vars = array(), $reserved = null)
- {
- if( is_null( $reserved ) )
- {
- $reserved = 'reserved';
- }
- if( is_string( $reserved ) )
- {
- $reserved = dumpvars( $reserved );
- }
- if( !is_array( $reserved ) )
- {
- $reserved = array();
- }
- foreach( $reserved as $key => $value )
- {
- if( isset( $vars[ $key ] ) )
- {
- unset( $vars[ $key ] );
- }
- }
- return $vars;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement