• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP UploadBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中UploadBase的典型用法代码示例。如果您正苦于以下问题:PHP UploadBase类的具体用法?PHP UploadBase怎么用?PHP UploadBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UploadBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: onUploadComplete

 public static function onUploadComplete(UploadBase $oForm)
 {
     wfProfileIn(__METHOD__);
     $oLocalFile = $oForm->getLocalFile();
     $oScribeProducer = new ScribeEventProducer('edit');
     if ($oScribeProducer->buildEditPackage(self::$oPage, self::$oUser, self::$oRevision, null, $oLocalFile)) {
         $oScribeProducer->sendLog();
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:ScribeEventProducerController.class.php


示例2: loadRequest

 private function loadRequest($request)
 {
     global $wgUser;
     $this->mRequest = $request;
     $this->mAction = $request->getInt(ADD_RESOURCE_ACTION_FIELD);
     switch ($this->mAction) {
         case ADD_RESOURCE_ACTION_UPLOAD:
             $this->mUpload = UploadBase::createFromRequest($request);
             # used by copied processUpload()
             $this->mUploadClicked = true;
             $this->mComment = $request->getVal('wpUploadDescription');
             break;
         case ADD_RESOURCE_ACTION_SUBPAGE:
             $this->mSubpageDest = $request->getVal('wpSubpageDest');
             break;
         case ADD_RESOURCE_ACTION_LINK:
             $this->mLinkUrl = $request->getVal('wpLinkUrl');
             $this->mLinkTitle = $request->getVal('wpLinkTitle');
             $this->mLinkDesc = $request->getVal('wpLinkDesc');
             break;
         default:
             break;
     }
     $this->mTokenOk = $wgUser->matchEditToken($request->getVal('wpEditToken'));
     $this->mCancelUpload = false;
 }
开发者ID:n0g,项目名称:AddResource,代码行数:26,代码来源:SpecialAddResource.php


示例3: checkPermission

 protected function checkPermission()
 {
     $permissionRequired = UploadBase::isAllowed($this->getUser());
     if ($permissionRequired !== true) {
         throw new PermissionsError($permissionRequired);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:WikiaVideoAdd_body.php


示例4: onSkinTemplateNavigation

 /**
  * Add "replace" button to File pages
  * Add "remove" action to MenuButtons on premium video file pages
  * This button will remove a video from a wiki but keep it on the Video Wiki.
  */
 public static function onSkinTemplateNavigation($skin, &$tabs)
 {
     global $wgUser;
     $app = F::app();
     $title = $app->wg->Title;
     if ($title instanceof Title && $title->getNamespace() == NS_FILE && $title->exists()) {
         $file = wfFindFile($title);
         if ($file instanceof File && UploadBase::userCanReUpload($wgUser, $file->getName())) {
             if (WikiaFileHelper::isFileTypeVideo($file)) {
                 $uploadTitle = SpecialPage::getTitleFor('WikiaVideoAdd');
                 $href = $uploadTitle->getFullURL(array('name' => $file->getName()));
             } else {
                 $uploadTitle = SpecialPage::getTitleFor('Upload');
                 $href = $uploadTitle->getFullURL(array('wpDestFile' => $file->getName(), 'wpForReUpload' => 1));
             }
             $tabs['actions']['replace-file'] = array('class' => 'replace-file', 'text' => wfMessage('file-page-replace-button'), 'href' => $href);
         }
     }
     // Ignore Video Wiki videos beyond this point
     if ($app->wg->CityId == self::VIDEO_WIKI) {
         return true;
     }
     if (WikiaFileHelper::isFileTypeVideo($title)) {
         $file = wfFindFile($title);
         if (!$file->isLocal()) {
             // Prevent move tab being shown.
             unset($tabs['actions']['move']);
         }
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:36,代码来源:FilePageHooks.class.php


示例5: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $context = RequestContext::getMain();
     try {
         $user = $context->getUser();
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         if (count($_SESSION) === 0) {
             // Empty session probably indicates that we didn't associate
             // with the session correctly. Note that being able to load
             // the user does not necessarily mean the session was loaded.
             // Most likely cause by suhosin.session.encrypt = On.
             $this->setLastError("Error associating with user session. " . "Try setting suhosin.session.encrypt = Off");
             return false;
         }
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood()));
         $upload = new UploadFromStash($user);
         // @todo initialize() causes a GET, ideally we could frontload the antivirus
         // checks and anything else to the stash stage (which includes concatenation and
         // the local file is thus already there). That way, instead of GET+PUT, there could
         // just be a COPY operation from the stash to the public zone.
         $upload->initialize($this->params['filekey'], $this->params['filename']);
         // Check if the local file checks out (this is generally a no-op)
         $verification = $upload->verifyUpload();
         if ($verification['status'] !== UploadBase::OK) {
             $status = Status::newFatal('verification-error');
             $status->value = array('verification' => $verification);
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => $status));
             $this->setLastError("Could not verify upload.");
             return false;
         }
         // Upload the stashed file to a permanent location
         $status = $upload->performUpload($this->params['comment'], $this->params['text'], $this->params['watch'], $user);
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => $status));
             $this->setLastError($status->getWikiText());
             return false;
         }
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Success', 'stage' => 'publish', 'filename' => $upload->getLocalFile()->getName(), 'imageinfo' => $imageInfo, 'status' => Status::newGood()));
     } catch (MWException $e) {
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => Status::newFatal('api-error-publishfailed')));
         $this->setLastError(get_class($e) . ": " . $e->getText());
         // To prevent potential database referential integrity issues.
         // See bug 32551.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:59,代码来源:PublishStashedFileJob.php


