• R/O
  • SSH
  • HTTPS

y2pukiwiki: Commit


Commit MetaInfo

Revision128 (tree)
Time2010-04-22 14:06:48
Authory2katayama

Log Message

gnuplot.inc.phpを試作

Change Summary

Incremental Difference

--- pukiwiki-1.4.7_notb_utf8/plugin/gnuplot.inc.php (nonexistent)
+++ pukiwiki-1.4.7_notb_utf8/plugin/gnuplot.inc.php (revision 128)
@@ -0,0 +1,40 @@
1+<?php
2+define('PLUGIN_GNUPLOT_PREFIX', 'gnuplot.');
3+define('PLUGIN_GNUPLOT_SUFFIX', '.png');
4+
5+function gnuplot_imagepath($digest)
6+{
7+ return CACHE_DIR.PLUGIN_GNUPLOT_PREFIX.$digest.PLUGIN_GNUPLOT_SUFFIX;
8+}
9+
10+function plugin_gnuplot_action()
11+{
12+ global $vars;
13+
14+ $digest=$vars['image'];
15+ $file = gnuplot_imagepath($digest);
16+ $size = filesize($file);
17+ header('Content-Disposition: inline');
18+ header('Content-Length: '.$size);
19+ header('Content-Type: image/png');
20+ @readfile($file);
21+ exit;
22+}
23+
24+function plugin_gnuplot_convert()
25+{
26+ global $vars;
27+ global $script;
28+
29+ $arg = str_replace('\r','; ',array_pop(func_get_args()));
30+ $digest = md5($arg);
31+ $file = gnuplot_imagepath($digest);
32+ $cmdline = 'echo "set term png; set output \"'.$file.'\"; '.$arg.'" | gnuplot';
33+
34+ system($cmdline);
35+
36+ $ret .= '<div class="gnuplot"><img src="'.$script.'?plugin=gnuplot&image='.$digest.'"/></div>';
37+ $ret .= '<pre>'.$cmdline.'</pre>';
38+ return $ret;
39+}
40+?>
\ No newline at end of file
Show on old repository browser