示例#1
0
文件: lib.debug.php 项目: noikiy/mdwp
    function show_vars($show_all_vars = false, $show_object_vars = false, $limit = 5) {
        if($limit === 0) $limit = false;

        if(isset($GLOBALS['no_vars'])) return;

        $script_globals = _script_globals();
        print '
            <style type="text/css" media="screen">
                .vars-container {
                    font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular, sans-serif;
                    font-size: 8pt;
                    padding:5px;
                }
                .varsname {
                    font-weight:bold;
                }
                .showvars {
                    background:white;
                    border-style:dotted;
                    border-width:1px;
                    padding:2px;
                    font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular, sans-serif;
                    font-size:10pt;
                    font-weight:bold;"
                }
            </style>
            <style type="text/css" media="print">
                .showvars {
                    display:none;
                    visibility:invisible;
                }
            </style>
        ';

        print '<br />
            <div class="showvars">
            DEBUG <span style="color:red;font-weight:normal;font-size:9px;">(runtime: '.script_runtime().' sec)</span>
        ';

        $vars_arr['script_globals'] = array('global script variables', '#7ACCC8');
        $vars_arr['_GET'] = array('$_GET', '#7DA7D9');
        $vars_arr['_POST'] = array('$_POST', '#F49AC1');
        $vars_arr['_FILES'] = array('$_FILES', '#82CA9C');
        $vars_arr['_SESSION'] = array('$_SESSION', '#FCDB26');
        $vars_arr['_COOKIE'] = array('$_COOKIE', '#A67C52');

        if($show_all_vars) {
            $vars_arr['_SERVER'] =  array('SERVER', '#A186BE');
            $vars_arr['_ENV'] =  array('ENV', '#7ACCC8');
        }

        foreach ($vars_arr as $vars_name => $vars_data) {
            if($vars_name != 'script_globals') global $$vars_name;
            if($$vars_name) {
                print '<div class="vars-container" style="background-color:'.$vars_data[1].';"><span class="varsname">'.$vars_data[0].'</span><br />';
                print_a($$vars_name, NULL, $show_object_vars, $limit);
                print '</div>';
            }
        }
        print '</div>';
    }
示例#2
0
function show_vars($show_all_vars = FALSE, $show_object_vars = FALSE, $limit = 5)
{
    if ($limit === 0) {
        $limit = FALSE;
    }
    function _script_globals()
    {
        global $GLOBALS_initial_count;
        $varcount = 0;
        foreach ($GLOBALS as $GLOBALS_current_key => $GLOBALS_current_value) {
            if (++$varcount > $GLOBALS_initial_count) {
                /* die wollen wir nicht! */
                if ($GLOBALS_current_key != 'HTTP_SESSION_VARS' && $GLOBALS_current_key != '_SESSION') {
                    $script_GLOBALS[$GLOBALS_current_key] = $GLOBALS_current_value;
                }
            }
        }
        unset($script_GLOBALS['GLOBALS_initial_count']);
        return $script_GLOBALS;
    }
    if (isset($GLOBALS['no_vars'])) {
        return;
    }
    $script_globals = _script_globals();
    print '
		<style type="text/css">
		.vars-container {
			font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular, sans-serif;
			font-size: 8pt;
			padding:5px;
		}
		.varsname {
			font-weight:bold;
		}
		</style>
	';
    print '<br />
		<div style="background:white;border-style:dotted;border-width:1px;padding:2px;font-family:Verdana;font-size:10pt;font-weight:bold;">
		DEBUG <span style="color:red;font-weight:normal;font-size:9px;">(runtime: ' . script_runtime() . ' sec)</span>
	';
    $vars_arr['script_globals'] = array('global script variables', '#7ACCC8');
    $vars_arr['_GET'] = array('$_GET', '#7DA7D9');
    $vars_arr['_POST'] = array('$_POST', '#F49AC1');
    $vars_arr['_FILES'] = array('$_FILES', '#82CA9C');
    $vars_arr['_SESSION'] = array('$_SESSION', '#FCDB26');
    $vars_arr['_COOKIE'] = array('$_COOKIE', '#A67C52');
    if ($show_all_vars) {
        $vars_arr['_SERVER'] = array('SERVER', '#A186BE');
        $vars_arr['_ENV'] = array('ENV', '#7ACCC8');
    }
    foreach ($vars_arr as $vars_name => $vars_data) {
        if ($vars_name != 'script_globals') {
            global ${$vars_name};
        }
        if (${$vars_name}) {
            print '<div class="vars-container" style="background-color:' . $vars_data[1] . ';"><span class="varsname">' . $vars_data[0] . '</span><br />';
            print_a(${$vars_name}, FALSE, $show_object_vars, $limit);
            print '</div>';
        }
    }
    print '</div>';
}