示例6: isUploadEnabled

 function isUploadEnabled()
 {
     if (\UploadBase::isEnabled() == true) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:mediawiki-extensions,项目名称:mediawiki-page-attachment,代码行数:8,代码来源:AbstractUploadPermissionChecker.php


示例7: isUploadAllowed

 function isUploadAllowed()
 {
     global $wgUser;
     if (\UploadBase::isAllowed($wgUser) == true) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:mediawiki-extensions,项目名称:mediawiki-page-attachment,代码行数:9,代码来源:UploadPermissionChecker_MediaWiki_v1170.php


示例8: uploadImage

 /**
  * Handle image upload
  *
  * Returns array with uploaded files details or error details
  */
 public function uploadImage($uploadFieldName = self::DEFAULT_FILE_FIELD_NAME, $destFileName = null, $forceOverwrite = false)
 {
     global $IP, $wgRequest, $wgUser;
     wfProfileIn(__METHOD__);
     $ret = false;
     // check whether upload is enabled (RT #53714)
     if (!WikiaPhotoGalleryHelper::isUploadAllowed()) {
         $ret = array('error' => true, 'message' => wfMsg('uploaddisabled'));
         wfProfileOut(__METHOD__);
         return $ret;
     }
     $imageName = stripslashes(!empty($destFileName) ? $destFileName : $wgRequest->getFileName($uploadFieldName));
     // validate name and content of uploaded photo
     $nameValidation = $this->checkImageName($imageName, $uploadFieldName);
     if ($nameValidation == UploadBase::SUCCESS) {
         // get path to uploaded image
         $imagePath = $wgRequest->getFileTempName($uploadFieldName);
         // check if image with this name is already uploaded
         if ($this->imageExists($imageName) && !$forceOverwrite) {
             // upload as temporary file
             $this->log(__METHOD__, "image '{$imageName}' already exists!");
             $tempName = $this->tempFileName($wgUser);
             $title = Title::makeTitle(NS_FILE, $tempName);
             $localRepo = RepoGroup::singleton()->getLocalRepo();
             $file = new FakeLocalFile($title, $localRepo);
             $file->upload($wgRequest->getFileTempName($uploadFieldName), '', '');
             // store uploaded image in GarbageCollector (image will be removed if not used)
             $tempId = $this->tempFileStoreInfo($tempName);
             // generate thumbnail (to fit 200x200 box) of temporary file
             $width = min(WikiaPhotoGalleryHelper::thumbnailMaxWidth, $file->width);
             $height = min(WikiaPhotoGalleryHelper::thumbnailMaxHeight, $file->height);
             $thumbnail = $file->transform(array('height' => $height, 'width' => $width));
             // split uploaded file name into name + extension (foo-bar.png => foo-bar + png)
             list($fileName, $extensionsName) = UploadBase::splitExtensions($imageName);
             $extensionName = !empty($extensionsName) ? end($extensionsName) : '';
             $this->log(__METHOD__, 'upload successful');
             $ret = array('conflict' => true, 'name' => $imageName, 'nameParts' => array($fileName, $extensionName), 'tempId' => $tempId, 'size' => array('height' => $file->height, 'width' => $file->width), 'thumbnail' => array('height' => $thumbnail->height, 'url' => $thumbnail->url, 'width' => $thumbnail->width));
         } else {
             // use regular MW upload
             $this->log(__METHOD__, "image '{$imageName}' is new one - uploading as MW file");
             $this->log(__METHOD__, "uploading '{$imagePath}' as File:{$imageName}");
             // create title and file objects for MW image to create
             $imageTitle = Title::newFromText($imageName, NS_FILE);
             $imageFile = new LocalFile($imageTitle, RepoGroup::singleton()->getLocalRepo());
             // perform upload
             $result = $imageFile->upload($imagePath, '', '');
             $this->log(__METHOD__, !empty($result->ok) ? 'upload successful' : 'upload failed');
             $ret = array('success' => !empty($result->ok), 'name' => $imageName, 'size' => array('height' => !empty($result->ok) ? $imageFile->getHeight() : 0, 'width' => !empty($result->ok) ? $imageFile->getWidth() : 0));
         }
     } else {
         $reason = $nameValidation;
         $this->log(__METHOD__, "upload failed - file name is not valid (error #{$reason})");
         $ret = array('error' => true, 'reason' => $reason, 'message' => $this->translateError($reason));
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:62,代码来源:WikiaPhotoGalleryUpload.class.php


示例9: performUpload

 /**
  * Perform the actual upload. Returns a suitable result array on success;
  * dies on failure.
  *
  * @param array $warnings Array of Api upload warnings
  * @return array
  */
 protected function performUpload($warnings)
 {
     // Use comment as initial page text by default
     if (is_null($this->mParams['text'])) {
         $this->mParams['text'] = $this->mParams['comment'];
     }
     /** @var $file File */
     $file = $this->mUpload->getLocalFile();
     // For preferences mode, we want to watch if 'watchdefault' is set or
     // if the *file* doesn't exist and 'watchcreations' is set. But
     // getWatchlistValue()'s automatic handling checks if the *title*
     // exists or not, so we need to check both prefs manually.
     $watch = $this->getWatchlistValue($this->mParams['watchlist'], $file->getTitle(), 'watchdefault');
     if (!$watch && $this->mParams['watchlist'] == 'preferences' && !$file->exists()) {
         $watch = $this->getWatchlistValue($this->mParams['watchlist'], $file->getTitle(), 'watchcreations');
     }
     // Deprecated parameters
     if ($this->mParams['watch']) {
         $watch = true;
     }
     // No errors, no warnings: do the upload
     if ($this->mParams['async']) {
         $progress = UploadBase::getSessionStatus($this->mParams['filekey']);
         if ($progress && $progress['result'] === 'Poll') {
             $this->dieUsage("Upload from stash already in progress.", 'publishfailed');
         }
         UploadBase::setSessionStatus($this->mParams['filekey'], array('result' => 'Poll', 'stage' => 'queued', 'status' => Status::newGood()));
         $ok = JobQueueGroup::singleton()->push(new PublishStashedFileJob(Title::makeTitle(NS_FILE, $this->mParams['filename']), array('filename' => $this->mParams['filename'], 'filekey' => $this->mParams['filekey'], 'comment' => $this->mParams['comment'], 'text' => $this->mParams['text'], 'watch' => $watch, 'session' => $this->getContext()->exportSession())));
         if ($ok) {
             $result['result'] = 'Poll';
         } else {
             UploadBase::setSessionStatus($this->mParams['filekey'], false);
             $this->dieUsage("Failed to start PublishStashedFile.php", 'publishfailed');
         }
     } else {
         /** @var $status Status */
         $status = $this->mUpload->performUpload($this->mParams['comment'], $this->mParams['text'], $watch, $this->getUser());
         if (!$status->isGood()) {
             $error = $status->getErrorsArray();
             if (count($error) == 1 && $error[0][0] == 'async') {
                 // The upload can not be performed right now, because the user
                 // requested so
                 return array('result' => 'Queued', 'statuskey' => $error[0][1]);
             }
             $this->getResult()->setIndexedTagName($error, 'error');
             $this->dieUsage('An internal error occurred', 'internal-error', 0, $error);
         }
         $result['result'] = 'Success';
     }
     $result['filename'] = $file->getName();
     if ($warnings && count($warnings) > 0) {
         $result['warnings'] = $warnings;
     }
     return $result;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:62,代码来源:ApiUpload.php


示例10: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $this->addTeardownCallback(function () use(&$scope) {
         ScopedCallback::consume($scope);
         // T126450
     });
     $context = RequestContext::getMain();
     $user = $context->getUser();
     try {
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood()]);
         $upload = new UploadFromStash($user);
         // @todo initialize() causes a GET, ideally we could frontload the antivirus
         // checks and anything else to the stash stage (which includes concatenation and
         // the local file is thus already there). That way, instead of GET+PUT, there could
         // just be a COPY operation from the stash to the public zone.
         $upload->initialize($this->params['filekey'], $this->params['filename']);
         // Check if the local file checks out (this is generally a no-op)
         $verification = $upload->verifyUpload();
         if ($verification['status'] !== UploadBase::OK) {
             $status = Status::newFatal('verification-error');
             $status->value = ['verification' => $verification];
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => $status]);
             $this->setLastError("Could not verify upload.");
             return false;
         }
         // Upload the stashed file to a permanent location
         $status = $upload->performUpload($this->params['comment'], $this->params['text'], $this->params['watch'], $user, isset($this->params['tags']) ? $this->params['tags'] : []);
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => $status]);
             $this->setLastError($status->getWikiText(false, false, 'en'));
             return false;
         }
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Success', 'stage' => 'publish', 'filename' => $upload->getLocalFile()->getName(), 'imageinfo' => $imageInfo, 'status' => Status::newGood()]);
     } catch (Exception $e) {
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => Status::newFatal('api-error-publishfailed')]);
         $this->setLastError(get_class($e) . ": " . $e->getMessage());
         // To prevent potential database referential integrity issues.
         // See bug 32551.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:55,代码来源:PublishStashedFileJob.php


