From: <var...@us...> - 2014-10-06 08:55:38
|
Revision: 9189 http://sourceforge.net/p/phpwiki/code/9189 Author: vargenau Date: 2014-10-06 08:55:30 +0000 (Mon, 06 Oct 2014) Log Message: ----------- Invert test Modified Paths: -------------- trunk/lib/plugin/Ploticus.php Modified: trunk/lib/plugin/Ploticus.php =================================================================== --- trunk/lib/plugin/Ploticus.php 2014-10-06 08:49:28 UTC (rev 9188) +++ trunk/lib/plugin/Ploticus.php 2014-10-06 08:55:30 UTC (rev 9189) @@ -205,77 +205,76 @@ function getImage($dbi, $argarray, $request) { $source =& $this->source; - if (!empty($source)) { - if ($this->withShellCommand($source)) { - $this->_errortext .= _("shell commands not allowed in Ploticus"); - return false; - } - if (is_array($argarray['data'])) { // support <!plugin-list !> pagelists - $src = "#proc getdata\ndata:"; - $i = 0; - foreach ($argarray['data'] as $data) { - // hash or array? - if (is_array($data)) - $src .= ("\t" . join(" ", $data) . "\n"); - else - $src .= ("\t" . '"' . $data . '" ' . $i++ . "\n"); - } - $src .= $source; - $source = $src; - } - $tempfile = $this->tempnam('Ploticus', 'plo'); - @unlink($tempfile); - $gif = $argarray['device']; - $args = "-$gif -o $tempfile.$gif"; - if (!empty($argarray['-csmap'])) { - $args .= " -csmap -mapfile $tempfile.map"; - $this->_mapfile = "$tempfile.map"; - } - if (!empty($argarray['-prefab'])) { - //check $_ENV['PLOTICUS_PREFABS'] and default directory - global $HTTP_ENV_VARS; - if (empty($HTTP_ENV_VARS['PLOTICUS_PREFABS'])) { - if (file_exists("/usr/share/ploticus")) - $HTTP_ENV_VARS['PLOTICUS_PREFABS'] = "/usr/share/ploticus"; - elseif (defined('PLOTICUS_PREFABS')) - $HTTP_ENV_VARS['PLOTICUS_PREFABS'] = constant('PLOTICUS_PREFABS'); - } - $args .= (" -prefab " . $argarray['-prefab']); - } - if (isWindows()) { - $fp = fopen("$tempfile.plo", "w"); - fwrite($fp, $source); - fclose($fp); - $code = $this->execute(PLOTICUS_EXE . " $tempfile.plo $args", $tempfile . ".$gif"); - } else { - $code = $this->filterThroughCmd($source, PLOTICUS_EXE . " -stdin $args"); - sleep(1); - } - if (!file_exists($tempfile . ".$gif")) { - $this->_errortext .= sprintf(_("%s error: outputfile “%s” not created"), - "Ploticus", "$tempfile.$gif"); - if (isWindows()) - $this->_errortext .= ("\ncmd-line: " . PLOTICUS_EXE . " $tempfile.plo $args"); + if (empty($source)) { + return $this->error(_("empty source")); + } + if ($this->withShellCommand($source)) { + $this->_errortext .= _("shell commands not allowed in Ploticus"); + return false; + } + if (is_array($argarray['data'])) { // support <!plugin-list !> pagelists + $src = "#proc getdata\ndata:"; + $i = 0; + foreach ($argarray['data'] as $data) { + // hash or array? + if (is_array($data)) + $src .= ("\t" . join(" ", $data) . "\n"); else - $this->_errortext .= ("\ncmd-line: cat script | " . PLOTICUS_EXE . " $args"); - @unlink("$tempfile.pl"); - @unlink("$tempfile"); - return false; + $src .= ("\t" . '"' . $data . '" ' . $i++ . "\n"); } - $ImageCreateFromFunc = "ImageCreateFrom$gif"; - if (function_exists($ImageCreateFromFunc)) { - $handle = $ImageCreateFromFunc("$tempfile.$gif"); - if ($handle) { - @unlink("$tempfile.$gif"); - @unlink("$tempfile.plo"); - @unlink("$tempfile"); - return $handle; - } + $src .= $source; + $source = $src; + } + $tempfile = $this->tempnam('Ploticus', 'plo'); + @unlink($tempfile); + $gif = $argarray['device']; + $args = "-$gif -o $tempfile.$gif"; + if (!empty($argarray['-csmap'])) { + $args .= " -csmap -mapfile $tempfile.map"; + $this->_mapfile = "$tempfile.map"; + } + if (!empty($argarray['-prefab'])) { + //check $_ENV['PLOTICUS_PREFABS'] and default directory + global $HTTP_ENV_VARS; + if (empty($HTTP_ENV_VARS['PLOTICUS_PREFABS'])) { + if (file_exists("/usr/share/ploticus")) + $HTTP_ENV_VARS['PLOTICUS_PREFABS'] = "/usr/share/ploticus"; + elseif (defined('PLOTICUS_PREFABS')) + $HTTP_ENV_VARS['PLOTICUS_PREFABS'] = constant('PLOTICUS_PREFABS'); } - return "$tempfile.$gif"; + $args .= (" -prefab " . $argarray['-prefab']); + } + if (isWindows()) { + $fp = fopen("$tempfile.plo", "w"); + fwrite($fp, $source); + fclose($fp); + $code = $this->execute(PLOTICUS_EXE . " $tempfile.plo $args", $tempfile . ".$gif"); } else { - return $this->error(_("empty source")); + $code = $this->filterThroughCmd($source, PLOTICUS_EXE . " -stdin $args"); + sleep(1); } + if (!file_exists($tempfile . ".$gif")) { + $this->_errortext .= sprintf(_("%s error: outputfile “%s” not created"), + "Ploticus", "$tempfile.$gif"); + if (isWindows()) + $this->_errortext .= ("\ncmd-line: " . PLOTICUS_EXE . " $tempfile.plo $args"); + else + $this->_errortext .= ("\ncmd-line: cat script | " . PLOTICUS_EXE . " $args"); + @unlink("$tempfile.pl"); + @unlink("$tempfile"); + return false; + } + $ImageCreateFromFunc = "ImageCreateFrom$gif"; + if (function_exists($ImageCreateFromFunc)) { + $handle = $ImageCreateFromFunc("$tempfile.$gif"); + if ($handle) { + @unlink("$tempfile.$gif"); + @unlink("$tempfile.plo"); + @unlink("$tempfile"); + return $handle; + } + } + return "$tempfile.$gif"; } // which argument must be set to 'png', for the fallback image when svg will fail on the client. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |