6b1819d664d1f5d063606449689aa9bb5b9766d3
2 // Copyright 2008 Grégory Burri
4 // This file is part of Euphorik.
6 // Euphorik is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // Euphorik is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
19 // La page d'administation, ne peut être accédée que par les ekMaster (admins)
21 /*jslint laxbreak:true */
24 euphorik
.PageAdmin = function(client
, formatter
, util
, communication
) {
28 this.formatter
= formatter
;
30 this.communication
= communication
;
32 this.comet
= this.communication
.createCometConnection("admin");
34 // a timer which will periodically refresh the banned IP list
35 this.timeoutIDmajIPs
= null;
39 * Interface des pages.
41 euphorik
.PageAdmin
.prototype.contenu = function() {
42 return '<h1>IPs bannies</h1><div id="ips"></div>';
46 * Interface des pages.
48 euphorik
.PageAdmin
.prototype.charger = function() {
57 * Interface des pages.
59 euphorik
.PageAdmin
.prototype.decharger = function() {
60 this.comet
.stopAttenteCourante();
62 // supprime le rafraichissement période des ips
63 if (this.timeoutIDmajIPs
) {
64 clearTimeout(this.timeoutIDmajIPs
);
69 * Met à jour la liste des IP bannies.
71 euphorik
.PageAdmin
.prototype.majIPs = function() {
72 if (this.timeoutIDmajIPs
) {
73 clearTimeout(this.timeoutIDmajIPs
);
76 var thisPageAdmin
= this;
78 this.communication
.requete(
80 {"cookie" : this.client
.cookie
},
83 data
.list
.each(function(i
, ip
) {
84 XHTML
+= '<div class="ban"><span class="ip">' + ip
.ip
+ '</span>|' +
85 '<span class="temps">' +
88 ip
.users
.each(function(j
, user
) {
89 XHTML
+= (j
> 0 ? ", " : "") +
90 '<span class="nick">' + thisPageAdmin
.formatter
.completeProcessing(user
.nick
) + '</span>' +
91 (user
.login
=== "" ? "" : '<span class="login">(' + thisPageAdmin
.formatter
.completeProcessing(user
.login
) + ')</span>');
93 XHTML
+= '<span class="deban">débannir</span></div>';
96 if (data
.list
.length
=== 0) {
97 XHTML
+= '<p>Aucune IP bannie</p>';
100 $("#ips").html(XHTML
);
102 $(".ban").each(function() {
103 var ip
= $(".ip", this).html();
104 $(".deban", this).click(
106 thisPageAdmin
.util
.messageDialog("Êtes-vous sur de vouloir débannir l'IP ''" + ip
+ "'' ?", euphorik
.Util
.messageType
.question
,
107 {"Oui" : function() {
108 thisPageAdmin
.deban(ip
);
117 // rafraichissement toutes les minutes (je sais c'est mal)
118 // le problème est le rafraichissement des temps restant de bannissement qui doit être fait du coté client
119 thisPageAdmin
.timeoutIDmajIPs
= setTimeout(function(){ thisPageAdmin
.majIPs(); }, 60 * 1000);
125 * Débannie une ip donnée.
127 euphorik
.PageAdmin
.prototype.deban = function(ip
) {
128 var thisPageAdmin
= this;
130 this.communication
.requete(
132 {"cookie" : this.client
.cookie
, "ip" : ip
}
137 * Attente d'événement de la part du serveur.
139 euphorik
.PageAdmin
.prototype.waitEvent = function() {
140 var thisPageAdmin
= this;
142 this.comet
.waitEvent(
144 "banned_ips_refresh" : function(data
){ thisPageAdmin
.majIPs(); },
147 thisPage
.util
.messageDialog(data
.error_message
);