示例11: verifyUpload

 /**
  * @return array
  */
 public function verifyUpload()
 {
     # Check for a post_max_size or upload_max_size overflow, so that a
     # proper error can be shown to the user
     if (is_null($this->mTempPath) || $this->isEmptyFile()) {
         if ($this->mUpload->isIniSizeOverflow()) {
             return array('status' => UploadBase::FILE_TOO_LARGE, 'max' => min(self::getMaxUploadSize($this->getSourceType()), wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size'))));
         }
     }
     return parent::verifyUpload();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:UploadFromFile.php


示例12: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $context = RequestContext::getMain();
     try {
         $user = $context->getUser();
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         if (count($_SESSION) === 0) {
             // Empty session probably indicates that we didn't associate
             // with the session correctly. Note that being able to load
             // the user does not necessarily mean the session was loaded.
             // Most likely cause by suhosin.session.encrypt = On.
             $this->setLastError("Error associating with user session. " . "Try setting suhosin.session.encrypt = Off");
             return false;
         }
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Poll', 'stage' => 'assembling', 'status' => Status::newGood()));
         $upload = new UploadFromChunks($user);
         $upload->continueChunks($this->params['filename'], $this->params['filekey'], $context->getRequest());
         // Combine all of the chunks into a local file and upload that to a new stash file
         $status = $upload->concatenateChunks();
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'assembling', 'status' => $status));
             $this->setLastError($status->getWikiText());
             return false;
         }
         // We have a new filekey for the fully concatenated file
         $newFileKey = $upload->getLocalFile()->getFileKey();
         // Remove the old stash file row and first chunk file
         $upload->stash->removeFileNoAuth($this->params['filekey']);
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Success', 'stage' => 'assembling', 'filekey' => $newFileKey, 'imageinfo' => $imageInfo, 'status' => Status::newGood()));
     } catch (MWException $e) {
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'assembling', 'status' => Status::newFatal('api-error-stashfailed')));
         $this->setLastError(get_class($e) . ": " . $e->getText());
         // To be extra robust.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:49,代码来源:AssembleUploadChunksJob.php


