function to check and delete email table on db added
[brisk.git] / web / index.php
1 <?php
2 /*
3  *  brisk - index.php
4  *
5  *  Copyright (C) 2006-2012 Matteo Nastasi
6  *                          mailto: nastasi@alternativeoutput.it
7  *                                  matteo.nastasi@milug.org
8  *                          web: http://www.alternativeoutput.it
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * General Public License for more details. You should have received a
19  * copy of the GNU General Public License along with this program; if
20  * not, write to the Free Software Foundation, Inc, 59 Temple Place -
21  * Suite 330, Boston, MA 02111-1307, USA.
22  *
23  */
24
25 require_once("Obj/brisk.phh");
26 require_once("Obj/auth.phh");
27 require_once("Obj/proxyscan.phh");
28
29 $mlang_room = array( 'userpasserr'  => array('it' => 'Utente e/o password errati.',
30                                              'en' => 'Wrong user and/or password.'),
31                      'userpassmust' => array('it' => 'Il nickname deve contenere almeno una lettera o una cifra.',
32                                              'en' => 'The nickname have to contain at least one letter or one number.'),
33                      'userpassend'  => array('it' => 'Spiacenti, non ci sono pi&ugrave; posti liberi. Riprova pi&ugrave; tardi.',
34                                              'en' => 'We are sorry, there aren\'t free place. Try again later.'),
35                      'userpassuse'  => array('it' => 'Il tuo nickname &egrave; gi&agrave; in uso.',
36                                              'en' => 'Your nickname is already in use.'),
37                      'standing'     => array('it' => 'Giocatori in piedi',
38                                              'en' => 'Standing players'),
39                      'headline'     => array('it' => 'briscola chiamata in salsa ajax',
40                                              'en' => 'declaration briscola in ajax sauce <b>(Beta)</b>'),
41                      'welcome'      => array('it' => 'Digita il tuo nickname per accedere ai tavoli della briscola',
42                                              'en' => 'Enter your nickname to access to the tables of briscola'),
43                      'btn_enter'    => array('it' => 'entra',
44                                              'en' => 'enter'),
45                      'passwarn'     => array('it' => 'Se non hai ancora una password, lascia il campo in bianco ed entra.',
46                                              'en' => 'If you don\'t have a password, leave blank the field and enter.'),
47                      'browwarn'     => array('it' => 'Se qualcosa non funziona prova a ricaricare la pagina con <b>Ctrl + F5</b><br><br>Se non riesci piĆ¹ ad entrare nel nuovo Brisk e prima ci riuscivi potrebbe essere un problema di antivirus,<br>guarda la <a class=\'flat\' style=\'background-color: white; font-weight: bold;\' target=\'_blank\' href=\'http://www.alternativeoutput.it/blog/doku.php?id=brisk:guida_agli_antivirus\'>pagina sugli antivirus</a> per maggiori informazioni su come configurarlo.<br><br>Se ancora non funziona nulla contatta <a class=\'flat\' style=\'background-color: white; font-weight: bold;\' href=\'mailto:brisk@alternativeoutput.it\'>l\'amministratore del sito</a>.',
48                                              'en' => '(if something don\'t work<br>try to reload the current page with <b>Ctrl + F5</b>)'),
49                      'regwarn'      => array('it' => '<br>Il nickname che stai usando &egrave; gi&agrave; registrato,<br><br>se il suo proprietario si autentificher&agrave;<br><br>verrai rinominato d\'ufficio come ghost<i>N</i>.',
50                                              'en' => '<br>The nickname you are using it\'s already registered, <br><br>if its proprietary authenticates<br><br>you will named ghost<i>N</i>.'),
51                      'btn_rettabs'  => array('it' => 'torna ai tavoli',
52                                              'en' => 'back to tables'),
53                      'btn_exit'     => array('it' => 'Esco.',
54                                              'en' => 'Exit.'),
55                      'btn_prefs_save' => array('it' => 'Salva.',
56                                              'en' => 'Save.'),
57                      'btn_prefs_reset' => array('it' => 'Annulla.',
58                                              'en' => 'Reset.'),
59                      'btn_prefs_close' => array('it' => 'Chiudi.',
60                                              'en' => 'Close.'),
61                      'tit_tabl'     => array('it' => 'Tavolo ',
62                                              'en' => 'Table '),
63                      'tit_stat'     => array('it' => 'imposta lo stato del tuo utente',
64                                              'en' => 'set the status of the user'),
65                      'stat_desc'    => array('it' => 'stato',
66                                              'en' => 'mode' ),
67                      'st_norm_desc' => array('it' => 'normale',
68                                              'en' => 'normal'),
69                      'st_paus_desc' => array('it' => 'pausa',
70                                              'en' => 'pause'),
71                      'st_out_desc'  => array('it' => 'fuori',
72                                              'en' => 'out'),
73                      'st_dog_desc'  => array('it' => 'cane',
74                                              'en' => 'dog'),
75                      'st_food_desc' => array('it' => 'cibo',
76                                              'en' => 'food'),
77                      'st_work_desc' => array('it' => 'lavoro',
78                                              'en' => 'work'),
79                      'st_smok_desc' => array('it' => 'sigaretta',
80                                              'en' => 'smoke'),
81                      'st_pres_desc' => array('it' => 'presente',
82                                              'en' => 'present'),
83                      'st_rabb_desc' => array('it' => 'coniglio',
84                                              'en' => 'rabbit'),
85                      'st_socc_desc' => array('it' => 'calcio',
86                                              'en' => 'soccer'),
87                      'st_baby_desc' => array('it' => 'pupo',
88                                              'en' => 'baby'),
89                      'st_mop_desc'  => array('it' => 'pulizie',
90                                              'en' => 'mop'),
91                      'st_babbo_desc'  => array('it' => 'babbo',
92                                              'en' => 'mop'),
93                      'st_renna_desc'  => array('it' => 'renna',
94                                              'en' => 'mop'),
95                      'st_pupaz_desc'  => array('it' => 'pupazzo',
96                                              'en' => 'mop'),
97                      'st_visch_desc'  => array('it' => 'vischio',
98                                              'en' => 'mop'),
99
100                      'tit_ticker'   => array('it' => 'scrivi un invito al tavolo e clicca',
101                                              'en' => 'write an invitation at the table and click'),
102                      'itm_warr'     => array('it' => 'garantisci',
103                                              'en' => 'guarantee'),
104                      'warr_desc'    => array('it' => 'garantisci per un tuo conoscente',
105                                              'en' => 'guarantee for a friend'),
106                      'tit_warr'     => array('it' => 'Garantisci per un tuo conoscente.',
107                                              'en' => 'Guarantee for a friend.'),
108                      'itm_list'     => array('it' => 'ascolta',
109                                              'en' => 'listen'),
110                      'list_desc'    => array('it' => 'imposta le regole di ascolto',
111                                              'en' => 'set the listen rules'),
112                      'tit_listall'  => array('it' => 'tutti',
113                                              'en' => 'everybody'),
114                      'listall_desc' => array('it' => 'leggi tutti i messaggi di tutti gli utenti collegati',
115                                              'en' => 'listen all messages from each user connected'),
116                      'tit_listaut'  => array('it' => 'solo autenticati',
117                                              'en' => 'only authorized'),
118                      'tit_listisol'  => array('it' => 'isolamento',
119                                              'en' => 'isolation'),
120                      'listaut_desc' => array('it' => 'leggi soltanto i messaggi degli utenti con password',
121                                              'en' => 'listen messages only from authenticated users'),
122                      'listisol_desc'=> array('it' => 'visualizza Brisk come se fosse solo per utenti con password',
123                                             'en' => 'show Brisk like an authenticated user only site'),
124                      'suppcomp_tit' =>  array('it' => 'personalizza la tua S',
125                                             'en' => 'customize your S'),
126                      'suppcomp_r' =>  array('it' => 'rosso',
127                                             'en' => 'red'),
128                      'suppcomp_g' =>  array('it' => 'verde',
129                                             'en' => 'green'),
130                      'suppcomp_b' =>  array('it' => 'blu',
131                                             'en' => 'blue'),
132                      'suppcomp_fg' =>  array('it' => 'colore',
133                                             'en' => 'color'),
134                      'suppcomp_bg' =>  array('it' => 'sfondo',
135                                             'en' => 'background'),
136                      'suppcomp_range' =>  array('it' => '(0-255)',
137                                             'en' => '(0-255)'),
138                      'tit_splash'   => array('it' => 'splash',
139                                              'en' => 'splash'),
140                      'splash_desc'  => array('it' => 'attiva la finestra di splash',
141                                              'en' => 'show the splash window'),
142                      'tit_prefs'   => array('it' => 'preferenze',
143                                              'en' => 'preferences'),
144                      'prefs_desc'  => array('it' => 'preferenze dell\' utente',
145                                              'en' => 'user\'s preferences'),
146                      'tit_help'     => array('it' => 'informazioni utili su Brisk',
147                                              'en' => 'usefull information about Brisk'),
148                      'itm_help'     => array('it' => 'aiuto',
149                                              'en' => 'help'),
150                      'tit_hpage'    => array('it' => 'homepage del progetto',
151                                              'en' => 'project homepage (ita)'),
152                      'tit_what'     => array('it' => 'di cosa si tratta',
153                                              'en' => 'what is the project'),
154                      'itm_what'     => array('it' => 'cos\'&egrave;',
155                                              'en' => 'what is it'),
156                      'url_rules'    => array('it' => 'http://it.wikipedia.org/wiki/Briscola#Gioco_a_5',
157                                              'en' => 'http://it.wikipedia.org/wiki/Briscola#Gioco_a_5&EN=true'),
158                      'itm_rules'    => array('it' => 'regole',
159                                              'en' => 'rules'),
160                      'tit_rules'    => array('it' => 'come si gioca',
161                                              'en' => 'how to play'),
162                      'tit_shot'     => array('it' => 'screenshots dell\'applicazione',
163                                              'en' => 'screenshots of the web-application'),
164                      'tit_comp'     => array('it' => 'compatibilit&agrave; con i browser',
165                                              'en' => 'browsers compatibility'),
166                      'itm_comp'     => array('it' => 'compatibilit&agrave;',
167                                              'en' => 'compatibility'),
168                      'tit_src'      => array('it' => 'sorgenti dell\'applicazione web',
169                                              'en' => 'sources of the web-application'),
170                      'itm_src'      => array('it' => 'sorgenti',
171                                              'en' => 'sources'),
172                      'tit_ml'       => array('it' => 'come iscriversi alla mailing list',
173                                              'en' => 'how to subscribe the mailing list'),
174                      'itm_ml'       => array('it' => 'mailing&nbsp;list',
175                                              'en' => 'mailing&nbsp;list'),
176                      'tit_pro'      => array('it' => 'come fare pubblicit&agrave; a Brisk!',
177                                              'en' => 'how to spread Brisk!'),
178                      'itm_pro'      => array('it' => 'propaganda',
179                                              'en' => 'propaganda'),
180                      'tit_mail'     => array('it' => 'contatti',
181                                              'en' => 'contacts'),
182                      'itm_mail'     => array('it' => 'contatti',
183                                              'en' => 'contacts'),
184                      'tit_cla'      => array('it' => 'classifiche degli utenti',
185                                              'en' => 'user\'s placings'),
186                      'itm_cla'      => array('it' => 'classifiche',
187                                              'en' => 'placings'),
188                      'tit_mnu'      => array('it' => 'minuta giornaliera',
189                                              'en' => 'daily report'),
190                      'itm_mnu'      => array('it' => 'minuta',
191                                              'en' => 'daily deport'),
192                      'tit_rmap'     => array('it' => 'prossime funzionalitĆ  implementate',
193                                              'en' => 'roadmap of next functionalities'),
194                      'itm_rmap'     => array('it' => 'roadmap',
195                                              'en' => 'roadmap'),
196                      'tit_meet'     => array('it' => 'foto dei raduni di briskisti (serve Facebook)',
197                                              'en' => 'photos of brisk meetings'),
198                      'itm_meet'     => array('it' => 'BriskMeeting',
199                                              'en' => 'BriskMeeting'),
200                      'tit_mesg'     => array('it' => 'manda un messaggio o una segnalazione all\'amministratore del sito',
201                                              'en' => 'send a message or a signalling to the administrator' ),
202                      'mesgtoadm_tit'=> array('it' => 'Invia un messaggio o una segnalazione all\'amministratore:',
203                                              'en' => 'Send a message to the administrator:'),
204                      'mesgtoadm_sub'=> array('it' => 'soggetto:',
205                                              'en' => 'subject:'),
206                      'btn_send'     => array('it' => 'Invia.',
207                                              'en' => 'Send.'),
208                      'btn_close'    => array('it' => 'Chiudi.',
209                                              'en' => 'Close.')
210                      );
211
212
213
214 require_once("briskin5/Obj/briskin5.phh");
215
216 function poll_dom() {
217   GLOBAL $G_with_poll, $G_poll_title, $G_poll_entries;
218
219   if ($G_with_poll) {
220     $ret = sprintf('<div style="padding: 0px;margin: 0px; height: 8px; font-size: 1px;"></div>
221
222 <img class="nobo" src="img/brisk_poll.png" onmouseover="menu_hide(0,0); menu_show(\'menu_poll\');">
223
224 <div style="width: 300px;" class="webstart" id="menu_poll" onmouseover="menu_over(1,this);" onmouseout="menu_over(-1,this);">
225 <b>%s</b><br><br>
226 <form id="poll_form" accept-charset="utf-8" method="post" action="" onsubmit="return j_pollbox(this);">
227 <input type="hidden" name="realsub" value="666">', $G_poll_title);
228     for ($i = 0 ; $i < count($G_poll_entries) ; $i++) {
229       $ret .= sprintf('<INPUT TYPE="radio" NAME="category" VALUE="%s">%s<hr><br>', $G_poll_entries[$i]['id'],
230                       $G_poll_entries[$i]['cont']);
231     }
232     $ret .= sprintf('<div style="text-align: center;"><input type="submit" class="input_sub" onclick="this.form.elements[\'realsub\'].value = this.value;" value="invia" name="sub" id="subid"/></div>
233 </form></div>');
234     return ($ret);
235   }
236   else
237     return '';
238 }
239
240 function index_main(&$brisk, $transp_type, &$header_out, $addr, $get, $post, $cookie)
241 {
242     GLOBAL $G_with_donors, $G_donors_cur, $G_donors_all;
243     GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local;
244     GLOBAL $G_with_sidebanner, $G_sidebanner;
245     GLOBAL $G_with_sidebanner2, $G_sidebanner2;
246     GLOBAL $G_with_poll;
247     GLOBAL $G_lang, $G_lng, $mlang_room;
248     GLOBAL $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER;
249
250     if (($sess = gpcs_var('sess', $get, $post, $cookie)) === FALSE)
251         $sess = "";
252     if (($name = gpcs_var('name', $get, $post, $cookie)) === FALSE)
253         unset($name);
254     if (($pass_private = gpcs_var('pass_private', $get, $post, $cookie)) === FALSE)
255         unset ($pass_private);
256     if (($table_idx = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE)
257         unset ($table_idx);
258     if (($table_token = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE)
259         unset ($table_token);
260
261     // Use of proxies isn't allowed.
262     if (!$G_is_local && is_proxy($addr)) {
263         return FALSE;
264     }
265
266   $is_login = FALSE;
267   $body = "";
268   $tables = "";
269   $standup = "";
270   $ACTION = "login";
271
272   if (isset($BRISK_SHOWHTML) == FALSE) {
273       $is_table = FALSE;
274       log_main("lock Brisk");
275       $curtime = time();
276
277       /* Actions */
278
279       if (validate_sess($sess)) {
280           log_main("pre garbage_manager UNO");
281           $brisk->garbage_manager(TRUE);
282           log_main("post garbage_manager");
283           if (($user = &$brisk->get_user($sess, &$idx)) != FALSE) {
284               $brisk->sess_cur_set($user->sess);
285               log_main("user stat: ".$user->stat);
286               if ($user->stat == "table") {
287                   $cookies = new Cookies();
288                   $cookies->add("table_token", $user->table_token, $curtime + 31536000);
289                   $cookies->add("table_idx", $user->table, $curtime + 31536000);
290                   $header_out['cookies'] = $cookies;
291                   $header_out['Location'] = "briskin5/index.php";
292                   return TRUE;
293               }
294               $ACTION = "room";
295           }
296       }
297
298       if ($ACTION == "login" && isset($name)) {
299           log_main("pre garbage_manager DUE");
300
301           if (isset($pass_private) == FALSE) {
302               $pass_private = FALSE;
303           }
304
305           $brisk->garbage_manager(TRUE);
306           /* try login */
307
308           $ipv4addr = addrtoipv4($addr);
309           if (($user = $brisk->add_user(&$sess, &$idx, $name, $pass_private, $ipv4addr, $cookie)) != FALSE) {
310               $brisk->sess_cur_set($user->sess);
311               $ACTION = "room";
312               if ($idx < 0) {
313                   $idx = -$idx - 1;
314                   $is_login = TRUE;
315               }
316
317               log_legal($curtime, $ipv4addr, $user, "STAT:LOGIN", '');
318
319               // recovery lost game
320               if ($user->stat == "table") {
321                   $cookies = new Cookies();
322                   $cookies->add("table_token", $user->table_token, $curtime + 31536000);
323                   $cookies->add("table_idx", $user->table, $curtime + 31536000);
324                   $header_out['cookies'] = $cookies;
325                   $header_out['Location'] = "briskin5/index.php";
326                   return TRUE;
327               }
328
329               // setcookie ("sess", "", time() + 180);      
330               $brisk->standup_update(&$user);
331           }
332           else {
333               /* Login Rendering */
334               /* MLANG: "Utente e/o password errati.", "Il nickname deve contenere almeno una lettera o una cifra.", "Spiacenti, non ci sono pi&ugrave; posti liberi. Riprova pi&ugrave; tardi.", "Il tuo nickname &egrave; gi&agrave; in uso." */
335               /*
336                if ($idx == -3)
337                $body .= '<div class="urgmsg"><b>'.$mlang_room['userpasserr'][$G_lang].'</b></div>';
338                else if ($idx == -2)
339                // $body .= '<div class="urgmsg"><b>Il nickname deve contenere almeno una lettera o una cifra.</b></div>';
340                $body .= '<div class="urgmsg"><b>'.$mlang_room['userpassmust'][$G_lang].'</b></div>';
341                else if ($idx == -1)
342                // $body .= '<div class="urgmsg"><b>Spiacenti, non ci sono pi&ugrave; posti liberi. Riprova pi&ugrave; tardi.</b></div>';
343                $body .= '<div class="urgmsg"><b>'.$mlang_room['userpassend'][$G_lang].'</b></div>';
344                else
345                // $body .= '<div class="urgmsg"><b>Il tuo nickname &egrave; gi&agrave; in uso.</b></div>';
346                $body .= '<div class="urgmsg"><b>'.$mlang_room['userpassuse'][$G_lang].'</b></div>';
347               */
348
349               if ($idx == -3)
350                   $sfx = 'err';
351               else if ($idx == -2)
352                   $sfx = 'must';
353               else if ($idx == -1)
354                   $sfx = 'end';
355               else
356                   $sfx = 'use';
357
358               $body .= '<div class="urgmsg"><b>'.$mlang_room['userpass'.$sfx][$G_lang].'</b></div>';
359           }
360       }
361   }
362   /* Rendering. */
363
364   if ($BRISK_SHOWHTML == "debugtable") {
365       $ACTION = "room";
366   }
367   else if ($BRISK_SHOWHTML == "debuglogin") {
368       $ACTION = "login";
369   }
370
371   if ($ACTION == "room") {
372       $tables .= '<div class="room_tab">';
373       $tables .= '<table class="room_tab">';
374       for ($ii = 0 ; $ii < TABLES_N ; $ii++) {
375           if ($user->flags & USER_FLAG_AUTH)
376         $i = $ii;
377           else
378               $i = TABLES_N - $ii - 1;
379
380           if ($ii % 4 == 0) {
381               $tables .= '<tr id = "tr_noauth'.$ii.'">';
382           }
383           if (TRUE || !($user->flags & USER_FLAG_ISOLAUTH) || $ii < TABLES_AUTH_N) {
384               $tables .= '<td id = "td_noauth'.$ii.'">';
385
386               $tables .= '<div class="room_div"><div class="room_tit"><b>'.$mlang_room['tit_tabl'][$G_lang].$i.'</b></div>';
387               $tables .= sprintf('<div class="proxhr" id="table%d"></div>', $i);
388               $tables .= sprintf('<div class="table_act" id="table_act%d"></div>', $i);
389               $tables .= '</div>';
390               $tables .= '</td>'."\n";
391           }
392           if ($ii % 4 == 3) {
393               $tables .= '</tr>';
394           }
395       }
396       $tables .= '</table></div>';
397
398       $standup .= '<table class="room_standup"><tr><td><div class="room_standup_orig" id="room_standup_orig"></div>';
399       $standup .= '<div class="room_ex_standup">';
400       /* MLANG: "Giocatori in piedi" */
401       // $standup .= '<div id="room_tit"><span class="room_titin"><b>Giocatori in piedi</b> - <a target="_blank" href="weboftrust.php">Come ottenere user e password</a> - </span></div>';
402       $standup .= '<div id="room_tit"><span class="room_titin"><b>'.$mlang_room['standing'][$G_lang].'</b></span></div>';
403
404       $standup .= sprintf('<div id="standup" class="room_standup"></div>');
405       // MLANG Esco.
406       $standup .= '<div id="esco" class="esco"><input type="button" class="button" name="xreload"  value="Reload." onclick="act_reloadroom();"><input class="button" name="logout" value="'.$mlang_room['btn_exit'][$G_lang].'" onclick="esco_cb();" type="button"></div>';
407       $standup .= '</div></td></tr></table>';
408   }
409   
410   $altout_sponsor_arr = array( array ( 'id' => 'btn_altout',
411                                        'url' => 'http://www.alternativeoutput.it',
412                                        'content' => 'img/altout80x15.png',
413                                        'content_big' => 'img/logotxt_banner.png'),
414                                array ( 'id' => 'btn_virtualsky',
415                                        'url' => 'http://virtualsky.alternativeoutput.it',
416                                        'content' => 'img/virtualsky80x15a.gif',
417                                        'content_big' => 'img/virtualsky_big.png'),
418                                array ( 'id' => 'btn_dynamica',
419                                        'url' => 'http://www.dynamica.it',
420                                        'content' => 'img/dynamica.png',
421                                        'content_big' => 'img/dynamica_big.png')
422                                );
423   
424   $altout_support_arr = array( array ( 'id' => 'btn_brichi',
425                                        'url' => 'http://www.briscolachiamata.it',
426                                        'content' => 'img/brichi.png',
427                                        'content_big' => 'img/brichi_big.png'),
428                                array ( 'id' => 'btn_foroli',
429                                        'url' => 'http://www.forumolimpia.it',
430                                        'content' => 'img/forumolimpia.gif',
431                                        'content_big' => 'img/forumolimpia_big.png' ),
432                                array ( 'id'=> 'btn_niini',
433                                        'url' => 'http://www.niinivirta.it',
434                                        'content' => 'img/niinivirta.png',
435                                        'content_big' => 'img/niinivirta_big.png') );
436   
437   
438   
439   $altout_support = "";
440   $altout_support_big = "";
441   for ($i = 0 ; $i < 4 ; $i++) {
442       $ii = ($i < 3 ? $i : 0);
443       
444       $altout_support .= sprintf('<a style="position: absolute; top: %dpx; left: 7px;" target="_blank" href="%s"><img class="nobo" id="%s" src="%s" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a><br>',
445                                  $i * 20, $altout_support_arr[$ii]['url'],
446                                  $altout_support_arr[$ii]['id'], $altout_support_arr[$ii]['content']);
447       
448       $altout_support_big .= sprintf('<img style="position: absolute;" class="nobohide" id="%s_big" src="%s">',
449                                      $altout_support_arr[$ii]['id'], $altout_support_arr[$ii]['content_big']);
450   }
451   
452   
453   // seed with microseconds since last "whole" second
454   // srand ((double) microtime() * 1000000);
455   // $randval = rand(0,count($altout_sponsor_arr)-1);
456   $altout_sponsor = "";
457   $altout_sponsor_big = "";
458   for ($i = 0 ; $i < 4 ; $i++) {
459       $ii = ($i < 3 ? $i : 0);
460       
461       $altout_sponsor .= sprintf('<a style="position: absolute; top: %dpx; left: 7px;" target="_blank" href="%s"><img class="nobo" id="%s" src="%s" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a><br>',
462                                  $i * 20, $altout_sponsor_arr[$ii]['url'],
463                                  $altout_sponsor_arr[$ii]['id'], $altout_sponsor_arr[$ii]['content']);
464       
465       $altout_sponsor_big .= sprintf('<img class="nobohide" id="%s_big" src="%s">',
466                                    $altout_sponsor_arr[$ii]['id'], $altout_sponsor_arr[$ii]['content_big']);
467   }
468   
469   
470   
471   /* NOTE: Brisk donate or donate fake if local */
472   if (!$G_is_local)
473       $brisk_donate = file_get_contents(FTOK_PATH."/brisk_donate.txt");
474   else
475       $brisk_donate = '<div style="background-color: #ff0; height: 27px; margin-top: 4px;">BRISK_DONATE</div>';
476
477   if ($brisk_donate == FALSE)
478       $brisk_donate = "";
479   
480   
481   /* MLANG: "briscola chiamata in salsa ajax", */
482   
483   mt_srand(make_seed());
484   if (!$G_is_local) {
485       $rn = rand(0, 1);
486       
487       if ($rn == 0) { 
488           $banner_top_left = '<script type="text/javascript"><!--
489 google_ad_client = "pub-5246925322544303";
490 google_ad_width = 234;
491 google_ad_height = 60;
492 google_ad_format = "234x60_as";
493 google_ad_type = "text_image";
494 google_ad_channel = "";
495 google_color_border = "808080";
496 google_color_bg = "f6f6f6";
497 google_color_link = "ffae00";
498 google_color_text = "404040";
499 google_color_url = "000000";
500 //-->
501 </script>
502 <script type="text/javascript"
503   src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
504 </script>';
505           $banner_top_right = carousel_top();
506       }
507       else { 
508           $banner_top_left = carousel_top();
509           $banner_top_right = '<script type="text/javascript"><!--
510 google_ad_client = "pub-5246925322544303";
511 google_ad_width = 234;
512 google_ad_height = 60;
513 google_ad_format = "234x60_as";
514 google_ad_type = "text_image";
515 google_ad_channel = "";
516 google_color_border = "808080";
517 google_color_bg = "f6f6f6";
518 google_color_link = "ffae00";
519 google_color_text = "404040";
520 google_color_url = "000000";
521 //-->
522 </script>
523 <script type="text/javascript"
524   src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
525 </script>';
526       }
527   }
528   else { // !$G_is_local
529       $banner_top_left  = carousel_top();
530       $banner_top_right = carousel_top();
531   }
532
533   $brisk_header_form = '<div class="container">
534 <!-- =========== header ===========  -->
535 <div id="header" class="header">
536 <table width="100%%" border="0" cols="3"><tr>
537 <td align="left"><div style="padding-left: 8px;">'.$banner_top_left.'</div></td>
538 <td align="center">'.(($G_with_topbanner || $G_with_donors) ? '<table><tr><td>' : '').'<div style="text-align: center;">
539     <img class="nobo" src="img/brisk_logo64.png">
540     '.$mlang_room['headline'][$G_lang].'<br>
541     </div>'.( ($G_with_topbanner || $G_with_donors) ? sprintf('</td><td>%s</td></tr></table>', 
542                                                                 ($G_with_topbanner ? $G_topbanner : 
543 "<div style='background-color: #ffd780; border: 1px solid black; text-align: center;'><img class='nobo' src=\"donometer.php?c=".$G_donors_cur."&a=".$G_donors_all."\"><div style='padding: 1px; background-color: white;'><b>donatori</b></div></div>") ) : '').'</td>
544 <td align="right"><div style="padding-right: 8px;">
545 '.$banner_top_right.'</div></td>
546 </tr></table>
547 </div>';
548
549 /* MLANG: ALL THE VERTICAL MENU */
550   $brisk_vertical_menu = '
551 <!--  =========== vertical menu ===========  -->
552 <div class="topmenu">
553 <!-- <a target="_blank" href="/briskhome.php"></a> -->
554
555 <div class="webstart_hilite">
556 <img class="nobo" style="cursor: pointer;" src="img/brisk_start.png" onmouseover="menu_hide(0,0); menu_show(\'menu_webstart\');">
557 <div class="webstart" id="menu_webstart" onmouseover="menu_over(1,this);" onmouseout="menu_over(-1,this);">
558
559 <a href="#" onmouseover="menu_hide(0,1);" title="'.$mlang_room['tit_help'][$G_lang].'" onclick="act_help();"
560    >'.$mlang_room['itm_help'][$G_lang].'</a><br>
561
562 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php" 
563    onmouseover="menu_hide(0,1);"
564    title="'.$mlang_room['tit_hpage'][$G_lang].'">homepage</a><br>
565
566 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#cose" 
567    onmouseover="menu_hide(0,1);"
568    title="'.$mlang_room['tit_what'][$G_lang].'">'.$mlang_room['itm_what'][$G_lang].'</a><br>
569
570 <a target="_blank" href="'.$mlang_room['url_rules'][$G_lang].'" 
571    onmouseover="menu_hide(0,1);"
572    title="'.$mlang_room['tit_rules'][$G_lang].'">'.$mlang_room['itm_rules'][$G_lang].'</a><br>
573
574 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#shots" 
575    onmouseover="menu_hide(0,1);"
576    title="'.$mlang_room['tit_shot'][$G_lang].'">screenshoots</a><br>
577
578 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#comp" 
579    onmouseover="menu_hide(0,1);"
580    title="'.$mlang_room['tit_comp'][$G_lang].'">'.$mlang_room['itm_comp'][$G_lang].'</a><br>
581
582 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#sources" 
583    onmouseover="menu_hide(0,1);"
584    title="'.$mlang_room['tit_src'][$G_lang].'">'.$mlang_room['itm_src'][$G_lang].'</a><br>
585
586 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#mailing" 
587    onmouseover="menu_hide(0,1);"
588    title="'.$mlang_room['tit_ml'][$G_lang].'">'.$mlang_room['itm_ml'][$G_lang].'</a><br>
589
590 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#prop" 
591    onmouseover="menu_hide(0,1);"
592    title="'.$mlang_room['tit_pro'][$G_lang].'">'.$mlang_room['itm_pro'][$G_lang].'</a><br>
593 <a href="#"
594    onmouseover="menu_hide(0,1);"
595    title="credits" onclick="act_about();">about</a><br>
596
597 <a href="mailto:brisk@alternativeoutput.it" 
598    onmouseover="menu_hide(0,1);"
599    title="'.$mlang_room['tit_mail'][$G_lang].'">'.$mlang_room['itm_mail'][$G_lang].'</a><br>
600
601 <hr>
602
603 <!--
604 <a href="#"
605    onmouseover="menu_hide(0,1);"
606    title="perchĆ© supportare brisk?" onclick="act_whysupport();">supportare?</a><br>
607 -->
608 <a href="#"
609    onmouseover="menu_hide(0,1);"
610    title="'.$mlang_room['tit_cla'][$G_lang].'" onclick="act_placing();">'.$mlang_room['itm_cla'][$G_lang].'</a><br>
611
612 <a target="_blank" href="briskin5/explain.php"
613    onmouseover="menu_hide(0,1);"
614    title="'.$mlang_room['tit_mnu'][$G_lang].'">'.$mlang_room['itm_mnu'][$G_lang].'</a><br>
615
616 <a href="#"
617    onmouseover="menu_hide(0,1);"
618    title="'.$mlang_room['tit_rmap'][$G_lang].'" onclick="act_roadmap();">'.$mlang_room['itm_rmap'][$G_lang].'</a><br>
619
620 <a href="#" title="'.$mlang_room['tit_meet'][$G_lang].'" 
621    onmouseover="menu_show(\'menu_meeting\');">'.$mlang_room['itm_meet'][$G_lang].'</a><br>
622
623 <div style="text-align: right;" id="menu_meeting" class="webstart">
624 <a href="http://it-it.facebook.com/event.php?eid=262482143080&index=1"
625    target="_blank" onmouseover="menu_hide(0,2);"
626    title="1Ā° Torneo-Meeting di Lodi del 21/02/2010" ><img style="display: inline;" class="nobo" src="img/coppa16.png">Lodi 02/10</a><br>
627
628 <a href="http://it-it.facebook.com/event.php?eid=165523204539&index=1"
629    target="_blank" onmouseover="menu_hide(0,2);"
630    title="1Ā° Torneo-Meeting di Parma del 22/11/2009" <img style="display: inline;" class="nobo" src="img/coppa16.png">Parma 11/09</a><br>
631
632 <a href="http://it-it.facebook.com/event.php?eid=105699129890&index=1"
633    target="_blank" onmouseover="menu_hide(0,2);"
634    title="BriskMeeting di Parma del 13/09/2009" >Parma 09/09</a><br>
635
636 <a href="http://it-it.facebook.com/event.php?eid=97829048656&index=1"
637    target="_blank" onmouseover="menu_hide(0,2);"
638    title="BriskMeeting di Clusane d\'Iseo del 5/07/2009" >Clusane 07/09</a><br>
639
640 <a href="http://it-it.facebook.com/event.php?eid=103366692570&index=1"
641    target="_blank" onmouseover="menu_hide(0,2);"
642    title="BriskMeeting Siciliano del 14/06/2009" >Catania 06/09</a><br>
643
644 <a href="http://it-it.facebook.com/event.php?eid=81488770852&index=1" 
645    target="_blank" onmouseover="menu_hide(0,2);"
646    title="BriskMeeting di Piacenza del 19/04/2009" >Piacenza 04/09</a><br>
647
648 <a href="http://it-it.facebook.com/event.php?eid=51159131399&index=1" 
649    target="_blank" onmouseover="menu_hide(0,2);"
650    title="BriskMeeting di Parma del 22/02/2009" >Parma 02/09</a><br>
651
652 <a href="http://www.anomalia.it/mop/photoo?album=brisk_pc0806" 
653    target="_blank" onmouseover="menu_hide(0,2);"
654    title="Raduno di Piacenza del del 15/06/2008" >Piacenza 06/08</a><br>
655
656 <a href="http://www.anomalia.it/mop/photoo" 
657    target="_blank" onmouseover="menu_hide(0,2);"
658    title="Torneo di Milano del 17/05/2008" >Milano 05/08</a><br>
659
660 </div>
661 </div>'. ($ACTION == "room" ? '<div style="padding: 0px; margin: 0px; witdh: 50px; height: 8px; font-size: 1px;"></div><img class="nobo" style="cursor: pointer;" src="img/brisk_commands'.langtolng($G_lang).'.png" onmouseover="menu_hide(0,0); menu_show(\'menu_commands\');">
662
663 <div class="webstart" id="menu_commands" onmouseover="menu_over(1,this);" onmouseout="menu_over(-1,this);">
664
665 <a href="#" title="'
666           // MLANG
667           .$mlang_room['tit_stat'][$G_lang].
668 '" 
669    onmouseover="menu_hide(0,1); menu_show(\'menu_state\');">'
670           // MLANG
671           .$mlang_room['stat_desc'][$G_lang].
672 '</a><br>
673 <div id="menu_state" class="webstart">
674 <a href="#"
675    onmouseover="menu_hide(0,2);"
676    title="" onclick="act_chatt(\'/st normale\'); menu_over(-1,this);">'
677           // MLANG
678           .$mlang_room['st_norm_desc'][$G_lang].
679 '</a><br>
680
681 <a href="#"
682    onmouseover="menu_hide(0,2);"
683    title="" onclick="act_chatt(\'/st pausa\'); menu_over(-1,this);">'
684           // MLANG
685           .$mlang_room['st_paus_desc'][$G_lang].
686 '&nbsp;<img class="unbo" src="img/st_pau.png"></a><br>
687
688 <a href="#"
689    onmouseover="menu_hide(0,2);"
690    title="" onclick="act_chatt(\'/st fuori\'); menu_over(-1,this);">'
691           // MLANG
692           .$mlang_room['st_out_desc'][$G_lang].
693 '&nbsp;<img class="unbo" src="img/st_out.png"></a><br>
694
695 <a href="#"
696    onmouseover="menu_hide(0,2);"
697    title="" onclick="act_chatt(\'/st cane\'); menu_over(-1,this);">'
698           // MLANG
699           .$mlang_room['st_dog_desc'][$G_lang].
700 '&nbsp;<img class="unbo" src="img/st_dog.png"></a><br>
701
702 <a href="#"
703    onmouseover="menu_hide(0,2);"
704    title="" onclick="act_chatt(\'/st cibo\'); menu_over(-1,this);">'
705           // MLANG
706           .$mlang_room['st_food_desc'][$G_lang].
707 '&nbsp;<img class="unbo" src="img/st_eat.png"></a><br>
708
709 <a href="#"
710    onmouseover="menu_hide(0,2);"
711    title="" onclick="act_chatt(\'/st lavoro\'); menu_over(-1,this);">'
712           // MLANG
713           .$mlang_room['st_work_desc'][$G_lang].
714 '&nbsp;<img class="unbo" src="img/st_wrk.png"></a><br>
715
716 <a href="#"
717    onmouseover="menu_hide(0,2);"
718    title="" onclick="act_chatt(\'/st sigaretta\'); menu_over(-1,this);">'
719           // MLANG
720           .$mlang_room['st_smok_desc'][$G_lang].
721 '&nbsp;<img class="unbo" src="img/st_smk.png"></a><br>
722
723 <a href="#"
724    onmouseover="menu_hide(0,2);"
725    title="" onclick="act_chatt(\'/st presente\'); menu_over(-1,this);">'
726           // MLANG
727           .$mlang_room['st_pres_desc'][$G_lang].
728 '&nbsp;<img class="unbo" src="img/st_eye.png"></a><br>
729
730 <a href="#"
731    onmouseover="menu_hide(0,2);"
732    title="" onclick="act_chatt(\'/st coniglio\'); menu_over(-1,this);">'
733           // MLANG
734           .$mlang_room['st_rabb_desc'][$G_lang].
735 '&nbsp;<img class="unbo" src="img/st_rabbit.png"></a><br>
736
737 <a href="#"
738    onmouseover="menu_hide(0,2);"
739    title="" onclick="act_chatt(\'/st calcio\'); menu_over(-1,this);">'
740           // MLANG
741           .$mlang_room['st_socc_desc'][$G_lang].
742 '&nbsp;<img class="unbo" src="img/st_soccer.png"></a><br>
743
744 <a href="#"
745    onmouseover="menu_hide(0,2);"
746    title="" onclick="act_chatt(\'/st pupo\'); menu_over(-1,this);">'
747           // MLANG
748           .$mlang_room['st_baby_desc'][$G_lang].
749 '&nbsp;<img class="unbo" src="img/st_baby.png"></a><br>
750
751 <a href="#"
752    onmouseover="menu_hide(0,2);"
753    title="" onclick="act_chatt(\'/st pulizie\'); menu_over(-1,this);">'
754           // MLANG
755           .$mlang_room['st_mop_desc'][$G_lang].
756 '&nbsp;<img class="unbo" src="img/st_mop.png"></a><br>
757
758 <a href="#"
759    onmouseover="menu_hide(0,2);"
760    title="" onclick="act_chatt(\'/st babbo\'); menu_over(-1,this);">'
761           // MLANG
762           .$mlang_room['st_babbo_desc'][$G_lang].
763 '&nbsp;<img class="unbo" src="img/st_babbo.png"></a><br>
764
765 <a href="#"
766    onmouseover="menu_hide(0,2);"
767    title="" onclick="act_chatt(\'/st renna\'); menu_over(-1,this);">'
768           // MLANG
769           .$mlang_room['st_renna_desc'][$G_lang].
770 '&nbsp;<img class="unbo" src="img/st_renna.png"></a><br>
771
772 <a href="#"
773    onmouseover="menu_hide(0,2);"
774    title="" onclick="act_chatt(\'/st pupazzo\'); menu_over(-1,this);">'
775           // MLANG
776           .$mlang_room['st_pupaz_desc'][$G_lang].
777 '&nbsp;<img class="unbo" src="img/st_pupaz.png"></a><br>
778
779 <a href="#"
780    onmouseover="menu_hide(0,2);"
781    title="" onclick="act_chatt(\'/st vischio\'); menu_over(-1,this);">'
782           // MLANG
783           .$mlang_room['st_visch_desc'][$G_lang].
784 '&nbsp;<img class="unbo" src="img/st_visch.png"></a><br>
785
786 </div>
787
788 <a href="#" title="avvia un ticker pubblicitario per il tuo tavolo" 
789    onmouseover="menu_hide(0,1);" onclick="act_chatt(\'/tav \'+$(\'txt_in\').value); menu_over(-1,this);">ticker &nbsp;<img class="unbo" src="img/train.png"></a><br>
790
791 <a href="#" title="'
792           // MLANG garantisci per un tuo conoscente
793           .$mlang_room['warr_desc'][$G_lang].
794 '" 
795    onmouseover="menu_hide(0,1);" onclick="act_chatt(\'/authreq\'); menu_over(-1,this);">'
796           // MLANG garantisci
797           .$mlang_room['itm_warr'][$G_lang].
798           '</a><br>
799
800
801
802 <a href="#" title="'
803           // MLANG garantisci per un tuo conoscente
804           .$mlang_room['splash_desc'][$G_lang].
805 '" 
806    onmouseover="menu_hide(0,1);" onclick="act_splash(); menu_over(-1,this);">'
807           // MLANG garantisci
808           .$mlang_room['tit_splash'][$G_lang].
809           '</a><br>
810 '.($user->flags & USER_FLAG_AUTH ? '
811 <a href="#" title="'
812           // MLANG garantisci per un tuo conoscente
813           .$mlang_room['prefs_desc'][$G_lang].'"
814    onmouseover="menu_hide(0,1);" onclick="$(\'preferences\').style.visibility = \'visible\'; menu_over(-1,this);">'
815           // MLANG garantisci
816    .$mlang_room['tit_prefs'][$G_lang].'</a><br>' : '').'
817
818 </div>'.($G_with_poll ? '' : '<div style="padding: 0px; margin: 0px; witdh: 50px; height: 8px; font-size: 1px;"></div>
819 <img style="cursor: pointer;" class="nobo" src="img/brisk_help'.langtolng($G_lang).'.png" title="'.$mlang_room['tit_help'][$G_lang].'" onmouseover="menu_hide(0,0);" onclick="act_help();">').'
820 <div style="padding: 0px; margin: 0px; witdh: 50px; height: 8px; font-size: 1px;"></div>
821 '.($user->flags & USER_FLAG_AUTH ? '
822 <img style="cursor: pointer;" class="nobo" src="img/brisk_signal'.langtolng($G_lang).'.png" title="'.$mlang_room['tit_mesg'][$G_lang].'" onmouseover="menu_hide(0,0);" onclick="act_chatt(\'/mesgtoadm\');">'.poll_dom()
823  : '
824 <img style="cursor: pointer;" class="nobo" src="img/brisk_password.png" title="Come ottenere una password su Brisk." onmouseover="menu_hide(0,0);" onclick="act_passwdhowto();">
825 ').'
826
827 ' : '').'
828
829 </div>
830 <div style="padding: 0px; margin: 0px; witdh: 50px; height: 8px; font-size: 1px;"></div>
831 sponsored by:<br>
832 <div style="padding: 0px; margin: 0px; witdh: 50px; height: 4px; font-size: 1px;"></div>
833 <div id="spon_caro" style="overflow: hidden; height: 18px; /* border: 1px solid red; */ ">
834 <div style="/*background-color: green; */ text-align: left; position: relative; padding: 0px; margin: 0px; top: 0px; height: 80px;">'.$altout_sponsor.'<br>
835 </div></div>
836 <div style="position: absolute;">
837 '.$altout_sponsor_big.'
838 </div>
839 <div style="padding: 0px; margin: 0px; witdh: 50px; height: 8px; font-size: 1px;"></div>
840 supported by:<br>
841 <div style="padding: 0px; margin: 0px; witdh: 50px; height: 4px; font-size: 1px;"></div>
842 <div id="supp_caro" style="overflow: hidden; height: 18px; /* border: 1px solid red; */">
843 <div style="/* background-color: green; */ text-align: left; position: relative; padding: 0px; margin: 0px; top: 0px; height: 80px;">'.$altout_support.'<br> 
844
845 </div>
846 </div>
847 <div style="position: absolute;">
848 '.$altout_support_big.'
849 </div>
850 <a style="/* position: absolute; top: 40px; left: 6px;" */ target="_blank" href="http://it-it.facebook.com/group.php?gid=59742820791"><img class="nobo" id="btn_facebook" src="img/facebook_btn.png" title="unisciti al gruppo \'quelli della brisk\'"></a>
851 ' . ( /* NOTE: here facebook or fake facebook */
852 ! $G_is_local ?
853 '<div class="fb-like" style="margin-top: 4px;" data-href="https://www.facebook.com/pages/Brisk-briscola-chiamata-in-salsa-ajax/716026558416911" data-share="false" data-send="true" data-width="70" data-show-faces="false" data-colorscheme="dark" layout="button_count"></div>
854 ' : '<div style="margin-top: 4px; height: 20px; background-color: #00f;">FACEBOOK HERE</div>
855 ' ) . '<div id="proflashext" class="proflashext"><div id="proflash" class="proflash"></div></div>
856 <img id="stm_stat" class="nobo" style="margin-top: 4px;" src="img/line-status_b.png">
857 %s
858 %s
859 </div>';
860     
861   /* Templates. */
862   if ($ACTION == 'login') {
863       $header_out['Content-type'] = "text/html; charset=\"utf-8\"";
864 ?>
865 <html>
866 <head>
867 <title>Brisk</title>
868 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
869 <link rel="shortcut icon" href="img/brisk_ico.png">
870 <script type="text/javascript" src="commons.js"></script> 
871 <script type="text/javascript" src="prefs.js"></script>
872 <!-- <script type="text/javascript" src="myconsole.js"></script> -->
873 <script type="text/javascript" src="menu.js"></script>
874 <script type="text/javascript" src="heartbit.js"></script>
875 <script type="text/javascript" src="xynt-streaming.js"></script>
876 <script type="text/javascript" src="preload_img<?php echo langtolng($G_lang); ?>.js"></script>
877 <script type="text/javascript" src="AC_OETags.js"></script>
878 <script type="text/javascript" src="room.js"></script>
879 <script type="text/javascript" src="md5.js"></script>
880 <script type="text/javascript" src="probrowser.js"></script>
881 <script type="text/javascript" src="json2.js"></script>
882 <link rel="stylesheet" type="text/css" href="brisk.css">
883 <link rel="stylesheet" type="text/css" href="room.css">
884
885 <SCRIPT type="text/javascript"><!--
886    var g_debug = 0;
887    var g_lang = "<? echo $G_lang; ?>";
888    var g_lng = "<? echo $G_lng; ?>";
889    var g_tables_n = <? echo TABLES_N; ?>;
890    var g_tables_auth_n = <? echo TABLES_AUTH_N; ?>;
891    var g_prefs, g_prefs_new = null;
892    var g_listen;
893    var g_withflash = false;
894    var g_is_spawn = 0;
895    var g_nd = null;
896    var g_brow = null;
897    var gst  = new globst();
898    var topbanner_sfx, topbanner_dx;
899    var xstm = null;
900    var sess = "not_connected";
901    var spo_slide, sup_slide;
902
903    window.onload = function() {
904      // alert(window.onbeforeunload);
905      g_brow = get_browser_agent();
906
907      g_prefs = new client_prefs(null);
908
909      spo_slide  = new sideslide($('spon_caro'), 80, 20);
910      sup_slide  = new sideslide($('supp_caro'), 80, 20);
911
912      login_init();
913 <?php
914      if ($G_with_topbanner) {
915        printf("     topbanner_init();\n");
916     }
917      if ($G_with_sidebanner) {
918        printf("     sidebanner_init();\n");
919     }
920      if ($G_with_sidebanner2) {
921        printf("     sidebanner2_init();\n");
922     }
923 ?>
924
925      g_withflash = DetectFlashVer(6,0,0);
926      if (g_withflash == false) {
927        $("proflash").innerHTML = 'Audio con Flash.<br><a href="http://www.macromedia.com/"><img class="nobo" style="padding: 4px; width:73; height: 19;" src="img/download_now_flash.gif"></a>';
928      }
929      else
930        $("proflashext").innerHTML = "";
931      $("nameid").focus();
932    }
933    //-->
934 </SCRIPT>
935 </head>
936 <?php
937     if (!$G_is_local) {
938 ?>
939 <!-- if myconsole <body onunload="deconsole();"> -->
940 <body xmlns:fb="http://ogp.me/ns/fb#">
941 <div id="fb-root"></div>
942 <script>(function(d, s, id) {
943   var js, fjs = d.getElementsByTagName(s)[0];
944   if (d.getElementById(id)) return;
945   js = d.createElement(s); js.id = id;
946   js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1";
947   fjs.parentNode.insertBefore(js, fjs);
948 }(document, 'script', 'facebook-jssdk'));</script>
949 <?php
950     }
951     else {
952 ?>
953 <body>
954 <?php
955   }
956 ?>
957 <?php
958     printf($brisk_header_form);
959     printf("<table class=\"floaty\"><tr><td class=\"floatyleft\">\n");
960     printf($brisk_vertical_menu, '', '');
961
962    if ($G_with_sidebanner xor $G_with_sidebanner2) {
963      printf("<br><br>");
964    }
965
966    if ($G_with_sidebanner) {
967      printf("%s", $G_sidebanner);
968    }
969
970
971    if ($G_with_sidebanner2) {
972      printf("%s", $G_sidebanner2);
973    }
974    printf("</td><td>");
975 ?> 
976
977 <!--  =========== tables ===========  -->
978 <?php
979
980 /* MLANG: "Digita il tuo nickname per accedere ai tavoli della briscola.", "entra", "Se non hai ancora una password, lascia il campo in bianco ed entra." ,"(se usi firefox e qualcosa non funziona prova a ricaricare la pagina con Ctrl + F5)" */
981 echo "$body"; ?>
982 <br>
983 <div style="text-align: center;">
984    <br><br><br>
985 <?php echo $mlang_room['welcome'][$G_lang];?>
986 <br><br>
987 <form accept-charset="utf-8" method="post" action="" onsubmit="return j_login_manager(this);">
988 <input id="passid_private" name="pass_private" type="hidden" value="">
989 <table class="login">
990 <tr><td>user:</td>
991 <td><input id="nameid" class="input_text" name="name" type="text" size="24" maxlength="12" value=""></td></tr>
992 <tr><td>pwd:</td>
993 <td><input id="passid" class="input_text" name="pass" type="password" size="24" maxlength="64" value=""></td></tr>
994 <tr><td colspan="2"><input id="sub" value="<?php echo $mlang_room['btn_enter'][$G_lang];?>" type="submit" class="button"></td></tr>
995 </table>
996 </form><br>
997 <b><?php echo $mlang_room['passwarn'][$G_lang];?></b><br><br>
998 <?php echo $mlang_room['browwarn'][$G_lang];?><br>
999 </div>
1000 <br><br><br><br>
1001 <br><br><br><br>
1002 <br><br><br><br>
1003 <br><br><br><br>
1004 <br><br><br><br>
1005
1006 <div id="imgct"></div>
1007 <div id="logz"></div>
1008 <div id="sandbox"></div>
1009 <div id="sandbox2"></div>
1010 <div id="response"></div>
1011 <div id="xhrstart"></div>
1012 <pre>
1013 <div id="xhrlog"></div>
1014 </pre>
1015 <div id="xhrdeltalog"></div>
1016 </body>
1017 </html>
1018 <?php
1019   }
1020   else if ($ACTION == 'room') {
1021       $header_out['Content-type'] = "text/html; charset=\"utf-8\"";
1022   ?>
1023 <html>
1024 <head>
1025 <title>Brisk</title>
1026 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
1027 <link rel="shortcut icon" href="img/brisk_ico.png">
1028 <script type="text/javascript" src="commons.js"></script>
1029 <script type="text/javascript" src="prefs.js"></script>
1030 <!-- <script type="text/javascript" src="myconsole.js"></script> -->
1031 <script type="text/javascript" src="menu.js"></script>
1032 <script type="text/javascript" src="ticker.js"></script>
1033 <script type="text/javascript" src="heartbit.js"></script>
1034 <script type="text/javascript" src="xynt-streaming.js"></script>
1035 <script type="text/javascript" src="room.js"></script>
1036 <script type="text/javascript" src="preload_img<?php echo langtolng($G_lang); ?>.js"></script>
1037 <script type="text/javascript" src="AC_OETags.js"></script>
1038 <script type="text/javascript" src="probrowser.js"></script>
1039 <script type="text/javascript" src="json2.js"></script>
1040 <link rel="stylesheet" type="text/css" href="brisk.css">
1041 <link rel="stylesheet" type="text/css" href="room.css">
1042 <SCRIPT type="text/javascript"><!--
1043    var sess = "not_connected";
1044    var g_debug = 0;
1045    var g_lang = "<? echo $G_lang; ?>";
1046    var g_lng = "<? echo $G_lng; ?>";
1047    var g_tables_n = <? echo TABLES_N; ?>;
1048    var g_tables_auth_n = <? echo TABLES_AUTH_N; ?>;
1049    var g_prefs, g_prefs_new = null;
1050    var g_listen;
1051    var g_is_spawn = 0;
1052    var g_withflash = false;
1053    var g_imgct = 0;
1054    var g_imgtot = g_preload_img_arr.length;
1055    var g_brow = null;
1056    var g_nd = null;
1057    var tra = null;
1058    var stat = "";
1059    var subst = "";
1060    var gst  = new globst();
1061    var topbanner_sfx, topbanner_dx;
1062    // var nonunload = false;
1063    var spo_slide, sup_slide;
1064
1065    window.onload = function() {
1066      g_brow = get_browser_agent();
1067
1068      g_prefs = new client_prefs(null);
1069
1070      spo_slide  = new sideslide($('spon_caro'), 80, 20);
1071      sup_slide  = new sideslide($('supp_caro'), 80, 20);
1072
1073 <?php
1074 if ($BRISK_SHOWHTML == "debugtable") {
1075 ?>
1076      room_checkspace(12, <?php echo TABLES_N; ?>, 50);
1077 <?php
1078 }
1079 else {
1080 ?>
1081     // alert("INDEX START");
1082      menu_init();
1083 <?php
1084      if ($G_with_topbanner) {
1085        printf("     topbanner_init();\n");
1086      }
1087      if ($G_with_sidebanner) {
1088        printf("     sidebanner_init();\n");
1089     }
1090      if ($G_with_sidebanner2) {
1091        printf("     sidebanner2_init();\n");
1092     }
1093
1094 ?>
1095      sess = "<?php echo "$sess"; ?>";
1096 xstm = new xynt_streaming(window, "<?php echo "$transp_type"; ?>", 80, 2, null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);});
1097      xstm.hbit_set(heartbit);
1098      tra = new train($('room_tit'));
1099      window.onunload = onunload_cb;
1100      window.onbeforeunload = onbeforeunload_cb;
1101      g_withflash = DetectFlashVer(6,0,0);
1102      if (g_withflash == false) {
1103        $("proflash").innerHTML = 'Audio con Flash.<br><a href="http://www.macromedia.com/"><img class="nobo" style="padding: 4px; width:73; height: 19;" src="img/download_now_flash.gif"></a>';
1104      }
1105      else
1106        $("proflashext").innerHTML = "";
1107
1108      // console.log("session from main: "+sess);
1109      xstm.start();
1110      // alert("ARR LENGTH "+g_preload_img_arr.length);
1111      // FIXME: preload image will be fired by stream instead here
1112      // setTimeout(preload_images, 0, g_preload_img_arr, g_imgct); 
1113      $("txt_in").focus();
1114 <?php
1115 if ($is_login) {
1116   /* MLANG: "<br>Il nickname che stai usando &egrave; gi&agrave; registrato,<br><br>se il suo proprietario si autentificher&agrave;<br><br>verrai rinominato d'ufficio come ghost<i>N</i>.", "torna ai tavoli" */
1117   echo show_notify($mlang_room['regwarn'][$G_lang], 0, $mlang_room['btn_rettabs'][$G_lang], 400, 150);
1118 }
1119 ?>
1120 <?php
1121 }
1122 ?>
1123    }
1124    //-->
1125 </SCRIPT>
1126 </head>
1127 <?php
1128     if (!$G_is_local) {
1129 ?>
1130 <!-- if myconsole <body onunload="deconsole();"> -->
1131 <body xmlns:fb="http://ogp.me/ns/fb#">
1132 <div id="fb-root"></div>
1133 <script>(function(d, s, id) {
1134   var js, fjs = d.getElementsByTagName(s)[0];
1135   if (d.getElementById(id)) return;
1136   js = d.createElement(s); js.id = id;
1137   js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1";
1138   fjs.parentNode.insertBefore(js, fjs);
1139 }(document, 'script', 'facebook-jssdk'));</script>
1140 <?php
1141     }
1142     else {
1143 ?>
1144 <body>
1145 <?php
1146   }
1147 ?>
1148 <?php
1149    printf($brisk_header_form);
1150    printf("<table class=\"floaty\"><tr><td class=\"floatyleft\">\n");
1151    printf($brisk_vertical_menu, '', $brisk_donate);
1152
1153
1154    if ($G_with_sidebanner xor $G_with_sidebanner2) {
1155      printf("<br><br>");
1156    }
1157
1158    if ($G_with_sidebanner) {
1159      printf("%s", $G_sidebanner);
1160    }
1161
1162
1163    if ($G_with_sidebanner2) {
1164      printf("%s", $G_sidebanner2);
1165    }
1166
1167    printf("</td><td>");
1168 ?>
1169 <!--  =========== tables ===========  -->
1170 <input name="sess" type="hidden" value="<?php echo "$user->sess"; ?>">
1171 <table class="macro"><tr><td>
1172 <?php echo "$tables"; ?>
1173 </td></tr><tr><td>
1174     <?php echo "$standup"; ?>
1175 </td></tr></table>
1176 </td></tr></table>
1177
1178 <!--  =========== bottom ===========  -->
1179     <div id="bottom" class="bottom">
1180 <b>Chat</b> <span id="list_info" style="color: red;"></span><br>
1181 <div id="txt" class="chatt">
1182 </div>
1183 <div style="text-align: center; ">
1184     <!-- MLANG: scrivi un invito al tavolo e clicca -->
1185     <table style="width: 98%; margin: auto;"><tr><td id="tickbut" class="tickbut"><img class="tickbut" src="img/train.png" onclick="act_tav();" title="<?php echo $mlang_room['tit_ticker'][$G_lang];?>"></td><td style="width:1%; text-align: center;">
1186     <div id="myname"></div>
1187     </td><td>
1188     <input id="txt_in" maxlength="128" type="text" style="width: 100%;" onkeypress="chatt_checksend(this,event);">
1189     </td></tr></table>
1190 </div>
1191 </div>
1192
1193     <div id="authbox" class="notify" style="text-align: center;">
1194        <br>
1195        <b>
1196     <!-- MLANG: Garantisci per un tuo conoscente: -->
1197     <?php echo $mlang_room['tit_warr'][$G_lang]; ?>
1198 </b>
1199        <br><br>
1200
1201        <form id="auth_form" accept-charset="utf-8" method="post" action="" onsubmit="return j_authbox(this);">
1202        <input type="hidden" name="realsub" value="666">
1203 <table class="login">
1204 <tr><td>nickname:</td>
1205 <td><input id="nameid" class="input_text" name="name" type="text" size="24" maxlength="12" value=""></td></tr>
1206 <tr><td>e-mail:</td>
1207 <td><input id="emailid" class="input_text" name="email" type="text" size="24" maxlength="1024" value=""></td></tr>
1208 <tr><td colspan="2" style="text-align: center;">
1209     <!-- MLANG: Garantisci per un tuo conoscente: -->
1210        <input id="subid" name="sub" value=
1211 "<?php echo $mlang_room['btn_send'][$G_lang]; ?>"
1212  type="submit" onclick="this.form.elements['realsub'].value = 'invia';" class="button">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1213     <!-- MLANG: Garantisci per un tuo conoscente: -->
1214 <input id="cloid" name="clo" value=
1215 "<?php echo $mlang_room['btn_close'][$G_lang]; ?>" 
1216 type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chiudi';"></td></tr>
1217 </table>
1218     </form>
1219     </div>
1220     <div id="mesgtoadmbox" class="notify_opaque" style="text-align: center;">
1221        <br>
1222 <!--MLANG: Invia un messaggio o una segnalazione all\'amministratore: -->
1223        <b><?php echo $mlang_room['mesgtoadm_tit'][$G_lang];?></b>
1224        <br><br>
1225        <form id="mesgtoadm_form" accept-charset="utf-8" method="post" action="" onsubmit="return j_mesgtoadmbox(this);">
1226        <input type="hidden" name="realsub" value="666">
1227 <table class="login">
1228 <!--MLANG: soggetto -->
1229 <tr><td><b><?php echo $mlang_room['mesgtoadm_sub'][$G_lang];?></b></td>
1230 <td><input id="subjid" class="input_text" name="subj" type="text" size="32" maxlength="255" value=""></td></tr></table>
1231 <table class="login">
1232 <tr><td><img title="messaggio" class="nobo" src="img/mesgtoadm_mesg<?php echo $G_lng;?>.png"></td>
1233 <td><textarea id="mesgid" class="input_text" name="mesg" cols="40" rows="8" wrap="soft"></textarea></td></tr>
1234 <tr><td colspan="2" style="text-align: center;">
1235        <input id="subid" name="sub" value="<?php echo $mlang_room['btn_send'][$G_lang];?>" type="submit" onclick="this.form.elements['realsub'].value = 'invia';" class="button">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1236 <input id="cloid" name="clo" value="<?php echo $mlang_room['btn_close'][$G_lang];?>" type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chiudi';"></td></tr>
1237 </table>
1238     </form>
1239     </div>
1240 <div id="heartbit"></div>
1241 <div id="sandbox"></div>
1242 <div id="imgct"></div>
1243 <div id="logz"></div>
1244 <div id="sandbox2"></div>
1245 <div id="response"></div>
1246 <div id="remark"></div>
1247 <div id="xhrstart"></div>
1248 <div id="xhrlog"></div>
1249 <div id="xhrdeltalog"></div>
1250 </div>
1251 <div id="preferences" class="notify" style="z-index: 200; width: 600px; margin-left: -300px; height: 240px; top: 150px; visibility: hidden;">
1252 <div id="preferences_child" style="border-bottom: 1px solid gray; overflow: auto; height: 370px;">
1253
1254 <h2><?php echo $mlang_room['tit_prefs'][$G_lang]; ?></h2>
1255 <table style="margin: auto;"><tr><td style="vertical-align: top;">
1256 <!--#
1257     #  LISTEN
1258     #-->
1259 <div style="float: left; padding: 8px;">
1260 <table style="border: 1px solid gray;"><tr><th style="background-color: #cccccc;">
1261 <?php echo $mlang_room['itm_list'][$G_lang];?>
1262 </th></tr>
1263 <tr><td><input style="vertical-align: bottom;" id="ra_listen_all" type="radio" name="listen" value="0" onclick="prefs_update('listen');" title="'
1264 <?php echo $mlang_room['listall_desc'][$G_lang];?>
1265 '"><span id="list_all">
1266 <?php echo $mlang_room['tit_listall'][$G_lang];?>
1267 </span></td></tr>
1268 <tr><td><input style="vertical-align: bottom;" id="ra_listen_auth" type="radio" name="listen" value="1" onclick="prefs_update('listen');" title="'
1269 <?php echo $mlang_room['listaut_desc'][$G_lang];?>
1270 '"><span id="list_auth">
1271 <?php echo $mlang_room['tit_listaut'][$G_lang];?>
1272 </span></td></tr>
1273 <tr><td><input style="vertical-align: bottom;" id="ra_listen_isol" type="radio" name="listen" value="2" onclick="prefs_update('listen');" title="'
1274 <?php echo $mlang_room['listisol_desc'][$G_lang];?>
1275 '"><span id="list_isol">
1276 <?php echo $mlang_room['tit_listisol'][$G_lang];?>
1277 </span></td></tr>
1278 </table>
1279 </div>
1280 <?php
1281 if ($user->is_supp_custom()) {
1282 ?>
1283 </td>
1284 <td style="vertical-align: top;">
1285 <!--#
1286     #  SUPPORTER ONLY
1287     #-->
1288 <div style="float: left; padding: 8px;">
1289 <table style="border: 1px solid gray;"><tr><th colspan="4" style="background-color: #cccccc;">
1290 <?php echo $mlang_room['suppcomp_tit'][$G_lang];?>
1291 </th></tr>
1292 <tr>
1293 <th>
1294 <?php echo $mlang_room['suppcomp_fg'][$G_lang];?>
1295 </th><td><input style="width: 3em;" id="s_fg_r" type="text" maxlength="3" size="3" name="s_fg_r"
1296  onchange="prefs_update('supp');" value="255"
1297  title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
1298    <span id="list_all"><?php echo $mlang_room['suppcomp_r'][$G_lang];?></span></td>
1299 <td><input style="width: 3em;" id="s_fg_g" type="text" maxlength="3" size="3" name="s_fg_g"
1300  onchange="prefs_update('supp');" value="255"
1301  title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
1302    <span id="list_all"><?php echo $mlang_room['suppcomp_g'][$G_lang];?></span></td>
1303 <td><input style="width: 3em;" id="s_fg_b" type="text" maxlength="3" size="3" name="s_fg_b"
1304  onchange="prefs_update('supp');" value="255"
1305  title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
1306    <span id="list_all"><?php echo $mlang_room['suppcomp_b'][$G_lang];?></span></td>
1307 </tr>
1308 <tr>
1309 <th>
1310 <?php echo $mlang_room['suppcomp_bg'][$G_lang];?>
1311 </th>
1312 <td><input style="width: 3em;" id="s_bg_r" type="text" maxlength="3" size="3" name="s_bg_r"
1313  onchange="prefs_update('supp');" value="255"
1314  title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
1315    <span id="list_all"><?php echo $mlang_room['suppcomp_r'][$G_lang];?></span></td>
1316 <td><input style="width: 3em;" id="s_bg_g" type="text" maxlength="3" size="3" name="s_bg_g"
1317  onchange="prefs_update('supp');" value="255"
1318  title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
1319    <span id="list_all"><?php echo $mlang_room['suppcomp_g'][$G_lang];?></span></td>
1320 <td><input style="width: 3em;" id="s_bg_b" type="text" maxlength="3" size="3" name="s_bg_b"
1321  onchange="prefs_update('supp');" value="255"
1322  title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
1323    <span id="list_all"><?php echo $mlang_room['suppcomp_b'][$G_lang];?></span></td>
1324 </tr>
1325 <tr><td colspan="4" style="text-align: center;">
1326 <img id="s_img" class="nobo" src="img/noimg.png">
1327 </td></tr>
1328 </table>
1329 </div>
1330 </td>
1331 <td>
1332 <?php
1333 }
1334 else {
1335 ?>
1336 <input id="s_fg_r" type="hidden" name="s_fg_r">
1337 <input id="s_fg_g" type="hidden" name="s_fg_g">
1338 <input id="s_fg_b" type="hidden" name="s_fg_b">
1339 <input id="s_bg_r" type="hidden" name="s_bg_r">
1340 <input id="s_bg_g" type="hidden" name="s_bg_g">
1341 <input id="s_bg_b" type="hidden" name="s_bg_b">
1342 <input id="s_img"  type="hidden" name="s_bg_b">
1343 <?php
1344 }
1345 ?>
1346 </td></tr></table>
1347 <div style="width: 95%; /* background-color: red; */ margin: auto; text-align: left;">
1348 <br><br>
1349                                                           <!-- <input type="checkbox" name="pref_ring_endauct" id="pref_ring_endauct" onclick="pref_ring_endauct_set(this);"><?php /* echo $mlang_room['itm_ringauc'][$G_lang]; */ ?> -->
1350 </div>
1351
1352
1353 </div>
1354 <div class="notify_clo">
1355 <input type="submit" class="input_sub" style="bottom: 4px;" onclick="$('preferences').style.visibility = 'hidden';" value="<?php echo $mlang_room['btn_prefs_close'][$G_lang]; ?>"/> 
1356 <input type="submit" class="input_sub" style="bottom: 4px;" onclick="prefs_reset();" value="<?php echo $mlang_room['btn_prefs_reset'][$G_lang]; ?>"/>
1357 <input type="submit" class="input_sub" style="bottom: 4px;" onclick="prefs_save();" value="<?php echo $mlang_room['btn_prefs_save'][$G_lang]; ?>"/>
1358 </div>
1359 </div>
1360 </body>
1361 </html>
1362 <?php
1363    }
1364 }
1365
1366 ?>