public function getBackgroundColor($subset, $total, $fuzzy = false) { wfSuppressWarnings(); $v = round(255 * $subset / $total); wfRestoreWarnings(); if ($fuzzy) { // Weigh fuzzy with factor 20. $v = $v * 20; if ($v > 255) { $v = 255; } $v = 255 - $v; } if ($v < 128) { // Red to Yellow $red = 'FF'; $green = sprintf('%02X', 2 * $v); } else { // Yellow to Green $red = sprintf('%02X', 2 * (255 - $v)); $green = 'FF'; } $blue = '00'; return $red . $green . $blue; }
private function useMWlock() { global $wgReadOnlyFile, $wgContLang; wfSuppressWarnings(); $fp = fopen($wgReadOnlyFile, 'w'); wfRestoreWarnings(); // wikia change start global $wgUser, $wgCityId; $reason = $this->reason . "\nby " . $wgUser->getName() . ' at ' . $wgContLang->timeanddate(wfTimestampNow()); if (!WikiFactory::setVarByName('wgReadOnly', $wgCityId, $reason) || !WikiFactory::clearCache($wgCityId)) { return Status::newFatal('lockdb-wikifactory-error'); } // wikia change end if (false === $fp) { # This used to show a file not found error, but the likeliest reason for fopen() # to fail at this point is insufficient permission to write to the file...good old # is_writable() is plain wrong in some cases, it seems... return false; } fwrite($fp, $data['Reason']); $timestamp = wfTimestampNow(); fwrite($fp, "\n<p>" . wfMsgExt('lockedbyandtime', array('content', 'parsemag'), $this->getUser()->getName(), $wgContLang->date($timestamp), $wgContLang->time($timestamp)) . "</p>\n"); fclose($fp); return true; }
/** * Delete files in the deleted directory if they are not referenced in the * filearchive table. This needs to be done in the repo because it needs to * interleave database locks with file operations, which is potentially a * remote operation. * * @param $storageKeys array * * @return FileRepoStatus */ function cleanupDeletedBatch($storageKeys) { $root = $this->getZonePath('deleted'); $dbw = $this->getMasterDB(); $status = $this->newGood(); $storageKeys = array_unique($storageKeys); foreach ($storageKeys as $key) { $hashPath = $this->getDeletedHashPath($key); $path = "{$root}/{$hashPath}{$key}"; $dbw->begin(); $inuse = $dbw->selectField('filearchive', '1', array('fa_storage_group' => 'deleted', 'fa_storage_key' => $key), __METHOD__, array('FOR UPDATE')); if (!$inuse) { $sha1 = self::getHashFromKey($key); $ext = substr($key, strcspn($key, '.') + 1); $ext = File::normalizeExtension($ext); $inuse = $dbw->selectField('oldimage', '1', array('oi_sha1' => $sha1, 'oi_archive_name ' . $dbw->buildLike($dbw->anyString(), ".{$ext}"), $dbw->bitAnd('oi_deleted', File::DELETED_FILE) => File::DELETED_FILE), __METHOD__, array('FOR UPDATE')); } if (!$inuse) { wfDebug(__METHOD__ . ": deleting {$key}\n"); wfSuppressWarnings(); $unlink = unlink($path); wfRestoreWarnings(); if (!$unlink) { $status->error('undelete-cleanup-error', $path); $status->failCount++; } } else { wfDebug(__METHOD__ . ": {$key} still in use\n"); $status->successCount++; } $dbw->commit(); } return $status; }
/** * Stream a file to the browser, adding all the headings and fun stuff. * Headers sent include: Content-type, Content-Length, Last-Modified, * and Content-Disposition. * * @param string $fname Full name and path of the file to stream * @param array $headers Any additional headers to send * @param bool $sendErrors Send error messages if errors occur (like 404) * @throws MWException * @return bool Success */ public static function stream($fname, $headers = array(), $sendErrors = true) { wfProfileIn(__METHOD__); if (FileBackend::isStoragePath($fname)) { // sanity wfProfileOut(__METHOD__); throw new MWException(__FUNCTION__ . " given storage path '{$fname}'."); } wfSuppressWarnings(); $stat = stat($fname); wfRestoreWarnings(); $res = self::prepareForStream($fname, $stat, $headers, $sendErrors); if ($res == self::NOT_MODIFIED) { $ok = true; // use client cache } elseif ($res == self::READY_STREAM) { wfProfileIn(__METHOD__ . '-send'); $ok = readfile($fname); wfProfileOut(__METHOD__ . '-send'); } else { $ok = false; // failed } wfProfileOut(__METHOD__); return $ok; }
/** * @param $key * @return Status */ function get($key) { $hashes = array(); foreach ($this->hostNames as $hostName) { $hashes[$hostName] = md5($hostName . $key); } asort($hashes); $errno = $errstr = ''; foreach ($hashes as $hostName => $hash) { if (isset($this->conns[$hostName])) { $this->refCounts[$hostName]++; return Status::newGood($this->conns[$hostName]); } $parts = explode(':', $hostName, 2); if (count($parts) < 2) { $parts[] = 7531; } wfProfileIn(__METHOD__ . '-connect'); wfSuppressWarnings(); $conn = fsockopen($parts[0], $parts[1], $errno, $errstr, $this->timeout); wfRestoreWarnings(); wfProfileOut(__METHOD__ . '-connect'); if ($conn) { break; } } if (!$conn) { return Status::newFatal('poolcounter-connection-error', $errstr); } wfDebug("Connected to pool counter server: {$hostName}\n"); $this->conns[$hostName] = $conn; $this->refCounts[$hostName] = 1; return Status::newGood($conn); }
/** * Constructor * * Creates an SVGReader drawing from the source provided * @param $source String: URI from which to read */ function __construct($source) { global $wgSVGMetadataCutoff; $this->reader = new XMLReader(); // Don't use $file->getSize() since file object passed to SVGHandler::getMetadata is bogus. $size = filesize($source); if ($size === false) { throw new MWException("Error getting filesize of SVG."); } if ($size > $wgSVGMetadataCutoff) { $this->debug("SVG is {$size} bytes, which is bigger than {$wgSVGMetadataCutoff}. Truncating."); $contents = file_get_contents($source, false, null, -1, $wgSVGMetadataCutoff); if ($contents === false) { throw new MWException('Error reading SVG file.'); } $this->reader->XML($contents, null, LIBXML_NOERROR | LIBXML_NOWARNING); } else { $this->reader->open($source, null, LIBXML_NOERROR | LIBXML_NOWARNING); } $this->metadata['width'] = self::DEFAULT_WIDTH; $this->metadata['height'] = self::DEFAULT_HEIGHT; // Because we cut off the end of the svg making an invalid one. Complicated // try catch thing to make sure warnings get restored. Seems like there should // be a better way. wfSuppressWarnings(); try { $this->read(); } catch (Exception $e) { wfRestoreWarnings(); throw $e; } wfRestoreWarnings(); }
function execute() { global $IP, $wgTitle; $siteName = isset($this->mArgs[0]) ? $this->mArgs[0] : "Don't care"; // Will not be set if used with --env-checks $adminName = isset($this->mArgs[1]) ? $this->mArgs[1] : null; $wgTitle = Title::newFromText('Installer script'); $dbpassfile = $this->getOption('dbpassfile', false); if ($dbpassfile !== false) { wfSuppressWarnings(); $dbpass = file_get_contents($dbpassfile); wfRestoreWarnings(); if ($dbpass === false) { $this->error("Couldn't open {$dbpassfile}", true); } $this->mOptions['dbpass'] = trim($dbpass, "\r\n"); } $installer = InstallerOverrides::getCliInstaller($siteName, $adminName, $this->mOptions); $status = $installer->doEnvironmentChecks(); if ($status->isGood()) { $installer->showMessage('config-env-good'); } else { $installer->showStatusMessage($status); return; } if (!$this->hasOption('env-checks')) { $installer->execute(); $installer->writeConfigurationFile($this->getOption('confpath', $IP)); } }
function getLongDesc($image) { global $wgLang; $original = parent::getLongDesc($image); wfSuppressWarnings(); $metadata = unserialize($image->getMetadata()); wfRestoreWarnings(); if (!$metadata || $metadata['frameCount'] <= 0) { return $original; } $info = array(); $info[] = $original; if ($metadata['loopCount'] == 0) { $info[] = wfMsgExt('file-info-png-looped', 'parseinline'); } elseif ($metadata['loopCount'] > 1) { $info[] = wfMsgExt('file-info-png-repeat', 'parseinline', $metadata['loopCount']); } if ($metadata['frameCount'] > 0) { $info[] = wfMsgExt('file-info-png-frames', 'parseinline', $metadata['frameCount']); } if ($metadata['duration']) { $info[] = $wgLang->formatTimePeriod($metadata['duration']); } return $wgLang->commaList($info); }
/** * Check if a tool exist * * @param string $path path to the tool * @return bool */ protected function checkIfToolExists($path) { wfSuppressWarnings(); $result = file_exists($path); wfRestoreWarnings(); return $result; }
public function execute() { if ($this->hasArg()) { $files = $this->mArgs; } else { $this->maybeHelp(true); // @todo fixme this is a lame API :) exit(1); // it should exit from the above first... } $parser = new JSParser(); foreach ($files as $filename) { wfSuppressWarnings(); $js = file_get_contents($filename); wfRestoreWarnings(); if ($js === false) { $this->output("{$filename} ERROR: could not read file\n"); $this->errs++; continue; } try { $parser->parse($js, $filename, 1); } catch (Exception $e) { $this->errs++; $this->output("{$filename} ERROR: " . $e->getMessage() . "\n"); continue; } $this->output("{$filename} OK\n"); } if ($this->errs > 0) { exit(1); } }
function extensionCredits() { global $wgExtensionCredits, $wgExtensionFunctions, $wgSkinExtensionFunction; if (!count($wgExtensionCredits) && !count($wgExtensionFunctions) && !count($wgSkinExtensionFunction)) { return ''; } $extensionTypes = array('specialpage' => 'Special pages', 'parserhook' => 'Parser hooks', 'other' => 'Other'); $out = "\n* Extensions:\n"; foreach ($extensionTypes as $type => $text) { if (count(@$wgExtensionCredits[$type])) { $out .= "** {$text}:\n"; foreach ($wgExtensionCredits[$type] as $extension) { wfSuppressWarnings(); $out .= $this->formatCredits($extension['name'], $extension['version'], $extension['author'], $extension['url'], $extension['description']); wfRestoreWarnings(); } } } if (count($wgExtensionFunctions)) { $out .= "** Extension functions:\n"; $out .= '***' . $this->langObj->listToText($wgExtensionFunctions) . "\n"; } if (count($wgSkinExtensionFunction)) { $out .= "** Skin extension functions:\n"; $out .= '***' . $this->langObj->listToText($wgSkinExtensionFunction) . "\n"; } return $out; }
protected function __construct() { $idFile = wfTempDir() . '/mw-' . __CLASS__ . '-UID-nodeid'; $nodeId = is_file( $idFile ) ? file_get_contents( $idFile ) : ''; // Try to get some ID that uniquely identifies this machine (RFC 4122)... if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) { wfSuppressWarnings(); if ( wfIsWindows() ) { // http://technet.microsoft.com/en-us/library/bb490913.aspx $csv = trim( wfShellExec( 'getmac /NH /FO CSV' ) ); $line = substr( $csv, 0, strcspn( $csv, "\n" ) ); $info = str_getcsv( $line ); $nodeId = isset( $info[0] ) ? str_replace( '-', '', $info[0] ) : ''; } elseif ( is_executable( '/sbin/ifconfig' ) ) { // Linux/BSD/Solaris/OS X // See http://linux.die.net/man/8/ifconfig $m = array(); preg_match( '/\s([0-9a-f]{2}(:[0-9a-f]{2}){5})\s/', wfShellExec( '/sbin/ifconfig -a' ), $m ); $nodeId = isset( $m[1] ) ? str_replace( ':', '', $m[1] ) : ''; } wfRestoreWarnings(); if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) { $nodeId = MWCryptRand::generateHex( 12, true ); $nodeId[1] = dechex( hexdec( $nodeId[1] ) | 0x1 ); // set multicast bit } file_put_contents( $idFile, $nodeId ); // cache } $this->nodeId32 = wfBaseConvert( substr( sha1( $nodeId ), 0, 8 ), 16, 2, 32 ); $this->nodeId48 = wfBaseConvert( $nodeId, 16, 2, 48 ); // If different processes run as different users, they may have different temp dirs. // This is dealt with by initializing the clock sequence number and counters randomly. $this->lockFile88 = wfTempDir() . '/mw-' . __CLASS__ . '-UID-88'; $this->lockFile128 = wfTempDir() . '/mw-' . __CLASS__ . '-UID-128'; }
public function execute() { global $wgRequest, $wgUser, $wgSitename, $wgSitenameshort, $wgCopyrightLink; global $wgCopyright, $wgBootstrap, $wgArticlePath, $wgGoogleAnalyticsID; global $wgSiteCSS; global $wgEnableUploads; global $wgLogo; global $wgTOCLocation; global $wgNavBarClasses; global $wgSubnavBarClasses; $this->skin = $this->data['skin']; $action = $wgRequest->getText('action'); $url_prefix = str_replace('$1', '', $wgArticlePath); // Suppress warnings to prevent notices about missing indexes in $this->data wfSuppressWarnings(); $this->html('headelement'); ?> <div class="ololo-wiki"> <?php $this->header($wgUser); $this->body(); $this->footer(); $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ $this->html('reporttime'); ?> </div> <?php echo Html::closeElement('body'); echo Html::closeElement('html'); wfRestoreWarnings(); }
public function initialize() { $dbr = wfGetDB(DB_MASTER); $res = $dbr->select('categorylinks', array('cl_to', 'COUNT(*) AS count'), array(), __METHOD__, array('GROUP BY' => 'cl_to', 'ORDER BY' => 'count DESC', 'LIMIT' => $this->limit)); wfSuppressWarnings(); // prevent PHP from bitching about strtotime() foreach ($res as $row) { $tag_name = Title::makeTitle(NS_CATEGORY, $row->cl_to); $tag_text = $tag_name->getText(); if (strtotime($tag_text) == '') { // don't want dates to show up if ($row->count > $this->tags_highest_count) { $this->tags_highest_count = $row->count; } $this->tags[$tag_text] = array('count' => $row->count); } } wfRestoreWarnings(); // sort tag array by key (tag name) if ($this->tags_highest_count == 0) { return; } ksort($this->tags); /* and what if we have _1_ category? like on a new wiki with nteen articles, mhm? */ if ($this->tags_highest_count == 1) { $coef = $this->tags_max_pts - $this->tags_min_pts; } else { $coef = ($this->tags_max_pts - $this->tags_min_pts) / (($this->tags_highest_count - 1) * 2); } foreach ($this->tags as $tag => $att) { $this->tags[$tag]['size'] = $this->tags_min_pts + ($this->tags[$tag]['count'] - 1) * $coef; } }
private static function dataDirOKmaybeCreate($dir, $create = false) { if (!is_dir($dir)) { if (!is_writable(dirname($dir))) { $webserverGroup = Installer::maybeGetWebserverPrimaryGroup(); if ($webserverGroup !== null) { return Status::newFatal('config-sqlite-parent-unwritable-group', $dir, dirname($dir), basename($dir), $webserverGroup); } else { return Status::newFatal('config-sqlite-parent-unwritable-nogroup', $dir, dirname($dir), basename($dir)); } } # Called early on in the installer, later we just want to sanity check # if it's still writable if ($create) { wfSuppressWarnings(); $ok = wfMkdirParents($dir, 0700); wfRestoreWarnings(); if (!$ok) { return Status::newFatal('config-sqlite-mkdir-error', $dir); } # Put a .htaccess file in in case the user didn't take our advice file_put_contents("{$dir}/.htaccess", "Deny from all\n"); } } if (!is_writable($dir)) { return Status::newFatal('config-sqlite-dir-unwritable', $dir); } # We haven't blown up yet, fall through return Status::newGood(); }
/** * @access private * @static */ function sendRPC($method, $params = array()) { global $mwBlockerHost, $mwBlockerPort, $mwBlockerDebug; $client = new XML_RPC_Client('/Blocker', $mwBlockerHost, $mwBlockerPort); if ($mwBlockerDebug) { $client->debug = true; } $rpcParams = array_map(array('MWBlocker', 'outParam'), $params); $message = new XML_RPC_Message($method, $rpcParams); wfSuppressWarnings(); $start = wfTime(); $result = $client->send($message); $delta = wfTime() - $start; wfRestoreWarnings(); $debug = sprintf("MWBlocker::sendRPC for %s took %0.2fms\n", $method, $delta * 1000.0); wfDebug($debug); if ($mwBlockerDebug) { echo $debug; } if (!is_object($result)) { throw new MWException("Unknown XML-RPC error"); } elseif ($result->faultCode()) { throw new MWException($result->faultCode() . ': ' . $result->faultString()); } else { $value = $result->value(); return $value->getval(); } }
/** * Establish conncetion * * @access private * * @return bool */ function connect() { wfSuppressWarnings(); $errno = $errstr = ''; $this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30); wfRestoreWarnings(); return !$this->mFP; }
function startSessionIfNotStarted() { \wfSuppressWarnings(); if (!isset($_SESSION)) { session_start(); } \wfRestoreWarnings(); }
/** * Generates a notification that can be easily interpreted by a machine. * @see RCFeedFormatter::getLine */ public function getLine(array $feed, RecentChange $rc, $actionComment) { global $wgCanonicalServer, $wgServerName, $wgScriptPath; $packet = array('id' => $rc->getAttribute('rc_id'), 'type' => RecentChange::parseFromRCType($rc->getAttribute('rc_type')), 'namespace' => $rc->getTitle()->getNamespace(), 'title' => $rc->getTitle()->getPrefixedText(), 'comment' => $rc->getAttribute('rc_comment'), 'timestamp' => (int) wfTimestamp(TS_UNIX, $rc->getAttribute('rc_timestamp')), 'user' => $rc->getAttribute('rc_user_text'), 'bot' => (bool) $rc->getAttribute('rc_bot')); if (isset($feed['channel'])) { $packet['channel'] = $feed['channel']; } $type = $rc->getAttribute('rc_type'); if ($type == RC_EDIT || $type == RC_NEW) { global $wgUseRCPatrol, $wgUseNPPatrol; $packet['minor'] = (bool) $rc->getAttribute('rc_minor'); if ($wgUseRCPatrol || $type == RC_NEW && $wgUseNPPatrol) { $packet['patrolled'] = (bool) $rc->getAttribute('rc_patrolled'); } } switch ($type) { case RC_EDIT: $packet['length'] = array('old' => $rc->getAttribute('rc_old_len'), 'new' => $rc->getAttribute('rc_new_len')); $packet['revision'] = array('old' => $rc->getAttribute('rc_last_oldid'), 'new' => $rc->getAttribute('rc_this_oldid')); break; case RC_NEW: $packet['length'] = array('old' => null, 'new' => $rc->getAttribute('rc_new_len')); $packet['revision'] = array('old' => null, 'new' => $rc->getAttribute('rc_this_oldid')); break; case RC_LOG: $packet['log_id'] = $rc->getAttribute('rc_logid'); $packet['log_type'] = $rc->getAttribute('rc_log_type'); $packet['log_action'] = $rc->getAttribute('rc_log_action'); if ($rc->getAttribute('rc_params')) { wfSuppressWarnings(); $params = unserialize($rc->getAttribute('rc_params')); wfRestoreWarnings(); if ($rc->getAttribute('rc_params') == serialize(false) || $params !== false) { // From ApiQueryLogEvents::addLogParams $logParams = array(); // Keys like "4::paramname" can't be used for output so we change them to "paramname" foreach ($params as $key => $value) { if (strpos($key, ':') === false) { $logParams[$key] = $value; continue; } $logParam = explode(':', $key, 3); $logParams[$logParam[2]] = $value; } $packet['log_params'] = $logParams; } else { $packet['log_params'] = explode("\n", $rc->getAttribute('rc_params')); } } $packet['log_action_comment'] = $actionComment; break; } $packet['server_url'] = $wgCanonicalServer; $packet['server_name'] = $wgServerName; $packet['server_script_path'] = $wgScriptPath ?: '/'; $packet['wiki'] = wfWikiID(); return $this->formatArray($packet); }
/** * Establish conncetion * * @access private */ function connect() { wfSuppressWarnings(); $this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30); wfRestoreWarnings(); if (!$this->mFP) { return false; } return true; }
private static function validateRegex($regex) { wfSuppressWarnings(); $ok = preg_match($regex, ''); wfRestoreWarnings(); if ($ok === false) { return false; } return true; }
function trimStars($str) { $i = $count = 0; wfSuppressWarnings(); while ($str[$i++] == '*') { ++$count; } wfRestoreWarnings(); return array($count, ltrim($str, '* ')); }
/** * @dataProvider provideCases * @covers JavaScriptMinifier::minify */ public function testJavaScriptMinifierOutput($code, $expectedOutput) { $minified = JavaScriptMinifier::minify($code); // JSMin+'s parser will throw an exception if output is not valid JS. // suppression of warnings needed for stupid crap wfSuppressWarnings(); $parser = new JSParser(); wfRestoreWarnings(); $parser->parse($minified, 'minify-test.js', 1); $this->assertEquals($expectedOutput, $minified, "Minified output should be in the form expected."); }
/** * @return mixed */ function getClockTick() { if (self::$clockTick === null) { wfSuppressWarnings(); self::$clockTick = intval(shell_exec('getconf CLK_TCK')); wfRestoreWarnings(); if (!self::$clockTick) { self::$clockTick = 100; } } return self::$clockTick; }
function execute() { // Suppress warnings to prevent notices about missing indexes in $this->data wfSuppressWarnings(); $this->html( 'headelement' ); echo $this->beforeContent(); $this->html( 'bodytext' ); echo "\n"; echo $this->afterContent(); $this->html( 'dataAfterContent' ); $this->printTrail(); echo "\n</body></html>"; wfRestoreWarnings(); }
public function testSchemaNotAvailableReturnValue() { $formatter = new AvroFormatter(array()); $noticeEnabled = PHPUnit_Framework_Error_Notice::$enabled; // disable conversion of notices PHPUnit_Framework_Error_Notice::$enabled = false; // have to keep the user notice from being output wfSuppressWarnings(); $res = $formatter->format(array('channel' => 'marty')); wfRestoreWarnings(); PHPUnit_Framework_Error_Notice::$enabled = $noticeEnabled; $this->assertNull($res); }
public static function isValid($data) { $conf = array('BASIC' => array('class' => 'FileBasedMessageGroup', 'namespace' => 8)); /** * @var FileBasedMessageGroup $group */ $group = MessageGroupBase::factory($conf); wfSuppressWarnings(); $ffs = new IniFFS($group); $parsed = $ffs->readFromVariable($data); wfRestoreWarnings(); return !!count($parsed['MESSAGES']); }
function confExtractArray($php, $varname) { try { $ce = new ConfEditor("<?php {$php}"); $vars = $ce->getVars(); wfSuppressWarnings(); $retval = $vars[$varname]; wfRestoreWarnings(); } catch (Exception $e) { print $e . "\n"; $retval = null; } return $retval; }
/** * 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]; }
public function onSubmit(array $data) { global $wgReadOnlyFile; if (!$data['Confirm']) { return Status::newFatal('locknoconfirm'); } wfSuppressWarnings(); $res = unlink($wgReadOnlyFile); wfRestoreWarnings(); if ($res) { return Status::newGood(); } else { return Status::newFatal('filedeleteerror', $wgReadOnlyFile); } }