/
stats_bis.php
199 lines (159 loc) · 5.92 KB
/
stats_bis.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
if (file_exists('root.php'))
include_once('root.php');
?><?php
$mail = '';
include_once(root.'class/db.class.php');
include_once(root.'fonction/time.inc.php');
include_once(root.'fonction/action.inc.php');
//Récupère le timestamp en milliseconde de début de création de la page
$debut = getmicrotime();
//Récupération des variables de connexion à la base et connexion à cette base
include_once(root.'connect.php');
//Inclusion du fichier contenant toutes les variables indispensablent
include_once(root.'inc/variable.inc.php');
//Inclusion du fichier contenant toutes les informations sur les races
include_once(root.'inc/race.inc.php');
//Inclusion du fichier contenant toutes les informations sur les classes
include_once(root.'inc/classe.inc.php');
//Inclusion du fichier contenant les traductions
include_once(root.'inc/traduction.inc.php');
//Inclusion du fichier contenant toutes les fonctions de base
include_once(root.'fonction/base.inc.php');
//Inclusion du fichier contenant toutes les fonctions concernant les groupes
include_once(root.'fonction/groupe.inc.php');
//Inclusion du fichier contenant les fonctions permettant de gérer les quètes
include_once(root.'fonction/quete.inc.php');
//Inclusion du fichier contenant les fonctions permettant de gérer l'équipement
include_once(root.'fonction/equipement.inc.php');
//Inclusion du fichier contenant la classe inventaire
include_once(root.'class/inventaire.class.php');
include_once ("jpgraph/src/jpgraph.php");
include_once ("jpgraph/src/jpgraph_pie.php");
include_once ("jpgraph/src/jpgraph_pie3d.php");
include_once ("jpgraph/src/jpgraph_line.php");
include_once ("jpgraph/src/jpgraph_bar.php");
include_once ("jpgraph/src/jpgraph_scatter.php");
include_once ("jpgraph/src/jpgraph_regstat.php");
$date = date("Y-m-d", mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
$root = '';
$data = array();
$legend = array();
$label = array();
$dates = array();
$date = date("Y-m-d");
$requete = "SELECT niveau_moyen, nombre_joueur, nombre_monstre, EXTRACT(YEAR FROM date) as year, EXTRACT(MONTH FROM date) as month, EXTRACT(DAY FROM date) as day FROM stat_jeu WHERE date > DATE_SUB('".$date."', INTERVAL 78 DAY) ORDER BY date;";
$req = $db->query($requete);
$strips = array('id', 'date', 'year', 'day', 'month');
while($row = $db->read_assoc($req))
{
$dates[] = $row['month'].'-'.$row['day'];
$keys = array_keys($row);
$j = 0;
while($j < count($keys))
{
if(!in_array($keys[$j], $strips))
{
$data[$keys[$j]][] = $row[$keys[$j]];
}
$j++;
}
/*$data[] = $row['total'];
$legend[] = $row['race'].'('.$row['total'].')';
$label[] = $row['race']."(".$row['total'].")\n%.1f%%";*/
}
//GRAPHES NBR JOUEURS
$graph = new Graph(900, 400, "auto");
$graph->SetShadow();
$graph->SetMarginColor('white');
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->SetMargin(50,120,30,30);
$graph->tabtitle->Set('Evolution du nombre de joueurs');
//$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,13);
$graph->yaxis->HideZeroLabel();
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$graph->xgrid->Show();
$graph->xaxis->SetTickLabels($dates);
// Create lines
$p1 = new LinePlot($data['nombre_joueur']);
$p1 ->SetWeight(2);
$graph->Add($p1);
$graph->legend->SetShadow('gray@0.4',5);
$graph->legend->SetPos(0, 0.1, "right", "top");
// Output line
$graph->Stroke($root.'image/stat_joueur2.jpg');
//GRAPHES NBR MONSTRES
$graph = new Graph(900, 400, "auto");
$graph->SetShadow();
$graph->SetMarginColor('white');
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->SetMargin(50,120,30,30);
$graph->tabtitle->Set('Evolution du nombre de monstres');
//$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,13);
$graph->yaxis->HideZeroLabel();
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$graph->xgrid->Show();
$graph->xaxis->SetTickLabels($dates);
// Create lines
$p1 = new LinePlot($data['nombre_monstre']);
$p1 ->SetWeight(2);
$graph->Add($p1);
$graph->legend->SetShadow('gray@0.4',5);
$graph->legend->SetPos(0, 0.1, "right", "top");
// Output line
$graph->Stroke($root.'image/stat_monstre2.jpg');
//GRAPHES NBR NIVEAUX MOYEN
$graph = new Graph(900, 400, "auto");
$graph->SetShadow();
$graph->SetMarginColor('white');
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->SetMargin(50,120,30,30);
$graph->tabtitle->Set('Evolution du niveau moyen');
//$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,13);
$graph->yaxis->HideZeroLabel();
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$graph->xgrid->Show();
$graph->xaxis->SetTickLabels($dates);
// Create lines
$p1 = new LinePlot($data['niveau_moyen']);
$p1 ->SetWeight(2);
$graph->Add($p1);
$graph->legend->SetShadow('gray@0.4',5);
$graph->legend->SetPos(0, 0.1, "right", "top");
// Output line
$graph->Stroke($root.'image/stat_niveau_moyen2.jpg');
$data = array();
$legend = array();
$label = array();
$requete = "SELECT race, COUNT(*) as total FROM perso WHERE statut = 'actif' GROUP BY race";
$req = $db->query($requete);
while($row = $db->read_array($req))
{
$data[] = $row['total'];
$legend[] = $Gtrad[$row['race']];
$label[] = $Gtrad[$row['race']]."(".$row['total'].")\n%.1f%%";
}
/* *********************** */
$graph = new Graph(700, 500, "auto");
$graph->SetScale("textlin");
$graph->yaxis->scale->SetGrace(20);
$graph->SetShadow();
$graph->title->Set("Répartition de la population par race le ".$date);
//$graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,13);
$p1 = new BarPlot($data);
$p1->SetShadow();
$p1->SetWidth(0.7);
$p1->value->Show();
//$p1->value->SetFont(FF_ARIAL, FS_BOLD, 10);
//$p1->value->SetAngle(45);
$p1->value->SetFormat('%d');
$graph->Add($p1);
$graph->xaxis->title->Set("Races");
$graph->yaxis->title->Set("Joueurs");
$graph->xaxis->SetTickLabels($legend);
$graph->xaxis->SetLabelAngle(90);
$graph->Stroke('image/stat_race2.jpg');
?>