|
From: Micha W. <mw...@gm...> - 2008-01-10 19:51:38
|
Mostafijur Rahman wrote: > I want to plot data using GNUplot and want to show the graph file in the web browser using PHP. I try to do the same with perl. BTW I think its gnuplot and has nothing to do with GNU (see "Does gnuplot have anything to do with the FSF and the GNU project?" <http://www.gnuplot.info/faq/faq.html#SECTION00037000000000000000> 1.7) > Is it possible to plot data in GNUplot from PHP code and show into web browser? You could add "<img src="/cgi-bin/plot.php?sin(x)"/> to your website and create a plot.php that calls gnuplot and make gnuplot output to standard out. Something like: print "Content-Type: image/png\n\n"; print `echo 'set term png; set output; plot sin(x)'|gnuplot`; But there is a HUGE PROBLEM, assume someone enters something like "< rm -rf" (with the quotes) (or ;`rm -rf` or something evil you did not think of yet). Assume futhermore you replace sin(x) with the input of the user (in our case "< rm -rf"), your plot command (which looks like plot "< rm -rf") would then delete files, so there is a HUGE SECURITY ISSUE. The only way of which I know to avoid this is by letting the user select between different functions to plot and have somthing like if input==A then plot sin(x) if input==B then plot cos(x) which is useless since you could create the plots in advance. > If possible please can you tell me how. Please be responsible and do not use the BROKEN CODE above! Micha |