本文整理汇总了PHP中wfEscapeShellArg函数的典型用法代码示例。如果您正苦于以下问题:PHP wfEscapeShellArg函数的具体用法?PHP wfEscapeShellArg怎么用?PHP wfEscapeShellArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfEscapeShellArg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: doTransform
function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0)
{
global $wgFLVConverters, $wgFLVConverter, $wgFLVConverterPath;
if (!$this->normaliseParams($image, $params)) {
return new TransformParameterError($params);
}
$clientWidth = $params['width'];
$clientHeight = $params['height'];
$physicalWidth = $params['physicalWidth'];
$physicalHeight = $params['physicalHeight'];
$srcPath = $image->getPath();
if ($flags & self::TRANSFORM_LATER) {
return new ThumbnailImage($image, $dstUrl, $clientWidth, $clientHeight, $dstPath);
}
if (!wfMkdirParents(dirname($dstPath), null, __METHOD__)) {
return new MediaTransformError('thumbnail_error', $clientWidth, $clientHeight, wfMsg('thumbnail_dest_directory'));
}
$err = false;
if (isset($wgFLVConverters[$wgFLVConverter])) {
$cmd = str_replace(array('$path/', '$width', '$height', '$input', '$output'), array($wgFLVConverterPath ? wfEscapeShellArg("{$wgFLVConverterPath}/") : "", intval($physicalWidth), intval($physicalHeight), wfEscapeShellArg($srcPath), wfEscapeShellArg($dstPath)), $wgFLVConverters[$wgFLVConverter]) . " 2>&1";
wfProfileIn('rsvg');
wfDebug(__METHOD__ . ": {$cmd}\n");
$err = wfShellExec($cmd, $retval);
wfProfileOut('rsvg');
}
$removed = $this->removeBadFile($dstPath, $retval);
if ($retval != 0 || $removed) {
wfDebugLog('thumbnail', sprintf('thumbnail failed on %s: error %d "%s" from "%s"', wfHostname(), $retval, trim($err), $cmd));
return new MediaTransformError('thumbnail_error', $clientWidth, $clientHeight, $err);
} else {
return new ThumbnailImage($image, $dstUrl, $clientWidth, $clientHeight, $dstPath);
}
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:33,代码来源:FlvImageHandler.php
示例2: addWatermark
function addWatermark($srcPath, $dstPath, $width, $height)
{
global $IP, $wgImageMagickConvertCommand, $wgImageMagickCompositeCommand;
// do not add a watermark if the image is too small
if (WatermarkSupport::validImageSize($width, $height) == false) {
return;
}
$wm = $IP . '/skins/WikiHow/images/watermark.svg';
$watermarkWidth = 1074.447;
$targetWidth = $width / 8;
$density = 72 * $targetWidth / $watermarkWidth;
// we have a lower limit on density so the watermark is readable
if ($density < 4.0) {
$density = 4.0;
}
$cmd = "";
// make sure image is rgb format so the watermark applies correctly
if (WatermarkSupport::isCMYK($srcPath)) {
$cmd = wfEscapeShellArg($wgImageMagickConvertCommand) . " " . wfEscapeShellArg($srcPath) . " " . "-colorspace RGB " . wfEscapeShellArg($dstPath) . ";";
$srcPath = $dstPath;
}
$cmd = $cmd . wfEscapeShellArg($wgImageMagickConvertCommand) . " -density {$density} -background none " . wfEscapeShellArg($wm) . " miff:- | " . wfEscapeShellArg($wgImageMagickCompositeCommand) . " -gravity southeast -quality 100 -geometry +8+10 - " . wfEscapeShellArg($srcPath) . " " . wfEscapeShellArg($dstPath) . " 2>&1";
$beforeExists = file_exists($dstPath);
wfDebug(__METHOD__ . ": running ImageMagick: {$cmd}\n");
$err = wfShellExec($cmd, $retval);
$afterExists = file_exists($dstPath);
$currentDate = `date`;
wfErrorLog(trim($currentDate) . " {$cmd} b:" . ($beforeExists ? 't' : 'f') . " a:" . ($afterExists ? 't' : 'f') . "\n", '/tmp/watermark.log');
wfProfileOut('watermark');
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:30,代码来源:Watermark.php
示例3: onSubmit
public function onSubmit(array $formData)
{
global $IP, $wgCreateWikiSQLfiles;
$DBname = $formData['dbname'];
$founderName = $formData['founder'];
$siteName = $formData['sitename'];
$language = $formData['language'];
$private = $formData['private'];
$reason = $formData['reason'];
$dbw = wfGetDB(DB_MASTER);
$farmerLogEntry = new ManualLogEntry('farmer', 'createwiki');
$farmerLogEntry->setPerformer($this->getUser());
$farmerLogEntry->setTarget($this->getTitle());
$farmerLogEntry->setComment($reason);
$farmerLogEntry->setParameters(array('4::wiki' => $DBname));
$farmerLogID = $farmerLogEntry->insert();
$farmerLogEntry->publish($farmerLogID);
$dbw->query('SET storage_engine=InnoDB;');
$dbw->query('CREATE DATABASE ' . $dbw->addIdentifierQuotes($DBname) . ';');
$dbw->selectDB($DBname);
foreach ($wgCreateWikiSQLfiles as $sqlfile) {
$dbw->sourceFile($sqlfile);
}
$this->writeToDBlist($DBname, $siteName, $language, $private);
$this->createMainPage($language);
$shcreateaccount = exec("/usr/bin/php " . "{$IP}/extensions/CentralAuth/maintenance/createLocalAccount.php " . wfEscapeShellArg($founderName) . " --wiki " . wfEscapeShellArg($DBname));
if (!strpos($shcreateaccount, 'created')) {
wfDebugLog('CreateWiki', 'Failed to create local account for founder. - error: ' . $shcreateaccount);
return wfMessage('createwiki-error-usernotcreated')->escaped();
}
$shpromoteaccount = exec("/usr/bin/php " . "{$IP}/maintenance/createAndPromote.php " . wfEscapeShellArg($founderName) . " --bureaucrat --sysop --force --wiki " . wfEscapeShellArg($DBname));
$this->getOutput()->addHTML('<div class="successbox">' . wfMessage('createwiki-success')->escaped() . '</div>');
return true;
}
开发者ID:reviforks,项目名称:miraheze-cw,代码行数:34,代码来源:SpecialCreateWiki.php
示例4: applyDefaultParameters
/**
* @param array $params
* @param Config $mainConfig
* @return array
*/
public static function applyDefaultParameters(array $params, Config $mainConfig)
{
$logger = LoggerFactory::getInstance('Mime');
$params += ['typeFile' => $mainConfig->get('MimeTypeFile'), 'infoFile' => $mainConfig->get('MimeInfoFile'), 'xmlTypes' => $mainConfig->get('XMLMimeTypes'), 'guessCallback' => function ($mimeAnalyzer, &$head, &$tail, $file, &$mime) use($logger) {
// Also test DjVu
$deja = new DjVuImage($file);
if ($deja->isValid()) {
$logger->info(__METHOD__ . ": detected {$file} as image/vnd.djvu\n");
$mime = 'image/vnd.djvu';
return;
}
// Some strings by reference for performance - assuming well-behaved hooks
Hooks::run('MimeMagicGuessFromContent', [$mimeAnalyzer, &$head, &$tail, $file, &$mime]);
}, 'extCallback' => function ($mimeAnalyzer, $ext, &$mime) {
// Media handling extensions can improve the MIME detected
Hooks::run('MimeMagicImproveFromExtension', [$mimeAnalyzer, $ext, &$mime]);
}, 'initCallback' => function ($mimeAnalyzer) {
// Allow media handling extensions adding MIME-types and MIME-info
Hooks::run('MimeMagicInit', [$mimeAnalyzer]);
}, 'logger' => $logger];
if ($params['infoFile'] === 'includes/mime.info') {
$params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
}
if ($params['typeFile'] === 'includes/mime.types') {
$params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
}
$detectorCmd = $mainConfig->get('MimeDetectorCommand');
if ($detectorCmd) {
$params['detectCallback'] = function ($file) use($detectorCmd) {
return wfShellExec("{$detectorCmd} " . wfEscapeShellArg($file));
};
}
return $params;
}
开发者ID:paladox,项目名称:mediawiki,代码行数:39,代码来源:MimeMagic.php
示例5: callFontConfig
protected static function callFontConfig($code)
{
if (ini_get('open_basedir')) {
wfDebugLog('fcfont', 'Disabled because of open_basedir is active');
// Most likely we can't access any fonts we might find
return false;
}
$cache = self::getCache();
$cachekey = wfMemckey('fcfont', $code);
$timeout = 60 * 60 * 12;
$cached = $cache->get($cachekey);
if (is_array($cached)) {
return $cached;
} elseif ($cached === 'NEGATIVE') {
return false;
}
$code = wfEscapeShellArg(":lang={$code}");
$ok = 0;
$cmd = "fc-match {$code}";
$suggestion = wfShellExec($cmd, $ok);
wfDebugLog('fcfont', "{$cmd} returned {$ok}");
if ($ok !== 0) {
wfDebugLog('fcfont', "fc-match error output: {$suggestion}");
$cache->set($cachekey, 'NEGATIVE', $timeout);
return false;
}
$pattern = '/^(.*?): "(.*)" "(.*)"$/';
$matches = array();
if (!preg_match($pattern, $suggestion, $matches)) {
wfDebugLog('fcfont', "fc-match: return format not understood: {$suggestion}");
$cache->set($cachekey, 'NEGATIVE', $timeout);
return false;
}
list(, $file, $family, $type) = $matches;
wfDebugLog('fcfont', "fc-match: got {$file}: {$family} {$type}");
$file = wfEscapeShellArg($file);
$family = wfEscapeShellArg($family);
$type = wfEscapeShellArg($type);
$cmd = "fc-list {$family} {$type} {$code} file | grep {$file}";
$candidates = trim(wfShellExec($cmd, $ok));
wfDebugLog('fcfont', "{$cmd} returned {$ok}");
if ($ok !== 0) {
wfDebugLog('fcfont', "fc-list error output: {$candidates}");
$cache->set($cachekey, 'NEGATIVE', $timeout);
return false;
}
# trim spaces
$files = array_map('trim', explode("\n", $candidates));
$count = count($files);
if (!$count) {
wfDebugLog('fcfont', "fc-list got zero canditates: {$candidates}");
}
# remove the trailing ":"
$chosen = substr($files[0], 0, -1);
wfDebugLog('fcfont', "fc-list got {$count} candidates; using {$chosen}");
$data = array('family' => $family, 'type' => $type, 'file' => $chosen);
$cache->set($cachekey, $data, $timeout);
return $data;
}
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:59,代码来源:Font.php
示例6: execute
public function execute()
{
global $wgCaptchaSecret, $wgCaptchaDirectoryLevels;
$instance = ConfirmEditHooks::getInstance();
if (!$instance instanceof FancyCaptcha) {
$this->error("\$wgCaptchaClass is not FancyCaptcha.\n", 1);
}
$backend = $instance->getBackend();
$countAct = $instance->estimateCaptchaCount();
$this->output("Estimated number of captchas is {$countAct}.\n");
$countGen = (int) $this->getOption('fill') - $countAct;
if ($countGen <= 0) {
$this->output("No need to generate anymore captchas.\n");
return;
}
$tmpDir = wfTempDir() . '/mw-fancycaptcha-' . time() . '-' . wfRandomString(6);
if (!wfMkdirParents($tmpDir)) {
$this->error("Could not create temp directory.\n", 1);
}
$e = null;
// exception
try {
$cmd = sprintf("python %s --key %s --output %s --count %s --dirs %s", wfEscapeShellArg(__DIR__ . '/../captcha.py'), wfEscapeShellArg($wgCaptchaSecret), wfEscapeShellArg($tmpDir), wfEscapeShellArg($countGen), wfEscapeShellArg($wgCaptchaDirectoryLevels));
foreach (array('wordlist', 'font', 'font-size', 'blacklist', 'verbose') as $par) {
if ($this->hasOption($par)) {
$cmd .= " --{$par} " . wfEscapeShellArg($this->getOption($par));
}
}
$this->output("Generating {$countGen} new captchas...\n");
$retVal = 1;
wfShellExec($cmd, $retVal, array(), array('time' => 0));
if ($retVal != 0) {
wfRecursiveRemoveDir($tmpDir);
$this->error("Could not run generation script.\n", 1);
}
$flags = FilesystemIterator::SKIP_DOTS;
$iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tmpDir, $flags), RecursiveIteratorIterator::CHILD_FIRST);
$this->output("Copying the new captchas to storage...\n");
foreach ($iter as $fileInfo) {
if (!$fileInfo->isFile()) {
continue;
}
list($salt, $hash) = $instance->hashFromImageName($fileInfo->getBasename());
$dest = $instance->imagePath($salt, $hash);
$backend->prepare(array('dir' => dirname($dest)));
$status = $backend->quickStore(array('src' => $fileInfo->getPathname(), 'dst' => $dest));
if (!$status->isOK()) {
$this->error("Could not save file '{$fileInfo->getPathname()}'.\n");
}
}
} catch (Exception $e) {
wfRecursiveRemoveDir($tmpDir);
throw $e;
}
$this->output("Removing temporary files...\n");
wfRecursiveRemoveDir($tmpDir);
$this->output("Done.\n");
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:58,代码来源:GenerateFancyCaptchas.php
示例7: doDBUpdates
public function doDBUpdates()
{
$method = $this->getOption('method', 'normal');
$file = $this->getOption('file');
$t = -microtime(true);
$dbw = wfGetDB(DB_MASTER);
if ($file) {
$res = $dbw->select('image', array('img_name'), array('img_name' => $file), __METHOD__);
if (!$res) {
$this->error("No such file: {$file}", true);
return false;
}
$this->output("Populating img_sha1 field for specified files\n");
} else {
$res = $dbw->select('image', array('img_name'), array('img_sha1' => ''), __METHOD__);
$this->output("Populating img_sha1 field\n");
}
$imageTable = $dbw->tableName('image');
if ($method == 'pipe') {
// @todo FIXME: Kill this and replace with a second unbuffered DB connection.
global $wgDBuser, $wgDBserver, $wgDBpassword, $wgDBname;
$cmd = 'mysql -u' . wfEscapeShellArg($wgDBuser) . ' -h' . wfEscapeShellArg($wgDBserver) . ' -p' . wfEscapeShellArg($wgDBpassword, $wgDBname);
$this->output("Using pipe method\n");
$pipe = popen($cmd, 'w');
}
$numRows = $res->numRows();
$i = 0;
foreach ($res as $row) {
if ($i % $this->mBatchSize == 0) {
$this->output(sprintf("Done %d of %d, %5.3f%% \r", $i, $numRows, $i / $numRows * 100));
wfWaitForSlaves();
}
$file = wfLocalFile($row->img_name);
if (!$file) {
continue;
}
$sha1 = $file->getRepo()->getFileSha1($file->getPath());
if (strval($sha1) !== '') {
$sql = "UPDATE {$imageTable} SET img_sha1=" . $dbw->addQuotes($sha1) . " WHERE img_name=" . $dbw->addQuotes($row->img_name);
if ($method == 'pipe') {
fwrite($pipe, "{$sql};\n");
} else {
$dbw->query($sql, __METHOD__);
}
}
$i++;
}
if ($method == 'pipe') {
fflush($pipe);
pclose($pipe);
}
$t += microtime(true);
$this->output(sprintf("\nDone %d files in %.1f seconds\n", $numRows, $t));
return !$file;
// we only updated *some* files, don't log
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:56,代码来源:populateImageSha1.php
示例8: setup7zCommand
/**
* @param string $file
* @return string
*/
function setup7zCommand($file)
{
$command = "7za a -bd -si -mx=";
$command .= wfEscapeShellArg($this->compressionLevel) . ' ';
$command .= wfEscapeShellArg($file);
// Suppress annoying useless crap from p7zip
// Unfortunately this could suppress real error messages too
$command .= ' >' . wfGetNull() . ' 2>&1';
return $command;
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:14,代码来源:Dump7ZipOutput.php
示例9: testMultipleArgsAsArray
public function testMultipleArgsAsArray()
{
if (wfIsWindows()) {
$expected = '"foo" "bar" "baz"';
} else {
$expected = "'foo' 'bar' 'baz'";
}
$actual = wfEscapeShellArg(['foo', 'bar', 'baz']);
$this->assertEquals($expected, $actual);
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:10,代码来源:wfEscapeShellArgTest.php
示例10: renderGnuplot
function renderGnuplot($gnuplotsrc)
{
global $wgGnuplotDefaultTerminal, $wgGnuplotDefaultSize, $wgGnuplotCommand;
global $wgUploadDirectory, $wgUploadPath;
// filter out harmfull system commands to close a security hole
$replaces = array("`" => "", "system" => "", "shell" => "");
$gnuplotsrc = strtr($gnuplotsrc, $replaces);
// create directory for storing the plot
$gnuplotDir = "/gnuplot/";
$dest = $wgUploadDirectory . $gnuplotDir;
if (!is_dir($dest)) {
mkdir($dest, 0777);
chmod($dest, 0777);
}
// get the name of the graph to be produced
$name = getOutputName($gnuplotsrc);
$graphname = $dest . $name;
$fname = $graphname . ".tmp";
// write the default settings and the input code from wiki into a
// temporary file to be executed by gnuplot, then execute the command
if (!(file_exists($fname) || file_exists($fname . '.err'))) {
$handle = fopen($fname, 'x');
if ($handle === FALSE) {
// not sure what to do here, this shouldn't happen
return '<p><b><img src="' . htmlspecialchars($wgUploadPath . $gnuplotDir . $name) . '" alt="Gnuplot Plot"></b></p>';
}
// if terminal and size are not set in the gnuplot source we do it here
if (strpos($gnuplotsrc, 'set terminal ') === false) {
fwrite($handle, $wgGnuplotDefaultTerminal . "\n");
}
if (strpos($gnuplotsrc, 'set size ') === false) {
fwrite($handle, $wgGnuplotDefaultSize . "\n");
}
// Need to find each occurance of src:<FILE NAME> and replace it
// with the complete file path
while (strpos($gnuplotsrc, 'src:') != false) {
$srcStartPosition = strpos($gnuplotsrc, 'src:') + strlen("src:");
$srcEndPosition = strpos($gnuplotsrc, ' ', $srcStartPosition);
$tmpString = substr($gnuplotsrc, $srcStartPosition, $srcEndPosition - $srcStartPosition - 1);
$srcFileNamePath = getSourceDataPath($tmpString);
$gnuplotsrc = str_replace("src:{$tmpString}", $srcFileNamePath, $gnuplotsrc);
}
fwrite($handle, "\nset output '" . $graphname . "'\n");
// Remove the 'set output' command from the source as we will set it.
$gnuplotsrc = preg_replace('/^set output.*$/m', '', $gnuplotsrc);
fwrite($handle, $gnuplotsrc . "\n");
fclose($handle);
$cmdlinePlot = wfEscapeShellArg($wgGnuplotCommand) . ' ' . wfEscapeShellArg($fname);
shell_exec($cmdlinePlot);
// some cleanup
unlink($fname);
}
return '<p><b><img src="' . htmlspecialchars($wgUploadPath . $gnuplotDir . $name) . '" alt="Gnuplot Plot"></b></p>';
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:54,代码来源:Gnuplot.php
示例11: execute
public function execute()
{
$method = $this->getOption('method', 'normal');
$file = $this->getOption('file');
$t = -microtime(true);
$dbw = wfGetDB(DB_MASTER);
if ($file) {
$res = $dbw->selectRow('image', array('img_name'), array('img_name' => $dbw->addQuotes($file)), __METHOD__);
if (!$res) {
$this->error("No such file: {$file}", true);
return;
}
} else {
$res = $dbw->select('image', array('img_name'), array('img_sha1' => ''), __METHOD__);
}
$imageTable = $dbw->tableName('image');
$oldimageTable = $dbw->tableName('oldimage');
$batch = array();
if ($method == 'pipe') {
// @fixme kill this and replace with a second unbuffered DB connection.
global $wgDBuser, $wgDBserver, $wgDBpassword, $wgDBname;
$cmd = 'mysql -u' . wfEscapeShellArg($wgDBuser) . ' -h' . wfEscapeShellArg($wgDBserver) . ' -p' . wfEscapeShellArg($wgDBpassword, $wgDBname);
$this->output("Using pipe method\n");
$pipe = popen($cmd, 'w');
}
$numRows = $res->numRows();
$i = 0;
foreach ($res as $row) {
if ($i % 100 == 0) {
$this->output(sprintf("Done %d of %d, %5.3f%% \r", $i, $numRows, $i / $numRows * 100));
wfWaitForSlaves(5);
}
$file = wfLocalFile($row->img_name);
if (!$file) {
continue;
}
$sha1 = File::sha1Base36($file->getPath());
if (strval($sha1) !== '') {
$sql = "UPDATE {$imageTable} SET img_sha1=" . $dbw->addQuotes($sha1) . " WHERE img_name=" . $dbw->addQuotes($row->img_name);
if ($method == 'pipe') {
fwrite($pipe, "{$sql};\n");
} else {
$dbw->query($sql, __METHOD__);
}
}
$i++;
}
if ($method == 'pipe') {
fflush($pipe);
pclose($pipe);
}
$t += microtime(true);
$this->output(sprintf("\nDone %d files in %.1f seconds\n", $numRows, $t));
}
开发者ID:amjadtbssm,项目名称:website,代码行数:54,代码来源:populateSha1.php
示例12: renderGraphviz
function renderGraphviz($timelinesrc)
{
global $wgUploadDirectory, $wgUploadPath, $IP, $wgGraphVizSettings, $wgArticlePath, $wgTmpDirectory;
$hash = md5($timelinesrc);
$dest = $wgUploadDirectory . "/graphviz/";
if (!is_dir($dest)) {
mkdir($dest, 0777);
}
if (!is_dir($wgTmpDirectory)) {
mkdir($wgTmpDirectory, 0777);
}
$fname = $dest . $hash;
// echo $fname;
if (!(file_exists($fname . ".png") || file_exists($fname . ".err"))) {
$handle = fopen($fname, "w");
fwrite($handle, $timelinesrc);
fclose($handle);
$cmdline = wfEscapeShellArg($wgGraphVizSettings->dotCommand) . " -Tpng -o " . wfEscapeShellArg($fname . ".png") . " " . wfEscapeShellArg($fname);
$cmdlinemap = wfEscapeShellArg($wgGraphVizSettings->dotCommand) . " -Tcmapx -o " . wfEscapeShellArg($fname . ".map") . " " . wfEscapeShellArg($fname);
// echo $cmdline;
// exit;
// break;
// echo "ADIOS";
$ret = `{$cmdline}`;
$ret = `{$cmdlinemap}`;
unlink($fname);
/*
if ( $ret == "" ) {
// Message not localized, only relevant during install
return "<div id=\"toc\"><tt>Timeline error: Executable not found. Command line was: {$cmdline}</tt></div>";
}
*/
}
@($err = file_get_contents($fname . ".err"));
if ($err != "") {
$txt = "<div id=\"toc\"><tt>{$err}</tt></div>";
} else {
//echo $fname.".map";
@($map = file_get_contents($fname . ".map"));
//echo "mapa-antes:".$map;
$map = preg_replace("#<ma(.*)>#", " ", $map);
$map = str_replace("</map>", "", $map);
//echo "mapa:".$map;
if (substr(php_uname(), 0, 7) == "Windows") {
$ext = "gif";
} else {
$ext = "png";
}
$txt = "<map name=\"{$hash}\">{$map}</map>" . "<img usemap=\"#{$hash}\" src=\"{$wgUploadPath}/graphviz/{$hash}.{$ext}\">";
}
return $txt;
}
开发者ID:xmaryposax,项目名称:GetTheLead,代码行数:52,代码来源:Graphviz.php
示例13: renderTimeline
function renderTimeline($timelinesrc)
{
global $wgUploadDirectory, $wgUploadPath, $IP, $wgTimelineSettings, $wgArticlePath, $wgTmpDirectory;
$hash = md5($timelinesrc);
$dest = $wgUploadDirectory . "/timeline/";
if (!is_dir($dest)) {
mkdir($dest, 0777);
}
if (!is_dir($wgTmpDirectory)) {
mkdir($wgTmpDirectory, 0777);
}
$fname = $dest . $hash;
$previouslyFailed = file_exists($fname . ".err");
$previouslyRendered = file_exists($fname . ".png");
$expired = $previouslyRendered && filemtime($fname . ".png") < wfTimestamp(TS_UNIX, $wgTimelineSettings->epochTimestamp);
if ($expired || !$previouslyRendered && !$previouslyFailed) {
$handle = fopen($fname, "w");
fwrite($handle, $timelinesrc);
fclose($handle);
$cmdline = wfEscapeShellArg($wgTimelineSettings->perlCommand, $wgTimelineSettings->timelineFile) . " -i " . wfEscapeShellArg($fname) . " -m -P " . wfEscapeShellArg($wgTimelineSettings->ploticusCommand) . " -T " . wfEscapeShellArg($wgTmpDirectory) . " -A " . wfEscapeShellArg($wgArticlePath);
$ret = `{$cmdline}`;
unlink($fname);
if ($ret == "") {
// Message not localized, only relevant during install
return "<div id=\"toc\"><tt>Timeline error: Executable not found. Command line was: {$cmdline}</tt></div>";
}
}
@($err = file_get_contents($fname . ".err"));
if ($err != "") {
$txt = "<div id=\"toc\"><tt>{$err}</tt></div>";
} else {
@($map = file_get_contents($fname . ".map"));
if (substr(php_uname(), 0, 7) == "Windows") {
$ext = "gif";
} else {
$ext = "png";
}
$url = "{$wgUploadPath}/timeline/{$hash}.{$ext}";
$txt = "<map name=\"{$hash}\">{$map}</map>" . "<img usemap=\"#{$hash}\" src=\"{$url}\">";
if ($expired) {
// Replacing an older file, we may need to purge the old one.
global $wgUseSquid;
if ($wgUseSquid) {
$u = new SquidUpdate(array($url));
$u->doUpdate();
}
}
}
return $txt;
}
开发者ID:akoehn,项目名称:wikireader,代码行数:50,代码来源:Timeline.php
示例14: tryFfmpegThumb
static function tryFfmpegThumb( $options ){
global $wgFFmpegLocation;
$cmd = wfEscapeShellArg( $wgFFmpegLocation );
$offset = intval( self::getThumbTime( $options ) );
/*
This is a workaround until ffmpegs ogg demuxer properly seeks to keyframes.
Seek 2 seconds before offset and seek in decoded stream after that.
-ss before input seeks without decode
-ss after input seeks in decoded stream
*/
if($offset > 2) {
$cmd .= ' -ss ' . ($offset - 2);
$offset = 2;
}
$srcPath = $options['file']->getLocalRefPath();
$cmd .= ' -y -i ' . wfEscapeShellArg( $srcPath );
$cmd .= ' -ss ' . $offset . ' ';
// Set the output size if set in options:
if( isset( $options['width'] ) && isset( $options['height'] ) ){
$cmd.= ' -s '. intval( $options['width'] ) . 'x' . intval( $options['height'] );
}
# MJPEG, that's the same as JPEG except it's supported by the windows build of ffmpeg
# No audio, one frame
$cmd .= ' -f mjpeg -an -vframes 1 ' .
wfEscapeShellArg( $options['dstPath'] ) . ' 2>&1';
$retval = 0;
$returnText = wfShellExec( $cmd, $retval );
// Check if it was successful
if ( !$options['file']->getHandler()->removeBadFile( $options['dstPath'], $retval ) ) {
return true;
}
// Filter nonsense
$lines = explode( "\n", str_replace( "\r\n", "\n", $returnText ) );
if ( substr( $lines[0], 0, 6 ) == 'FFmpeg' ) {
for ( $i = 1; $i < count( $lines ); $i++ ) {
if ( substr( $lines[$i], 0, 2 ) != ' ' ) {
break;
}
}
$lines = array_slice( $lines, $i );
}
// Return error box
return new MediaTransformError( 'thumbnail_error', $options['width'], $options['height'], implode( "\n", $lines ) );
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:49,代码来源:TimedMediaThumbnail.php
示例15: execute
public function execute() {
$max_words = intval( $this->getOption( 'maxwords', 10000 ) );
$indexer = wfEscapeShellArg( $this->getOption( 'indexer', 'indexer' ) );
$index = wfEscapeShellArg( $this->getOption( 'useindex', 'wiki_main' ) );
$conf = wfEscapeShellArg( $this->getOption( 'spinxconf' ) );
$cmd = "$indexer --config $conf $index --buildstops sphinx.dic $max_words";
$this->output( wfShellExec( $cmd, $retval ) );
if ( file_exists( 'sphinx.dic' ) ) {
$words = file('sphinx.dic');
$cnt = count($words);
if ($cnt) {
file_put_contents( 'sphinx.dic', $cnt . "\n" . join( '', $words ) );
file_put_contents( 'sphinx.aff', "SET UTF-8\n" );
}
}
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:17,代码来源:SphinxSearch_setup.php
示例16: runLatex
function runLatex($text, $command, $ext)
{
global $wgOut, $IP;
// Filter out obvious insecure control sequences
$text = preg_replace("/\\\\(input|openin|openout|read|write|escapechar)/", '\\begin{math}\\backslash\\end{math}\\1', $text);
// Get path
if (!is_dir($this->workingDir)) {
if (!mkdir($this->workingDir, 0777)) {
$wgOut->addWikiText(wfMsg('latexdoc_cant_create_dir', $this->workingDir));
return;
}
}
$hash = md5($text);
$fn = $this->workingDir . '/' . 'ltd_' . $hash;
$url = $this->workingPath . '/' . 'ltd_' . $hash;
if (!file_exists("{$fn}.{$ext}")) {
// Write input file
$inFile = fopen("{$fn}.tex", 'w');
if (!$inFile) {
$wgOut->addWikiText(wfMsg('latexdoc_cant_write', "{$fn}.tex"));
return;
}
fwrite($inFile, $text);
fclose($inFile);
// Run LaTeX
$cmd = $command . ' -interaction=batchmode -quiet ' . '\\input ' . wfEscapeShellArg("{$fn}.tex") . ' 2>&1';
chdir($this->workingDir);
$errorText = shell_exec($cmd);
chdir($IP);
// Report errors
if (!file_exists("{$fn}.{$ext}")) {
wfSuppressWarnings();
$log = '<pre>' . file_get_contents("{$fn}.log") . '</pre>';
wfRestoreWarnings();
$wgOut->addWikiText(wfMsg('latexdoc_error', $cmd, $errorText, $log));
return;
}
}
// Redirect to output file
$wgOut->redirect("{$url}.{$ext}");
// Delete temporary files
@unlink("{$fn}.tex");
@unlink("{$fn}.aux");
@unlink("{$fn}.log");
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:45,代码来源:LatexDoc.php
示例17: rasterize
public function rasterize($srcPath, $dstPath, $width, $height)
{
global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath;
$err = false;
if (isset($wgSVGConverters[$wgSVGConverter])) {
$cmd = str_replace(array('$path/', '$width', '$height', '$input', '$output'), array($wgSVGConverterPath ? wfEscapeShellArg("{$wgSVGConverterPath}/") : "", intval($width), intval($height), wfEscapeShellArg($srcPath), wfEscapeShellArg($dstPath)), $wgSVGConverters[$wgSVGConverter]) . " 2>&1";
wfProfileIn('rsvg');
wfDebug(__METHOD__ . ": {$cmd}\n");
$err = wfShellExec($cmd, $retval);
wfProfileOut('rsvg');
}
$removed = $this->removeBadFile($dstPath, $retval);
if ($retval != 0 || $removed) {
wfDebugLog('thumbnail', sprintf('thumbnail failed on %s: error %d "%s" from "%s"', wfHostname(), $retval, trim($err), $cmd));
return new MediaTransformError('thumbnail_error', $width, $height, $err);
}
return true;
}
开发者ID:amjadtbssm,项目名称:website,代码行数:18,代码来源:SVG.php
示例18: stream_open
function stream_open($path, $mode, $options, &$opened_path)
{
if ($mode[0] == 'r') {
$options = 'e -bd -so';
} elseif ($mode[0] == 'w') {
$options = 'a -bd -si';
} else {
return false;
}
$arg = wfEscapeShellArg($this->stripPath($path));
$command = "7za {$options} {$arg}";
if (!wfIsWindows()) {
// Suppress the stupid messages on stderr
$command .= ' 2>/dev/null';
}
$this->stream = popen($command, $mode);
return $this->stream !== false;
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:18,代码来源:dumpTextPass.php
示例19: getParseTree
/**
* Execute a shell command to obtain the parse tree of a string of wikitext
*
* @param String wikitext
* @return Array ret Array of two keys, 'contents' with script output, 'errors' with errors if any.
*/
public function getParseTree($text)
{
global $wgVisualEditorParserCmd, $wgServer, $wgScriptPath;
// TODO This is probably not very portable to non-Unix OS. There's a lot of code in wfShellExec to make
// that portable and secure on Windows etc. In any case the existing PHP-based parser calls out to an external script to do
// HTML-tidy anyway, in a similar manner, without any shell escapes...
$cmd = join(" ", array($wgVisualEditorParserCmd, '--wgScriptPath', wfEscapeShellArg($wgServer . $wgScriptPath)));
$parserIn = 0;
$parserOut = 1;
$parserErr = 2;
$descriptorSpec = array($parserIn => array('pipe', 'r'), $parserOut => array('pipe', 'w'), $parserErr => array('pipe', 'w'));
$pipes = array();
$process = proc_open($cmd, $descriptorSpec, $pipes);
$ret = array('contents' => null);
if (is_resource($process)) {
// Theoretically, this style of communication could cause a deadlock
// here. If the stdout buffer fills up, then writes to stdin could
// block.
//
// TODO This might be an opportune time to give the parser all the subtemplates it's going to need,
// such that we can. The DB does have a mapping of title to templates used.
// Would need a convention for indicating multiple files in the text we write to the parser, like mime multipart
fwrite($pipes[$parserIn], $text);
fclose($pipes[$parserIn]);
$ret['contents'] = FormatJson::decode(self::readFilehandle($pipes[$parserOut]));
$errors = self::readFilehandle($pipes[$parserErr]);
if ($errors != '' and $errors != null) {
$ret['errors'] = $errors;
}
$retval = proc_close($process);
if ($retval != 0) {
wfWarn("Parser process returned {$retval}");
if (!$ret['errors']) {
$ret['errors'] = 'External parser process returned error code, check server logs';
}
}
} else {
wfWarn("Unable to start external parser process");
$ret['errors'] = "Unable to start external parser process, check server logs";
}
return $ret;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:48,代码来源:ApiQueryParseTree.php
示例20: rotate
/**
* @param $file File
* @param array $params Rotate parameters.
* 'rotation' clockwise rotation in degrees, allowed are multiples of 90
* @since 1.21
* @return bool
*/
public function rotate($file, $params)
{
global $wgJpegTran;
$rotation = ($params['rotation'] + $this->getRotation($file)) % 360;
if ($wgJpegTran && is_file($wgJpegTran)) {
$cmd = wfEscapeShellArg($wgJpegTran) . " -rotate " . wfEscapeShellArg($rotation) . " -outfile " . wfEscapeShellArg($params['dstPath']) . " " . wfEscapeShellArg($params['srcPath']) . " 2>&1";
wfDebug(__METHOD__ . ": running jpgtran: {$cmd}\n");
wfProfileIn('jpegtran');
$retval = 0;
$err = wfShellExec($cmd, $retval, $env);
wfProfileOut('jpegtran');
if ($retval !== 0) {
$this->logErrorForExternalProcess($retval, $err, $cmd);
return new MediaTransformError('thumbnail_error', 0, 0, $err);
}
return false;
} else {
return parent::rotate($file, $params);
}
}
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:27,代码来源:Jpeg.php
注:本文中的wfEscapeShellArg函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论