spostata la chiusura finestra in fondo alla pagina
[brisk.git] / web / index.php
index 2cfa99e..090f960 100644 (file)
@@ -42,29 +42,26 @@ function main()
     $bri = &load_data();
     
     /* Actions */
-    if (isset($sess)) {
+    if (validate_sess($sess)) {
       $bri->garbage_manager(TRUE);
-      if (($user = &get_user(&$bri, $sess, &$idx)) != FALSE) {
+      if (($user = &$bri->get_user($sess, &$idx)) != FALSE) {
        if ($user->stat == "table") {
          header ("Location: table.php");
          unlock_data($sem);
          exit;
        }
-       $ACTION = "table";
-      }
-      else {
-       setcookie ("sess", "", time() - 3600);
+       $ACTION = "room";
       }
     }
-    else if (isset($name)) {
+    
+    if ($ACTION == "login" && isset($name)) {
       $bri->garbage_manager(TRUE);
       /* try login */
-      $name = substr($name, 0, 12);
-      if (($user = &add_user(&$bri, &$sess, &$idx, $name)) != FALSE) {
-       $ACTION = "table";
+      if (($user = &$bri->add_user(&$sess, &$idx, $name)) != FALSE) {
+       $ACTION = "room";
        
-       setcookie ("sess", "", time() + 180);      
-       standup_update(&$bri,&$user);
+       // setcookie ("sess", "", time() + 180);      
+       $bri->standup_update(&$user);
        
        if (save_data(&$bri) == FALSE) {
          echo "ERRORE SALVATAGGIO\n";
@@ -73,7 +70,9 @@ function main()
       }
       else {
        /* Login Rendering */
-       if ($idx == -1) 
+       if ($idx == -2)
+         $body .= '<div class="urgmsg"><b>Il nickname deve contenere almeno una lettera o una cifra.</b></div>';
+       else if ($idx == -1) 
          $body .= '<div class="urgmsg"><b>Spiacenti, non ci sono pi&ugrave; posti liberi. Riprova pi&ugrave; tardi.</b></div>';
        else
          $body .= '<div class="urgmsg"><b>Il tuo nickname &egrave; gi&agrave; in uso.</b></div>';
@@ -84,13 +83,13 @@ function main()
   /* Rendering. */
 
   if ($BRISK_DEBUG == "debugtable") {
-    $ACTION = "table";
+    $ACTION = "room";
   }
   else if ($BRISK_DEBUG == "debuglogin") {
     $ACTION = "login";
   }
 
-  if ($ACTION == "table") {
+  if ($ACTION == "room") {
     $tables .= '<table class="room_tab" align="center">';
     for ($i = 0 ; $i < TABLES_N ; $i++) {
       if ($i % 4 == 0)
@@ -113,9 +112,23 @@ function main()
     $tables .= '</table>';
   }
 
-$brisk_header = '<div class="container">
+  $altout_propag = array( array ( 'url' => 'http://www.alternativeoutput.it',
+                                 'content' => '<img class="nobo" src="img/altout80x15.png">' ),
+                         array ( 'url' => 'http://virtualsky.alternativeoutput.it',
+                                 'content' => '<img class="nobo" src="img/virtualsky80x15.png">' )
+                         );
+  
+  // seed with microseconds since last "whole" second
+  srand ((double) microtime() * 1000000);
+  $randval = rand(0,count($altout_propag)-1);
+  $altout_carousel = sprintf('<a target="_blank" href="%s">%s</a>',
+                            $altout_propag[$randval]['url'],
+                            $altout_propag[$randval]['content']);
+                        
+
+$brisk_header_form = '<div class="container">
 <!-- =========== header ===========  -->
-<div class="header">
+<div id="header" class="header">
 <img class="nobo" src="img/brisk_logo64.png">
 briscola chiamata in salsa ajax<br><br>
 </div>
@@ -124,11 +137,13 @@ briscola chiamata in salsa ajax<br><br>
 <div class="topmenu">
 <a target="_blank" href="/briskhome.php"><img class="nobo" src="img/brisk_homebutt.png"></a>
 <br><br><br>
-sponsored by:<br><br>
-<a target="_blank" href="http://www.alternativeoutput.it"><img class="nobo" src="img/altout80x15.png"></a><br>
+sponsored by:<br><br>'.$altout_carousel.'<br>
 <a target="_blank" href="http://www.dynamica.it"><img class="nobo" src="img/dynamica.png"></a><br><br>
 supported by:<br><br>
 <a target="_blank" href="http://www.briscolachiamata.it"><img class="nobo" src="img/brichi.png"></a><br><br>
+<div id="proflashext" class="proflashext"><div id="proflash" class="proflash">
+</div><br><br></div>
+%s
 </div>';
     
   /* Templates. */
@@ -143,20 +158,30 @@ supported by:<br><br>
 <script type="text/javascript" src="commons.js"></script> 
 <script type="text/javascript" src="xhr.js"></script>
 <script type="text/javascript" src="preload_img.js"></script>
+<script type="text/javascript" src="AC_OETags.js"></script>
+<link rel="stylesheet" type="text/css" href="brisk.css">
 <link rel="stylesheet" type="text/css" href="room.css">
 </head>
 <body>
 <SCRIPT type="text/javascript">
+   var g_withflash = false;
+
    window.onload = function() {
+     g_withflash = DetectFlashVer(6,0,0);
+     if (g_withflash == false) {
+       $("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>';
+     }
+     else
+       $("proflashext").innerHTML = "";
      $("nameid").focus();
    }
 </SCRIPT>
 <?php
-    echo "$brisk_header";
+    printf($brisk_header_form, '');
 ?> 
 
 <!--  =========== tables ===========  -->
-<div class="tables">
+<div id="tables" class="tables">
 <?php echo "$body"; ?>
 
 <br>
@@ -165,6 +190,7 @@ supported by:<br><br>
 Digita il tuo nickname per accedere ai tavoli della briscola.<br><br>
 <form method="post" action="">
 <input id="nameid" name="name" type="text" size="24" maxlength="12" value="">
+<input id="sub"    value="entra" type="submit" class="button">
 </form>
 </div>
 </div></div>
@@ -184,7 +210,7 @@ Digita il tuo nickname per accedere ai tavoli della briscola.<br><br>
 </html>
 <?php
   }
-  else if ($ACTION == 'table') {
+  else if ($ACTION == 'room') {
   ?>
 <html>
 <head>
@@ -195,6 +221,8 @@ Digita il tuo nickname per accedere ai tavoli della briscola.<br><br>
 <script type="text/javascript" src="commons.js"></script> 
 <script type="text/javascript" src="xhr.js"></script>
 <script type="text/javascript" src="preload_img.js"></script>
+<script type="text/javascript" src="AC_OETags.js"></script>
+<link rel="stylesheet" type="text/css" href="brisk.css">
 <link rel="stylesheet" type="text/css" href="room.css">
 </head>
 <body>
@@ -204,6 +232,7 @@ Digita il tuo nickname per accedere ai tavoli della briscola.<br><br>
    var subst = "";
    var gst  = new globst();
 
+   var g_withflash = false;
    var g_imgct= 0;
    var g_imgtot = g_preload_img_arr.length;
    var myfrom = "index_php";
@@ -221,7 +250,12 @@ else {
      sess = "<?php echo "$sess"; ?>";
 
      window.onunload = onunload_cb;
-
+     g_withflash = DetectFlashVer(6,0,0);
+     if (g_withflash == false) {
+       $("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>';
+     }
+     else
+       $("proflashext").innerHTML = "";
      setTimeout(xhr_rd_poll, 0, sess); 
      // alert("ARR LENGTH "+g_preload_img_arr.length);
      setTimeout(preload_images, 0, g_preload_img_arr, g_imgct); 
@@ -233,16 +267,16 @@ else {
 
 </SCRIPT>
 <?php
-    echo "$brisk_header";
+    printf($brisk_header_form, '<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>');
 ?> 
 <!--  =========== tables ===========  -->
-<div class="tables">
+<div id="tables" class="tables">
 <input name="sess" type="hidden" value="<?php echo "$user->sess"; ?>">
 <?php echo "$tables"; ?>
 </div>
 
 <!--  =========== bottom ===========  -->
-<div class="bottom">
+<div id="bottom" class="bottom">
 <b>Chat</b>
 <div id="txt" class="chatt">
 </div>