-
Notifications
You must be signed in to change notification settings - Fork 0
/
inactivite.php
133 lines (123 loc) · 5.43 KB
/
inactivite.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
<?php
if (!defined('IN_SPYOGAME')) die("Hacking attempt");
global $db,$table_prefix;
$nom_table= $table_prefix."inactivite";
//**********************************************************************************************************
//on recupere la liste des inactifs de la table pour enlever les joueurs qui ne jouent plus, ou qui ne sont plus inactif
//**********************************************************************************************************
//etape 1 suppression des joueurs delete
$request_ogspy_universe = "SELECT distinct inactivite_nom ".
"FROM ".$nom_table." ".
"WHERE inactivite_nom not in ( select distinct player from ".TABLE_UNIVERSE." );";
$result_ogspy_universe = $db->sql_query($request_ogspy_universe);
while(list($inactivite_nom)=$db->sql_fetch_row($result_ogspy_universe)){
$request = "DELETE FROM $nom_table WHERE inactivite_nom = '$inactivite_nom'";
$resultat = $db->sql_query($request);
}
//etape 2 suppression des joueurs qui ne sont plus inactif ou qui sont en mv
$request_ogspy_universe = "select player, last_update, status from ".TABLE_UNIVERSE." ".
"where not(player = '') order by player ;";
$result_ogspy_universe = $db->sql_query($request_ogspy_universe);
$nom_temp = "";
$date = 0;
$old_status = "";
while(list($player, $last_update, $status)=$db->sql_fetch_row($result_ogspy_universe)){
if($nom_temp != $player)
{
//si non inactif on supprime de la table inactif
if($old_status != "i")
{
$request = "DELETE FROM $nom_table WHERE inactivite_nom = '$nom_temp'";
$resultat = $db->sql_query($request);
}
$nom_temp = $player;
$date = 0;
$old_status = $status;
}
else
{
if($date < $last_update)
{
$date = $last_update;
$old_status = $status;
}
}
}
//************************************
//on recherche les joueurs inactifs
//************************************
//il ne faut pas filtrer avec and (status like '%i%') , un joueur peut ne pas etre inactif mais avoir encore des syst marqué i (syst non à jour, ancien i)
$request_ogspy_universe_inactif = "select player, last_update, status from ".TABLE_UNIVERSE." where ".
"not(player = '') order by player;";
$result_ogspy_universe_inactif = $db->sql_query($request_ogspy_universe_inactif);
$date = 0;
$old_status = "";
$nom_temp = "";
//trier par player, il faut chercher le systeme le plus à jour pour avoir le dernier status connu
while(list($player, $last_update, $status)=$db->sql_fetch_row($result_ogspy_universe_inactif)){
if($nom_temp != $player)
{
if($old_status == "i")
{
//si joueur n'est pas dans la table inactivite, on l'insere
$request = "select count(distinct inactivite_nom) from $nom_table where inactivite_nom = '$nom_temp';";
$result = $db->sql_query($request);
list($nb) = $db->sql_fetch_row( $result );
if($nb == 0)
{
if($date == 0)
{
$request = "INSERT INTO $nom_table ( inactivite_nom, inactivite_date ) VALUES ('$nom_temp', '$last_update')";
}
else
{
$request = "INSERT INTO $nom_table ( inactivite_nom, inactivite_date ) VALUES ('$nom_temp', '$date')";
}
$resultat = $db->sql_query($request);
}
}
$nom_temp = $player;
$old_status = $status;
$date = 0;
}
else
{
if($date < $last_update)
{
$date = $last_update;
$old_status = $status;
}
}
}
//***************************************
//on afffiche la table inactivite
//***************************************
$request_inactivite = "select inactivite_id, inactivite_nom, inactivite_date from `$nom_table` order by inactivite_date desc LIMIT 150;";
$result_inactivite = $db->sql_query($request_inactivite);
$ttttttttt = time();
echo "<table style=\"background-color: rgba(0,0,0,0.8);\" cellpudding=0 cellspacing=0 border=1>";
echo "<th>Nom</th>";
if(UNITROUVE) echo "<th>War riders</th>";
echo "<th>Général rank</th><th>Général point</th><th>Militaire rank</th><th>Militaire point</th><th>Date</th><th>nb jours ".help("inactif_nbjours")."</th>";
while(list($index,$nom, $date_inactivite)=$db->sql_fetch_row($result_inactivite)){
$trouve = False;
$ligne = "<tr><td><a href='".SEARCH.$nom."&strict=on'>$nom</a></td>";
if(UNITROUVE) $ligne .="<td><a href='".WARRIDERS.$nom."'>$nom</a></td>";
$individual_ranking = galaxy_show_ranking_unique_player($nom);
//à refaire
while ($ranking = current($individual_ranking)){
$datadate = strftime("%d %b %Y é %Hh", key($individual_ranking));
$general_rank = isset($ranking["general"]) ? formate_number($ranking["general"]["rank"]) : " ";
$general_points = isset($ranking["general"]) ? formate_number($ranking["general"]["points"]) : " ";
$fleet_rank = isset($ranking["military"]) ? formate_number($ranking["military"]["rank"]) : " ";
$fleet_points = isset($ranking["military"]) ? formate_number($ranking["military"]["points"]) : " ";
$ligne.="<td>$general_rank</td><td>$general_points</td><td>$fleet_rank</td><td>$fleet_points</td>";
$trouve = True;
break;
}
if(!$trouve) $ligne.="<td></td><td></td><td></td><td></td>";
$dif = $ttttttttt - $date_inactivite;
$ligne .="<td>".strftime("%d %b %Y à %Hh", $date_inactivite)."</td><td style='text-align:right;'>".(round($dif/(3600*24),1))."</td></tr>";
echo $ligne;
}
echo "</table>";