home support FAQ resources services partners contact us contact us
 Web Application Previous  Next  
 Tutorial

// see if we’ve been invoked with a function string set
if(!isset($function_string))
{
// no, there’s no function string present,
// generate an input form
print(“<html><body>”);
print(“<form action=\””.basename($PHP_SELF).”\” method=\”post\”>”);
print(“Function definition: <input type=\”text\”
➥name=\”function_string\” value=\”(m*x+b)/(x/3)\”><br>”);
print(“Required PHP code: <input type=\”text\” name=\”req_code\”
➥value=\”\$m = 10; \$b = 20;\”><br>”);
print(“<input type=\”submit\” value=\”Parse\”>”);
print(“</form>”);
print(“</body></html>”);
}
else
{
// translate input function to PHP code
$parsed_function = parse_function($function_string);
// *** NOTE: security holes! (see book contents) ***
eval($parsed_function);
// create image
$image = create_image();
// plot the function
for($x = PLOT_MIN; $x < PLOT_MAX; $x += PLOT_STEP)
{
$y = calculate($req_code, $x);
plot($image, $x, $y);
}
// set content type
// header(“Content-type: image/gif”);
header(“Content-type: image/png”);
// send image
// imagegif($image);
imagepng($image);
}
Previous  Next  
Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist