manage list update (remove too old lines)
[brisk.git] / web / index_wr.php
index 8571c76..fe7a798 100644 (file)
@@ -105,7 +105,7 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
 
     /* if the IP is banned, exit without do nothing */
     if (array_search($remote_addr, $G_black_list) !== FALSE) {
-        sleep(5);
+        // TODO: find a way to add a nonblocking sleep(5) here
         return (FALSE);
     }
 
@@ -199,6 +199,11 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
     // LACC UPDATED
     $user->lacc = $curtime;
 
+    if (array_search($user->ip, $G_black_list) !== FALSE) {
+        // TODO: find a way to add a nonblocking sleep(5) here
+        return (FALSE);
+    }
+
     if ($argz[0] == 'ping') {
         log_wr("PING RECEIVED");
     }
@@ -275,13 +280,13 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
             }
             else {
                 /* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" */
-                $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
+                $mesg_to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
             }
             
         }
         else {
             /* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>" */
-            $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['warrmust'][$G_lang]);
+            $mesg_to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['warrmust'][$G_lang]);
         }
         
         if ($mesg_to_user != "") {
@@ -328,19 +333,19 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
                 }
                 else {
                     /* MLANG: "<b>Il database è temporaneamente irraggiungibile, riprova più tardi o contatta l\'amministratore.</b>" */
-                    $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['coerrdb'][$G_lang]);
+                    $mesg_to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['coerrdb'][$G_lang]);
                     $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
                 }
             }
             else {
                 /* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" */
-                $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
+                $mesg_to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
             }
             
         }
         else {
             /* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>" */
-            $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['mesgmust'][$G_lang]);
+            $mesg_to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['mesgmust'][$G_lang]);
         }
         
         if ($mesg_to_user != "") {
@@ -350,9 +355,6 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
             $user->step_inc();
         }
     }
-
-
-
     else if ($argz[0] == 'poll') {
         GLOBAL $G_with_poll, $G_poll_name;
         if (($cli_choose = gpcs_var('cli_choose', $get, $post, $cookie)) === FALSE) 
@@ -384,7 +386,7 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
             log_wr("INFO:SKIP:argz == poll name: [".$cli_poll_name."] AUTH: ".($user->flags & USER_FLAG_AUTH));
             if (($user->flags & USER_FLAG_AUTH) != USER_FLAG_AUTH) {
                 // MLANG: <b>Per partecipare al sondaggio devi essere autenticato.</b>
-                $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['pollmust'][$G_lang]);
+                $mesg_to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['pollmust'][$G_lang]);
                 log_wr("break1");
                 break;
             }
@@ -403,7 +405,7 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
     
             if (($poll_lock = Poll::lock_data(TRUE)) == FALSE) {
                 /* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" */
-                $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
+                $mesg_to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
                 log_wr("break3");
                 break;
             }
@@ -412,7 +414,7 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
                 $fp = @fopen(LEGAL_PATH."/".$G_poll_name.".txt", 'w+');
             
             if ($fp == FALSE) {
-                $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
+                $mesg_to_user = sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]);
                 log_wr("break4");
                 break;
             }
@@ -465,7 +467,24 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
 
         echo "$echont";
     }
-
+    else if ($argz[0] == 'moderate') {
+        // TODO: add certification check
+        if (1 == 1) {
+            if ($user->flags_vlt_get(USER_FLAG_MODER) == 0 && $argz[1] == 'true') {
+                /* enable moderation */
+                $moder_enable = 'true';
+                $user->flags_vlt_set(USER_FLAG_MODER, USER_FLAG_MODER);
+            }
+            else {
+                /* disable moderation */
+                $moder_enable = 'false';
+                $user->flags_vlt_set(0, USER_FLAG_MODER);
+            }
+            $user->comm[$user->step % COMM_N] = sprintf("gst.st = %d; moderate(%s);", 
+                                                        $user->step+1, $moder_enable);
+            $user->step_inc();
+        }
+    }
     /******************
      *                *
      *   STAT: room   *
@@ -568,13 +587,13 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
 
                     /* MLANG: "<b>Il server sta per essere riavviato, non possono avere inizio nuove partite.</b>", "<b>Il tavolo a cui volevi sederti richiede autentifica.</b>", "<b>Il tavolo si &egrave; appena liberato, ci si potr&agrave; sedere tra %d secondi.</b>" */
                     if ($G_shutdown) {
-                        $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['shutmsg'][$G_lang]);
+                        $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['shutmsg'][$G_lang]);
                     }
                     else if ($table->auth_only && (($user->flags & USER_FLAG_AUTH) == 0)) {
-                        $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['mustauth'][$G_lang]);
+                        $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['mustauth'][$G_lang]);
                     }
                     else {
-                        $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, "%s"],"%s%d%s");', $dt, NICKSERV, $mlang_indwr['tabwait_a'][$G_lang], $table->wakeup_time - $curtime, $mlang_indwr['tabwait_b'][$G_lang]);
+                        $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, 0, "%s"],"%s%d%s");', $dt, NICKSERV, $mlang_indwr['tabwait_a'][$G_lang], $table->wakeup_time - $curtime, $mlang_indwr['tabwait_b'][$G_lang]);
                     }
                     $user->step_inc();
                     return TRUE;