示例13: loadRequest

 /**
  * Initialize instance variables from request and create an Upload handler
  *
  * @param WebRequest $request The request to extract variables from
  */
 protected function loadRequest($request)
 {
     global $wgUser, $wgMaxUploadFiles;
     // let's make the parent happy
     wfSuppressWarnings();
     $_FILES['wpUploadFile'] = $_FILES['wpUploadFile0'];
     wfRestoreWarnings();
     // Guess the desired name from the filename if not provided
     $this->mDesiredDestNames = array();
     $this->mUploads = array();
     // deal with session keys, if we have some pick the first one, for now
     $vals = $request->getValues();
     $fromsession = false;
     foreach ($vals as $k => $v) {
         if (preg_match("@^wpSessionKey@", $k)) {
             $request->setVal('wpSessionKey', $v);
             $fromsession = true;
             $filenum = preg_replace("@wpSessionKey@", '', $k);
             $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $filenum));
             $up = UploadBase::createFromRequest($request);
             $this->mUploads[] = $up;
             $this->mDesiredDestNames[] = $request->getVal('wpDestFile' . $filenum);
         }
     }
     parent::loadRequest($request);
     $this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning'));
     if (!$fromsession) {
         for ($i = 0; $i < $wgMaxUploadFiles; $i++) {
             $this->mDesiredDestNames[$i] = $request->getText('wpDestFile' . $i);
             if (!$this->mDesiredDestNames[$i] && $request->getFileName('wpUploadFile' . $i) !== null) {
                 $this->mDesiredDestNames[$i] = $request->getFileName('wpUploadFile' . $i);
             }
             wfSuppressWarnings();
             $request->setVal('wpUploadFile', $_FILES['wpUploadFile' . $i]);
             wfRestoreWarnings();
             $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $i));
             move_uploaded_file('wpUploadFile' . $i, 'wpUploadFile');
             wfSuppressWarnings();
             $_FILES['wpUploadFile'] = $_FILES['wpUploadFile' . $i];
             wfRestoreWarnings();
             $up = UploadBase::createFromRequest($request);
             if ($up) {
                 $this->mUploads[] = $up;
             }
         }
     }
     $this->mDesiredDestName = $this->mDesiredDestNames[0];
     $this->mUpload = $this->mUploads[0];
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:54,代码来源:MultiUpload.body.php


