here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
<?php
|
2012-06-05 22:58:54 +00:00
|
|
|
/**
|
|
|
|
|
* Backend for uploading files from a HTTP resource.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Upload
|
|
|
|
|
*/
|
|
|
|
|
|
2009-08-26 17:05:24 +00:00
|
|
|
/**
|
|
|
|
|
* Implements uploading from a HTTP resource.
|
2010-02-05 04:25:30 +00:00
|
|
|
*
|
2012-02-08 17:03:43 +00:00
|
|
|
* @ingroup Upload
|
2009-08-26 17:05:24 +00:00
|
|
|
* @author Bryan Tong Minh
|
|
|
|
|
* @author Michael Dale
|
|
|
|
|
*/
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
class UploadFromUrl extends UploadBase {
|
2010-07-28 17:14:51 +00:00
|
|
|
protected $mAsync, $mUrl;
|
2010-07-29 13:53:51 +00:00
|
|
|
protected $mIgnoreWarnings = true;
|
2009-07-15 19:18:12 +00:00
|
|
|
|
2011-12-24 23:11:25 +00:00
|
|
|
protected $mTempPath, $mTmpHandle;
|
2011-02-20 13:33:42 +00:00
|
|
|
|
2009-07-15 19:18:12 +00:00
|
|
|
/**
|
2010-02-05 04:25:30 +00:00
|
|
|
* Checks if the user is allowed to use the upload-by-URL feature. If the
|
2009-08-26 17:05:24 +00:00
|
|
|
* user is allowed, pass on permissions checking to the parent.
|
2011-02-20 13:33:42 +00:00
|
|
|
*
|
|
|
|
|
* @param $user User
|
2011-07-24 21:36:04 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2009-07-15 19:18:12 +00:00
|
|
|
*/
|
2009-08-26 17:05:24 +00:00
|
|
|
public static function isAllowed( $user ) {
|
2011-07-24 21:36:04 +00:00
|
|
|
if ( !$user->isAllowed( 'upload_by_url' ) ) {
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
return 'upload_by_url';
|
2011-07-24 21:36:04 +00:00
|
|
|
}
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
return parent::isAllowed( $user );
|
|
|
|
|
}
|
2009-07-15 19:18:12 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if the upload from URL feature is enabled
|
2010-04-17 16:49:20 +00:00
|
|
|
* @return bool
|
2009-07-15 19:18:12 +00:00
|
|
|
*/
|
2009-08-26 17:05:24 +00:00
|
|
|
public static function isEnabled() {
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
global $wgAllowCopyUploads;
|
|
|
|
|
return $wgAllowCopyUploads && parent::isEnabled();
|
2009-07-15 19:18:12 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-09 23:22:38 +00:00
|
|
|
/**
|
|
|
|
|
* Checks whether the URL is for an allowed host
|
|
|
|
|
*
|
|
|
|
|
* @param $url string
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public static function isAllowedHost( $url ) {
|
|
|
|
|
global $wgCopyUploadsDomains;
|
|
|
|
|
if ( !count( $wgCopyUploadsDomains ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
$parsedUrl = wfParseUrl( $url );
|
2012-02-11 15:13:01 +00:00
|
|
|
if ( !$parsedUrl ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$valid = false;
|
2012-02-09 23:22:38 +00:00
|
|
|
foreach( $wgCopyUploadsDomains as $domain ) {
|
|
|
|
|
if ( $parsedUrl['host'] === $domain ) {
|
|
|
|
|
$valid = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $valid;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-05 04:25:30 +00:00
|
|
|
/**
|
|
|
|
|
* Entry point for API upload
|
2010-12-08 18:59:43 +00:00
|
|
|
*
|
2010-07-28 17:14:51 +00:00
|
|
|
* @param $name string
|
|
|
|
|
* @param $url string
|
2010-12-08 18:59:43 +00:00
|
|
|
* @param $async mixed Whether the download should be performed
|
2010-07-28 17:14:51 +00:00
|
|
|
* asynchronous. False for synchronous, async or async-leavemessage for
|
|
|
|
|
* asynchronous download.
|
2009-08-26 17:05:24 +00:00
|
|
|
*/
|
2010-07-28 17:14:51 +00:00
|
|
|
public function initialize( $name, $url, $async = false ) {
|
2010-07-29 13:53:51 +00:00
|
|
|
global $wgAllowAsyncCopyUploads;
|
2010-12-08 18:59:43 +00:00
|
|
|
|
2010-07-28 17:14:51 +00:00
|
|
|
$this->mUrl = $url;
|
2010-07-29 13:53:51 +00:00
|
|
|
$this->mAsync = $wgAllowAsyncCopyUploads ? $async : false;
|
2011-02-06 22:53:07 +00:00
|
|
|
if ( $async ) {
|
|
|
|
|
throw new MWException( 'Asynchronous copy uploads are no longer possible as of r81612.' );
|
|
|
|
|
}
|
2010-12-08 18:59:43 +00:00
|
|
|
|
2010-07-29 13:53:51 +00:00
|
|
|
$tempPath = $this->mAsync ? null : $this->makeTemporaryFile();
|
2010-07-28 17:14:51 +00:00
|
|
|
# File size and removeTempFile will be filled in later
|
|
|
|
|
$this->initializePathInfo( $name, $tempPath, 0, false );
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
}
|
2009-07-15 19:18:12 +00:00
|
|
|
|
|
|
|
|
/**
|
2009-11-26 12:00:36 +00:00
|
|
|
* Entry point for SpecialUpload
|
2011-02-20 13:33:42 +00:00
|
|
|
* @param $request WebRequest object
|
2009-07-15 19:18:12 +00:00
|
|
|
*/
|
2009-08-26 17:05:24 +00:00
|
|
|
public function initializeFromRequest( &$request ) {
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
$desiredDestName = $request->getText( 'wpDestFile' );
|
2012-01-19 19:16:06 +00:00
|
|
|
if ( !$desiredDestName ) {
|
2009-10-23 20:05:31 +00:00
|
|
|
$desiredDestName = $request->getText( 'wpUploadFileURL' );
|
2012-01-19 19:16:06 +00:00
|
|
|
}
|
2012-04-19 13:07:40 +00:00
|
|
|
$this->initialize(
|
2009-07-15 19:18:12 +00:00
|
|
|
$desiredDestName,
|
2011-03-04 22:21:48 +00:00
|
|
|
trim( $request->getVal( 'wpUploadFileURL' ) ),
|
2010-07-28 17:14:51 +00:00
|
|
|
false
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
);
|
|
|
|
|
}
|
2009-07-15 19:18:12 +00:00
|
|
|
|
|
|
|
|
/**
|
2011-02-20 13:33:42 +00:00
|
|
|
* @param $request WebRequest object
|
2011-12-24 23:11:25 +00:00
|
|
|
* @return bool
|
2009-07-15 19:18:12 +00:00
|
|
|
*/
|
2010-07-28 13:43:38 +00:00
|
|
|
public static function isValidRequest( $request ) {
|
2010-04-17 21:44:51 +00:00
|
|
|
global $wgUser;
|
|
|
|
|
|
|
|
|
|
$url = $request->getVal( 'wpUploadFileURL' );
|
|
|
|
|
return !empty( $url )
|
|
|
|
|
&& Http::isValidURI( $url )
|
|
|
|
|
&& $wgUser->isAllowed( 'upload_by_url' );
|
here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview
= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions
== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php
* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)
== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.
= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.
= js2 system / mwEmbed=
$wgEnableJS2system = false
* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)
* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.
= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)
== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.
== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
|
|
|
}
|
2010-12-08 18:59:43 +00:00
|
|
|
|
2011-12-24 23:11:25 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2011-01-06 19:42:55 +00:00
|
|
|
public function getSourceType() { return 'url'; }
|
2009-07-15 19:18:12 +00:00
|
|
|
|
2011-12-24 23:11:25 +00:00
|
|
|
/**
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
2010-07-28 17:14:51 +00:00
|
|
|
public function fetchFile() {
|
|
|
|
|
if ( !Http::isValidURI( $this->mUrl ) ) {
|
|
|
|
|
return Status::newFatal( 'http-invalid-url' );
|
|
|
|
|
}
|
2010-12-08 18:59:43 +00:00
|
|
|
|
2012-02-09 23:22:38 +00:00
|
|
|
if( !self::isAllowedHost( $this->mUrl ) ) {
|
|
|
|
|
return Status::newFatal( 'upload-copy-upload-invalid-domain' );
|
|
|
|
|
}
|
2010-07-28 17:14:51 +00:00
|
|
|
if ( !$this->mAsync ) {
|
|
|
|
|
return $this->reallyFetchFile();
|
|
|
|
|
}
|
|
|
|
|
return Status::newGood();
|
|
|
|
|
}
|
2010-07-29 13:53:51 +00:00
|
|
|
/**
|
|
|
|
|
* Create a new temporary file in the URL subdirectory of wfTempDir().
|
2010-12-08 18:59:43 +00:00
|
|
|
*
|
2010-07-29 13:53:51 +00:00
|
|
|
* @return string Path to the file
|
|
|
|
|
*/
|
2010-07-28 17:14:51 +00:00
|
|
|
protected function makeTemporaryFile() {
|
|
|
|
|
return tempnam( wfTempDir(), 'URL' );
|
|
|
|
|
}
|
2011-05-27 22:31:48 +00:00
|
|
|
|
2010-07-29 13:53:51 +00:00
|
|
|
/**
|
2011-05-27 22:31:48 +00:00
|
|
|
* Callback: save a chunk of the result of a HTTP request to the temporary file
|
2010-12-08 18:59:43 +00:00
|
|
|
*
|
2011-05-27 22:31:48 +00:00
|
|
|
* @param $req mixed
|
|
|
|
|
* @param $buffer string
|
|
|
|
|
* @return int number of bytes handled
|
2010-07-29 13:53:51 +00:00
|
|
|
*/
|
2011-05-27 22:31:48 +00:00
|
|
|
public function saveTempFileChunk( $req, $buffer ) {
|
|
|
|
|
$nbytes = fwrite( $this->mTmpHandle, $buffer );
|
|
|
|
|
|
|
|
|
|
if ( $nbytes == strlen( $buffer ) ) {
|
|
|
|
|
$this->mFileSize += $nbytes;
|
|
|
|
|
} else {
|
|
|
|
|
// Well... that's not good!
|
|
|
|
|
fclose( $this->mTmpHandle );
|
|
|
|
|
$this->mTmpHandle = false;
|
2010-04-17 02:43:13 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-27 22:31:48 +00:00
|
|
|
return $nbytes;
|
2009-11-26 12:00:36 +00:00
|
|
|
}
|
2011-05-27 22:31:48 +00:00
|
|
|
|
2010-07-29 13:53:51 +00:00
|
|
|
/**
|
|
|
|
|
* Download the file, save it to the temporary file and update the file
|
|
|
|
|
* size and set $mRemoveTempFile to true.
|
2011-12-24 23:11:25 +00:00
|
|
|
* @return Status
|
2010-07-29 13:53:51 +00:00
|
|
|
*/
|
2010-07-28 17:14:51 +00:00
|
|
|
protected function reallyFetchFile() {
|
2011-05-27 22:31:48 +00:00
|
|
|
if ( $this->mTempPath === false ) {
|
|
|
|
|
return Status::newFatal( 'tmp-create-error' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Note the temporary file should already be created by makeTemporaryFile()
|
|
|
|
|
$this->mTmpHandle = fopen( $this->mTempPath, 'wb' );
|
|
|
|
|
if ( !$this->mTmpHandle ) {
|
|
|
|
|
return Status::newFatal( 'tmp-create-error' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->mRemoveTempFile = true;
|
|
|
|
|
$this->mFileSize = 0;
|
|
|
|
|
|
2011-09-22 01:15:06 +00:00
|
|
|
$req = MWHttpRequest::factory( $this->mUrl, array(
|
|
|
|
|
'followRedirects' => true
|
|
|
|
|
) );
|
2011-05-27 22:31:48 +00:00
|
|
|
$req->setCallback( array( $this, 'saveTempFileChunk' ) );
|
2010-04-17 02:43:13 +00:00
|
|
|
$status = $req->execute();
|
|
|
|
|
|
2011-05-27 22:31:48 +00:00
|
|
|
if ( $this->mTmpHandle ) {
|
|
|
|
|
// File got written ok...
|
|
|
|
|
fclose( $this->mTmpHandle );
|
|
|
|
|
$this->mTmpHandle = null;
|
|
|
|
|
} else {
|
|
|
|
|
// We encountered a write error during the download...
|
|
|
|
|
return Status::newFatal( 'tmp-write-error' );
|
2009-11-26 12:00:36 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-27 22:31:48 +00:00
|
|
|
if ( !$status->isOk() ) {
|
2010-04-17 02:43:13 +00:00
|
|
|
return $status;
|
2009-11-26 12:00:36 +00:00
|
|
|
}
|
2010-05-14 20:36:23 +00:00
|
|
|
|
2010-06-12 03:58:31 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
2010-04-15 09:28:33 +00:00
|
|
|
|
2010-07-29 13:53:51 +00:00
|
|
|
/**
|
2010-12-08 18:59:43 +00:00
|
|
|
* Wrapper around the parent function in order to defer verifying the
|
2010-07-29 13:53:51 +00:00
|
|
|
* upload until the file really has been fetched.
|
2012-02-09 21:36:14 +00:00
|
|
|
* @return array|mixed
|
2010-07-29 13:53:51 +00:00
|
|
|
*/
|
|
|
|
|
public function verifyUpload() {
|
|
|
|
|
if ( $this->mAsync ) {
|
2010-12-22 00:25:16 +00:00
|
|
|
return array( 'status' => UploadBase::OK );
|
2010-07-29 13:53:51 +00:00
|
|
|
}
|
|
|
|
|
return parent::verifyUpload();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Wrapper around the parent function in order to defer checking warnings
|
|
|
|
|
* until the file really has been fetched.
|
2012-02-09 21:36:14 +00:00
|
|
|
* @return Array
|
2010-07-29 13:53:51 +00:00
|
|
|
*/
|
|
|
|
|
public function checkWarnings() {
|
|
|
|
|
if ( $this->mAsync ) {
|
|
|
|
|
$this->mIgnoreWarnings = false;
|
|
|
|
|
return array();
|
|
|
|
|
}
|
|
|
|
|
return parent::checkWarnings();
|
|
|
|
|
}
|
2010-12-08 18:59:43 +00:00
|
|
|
|
2010-07-29 13:53:51 +00:00
|
|
|
/**
|
|
|
|
|
* Wrapper around the parent function in order to defer checking protection
|
|
|
|
|
* until we are sure that the file can actually be uploaded
|
2012-02-09 21:36:14 +00:00
|
|
|
* @return bool|mixed
|
2010-07-29 13:53:51 +00:00
|
|
|
*/
|
2011-03-25 20:37:26 +00:00
|
|
|
public function verifyTitlePermissions( $user ) {
|
2010-07-29 13:53:51 +00:00
|
|
|
if ( $this->mAsync ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2011-03-25 20:37:26 +00:00
|
|
|
return parent::verifyTitlePermissions( $user );
|
2010-07-29 13:53:51 +00:00
|
|
|
}
|
2010-12-08 18:59:43 +00:00
|
|
|
|
2010-07-29 13:53:51 +00:00
|
|
|
/**
|
|
|
|
|
* Wrapper around the parent function in order to defer uploading to the
|
|
|
|
|
* job queue for asynchronous uploads
|
2012-02-09 21:36:14 +00:00
|
|
|
* @return Status
|
2010-07-29 13:53:51 +00:00
|
|
|
*/
|
2010-07-28 17:14:51 +00:00
|
|
|
public function performUpload( $comment, $pageText, $watch, $user ) {
|
|
|
|
|
if ( $this->mAsync ) {
|
|
|
|
|
$sessionKey = $this->insertJob( $comment, $pageText, $watch, $user );
|
2010-12-08 18:59:43 +00:00
|
|
|
|
2012-01-19 19:16:06 +00:00
|
|
|
return Status::newFatal( 'async', $sessionKey );
|
2010-05-14 20:36:23 +00:00
|
|
|
}
|
2010-12-08 18:59:43 +00:00
|
|
|
|
2010-07-28 17:14:51 +00:00
|
|
|
return parent::performUpload( $comment, $pageText, $watch, $user );
|
|
|
|
|
}
|
2010-05-14 20:36:23 +00:00
|
|
|
|
2011-02-02 10:42:17 +00:00
|
|
|
/**
|
|
|
|
|
* @param $comment
|
|
|
|
|
* @param $pageText
|
|
|
|
|
* @param $watch
|
|
|
|
|
* @param $user User
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2010-07-28 17:14:51 +00:00
|
|
|
protected function insertJob( $comment, $pageText, $watch, $user ) {
|
2010-12-08 18:59:43 +00:00
|
|
|
$sessionKey = $this->stashSession();
|
2010-07-28 17:14:51 +00:00
|
|
|
$job = new UploadFromUrlJob( $this->getTitle(), array(
|
|
|
|
|
'url' => $this->mUrl,
|
|
|
|
|
'comment' => $comment,
|
|
|
|
|
'pageText' => $pageText,
|
|
|
|
|
'watch' => $watch,
|
|
|
|
|
'userName' => $user->getName(),
|
|
|
|
|
'leaveMessage' => $this->mAsync == 'async-leavemessage',
|
|
|
|
|
'ignoreWarnings' => $this->mIgnoreWarnings,
|
2010-09-06 10:18:53 +00:00
|
|
|
'sessionId' => session_id(),
|
2010-07-28 17:14:51 +00:00
|
|
|
'sessionKey' => $sessionKey,
|
|
|
|
|
) );
|
2010-09-06 10:18:53 +00:00
|
|
|
$job->initializeSessionData();
|
2010-07-28 17:14:51 +00:00
|
|
|
$job->insert();
|
|
|
|
|
return $sessionKey;
|
2009-11-26 12:00:36 +00:00
|
|
|
}
|
2010-12-08 18:59:43 +00:00
|
|
|
|
2009-11-26 12:00:36 +00:00
|
|
|
}
|