-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats_img.php
111 lines (94 loc) · 2.69 KB
/
stats_img.php
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
require_once('includes/config.php');
require_once('jpgraph/jpgraph.php');
require_once('jpgraph/jpgraph_line.php');
$all = isset($_GET['all']) && $_GET['all'] == 'true' ? true : false;
$type = isset($_GET['type'])?$_GET['type']:0;
switch($type) {
case 1:
$column = array('select');
$text = 'Interviews by Hour';
break;
case 2:
$column = array('nselect');
$text = 'Rejections by Hour';
break;
case 3:
$column = array('email');
$text = 'E-Mail Notifications by Hour';
break;
case 4:
$column = array('sms');
$text = 'SMS Notifications by Hour';
break;
case 5:
$column = array('new');
$text = 'New Users by Hour';
break;
case 6:
$column = array('iau', 'dau');
$text = 'Users by Hour';
$legend = array('Total Users', 'Hourly Active Users');
break;
case 7:
$column = array('tj', 'aj', 'uj');
$text = 'Jobs by Hour';
$legend = array('Total Jobs Tracked', 'Actively Tracked Job Applications', 'Unique Jobs Tracked');
// $fill = true;
break;
default:
die();
}
if(is_array($column)) {
$queries = array();
$graphs = array();
foreach($column as $col) {
if($all) {
$queries[] = mysql_query("SELECT * FROM `log` WHERE `type` = '$col' ORDER BY `log_id` ASC") or die(mysql_error());
} else {
$queries[] = mysql_query("SELECT * FROM (SELECT * FROM `log` WHERE `type` = '$col' ORDER BY `log_id` DESC LIMIT 80) as `tbl` ORDER BY `tbl`.`log_id` ASC") or die(mysql_error());
}
$graphs[] = array('x' => array(), 'y' => array());
}
for($i = 0; $i < count($queries); $i++) {
if(@mysql_num_rows($queries[$i]) > 0) {
while($row = @mysql_fetch_assoc($queries[$i])) {
$graphs[$i]['x'][] = $row['hour'];
$graphs[$i]['y'][] = $row['count'];
}
} else {
die();
}
}
$ngraph = null;
if($all) {
$ngraph = new Graph(1600, 1200);
} else {
$ngraph = new Graph(800, 600);
}
$ngraph->SetScale("textint");
$theme_class = new UniversalTheme;
$ngraph->SetTheme($theme_class);
$ngraph->title->Set($text);
$ngraph->SetBox(false);
$ngraph->yaxis->HideZeroLabel();
$ngraph->yaxis->HideLine(false);
$ngraph->yaxis->HideTicks(false, false);
$ngraph->xgrid->Show();
$ngraph->xgrid->SetLineStyle("solid");
$ngraph->xaxis->SetTickLabels($graphs[0]['x']);
$ngraph->xgrid->SetColor('#E3E3E3');
for($i = 0; $i < count($graphs); $i++) {
$lines[$i] = new LinePlot($graphs[$i]['y']);
$ngraph->Add($lines[$i]);
if(isset($legend)) {
$lines[$i]->SetLegend($legend[$i]);
}
if(isset($fill)) {
$lines[$i]->SetFilled($fill);
}
}
$ngraph->legend->SetFrameWeight(1);
// Output line
$ngraph->Stroke();
}