示例14: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $this->addTeardownCallback(function () use(&$scope) {
         ScopedCallback::consume($scope);
         // T126450
     });
     $context = RequestContext::getMain();
     $user = $context->getUser();
     try {
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Poll', 'stage' => 'assembling', 'status' => Status::newGood()]);
         $upload = new UploadFromChunks($user);
         $upload->continueChunks($this->params['filename'], $this->params['filekey'], new WebRequestUpload($context->getRequest(), 'null'));
         // Combine all of the chunks into a local file and upload that to a new stash file
         $status = $upload->concatenateChunks();
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'assembling', 'status' => $status]);
             $this->setLastError($status->getWikiText(false, false, 'en'));
             return false;
         }
         // We can only get warnings like 'duplicate' after concatenating the chunks
         $status = Status::newGood();
         $status->value = ['warnings' => $upload->checkWarnings()];
         // We have a new filekey for the fully concatenated file
         $newFileKey = $upload->getStashFile()->getFileKey();
         // Remove the old stash file row and first chunk file
         $upload->stash->removeFileNoAuth($this->params['filekey']);
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Success', 'stage' => 'assembling', 'filekey' => $newFileKey, 'imageinfo' => $imageInfo, 'status' => $status]);
     } catch (Exception $e) {
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'assembling', 'status' => Status::newFatal('api-error-stashfailed')]);
         $this->setLastError(get_class($e) . ": " . $e->getMessage());
         // To be extra robust.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:48,代码来源:AssembleUploadChunksJob.php


