Go to the documentation of this file.
49 if ( !
$user->isAllowed(
'upload_by_url' ) ) {
50 return 'upload_by_url';
52 return parent::isAllowed(
$user );
60 global $wgAllowCopyUploads;
61 return $wgAllowCopyUploads && parent::isEnabled();
73 global $wgCopyUploadsDomains;
74 if ( !count( $wgCopyUploadsDomains ) ) {
82 foreach ( $wgCopyUploadsDomains
as $domain ) {
84 $whitelistedDomainPieces = explode(
'.', $domain );
85 $uploadDomainPieces = explode(
'.', $parsedUrl[
'host'] );
86 if ( count( $whitelistedDomainPieces ) === count( $uploadDomainPieces ) ) {
89 foreach ( $whitelistedDomainPieces
as $index => $piece ) {
90 if ( $piece !==
'*' && $piece !== $uploadDomainPieces[$index] ) {
116 if ( !isset( self::$allowedUrls[$url] ) ) {
119 self::$allowedUrls[$url] = $allowed;
121 return self::$allowedUrls[$url];
135 global $wgAllowAsyncCopyUploads;
138 $this->mAsync = $wgAllowAsyncCopyUploads ? $async :
false;
140 throw new MWException(
'Asynchronous copy uploads are no longer possible as of r81612.' );
144 # File size and removeTempFile will be filled in later
153 $desiredDestName = $request->getText(
'wpDestFile' );
154 if ( !$desiredDestName ) {
155 $desiredDestName = $request->getText(
'wpUploadFileURL' );
159 trim( $request->getVal(
'wpUploadFileURL' ) ),
171 $url = $request->getVal(
'wpUploadFileURL' );
172 return !empty( $url )
174 &&
$wgUser->isAllowed(
'upload_by_url' );
196 if ( !self::isAllowedHost( $this->mUrl ) ) {
199 if ( !self::isAllowedUrl( $this->mUrl ) ) {
202 if ( !$this->mAsync ) {
215 $tmpFile->bind( $this );
216 return $tmpFile->getPath();
227 $nbytes = fwrite( $this->mTmpHandle, $buffer );
229 if ( $nbytes == strlen( $buffer ) ) {
230 $this->mFileSize += $nbytes;
233 fclose( $this->mTmpHandle );
234 $this->mTmpHandle =
false;
248 global $wgCopyUploadProxy, $wgCopyUploadTimeout;
249 if ( $this->mTempPath ===
false ) {
254 $this->mTmpHandle = fopen( $this->mTempPath,
'wb' );
255 if ( !$this->mTmpHandle ) {
259 $this->mRemoveTempFile =
true;
260 $this->mFileSize = 0;
263 'followRedirects' =>
true,
265 if ( $wgCopyUploadProxy !==
false ) {
266 $options[
'proxy'] = $wgCopyUploadProxy;
268 if ( $wgCopyUploadTimeout && !isset(
$options[
'timeout'] ) ) {
269 $options[
'timeout'] = $wgCopyUploadTimeout;
272 $req->setCallback(
array( $this,
'saveTempFileChunk' ) );
273 $status = $req->execute();
275 if ( $this->mTmpHandle ) {
277 fclose( $this->mTmpHandle );
278 $this->mTmpHandle =
null;
284 if ( !$status->isOk() ) {
297 if ( $this->mAsync ) {
300 return parent::verifyUpload();
309 if ( $this->mAsync ) {
310 $this->mIgnoreWarnings =
false;
313 return parent::checkWarnings();
323 if ( $this->mAsync ) {
326 return parent::verifyTitlePermissions(
$user );
339 if ( $this->mAsync ) {
345 return parent::performUpload(
$comment, $pageText, $watch,
$user );
358 'url' => $this->mUrl,
360 'pageText' => $pageText,
362 'userName' =>
$user->getName(),
363 'leaveMessage' => $this->mAsync ==
'async-leavemessage',
365 'sessionId' => session_id(),
366 'sessionKey' => $sessionKey,
368 $job->initializeSessionData();
stashSession()
alias for stashFileGetKey, for backwards compatibility
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
fetchFile( $httpOptions=array())
Download the file (if not async)
getTitle()
Returns the title of the file to be uploaded.
static newGood( $value=null)
Factory function for good results.
insertJob( $comment, $pageText, $watch, $user)
verifyUpload()
Wrapper around the parent function in order to defer verifying the upload until the file really has b...
saveTempFileChunk( $req, $buffer)
Callback: save a chunk of the result of a HTTP request to the temporary file.
initialize( $name, $url, $async=false)
Entry point for API upload.
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
Implements uploading from a HTTP resource.
makeTemporaryFile()
Create a new temporary file in the URL subdirectory of wfTempDir().
checkWarnings()
Wrapper around the parent function in order to defer checking warnings until the file really has been...
static isEnabled()
Checks if the upload from URL feature is enabled.
static isValidRequest( $request)
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
reallyFetchFile( $httpOptions=array())
Download the file, save it to the temporary file and update the file size and set $mRemoveTempFile to...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Allows to change the fields on the form that will be generated $name
static factory( $prefix, $extension='')
Make a new temporary file on the file system.
static isAllowedUrl( $url)
Checks whether the URL is not allowed.
Job for asynchronous upload-by-url.
performUpload( $comment, $pageText, $watch, $user)
Wrapper around the parent function in order to defer uploading to the job queue for asynchronous uplo...
verifyTitlePermissions( $user)
Wrapper around the parent function in order to defer checking protection until we are sure that the f...
static isAllowedHost( $url)
Checks whether the URL is for an allowed host The domains in the whitelist can include wildcard chara...
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
initializePathInfo( $name, $tempPath, $fileSize, $removeTempFile=false)
Initialize the path information.
if(count( $args)< 1) $job
static singleton( $wiki=false)
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static isValidURI( $uri)
Checks that the given URI is a valid one.
static isAllowed( $user)
Checks if the user is allowed to use the upload-by-URL feature.
initializeFromRequest(&$request)
Entry point for SpecialUpload.
static factory( $url, $options=null)
Generate a new request object.
static newFatal( $message)
Factory function for fatal errors.