REPORT de la branche 1.0 (tag 1.0.1)
[euphorik.git] / modules / erl / euphorik_requests.erl
index f8dad51..28019da 100755 (executable)
@@ -1,31 +1,42 @@
 % coding: utf-8\r
+% Copyright 2008 Grégory Burri\r
+%\r
+% This file is part of Euphorik.\r
+%\r
+% Euphorik is free software: you can redistribute it and/or modify\r
+% it under the terms of the GNU General Public License as published by\r
+% the Free Software Foundation, either version 3 of the License, or\r
+% (at your option) any later version.\r
+%\r
+% Euphorik is distributed in the hope that it will be useful,\r
+% but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+% GNU General Public License for more details.\r
+%\r
+% You should have received a copy of the GNU General Public License\r
+% along with Euphorik.  If not, see <http://www.gnu.org/licenses/>.\r
+% \r
 % Ce module est fait pour répondre à des requêtes 'AJAX'.\r
 % Il est définit comme 'appmods' pour l'url "request" dans yaws.\r
 % Par exemple http://www.euphorik.ch/request abouti sur la fonction out() de ce module.
 % @author G.Burri
+\r
 
 -module(euphorik_requests).\r
--export([\r
-   tester/0,\r
-   out/1\r
-]).\r
+-export([out/1]).\r
 -include_lib("xmerl/include/xmerl.hrl").\r
 -include_lib("yaws/include/yaws_api.hrl").
 
 \r
-% Test du module (TODO)\r
-tester() ->
-   que_dal.\r
-
-\r
 out(A) ->
    %io:format("~p~n", [A]), % utilisé parfois pendant le debug
    IP = case inet:peername(A#arg.clisock) of
       {ok, {Adresse, _Port}} -> Adresse;
       _ -> inconnue
    end,
-   % passive -> active, permet de recevoir {tcp_closed, _} lorsque le socket se ferme\r
-   inet:setopts(A#arg.clisock, [{active, true}]),\r
+   % passive -> active, permet de recevoir {tcp_closed, _} lorsque le socket se ferme
+   % keepalive -> true, evite que des firewalls coupe la connexion TCP sans prévenir\r
+   inet:setopts(A#arg.clisock, [{active, true}, {keepalive, true}]),\r
    {value, {_, Contenu}} = lists:keysearch("action", 1, yaws_api:parse_post(A)),\r
    Ret = traiter_donnees(Contenu, IP),
    {content, "application/json", Ret}.\r
@@ -64,5 +75,9 @@ traiter_action("put_troll", JSON, _) ->
 traiter_action("mod_troll", JSON, _) ->
    euphorik_protocole:mod_troll(JSON);
 traiter_action("del_troll", JSON, _) ->
-   euphorik_protocole:del_troll(JSON).
+   euphorik_protocole:del_troll(JSON);
+traiter_action("list_banned_ips", JSON, _) ->
+   euphorik_protocole:list_banned_ips(JSON);
+traiter_action("unban", JSON, _) ->
+   euphorik_protocole:unban_ip(JSON).
  
\ No newline at end of file