示例15: loadFile

 function loadFile($type)
 {
     global $wgRequest, $wgUser;
     $ext = $type;
     $file_name = "Drawio_" . $wgRequest->getVal('drawio') . "." . $ext;
     $wgRequest->setVal('wpDestFile', $file_name);
     $wgRequest->setVal('wpIgnoreWarning', '1');
     $wgRequest->setVal('wpDestFileWarningAck', '1');
     $wgRequest->setVal('wpUploadDescription', "");
     $wgRequest->setVal('action', "");
     if ($type == "png") {
         $file_type = "image/png";
         $pngval = $wgRequest->getVal($type);
         $comma_pos = strpos($pngval, ',');
         if ($comma_pos === false) {
             $file_body = stripslashes($pngval);
         } else {
             $file_body = base64_decode(substr($pngval, $comma_pos + 1));
         }
     } else {
         $file_type = "text/xml";
         $file_body = $wgRequest->getVal($type);
     }
     $file_len = strlen($file_body);
     if ($file_len > 0) {
         $_FILES['wpUploadFile']['name'] = $file_name;
         $_FILES['wpUploadFile']['type'] = $file_type;
         $_FILES['wpUploadFile']['error'] = 0;
         $_FILES['wpUploadFile']['size'] = $file_len;
         // $tmp_name = $_SERVER["DOCUMENT_ROOT"] . "tmp/tmp_".rand(0,1000).rand(0,1000).".".$ext;
         $tmp_name = wfTempDir() . "tmp_" . rand(0, 1000) . rand(0, 1000) . "." . $ext;
         $f = fopen($tmp_name, "w");
         fwrite($f, $file_body);
         fclose($f);
         $_FILES['wpUploadFile']['tmp_name'] = $tmp_name;
         // Upload
         $form = UploadBase::createFromRequest($wgRequest, null);
         $outcome = $form->verifyUpload();
         $res = $form->performUpload("", "", true, $wgUser);
         if (file_exists($tmp_name)) {
             unlink($tmp_name);
         }
     }
     // $outcome['request'] = $wgRequest;
     // $outcome['form'] = $form;
     return $outcome;
 }
开发者ID:tosher,项目名称:wiki_drawio,代码行数:47,代码来源:Drawio.body.php


示例16: wfGetType

/** */
function wfGetType($filename, $safe = true)
{
    global $wgTrivialMimeDetection;
    $ext = strrchr($filename, '.');
    $ext = $ext === false ? '' : strtolower(substr($ext, 1));
    # trivial detection by file extension,
    # used for thumbnails (thumb.php)
    if ($wgTrivialMimeDetection) {
        switch ($ext) {
            case 'gif':
                return 'image/gif';
            case 'png':
                return 'image/png';
            case 'jpg':
                return 'image/jpeg';
            case 'jpeg':
                return 'image/jpeg';
        }
        return 'unknown/unknown';
    }
    $magic = MimeMagic::singleton();
    // Use the extension only, rather than magic numbers, to avoid opening
    // up vulnerabilities due to uploads of files with allowed extensions
    // but disallowed types.
    $type = $magic->guessTypesForExtension($ext);
    /**
     * Double-check some security settings that were done on upload but might 
     * have changed since.
     */
    if ($safe) {
        global $wgFileBlacklist, $wgCheckFileExtensions, $wgStrictFileExtensions, $wgFileExtensions, $wgVerifyMimeType, $wgMimeTypeBlacklist, $wgRequest;
        list($partName, $extList) = UploadBase::splitExtensions($filename);
        if (UploadBase::checkFileExtensionList($extList, $wgFileBlacklist)) {
            return 'unknown/unknown';
        }
        if ($wgCheckFileExtensions && $wgStrictFileExtensions && !UploadBase::checkFileExtensionList($extList, $wgFileExtensions)) {
            return 'unknown/unknown';
        }
        if ($wgVerifyMimeType && in_array(strtolower($type), $wgMimeTypeBlacklist)) {
            return 'unknown/unknown';
        }
    }
    return $type;
}
开发者ID:rocLv,项目名称:conference,代码行数:45,代码来源:StreamFile.php


