/** * Puts the specified file to Amazon S3 storage * * if $bPublic, the file will be available for all users * if $sMimeType is set then the specified mime tipe is set, otherwise * let AmazonS3 decide on mime type. */ public static function putToAmazonS3($sPath, $bPublic = true, $sMimeType = null) { $time = wfTime(); $sDestination = wfEscapeShellArg('s3://wikia_xml_dumps/' . DumpsOnDemand::getPath(basename($sPath))); $sPath = wfEscapeShellArg($sPath); $sCmd = 'sudo /usr/bin/s3cmd -c /root/.s3cfg --add-header=Content-Disposition:attachment'; if (!is_null($sMimeType)) { $sMimeType = wfEscapeShellArg($sMimeType); $sCmd .= " --mime-type={$sMimeType}"; } $sCmd .= $bPublic ? ' --acl-public' : ''; $sCmd .= " put {$sPath} {$sDestination}"; wfShellExec($sCmd, $iStatus); $time = Wikia::timeDuration(wfTime() - $time); Wikia::log(__METHOD__, "info", "Put {$sPath} to Amazon S3 storage: status: {$iStatus}, time: {$time}", true, true); return $iStatus; }
function showClosedMsg() { global $wgOut, $wgStylePath, $wgExtensionsPath; wfProfileIn(__METHOD__); if ($this->closedWiki === false) { wfProfileOut(__METHOD__); return; } $bShowDumps = false; $aFiles = array(); if (!($this->closedWiki->city_flags & WikiFactory::FLAG_HIDE_DB_IMAGES) && $this->closedWiki->city_lastdump_timestamp >= DumpsOnDemand::S3_MIGRATION) { $dumpInfo = DumpsOnDemand::getLatestDumpInfo($this->closedWiki->city_id); $extension = DumpsOnDemand::getExtensionFromCompression($dumpInfo ? $dumpInfo['compression'] : false); $aFiles = array('pages_current' => "_pages_current.xml{$extension}", 'pages_full' => "_pages_full.xml{$extension}"); foreach ($aFiles as $sKey => $sValue) { $aFiles[$sKey] = $this->mUrlDump . DumpsOnDemand::getPath($this->closedWiki->city_dbname . $sValue); } $bShowDumps = true; } $this->mTmpl->reset(); $this->mTmpl->set_vars(array("wgExtensionsPath" => $wgExtensionsPath, "aDumps" => $aFiles, "bShowDumps" => $bShowDumps, "isDisabled" => $this->closedWiki->city_flags == 0 && $this->closedWiki->city_public == 0)); $wgOut->setPageTitle(wfMsg('closed-wiki')); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setArticleRelated(false); $wgOut->addHtml($this->mTmpl->render("close-info")); wfProfileOut(__METHOD__); }