a6c8efadb9
The exceptions to this are update_post_meta() and add_post_meta() which are often used by plugins in POST handlers and will continue accepting slashed data for now. Introduce wp_upate_post_meta() and wp_add_post_meta() as unslashed alternatives to update_post_meta() and add_post_meta(). These functions could become methods in WP_Post so don't use them too heavily yet. Remove all escape() calls from wp_xmlrpc_server. Now that core expects unslashed data this is no longer needed. Remove addslashes(), addslashes_gpc(), add_magic_quotes() calls on data being prepared for handoff to core functions that until now expected slashed data. Adding slashes in no longer necessary. Introduce wp_unslash() and use to it remove slashes from GPCS data before using it in core API. Almost every instance of stripslashes() in core should now be wp_unslash(). In the future (a release or three) when GPCS is no longer slashed, wp_unslash() will stop stripping slashes and simply return what is passed. At this point wp_unslash() calls can be removed from core. Introduce wp_slash() for slashing GPCS data. This will also turn into a noop once GPCS is no longer slashed. wp_slash() should almost never be used. It is mainly of use in unit tests. Plugins should use wp_unslash() on data being passed to core API. Plugins should no longer slash data being passed to core. So when you get_post() and then wp_insert_post() the post data from get_post() no longer needs addslashes(). Most plugins were not bothering with this. They will magically start doing the right thing. Unfortunately, those few souls who did it properly will now have to avoid calling addslashes() for 3.6 and newer. Use wp_kses_post() and wp_kses_data(), which expect unslashed data, instead of wp_filter_post_kses() and wp_filter_kses(), which expect slashed data. Filters are no longer passed slashed data. Remove many no longer necessary calls to $wpdb->escape() and esc_sql(). In wp_get_referer() and wp_get_original_referer(), return unslashed data. Remove old stripslashes() calls from WP_Widget::update() handlers. These haven't been necessary since WP_Widget. Switch several queries over to prepare(). Expect something to break. Props alexkingorg see #21767 git-svn-id: https://develop.svn.wordpress.org/trunk@23416 602fd350-edb4-49c9-b593-d223f7449a82
83 lines
2.5 KiB
PHP
83 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* Multisite upload handler.
|
|
*
|
|
* @since 3.0.0
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Multisite
|
|
*/
|
|
|
|
define( 'SHORTINIT', true );
|
|
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
|
|
|
|
if( !is_multisite() )
|
|
die( 'Multisite support not enabled' );
|
|
|
|
ms_file_constants();
|
|
|
|
error_reporting( 0 );
|
|
|
|
if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) {
|
|
status_header( 404 );
|
|
die( '404 — File not found.' );
|
|
}
|
|
|
|
$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file' ] );
|
|
if ( !is_file( $file ) ) {
|
|
status_header( 404 );
|
|
die( '404 — File not found.' );
|
|
}
|
|
|
|
$mime = wp_check_filetype( $file );
|
|
if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
|
|
$mime[ 'type' ] = mime_content_type( $file );
|
|
|
|
if( $mime[ 'type' ] )
|
|
$mimetype = $mime[ 'type' ];
|
|
else
|
|
$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
|
|
|
|
header( 'Content-Type: ' . $mimetype ); // always send this
|
|
if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
|
|
header( 'Content-Length: ' . filesize( $file ) );
|
|
|
|
// Optional support for X-Sendfile and X-Accel-Redirect
|
|
if ( WPMU_ACCEL_REDIRECT ) {
|
|
header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) );
|
|
exit;
|
|
} elseif ( WPMU_SENDFILE ) {
|
|
header( 'X-Sendfile: ' . $file );
|
|
exit;
|
|
}
|
|
|
|
$last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) );
|
|
$etag = '"' . md5( $last_modified ) . '"';
|
|
header( "Last-Modified: $last_modified GMT" );
|
|
header( 'ETag: ' . $etag );
|
|
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
|
|
|
|
// Support for Conditional GET
|
|
$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
|
|
|
|
if( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
|
|
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
|
|
|
|
$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
|
|
// If string is empty, return 0. If not, attempt to parse into a timestamp
|
|
$client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
|
|
|
|
// Make a timestamp for our most recent modification...
|
|
$modified_timestamp = strtotime($last_modified);
|
|
|
|
if ( ( $client_last_modified && $client_etag )
|
|
? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) )
|
|
: ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) )
|
|
) {
|
|
status_header( 304 );
|
|
exit;
|
|
}
|
|
|
|
// If we made it this far, just serve the file
|
|
readfile( $file );
|