From 3e4d1197d58b9d5a7ca4c6e0b6e11194a8136d1a Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 20 Mar 2008 00:33:59 +0000 Subject: [PATCH] Degrade flash upload if the server is lightttpd < 1.5. Props nbachyski. fixes #6243 git-svn-id: https://develop.svn.wordpress.org/trunk@7406 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/media.php | 4 +++- wp-includes/functions.php | 11 +++++++++++ wp-includes/js/swfupload/handlers.js | 5 ----- .../plugins/swfupload.graceful_degradation.js | 1 + wp-includes/script-loader.php | 3 +++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 779682ca54..e266d68fed 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -811,7 +811,6 @@ jQuery(function($){ file_size_limit : "b", swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available degraded_element_id : "html-upload-ui", // when swfupload is unavailable - swfupload_loaded_handler : uploadLoaded, file_dialog_start_handler : fileDialogStart, file_queued_handler : fileQueued, upload_start_handler : uploadStart, @@ -843,6 +842,9 @@ jQuery(function($){


+ +

+ deprecated since version %2$s with no alternative available."), $file, $version ) ); } } + +/** + * is_lighttpd_before_150() - Is the server running earlier than 1.5.0 version of lighttpd + * + * @return bool Whether the server is running lighttpd < 1.5.0 + */ +function is_lighttpd_before_150() { + $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' ); + $server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : ''; + return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ); +} ?> diff --git a/wp-includes/js/swfupload/handlers.js b/wp-includes/js/swfupload/handlers.js index c53edf1d04..3dd3c4f1ee 100644 --- a/wp-includes/js/swfupload/handlers.js +++ b/wp-includes/js/swfupload/handlers.js @@ -1,8 +1,3 @@ -function uploadLoaded() { - jQuery("#html-upload-ui").remove(); - jQuery("#flash-upload-ui").show(); -} - function fileDialogStart() { jQuery("#media-upload-error").empty(); } diff --git a/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js b/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js index 16bf12ed7b..c26b4046db 100644 --- a/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js +++ b/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js @@ -36,6 +36,7 @@ if (typeof(SWFUpload) === "function") { SWFUpload.gracefulDegradation.swfUploadLoaded = function () { var swfupload_container_id, swfupload_container, degraded_container_id, degraded_container, user_swfUploadLoaded_handler; try { + if (uploadDegradeOptions.is_lighttpd_before_150) throw "Lighttpd versions earlier than 1.5.0 aren't supported!"; swfupload_element_id = this.getSetting("swfupload_element_id"); degraded_element_id = this.getSetting("degraded_element_id"); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 1200174b44..b34a4f5707 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -83,6 +83,9 @@ class WP_Scripts { $this->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1'); $this->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2'); $this->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2'); + $this->localize( 'swfupload-degrade', 'uploadDegradeOptions', array( + 'is_lighttpd_before_150' => is_lighttpd_before_150(), + ) ); $this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2'); $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080301'); // these error messages came from the sample swfupload js, they might need changing.