5 * Copyright (C) 2006-2008 Matteo Nastasi
6 * mailto: nastasi@alternativeoutput.it
7 * matteo.nastasi@milug.org
8 * web: http://www.alternativeoutput.it
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.
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.
27 require_once("Obj/brisk.phh");
28 require_once("Obj/auth.phh");
29 require_once("Obj/proxyscan.phh");
31 // Use of proxies isn't allowed.
32 if (!$G_is_local && is_proxy())
35 require_once("briskin5/Obj/briskin5.phh");
36 if (DEBUGGING == "local" && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
37 echo "Debugging time!";
41 log_load("index.php");
45 GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local;
46 GLOBAL $sess, $name, $pass_private, $table_idx, $table_token, $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER;
53 if (isset($BRISK_SHOWHTML) == FALSE) {
55 $sem = Room::lock_data();
56 log_main("lock Room");
57 $room = &Room::load_data();
62 if (validate_sess($sess)) {
63 log_main("pre garbage_manager UNO");
64 $room->garbage_manager(TRUE);
65 log_main("post garbage_manager");
66 if (($user = &$room->get_user($sess, &$idx)) != FALSE) {
67 log_main("user stat: ".$user->stat);
68 if ($user->stat == "table") {
69 if (Room::save_data(&$room) == FALSE) {
70 echo "ERRORE SALVATAGGIO\n";
73 log_main("unlock Room");
74 Room::unlock_data($sem);
75 setcookie("table_token", $user->table_token, $curtime + 31536000);
76 setcookie("table_idx", $user->table, $curtime + 31536000);
77 header ("Location: briskin5/index.php");
83 if (Room::save_data(&$room) == FALSE) {
84 echo "ERRORE SALVATAGGIO\n";
89 if ($ACTION == "login" && isset($name)) {
91 log_main("pre garbage_manager DUE");
93 if (isset($pass_private) == FALSE) {
94 $pass_private = FALSE;
97 $room->garbage_manager(TRUE);
99 if (($user = &$room->add_user(&$sess, &$idx, $name, $pass_private, $_SERVER['REMOTE_ADDR'])) != FALSE) {
103 $login_exists = TRUE;
106 $login_exists = FALSE;
108 log_legal($curtime, $user->sess, $user->name, "STAT:LOGIN", '');
111 // setcookie ("sess", "", time() + 180);
112 $room->standup_update(&$user);
114 if (Room::save_data(&$room) == FALSE) {
115 echo "ERRORE SALVATAGGIO\n";
120 /* Login Rendering */
122 $body .= '<div class="urgmsg"><b>Utente e/o password errati.</b></div>';
124 $body .= '<div class="urgmsg"><b>Il nickname deve contenere almeno una lettera o una cifra.</b></div>';
126 $body .= '<div class="urgmsg"><b>Spiacenti, non ci sono più posti liberi. Riprova più tardi.</b></div>';
128 $body .= '<div class="urgmsg"><b>Il tuo nickname è già in uso.</b></div>';
131 Room::unlock_data($sem);
135 if ($BRISK_SHOWHTML == "debugtable") {
138 else if ($BRISK_SHOWHTML == "debuglogin") {
142 if ($ACTION == "room") {
143 $tables .= '<div class="room_tab">';
144 $tables .= '<table class="room_tab">';
145 for ($i = 0 ; $i < TABLES_N ; $i++) {
149 $tables .= '<div class="room_div"><div class="room_tit"><b>Tavolo '.$i.'</b></div>';
150 $tables .= sprintf('<div class="proxhr" id="table%d"></div>', $i);
151 $tables .= sprintf('<div class="table_act" id="table_act%d"></div>', $i);
153 $tables .= '</td>'."\n";
157 $tables .= '</table></div>';
160 $standup .= '<table class="room_standup"><tr><td><div class="room_standup_orig" id="room_standup_orig"></div>';
161 $standup .= '<div class="room_ex_standup">';
162 $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>';
164 $standup .= sprintf('<div id="standup" class="room_standup"></div>');
165 $standup .= '<div id="esco" class="esco"></div>';
166 $standup .= '</div></td></tr></table>';
169 $altout_propag = array( array ( 'id' => 'btn_altout',
170 'url' => 'http://www.alternativeoutput.it',
171 'content' => 'img/altout80x15.png',
172 'content_big' => 'img/altout80x15.png'),
173 array ( 'id' => 'btn_virtualsky',
174 'url' => 'http://virtualsky.alternativeoutput.it',
175 'content' => 'img/virtualsky80x15a.gif',
176 'content_big' => 'img/virtualsky_big.png')
179 // seed with microseconds since last "whole" second
180 srand ((double) microtime() * 1000000);
181 // $randval = rand(0,count($altout_propag)-1);
183 $altout_carousel = sprintf('<a target="_blank" href="%s"><img id="%s" class="nobo" src="%s" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a>',
184 $altout_propag[$randval]['url'],
185 $altout_propag[$randval]['id'],
186 $altout_propag[$randval]['content']);
188 $altout_carousel_big = sprintf('<img class="nobohide" id="%s_big" src="%s">',
189 $altout_propag[$randval]['id'],
190 $altout_propag[$randval]['content_big']);
193 $brisk_donate = file_get_contents(FTOK_PATH."/brisk_donate.txt");
194 if ($brisk_donate == FALSE)
200 $brisk_header_form = '<div class="container">
201 <!-- =========== header =========== -->
202 <div id="header" class="header">
203 <table width="100%%" border="0" cols="3"><tr>
204 <td align="left"><div style="padding-left: 8px;">'.($G_is_local ? '' :
205 '<script type="text/javascript"><!--
206 google_ad_client = "pub-5246925322544303";
207 google_ad_width = 234;
208 google_ad_height = 60;
209 google_ad_format = "234x60_as";
210 google_ad_type = "text_image";
211 google_ad_channel = "";
212 google_color_border = "808080";
213 google_color_bg = "f6f6f6";
214 google_color_link = "ffae00";
215 google_color_text = "404040";
216 google_color_url = "000000";
219 <script type="text/javascript"
220 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
223 <td align="center">'.($G_with_topbanner ? '<table><tr><td>' : '').'<div style="text-align: center;">
224 <img class="nobo" src="img/brisk_logo64.png">
225 briscola chiamata in salsa ajax<br>
226 </div>'.($G_with_topbanner ? sprintf('</td><td>%s</td></tr></table>', $G_topbanner) : '').'</td>
227 <td align="right"><div style="padding-right: 8px;">
228 '.($G_is_local ? '' :
229 '<script type="text/javascript"><!--
230 google_ad_client = "pub-5246925322544303";
231 google_ad_width = 234;
232 google_ad_height = 60;
233 google_ad_format = "234x60_as";
234 google_ad_type = "text_image";
235 google_ad_channel = "";
236 google_color_border = "808080";
237 google_color_bg = "f6f6f6";
238 google_color_link = "ffae00";
239 google_color_text = "404040";
240 google_color_url = "000000";
243 <script type="text/javascript"
244 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
250 $brisk_vertical_menu = '
251 <!-- =========== vertical menu =========== -->
252 <div class="topmenu">
253 <!-- <a target="_blank" href="/briskhome.php"></a> -->
255 <div class="webstart_hilite">
256 <img class="nobo" src="img/brisk_start.png" onmouseover="menu_show(\'menu_webstart\');">
257 <div class="webstart" id="menu_webstart" onmouseover="menu_over(1,this);" onmouseout="menu_over(-1,this);">
259 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php"
260 onmouseover="menu_hide(0,1);"
261 title="homepage del progetto">homepage</a><br>
263 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#cose"
264 onmouseover="menu_hide(0,1);"
265 title="di cosa si tratta">cos\'è</a><br>
267 <a target="_blank" href="http://it.wikipedia.org/wiki/Briscola#Gioco_a_5"
268 onmouseover="menu_hide(0,1);"
269 title="come si gioca">regole</a><br>
271 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#shots"
272 onmouseover="menu_hide(0,1);"
273 title="screenshots dell\'applicazione">screenshoots</a><br>
275 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#comp"
276 onmouseover="menu_hide(0,1);"
277 title="compatibilità con i browser">compatibilità</a><br>
279 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#sources"
280 onmouseover="menu_hide(0,1);"
281 title="sorgenti dell\'applicazione">sorgenti</a><br>
283 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#mailing"
284 onmouseover="menu_hide(0,1);"
285 title="come iscriversi alla mailing list">mailing list</a><br>
287 <a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#prop"
288 onmouseover="menu_hide(0,1);"
289 title="come fare pubblicità a brisk!">propaganda</a><br>
291 onmouseover="menu_hide(0,1);"
292 title="credits" onclick="act_about();">about</a><br>
294 <a href="mailto:brisk@alternativeoutput.it"
295 onmouseover="menu_hide(0,1);"
296 title="contatti">contatti</a><br>
302 onmouseover="menu_hide(0,1);"
303 title="perché supportare brisk?" onclick="act_whysupport();">supportare?</a><br>
306 onmouseover="menu_hide(0,1);"
307 title="prossime funzionalità implementate" onclick="act_roadmap();">roadmap</a><br>
309 <a href="#" title="foto dei raduni di briskisti"
310 onmouseover="menu_show(\'menu_raduni\');">raduni</a><br>
312 <div id="menu_raduni" class="webstart">
313 <a href="http://www.anomalia.it/mop/photoo"
314 target="_blank" onmouseover="menu_hide(0,2);"
315 title="Torneo di Milano del 17/05/2008" >Milano 05/08</a><br>
317 <a href="http://www.anomalia.it/mop/photoo?album=brisk_pc0806"
318 target="_blank" onmouseover="menu_hide(0,2);"
319 title="Raduno di Piacenza del del 15/06/2008" >Piacenza 06/08</a><br>
324 sponsored by:<br><br>'.$altout_carousel.'<br>
325 <a target="_blank" href="http://www.dynamica.it"><img class="nobo" id="btn_dynamica" src="img/dynamica.png" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a><br><br>
326 supported by:<br><br>
327 <a target="_blank" href="http://www.briscolachiamata.it"><img class="nobo" id="btn_brichi" src="img/brichi.png" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a><br>
328 <a target="_blank" href="http://www.forumolimpia.it"><img class="nobo" id="btn_foroli" src="img/forumolimpia.gif" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a><br><br>
329 <div id="proflashext" class="proflashext"><div id="proflash" class="proflash">
333 <img class="nobohide" id="btn_dynamica_big" src="img/dynamica_big.png">
334 <img class="nobohide" id="btn_brichi_big" src="img/brichi_big.png">
335 <img class="nobohide" id="btn_foroli_big" src="img/forumolimpia_big.png">
336 '.$altout_carousel_big.'</div>';
339 if ($ACTION == 'login') {
340 header('Content-type: text/html; charset="utf-8"',true);
345 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
346 <link rel="shortcut icon" href="img/brisk_ico.png">
347 <script type="text/javascript" src="dnd.js"></script>
348 <script type="text/javascript" src="menu.js"></script>
349 <script type="text/javascript" src="dom-drag.js"></script>
350 <script type="text/javascript" src="commons.js"></script>
351 <script type="text/javascript" src="xhr.js"></script>
352 <script type="text/javascript" src="preload_img.js"></script>
353 <script type="text/javascript" src="AC_OETags.js"></script>
354 <script type="text/javascript" src="room.js"></script>
355 <script type="text/javascript" src="md5.js"></script>
356 <link rel="stylesheet" type="text/css" href="brisk.css">
357 <link rel="stylesheet" type="text/css" href="room.css">
359 <SCRIPT type="text/javascript"><!--
360 var g_withflash = false;
362 var gst = new globst();
363 var topbanner_sfx, topbanner_dx;
365 var sess = "not_connected";
367 window.onload = function() {
368 // alert(window.onbeforeunload);
372 if ($G_with_topbanner) {
373 printf(" topbanner_init();\n");
377 g_withflash = DetectFlashVer(6,0,0);
378 if (g_withflash == false) {
379 $("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>';
382 $("proflashext").innerHTML = "";
390 printf($brisk_header_form);
391 printf("<table class=\"floaty\"><tr><td class=\"floatyleft\">\n");
392 printf($brisk_vertical_menu, '', '');
396 <!-- =========== tables =========== -->
397 <?php echo "$body"; ?>
399 <div style="text-align: center;">
401 Digita il tuo nickname per accedere ai tavoli della briscola.<br><br>
402 <form accept-charset="utf-8" method="post" action="" onsubmit="return j_login_manager(this);">
403 <input id="passid_private" name="pass_private" type="hidden" value="">
404 <table class="login">
406 <td><input id="nameid" class="input_text" name="name" type="text" size="24" maxlength="12" value=""></td></tr>
408 <td><input id="passid" class="input_text" name="pass" type="password" size="24" maxlength="64" value=""></td></tr>
409 <tr><td colspan="2"><input id="sub" value="entra" type="submit" class="button"></td></tr>
412 <b>Se non hai ancora una password, lascia il campo in bianco ed entra.</b><br><br>
413 (se usi firefox e qualcosa non funziona<br>prova a ricaricare la pagina con <b>Ctrl + F5</b>)<br>
417 <div id="imgct"></div>
418 <div id="logz"></div>
419 <div id="sandbox"></div>
420 <div id="sandbox2"></div>
421 <div id="response"></div>
422 <div id="xhrstart"></div>
424 <div id="xhrlog"></div>
426 <div id="xhrdeltalog"></div>
431 else if ($ACTION == 'room') {
432 header('Content-type: text/html; charset="utf-8"',true);
437 <link rel="shortcut icon" href="img/brisk_ico.png">
438 <script type="text/javascript" src="dnd.js"></script>
439 <script type="text/javascript" src="menu.js"></script>
440 <script type="text/javascript" src="dom-drag.js"></script>
441 <script type="text/javascript" src="commons.js"></script>
442 <script type="text/javascript" src="ticker.js"></script>
443 <script type="text/javascript" src="xhr.js"></script>
444 <script type="text/javascript" src="room.js"></script>
445 <script type="text/javascript" src="preload_img.js"></script>
446 <script type="text/javascript" src="AC_OETags.js"></script>
447 <link rel="stylesheet" type="text/css" href="brisk.css">
448 <link rel="stylesheet" type="text/css" href="room.css">
449 <SCRIPT type="text/javascript"><!--
454 var gst = new globst();
456 var topbanner_sfx, topbanner_dx;
457 // var nonunload = false;
458 var g_withflash = false;
460 var g_imgtot = g_preload_img_arr.length;
461 var myfrom = "index_php";
462 window.onload = function() {
464 if ($BRISK_SHOWHTML == "debugtable") {
466 room_checkspace(12, <?php echo TABLES_N; ?>, 50);
471 // alert("INDEX START");
474 if ($G_with_topbanner) {
475 printf(" topbanner_init();\n");
478 xhr_rd = createXMLHttpRequest();
479 // xhr_rd.setRequestHeader("Content-type", "text/html; charset=utf-8");
480 sess = "<?php echo "$sess"; ?>";
481 tra = new train($('room_tit'));
482 window.onunload = onunload_cb;
483 window.onbeforeunload = onbeforeunload_cb;
484 g_withflash = DetectFlashVer(6,0,0);
485 if (g_withflash == false) {
486 $("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>';
489 $("proflashext").innerHTML = "";
491 setTimeout(xhr_rd_poll, 0, sess);
492 // alert("ARR LENGTH "+g_preload_img_arr.length);
493 setTimeout(preload_images, 0, g_preload_img_arr, g_imgct);
497 echo show_notify("<br>Il nickname che stai usando è già registrato,<br><br>se il suo proprietario si autentificherà<br><br>verrai rinominato d'ufficio come ghost<i>N</i>.", 0, "torna ai tavoli", 400, 150);
509 printf($brisk_header_form);
510 printf("<table class=\"floaty\"><tr><td class=\"floatyleft\">\n");
511 printf($brisk_vertical_menu, '<input type="button" class="button" name="xhelp" value="Help." onclick="act_help();"><br><!-- <br><input type="button" class="button" name="xabout" value="About." onclick="act_about();">--><br><br><br>',
515 <!-- =========== tables =========== -->
516 <input name="sess" type="hidden" value="<?php echo "$user->sess"; ?>">
517 <table class="macro"><tr><td>
518 <?php echo "$tables"; ?>
520 <?php echo "$standup"; ?>
524 <!-- =========== bottom =========== -->
525 <div id="bottom" class="bottom">
527 <div id="txt" class="chatt">
529 <div style="text-align: center; ">
530 <table style="width: 98%; margin: auto;"><tr><td id="tickbut" class="tickbut"><img class="tickbut" src="img/train.png" onclick="act_tav();" title="scrivi un invito al tavolo e clicca"></td><td style="width:1%; text-align: center;">
531 <div id="myname"></div>
533 <input id="txt_in" maxlength="128" type="text" style="width: 100%;" onkeypress="chatt_checksend(this,event);">
539 box = document.createElement("div");
540 box.className = "notify";
541 box.style.zIndex = 200;
542 box.style.width = w+"px";
543 box.style.marginLeft = -parseInt(w/2)+"px";
544 box.style.height = h+"px";
545 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
546 box.appendChild(cont);
547 box.appendChild(clodiv);
548 box.style.visibility = "visible";
551 <div id="authbox" class="notify" style="text-align: center;">
553 <b>Garantisci per un tuo conoscente:</b>
558 <form accept-charset="utf-8" method="post" action="" onsubmit="return j_authbox(this);">
559 <input type="hidden" name="realsub" value="666">
560 <table class="login">
561 <tr><td>nickname:</td>
562 <td><input id="nameid" class="input_text" name="name" type="text" size="24" maxlength="12" value=""></td></tr>
564 <td><input id="emailid" class="input_text" name="email" type="text" size="24" maxlength="1024" value=""></td></tr>
565 <tr><td colspan="2" style="text-align: center;">
566 <input id="subid" name="sub" value="invia" type="submit" onclick="this.form.elements['realsub'].value = this.value;" class="button">
567 <input id="cloid" name="clo" value="chiudi" type="submit" class="button" onclick="this.form.elements['realsub'].value = this.value;"></td></tr>
571 <div id="heartbit"></div>
572 <div id="sandbox"></div>
573 <div id="imgct"></div>
574 <div id="logz"></div>
575 <div id="sandbox2"></div>
576 <div id="response"></div>
577 <div id="remark"></div>
578 <div id="xhrstart"></div>
579 <div id="xhrlog"></div>
580 <div id="xhrdeltalog"></div>