Extension:Ploticus/pt-br
| AVISO: o código ou a configuração descrita aqui representa um grande risco de segurança.
Problema: aberto para manipulação de arquivos e possíveis ataques a execução de código arbitrário |
|
Estado release: beta |
|
|---|---|
| Implementação | Parser extension, Tag |
| Descrição | |
| Autor(es) | Flavien Scheurer |
| Última versão | 1.0 (2007-10-16) |
| MediaWiki | 1.11.0 |
| Licença | Domínio público |
| Baixar | Extension:Ploticus |
Contents |
Aviso [edit]
Esta extensão remove o #shell e #system functions entre outras funções ploticus que podem produzir arquivos, ler arquivos, etc. Uma combinação destas funções podem permitir que um invasor grave um arquivo, e torná-lo executável, permitindo a execução de código arbitrário. As funções abaixo são algumas das que eu vejo durante uma aparência inicial, através de API:
#proc annotate #proc axis #proc drawcommands #proc getdata #proc page #proc print #proc processdata $tmpfilename(tag) $fileexists( dir, name ) $rename( pathname, newpathname ) $unlink( pathname ) $chmod( pathname, mode ) <-- this is *really* dangerous
Observe que pode haver outros, então se você estiver esterilizando o código, você deve olhar em profundidade!
Ploticus.php [edit]
Essa extensão é inspirado no EasyTimeline e as extensões Gnuplot.
Feita por Flavien Scheurer, outubro de 2007.
Testado em [edit]
- MediaWiki 1.11.0
- Apache 2.2.4 no Windows Server 2003
- PHP 5.2.4
- Não testado em *nix, mas deve funcionar direito mudando o separador de caminho de \ para /.
Requisitos [edit]
Sintaxe [edit]
<ploticus>...</ploticus>
Script manual [edit]
http://ploticus.sourceforge.net/doc/scripthome.html
Instalação [edit]
- Instale Ploticus se for necessário (para evitar espaços em caminho).
- Adicione o seguinte no arquivo LocalSettings.php da sua wiki:
require_once('extensions/Ploticus.php'); $wgPloticusSettings->exePath = 'D:\Ploticus\bin\pl.exe'; $wgPloticusSettings->imageFormat = 'gif';
Ver também [edit]
- Ploticus 1.1 pode ser usado em conjunto com a extensão DynamicPageList que permite gerar gráficos a partir de dados contidos em suas páginas da wiki * Outra versão.
Todo [edit]
- Adicione suporte para os mapas clicáveis.
- Limpeza de arquivos anteriores generaget na pasta Ploticus.
- Adiciona suporte para PNG bonita.
Por favor, note que não estou mais correndo no MediaWiki. Eu mudei a licença para "domínio público". Qualquer pessoa disposta a continuar a trabalhar sobre isto sinta-se livre para fazê-lo.
Aviso [edit]
Projetado com a segurança em mente, mas este é meu primeiro script PHP público e deve ser revisto!
<?php /** * Ploticus.php * Ploticus extension for just-in-time graph generation * This extension is inspired from the EasyTimeline and the Gnuplot extensions. * Created Flavien Scheurer, October 2007, Public domain * * Tested on: * - MediaWiki 1.11.0 * - Apache 2.2.4 on Windows Server 2003 * - PHP 5.2.4 * - Not tested on *nix but should work ok by switching path separator from \ to /. * Requirements: * - Ploticus 2.33 (http://ploticus.sourceforge.net/doc/download.html). * Syntax: * <ploticus>...</ploticus> * Script handbook: * http://ploticus.sourceforge.net/doc/scripthome.html * Installation: * - Install Ploticus if needed (avoid spaces in path). * - Add in LocalSettings.php: * require_once('extensions/Ploticus.php'); * $wgPloticusSettings->exePath = 'D:\Ploticus\bin\pl.exe'; * $wgPloticusSettings->imageFormat = 'gif'; * Todo: * - Add support for clickable maps. * - Cleanup previous generaget files in the Ploticus folder. * - Add support for pretty PNG. * Warning: * - Designed with security in mind, but this is my first public PHP script and should be reviewed! */ if (!defined('MEDIAWIKI')) die(); class PloticusSettings { function PloticusSettings () { // Set path to the Ploticus executable (can be overridden in LocalSettings.php). $this->exePath = 'D:\Ploticus\bin\pl.exe'; // Set the image format (gif by default, png not supported on Windows, svg not supported on IE 6). $this->imageFormat = 'gif'; } } $wgPloticusSettings = new PloticusSettings; $wgExtensionFunctions[] = 'wfPloticusExtension'; $wgExtensionCredits['parserhook'][] = array( 'name' => 'Ploticus', 'version'=> '1.0', 'author' => 'Flavien Scheurer', 'url' => '[[Extension:Ploticus]]', 'description' => 'Ploticus extension for just-in-time graph generation<br/>Syntax is <ploticus>...</ploticus><br/>Script handbook: http://ploticus.sourceforge.net/doc/scripthome.html', ); function wfPloticusExtension() { global $wgParser; $wgParser->setHook('ploticus', 'renderPloticus'); } function renderPloticus( $ploticusData ) { global $wgPloticusSettings, $wgUploadDirectory, $wgUploadPath; // Remove potentially dangerous keywords. $replaces = array('`' => '', 'system' => '', 'shell' => ''); $ploticusData = strtr($ploticusData, $replaces); // Create the image directory. $ploticusDirectory = $wgUploadDirectory . '/ploticus/'; if (!is_dir($ploticusDirectory)) { mkdir($ploticusDirectory, 0777); chmod($ploticusDirectory, 0777); } // Generate a file name based on the hashed ploticus data. $name = md5($ploticusData); $graphFile = $ploticusDirectory . $name . '.' . $wgPloticusSettings->imageFormat; $graphURL = $wgUploadPath . '/ploticus/' . $name . '.' . $wgPloticusSettings->imageFormat; // Check if a previous plot is available. if (!file_exists($graphFile)) { $dataFile = $ploticusDirectory . $name . '.plo'; $errorFile = $ploticusDirectory . $name . '.txt'; // Verify that Ploticus is installed. if (!file_exists($wgPloticusSettings->exePath)) { return ('<p><strong>Error: Could not find Ploticus in <em>' . $wgPloticusSettings->exePath . '</em></strong></p>'); } // Write the ploticus data to a file. $handle = fopen($dataFile, 'w'); fwrite($handle, $ploticusData); fclose($handle); //Set the command line. $commandline = wfEscapeShellArg($wgPloticusSettings->exePath) . ' -' . $wgPloticusSettings->imageFormat . ' ' . wfEscapeShellArg($dataFile) . ' -o ' . wfEscapeShellArg($graphFile) . ' 2>' . wfEscapeShellArg($errorFile); // Execute Ploticus. wfShellExec($commandline); // Read the error messages from the error file. $errorData = file_get_contents($errorFile); // Delete the ploticus data and error files. if (file_exists($dataFile)) { unlink($dataFile);} if (file_exists($errorFile)) { unlink($errorFile);} } // Prepare the output. if ($errorData != '') { return ('<p><strong>Error processing Ploticus data:</strong><br/><pre>' . $errorData . '</pre></p>'); } else { return ('<p><img src="' . $graphURL . '" alt="Ploticus Chart"></p>'); } }
| Língua: | English • português do Brasil |
|---|