示例17: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $context = RequestContext::getMain();
     try {
         $user = $context->getUser();
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Poll', 'stage' => 'assembling', 'status' => Status::newGood()));
         $upload = new UploadFromChunks($user);
         $upload->continueChunks($this->params['filename'], $this->params['filekey'], $context->getRequest());
         // Combine all of the chunks into a local file and upload that to a new stash file
         $status = $upload->concatenateChunks();
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'assembling', 'status' => $status));
             $this->setLastError($status->getWikiText());
             return false;
         }
         // We have a new filekey for the fully concatenated file
         $newFileKey = $upload->getLocalFile()->getFileKey();
         // Remove the old stash file row and first chunk file
         $upload->stash->removeFileNoAuth($this->params['filekey']);
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Success', 'stage' => 'assembling', 'filekey' => $newFileKey, 'imageinfo' => $imageInfo, 'status' => Status::newGood()));
     } catch (MWException $e) {
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'assembling', 'status' => Status::newFatal('api-error-stashfailed')));
         $this->setLastError(get_class($e) . ": " . $e->getText());
         return false;
     }
     return true;
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:39,代码来源:AssembleUploadChunksJob.php


示例18: execute

	public function execute() {
		global $wgUser;

		// Check whether upload is enabled
		if ( !UploadBase::isEnabled() ) {
			$this->dieUsageMsg( array( 'uploaddisabled' ) );
		}

		$this->mParams = $this->extractRequestParams();

		$this->validateParams( $this->mParams );

		$request = $this->getMain()->getRequest();
		$this->mUpload = new ResumableUploadHandler;

		$status = $this->mUpload->initialize(
			$request->getVal( 'done', null ),
			$request->getVal( 'offset', null ),
			$request->getVal( 'filename', null ),
			$request->getVal( 'chunksession', null ),
			$request->getFileTempName( 'chunk' ),
			$request->getFileSize( 'chunk' ),
			$request->getSessionData( UploadBase::getSessionKeyname() )
		);

		if ( $status !== true ) {
			$this->dieUsage(  $status, 'chunk-init-error' );
		}

		$ret = $this->performUpload( );

		if(is_array($ret)) {
			foreach($ret as $key => $val) {
				$this->getResult()->addValue(null, $key, $val);
			}
		} else {
			$this->dieUsage($ret, 'error');
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:39,代码来源:ApiResumableUpload.php


示例19: execute3rdPartyVideo

 private function execute3rdPartyVideo($url)
 {
     if (empty(F::app()->wg->allowNonPremiumVideos)) {
         $this->dieUsage('Only premium videos are allowed', 'onlyallowpremium');
     }
     if (!preg_match('/^https?:\\/\\//', $url)) {
         $url = 'http://' . $url;
     }
     try {
         $apiwrapper = ApiWrapperFactory::getInstance()->getApiWrapper($url);
     } catch (Exception $e) {
         $this->dieUsage('There was an issue with ApiWrapper', 'apiwrapper-error');
     }
     if (empty($apiwrapper)) {
         $this->dieUsageMsg('The supplied video does not exist');
     }
     $duplicate = $this->getVideoDuplicate($apiwrapper->getProvider(), $apiwrapper->getVideoId());
     $result = array('provider' => $apiwrapper->getProvider(), 'videoId' => $apiwrapper->getVideoId());
     if ($duplicate) {
         $result['title'] = $duplicate->getTitle()->getText();
         $result['url'] = $duplicate->getUrl();
     } else {
         // Check whether upload is enabled
         if (!UploadBase::isEnabled()) {
             $this->dieUsageMsg('uploaddisabled');
         }
         F::app()->wg->DisableProxy = true;
         $this->mUpload = new UploadFromUrl();
         $this->mUpload->initializeFromRequest(new FauxRequest(array('wpUpload' => 1, 'wpSourceType' => 'web', 'wpUploadFileURL' => $apiwrapper->getThumbnailUrl()), true));
         $this->mUpload->fetchFile();
         $this->checkPermissions();
         $this->verifyUpload();
         $tempFile = $this->createTempFile($this->mUpload->getTempPath());
         $result['title'] = $apiwrapper->getTitle();
         $result['tempUrl'] = $tempFile->getUrl();
         $result['tempName'] = $tempFile->getName();
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:39,代码来源:ApiAddMediaTemporary.php


示例20: topLinks

 function topLinks()
 {
     global $wgOut, $wgUser;
     $sep = " |\n";
     $s = $this->mainPageLink() . $sep . $this->specialLink('Recentchanges');
     if ($wgOut->isArticle()) {
         $s .= $sep . '< 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP UploadField类代码示例发布时间:2022-05-23
下一篇:
PHP Upload类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap