-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.php
More file actions
45 lines (34 loc) · 1.11 KB
/
graph.php
File metadata and controls
45 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
$user_name = $_GET{"user"};
$list_name = $_GET{"list"};
$f_name = $user_name . "." . $list_name;
$dName = $f_name . ".dot";
$userwhite = "/\A([a-zA-Z0-9_]){1,15}\z/";
$listwhite = "/\A([a-zA-Z0-9-_]){1,25}\z/";
if (!(preg_match($userwhite,$user_name,$matches))) {
exit("<p class=\"error\">Invalid user name</p>");
}
if (!(preg_match($listwhite,$list_name,$matches))) {
exit("<p class=\"error\">Invalid list name</p>");
}
if (file_exists($dName)) {
$lines=file($dName);
$dot = implode("",$lines);
header('content-type: image/png');
$url = 'https://chart.googleapis.com/chart?chid='. md5(uniqid(rand(), true));
// Add data, chart type, chart size, and scale to params.
$chart = array(
'cht' => 'gv',
'chl' => $dot);
// Send the request, and print out the returned bytes.
$context = stream_context_create(
array('http' => array(
'method' => 'POST',
'content' => http_build_query($chart)
))
);
fpassthru(fopen($url, 'r', false, $context));
} else {
exit("Image not found");
}
?>