Ejemplo n.º 1
0
/**
 * Include the contents of a file as output.
 * @param string File name
 * @param string Plugin basename
 */
function plugin_file_include($p_filename, $p_basename = null)
{
    if (is_null($p_basename)) {
        $t_current = plugin_get_current();
    } else {
        $t_current = $p_basename;
    }
    $t_file_path = plugin_file_path($p_filename, $t_current);
    if (false === $t_file_path) {
        trigger_error(ERROR_GENERIC, ERROR);
    }
    readfile($t_file_path);
}
Ejemplo n.º 2
0
/**
 * Include the contents of a file as output.
 * @param string File name
 * @param string Plugin basename
 */
function plugin_file_include($p_filename, $p_basename = null)
{
    global $g_plugin_mime_types;
    if (is_null($p_basename)) {
        $t_current = plugin_get_current();
    } else {
        $t_current = $p_basename;
    }
    $t_file_path = plugin_file_path($p_filename, $t_current);
    if (false === $t_file_path) {
        trigger_error(ERROR_GENERIC, ERROR);
    }
    $t_content_type = '';
    $finfo = finfo_get_if_available();
    if ($finfo) {
        $t_file_info_type = $finfo->file($t_file_path);
        if ($t_file_info_type !== false) {
            $t_content_type = $t_file_info_type;
        }
    }
    // allow overriding the content type for specific text and image extensions
    // see bug #13193 for details
    if (strpos($t_content_type, 'text/') === 0 || strpos($t_content_type, 'image/') === 0) {
        $t_extension = pathinfo($t_file_path, PATHINFO_EXTENSION);
        if ($t_extension && array_key_exists($t_extension, $g_plugin_mime_types)) {
            $t_content_type = $g_plugin_mime_types[$t_extension];
        }
    }
    if ($t_content_type) {
        header('Content-Type: ' . $t_content_type);
    }
    readfile($t_file_path);
}
Ejemplo n.º 3
0
/**
 * Include the contents of a file as output.
 * @param string File name
 * @param string Plugin basename
 */
function plugin_file_include( $p_filename, $p_basename = null ) {
    
    global $g_plugin_mime_types;
    
	if( is_null( $p_basename ) ) {
		$t_current = plugin_get_current();
	} else {
		$t_current = $p_basename;
	}

	$t_file_path = plugin_file_path( $p_filename, $t_current );
	if( false === $t_file_path ) {
		trigger_error( ERROR_GENERIC, ERROR );
	}
	
	$t_extension = pathinfo( $t_file_path, PATHINFO_EXTENSION );
	if ( $t_extension && array_key_exists( $t_extension , $g_plugin_mime_types ) ) {
	    header('Content-Type: ' . $g_plugin_mime_types [ $t_extension ] );
	}
	
	readfile( $t_file_path );
}