예제 #1
0
function print_config_value_as_string($p_type, $p_value)
{
    switch ($p_type) {
        case CONFIG_TYPE_INT:
            $t_value = (int) $p_value;
            echo $t_value;
            return;
        case CONFIG_TYPE_STRING:
            $t_value = config_eval($p_value);
            echo string_nl2br(string_html_specialchars("'{$t_value}'"));
            return;
        case CONFIG_TYPE_COMPLEX:
            $t_value = unserialize($p_value);
            break;
        default:
            $t_value = config_eval($p_value);
            break;
    }
    echo '<pre>';
    if (function_exists('var_export')) {
        var_export($t_value);
    } else {
        print_r($t_value);
    }
    echo '</pre>';
}
예제 #2
0
function print_config_value_as_string($p_type, $p_value, $p_for_display = true)
{
    $t_corrupted = false;
    switch ($p_type) {
        case CONFIG_TYPE_DEFAULT:
            return;
        case CONFIG_TYPE_FLOAT:
            echo (double) $p_value;
            return;
        case CONFIG_TYPE_INT:
            echo (int) $p_value;
            return;
        case CONFIG_TYPE_STRING:
            $t_value = string_nl2br(string_html_specialchars(config_eval($p_value)));
            if ($p_for_display) {
                $t_value = "'{$t_value}'";
            }
            echo $t_value;
            return;
        case CONFIG_TYPE_COMPLEX:
            $t_value = @unserialize($p_value);
            if ($t_value === false) {
                $t_corrupted = true;
            }
            break;
        default:
            $t_value = config_eval($p_value);
            break;
    }
    if ($t_corrupted) {
        $t_output = $p_for_display ? lang_get('configuration_corrupted') : '';
    } else {
        $t_output = var_export($t_value, true);
    }
    if ($p_for_display) {
        echo '<pre>' . string_attribute($t_output) . '</pre>';
    } else {
        echo $t_output;
    }
}
function print_config_value_as_string($p_type, $p_value)
{
    $t_corrupted = false;
    switch ($p_type) {
        case CONFIG_TYPE_FLOAT:
            $t_value = (double) $p_value;
            echo $t_value;
            return;
        case CONFIG_TYPE_INT:
            $t_value = (int) $p_value;
            echo $t_value;
            return;
        case CONFIG_TYPE_STRING:
            $t_value = config_eval($p_value);
            echo string_nl2br(string_html_specialchars("'{$t_value}'"));
            return;
        case CONFIG_TYPE_COMPLEX:
            $t_value = @unserialize($p_value);
            if ($t_value === false) {
                $t_corrupted = true;
            }
            break;
        default:
            $t_value = config_eval($p_value);
            break;
    }
    echo '<pre>';
    if ($t_corrupted) {
        echo lang_get('configuration_corrupted');
    } else {
        if (function_exists('var_export')) {
            var_export($t_value);
        } else {
            print_r($t_value);
        }
    }
    echo '</pre>';
}
예제 #4
0
/**
 * get list database tables
 * @return array containing table names
 */
function db_get_table_list()
{
    $t_tables = array();
    foreach ($GLOBALS['g_db_table'] as $t_table) {
        $t_tables[] = config_eval($t_table);
    }
    return $t_tables;
}
예제 #5
0
/**
 * force config variable from a global to avoid recursion
 *
 * @param string $p_option  Configuration option to retrieve.
 * @param string $p_default Default value if not set.
 * @return string
 */
function config_get_global($p_option, $p_default = null)
{
    global $g_cache_config_eval;
    if (isset($GLOBALS['g_' . $p_option])) {
        if (!isset($g_cache_config_eval['g_' . $p_option])) {
            $t_value = config_eval($GLOBALS['g_' . $p_option], true);
            $g_cache_config_eval['g_' . $p_option] = $t_value;
        } else {
            $t_value = $g_cache_config_eval['g_' . $p_option];
        }
        return $t_value;
    } else {
        # unless we were allowing for the option not to exist by passing
        #  a default, trigger a WARNING
        if (null === $p_default) {
            error_parameters($p_option);
            trigger_error(ERROR_CONFIG_OPT_NOT_FOUND, WARNING);
        }
        return $p_default;
    }
}
예제 #6
0
/**
 * Display a given config value appropriately
 * @param integer $p_type        Configuration type id.
 * @param mixed   $p_value       Configuration value.
 * @param boolean $p_for_display Whether to pass the value via string attribute for web browser display.
 * @return void
 */
function print_config_value_as_string( $p_type, $p_value, $p_for_display = true ) {
	$t_corrupted = false;

	switch( $p_type ) {
		case CONFIG_TYPE_DEFAULT:
			return;
		case CONFIG_TYPE_FLOAT:
			echo (float)$p_value;
			return;
		case CONFIG_TYPE_INT:
			echo (integer)$p_value;
			return;
		case CONFIG_TYPE_STRING:
			$t_value = string_nl2br( string_html_specialchars( config_eval( $p_value ) ) );
			if( $p_for_display ) {
				$t_value = '<p id="adm-config-value">\'' . $t_value . '\'</p>';
			}
			echo $t_value;
			return;
		case CONFIG_TYPE_COMPLEX:
			$t_value = @json_decode( $p_value, true );
			if( $t_value === false ) {
				$t_corrupted = true;
			}
			break;
		default:
			$t_value = config_eval( $p_value );
			break;
	}

	if( $t_corrupted ) {
		$t_output = $p_for_display ? lang_get( 'configuration_corrupted' ) : '';
	} else {
		$t_output = var_export( $t_value, true );
	}

	if( $p_for_display ) {
		echo '<pre id="adm-config-value">' . string_attribute( $t_output ) . '</pre>';
	} else {
		echo $t_output;
	}
}