changed path to pics and cards and css to be absolute paths
[e-DoKo.git] / index.php
index f2228988735f7ae6b926a33eb4b972afc453d8b7..e86854cea5addfe466f243cd0d628f4f337af8ac 100644 (file)
--- a/index.php
+++ b/index.php
@@ -3,9 +3,9 @@
     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <head>
     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <head>
-     <title>e-Doko</title>
+     <title>e-DoKo</title>
      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
-     <link rel="stylesheet" type="text/css" href="standard.css" />     
+     <link rel="stylesheet" type="text/css" href="http://doko.nubati.net/css/standard.css" />  
      <script type="text/javascript">
        function hl(num) {
          if(document.getElementById){
      <script type="text/javascript">
        function hl(num) {
          if(document.getElementById){
   </head>
 <body onload="high_last();">
 <div class="header">
   </head>
 <body onload="high_last();">
 <div class="header">
-<h1> Welcome to E-Doko </h1>
+<h1> Welcome to E-DoKo </h1>
 <?php
 
 /*
  * config 
  */
 
 <?php
 
 /*
  * config 
  */
 
-$host  = "http://doko.nubati.net/index.php";
+$base  = "http://doko.nubati.net/";
+$host  = $base."index.php";
 $wiki  = "http://wiki.nubati.net/index.php?title=EmailDoko";
 $wiki  = "http://wiki.nubati.net/index.php?title=EmailDoko";
-$debug = 1;
+$debug = 0;
 
 $last=-2;
 
 
 $last=-2;
 
@@ -53,7 +54,6 @@ $last=-2;
 echo "</div>\n";
 
 /* end header */
 echo "</div>\n";
 
 /* end header */
-
                                        
 /* helper function */
 function mymail($To,$Subject,$message)
                                        
 /* helper function */
 function mymail($To,$Subject,$message)
@@ -399,9 +399,9 @@ function display_card($card)
    * convert even cards to the matching odd value */
 
   if( $card/2 - (int)($card/2) == 0.5)
    * convert even cards to the matching odd value */
 
   if( $card/2 - (int)($card/2) == 0.5)
-    echo "<img src=\"cards/".$card.".png\"  alt=\"".card_to_name($card)."\" />\n";
+    echo "<img src=\"".$base."cards/".$card.".png\"  alt=\"".card_to_name($card)."\" />\n";
   else
   else
-    echo "<img src=\"cards/".($card-1).".png\"  alt=\"".card_to_name($card-1)."\" />\n";
+    echo "<img src=\"".$base."cards/".($card-1).".png\"  alt=\"".card_to_name($card-1)."\" />\n";
 
   return;
 }
 
   return;
 }
@@ -409,9 +409,9 @@ function display_card($card)
 function display_link_card($card,$me)
 {
   if( $card/2 - (int)($card/2) == 0.5)
 function display_link_card($card,$me)
 {
   if( $card/2 - (int)($card/2) == 0.5)
-    echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".$card.".png\" alt=\"\" />\n";
+    echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"".$base."cards/".$card.".png\" alt=\"\" />\n";
   else
   else
-    echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".($card-1).".png\" alt=\"\" />\n";
+    echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"".$base."cards/".($card-1).".png\" alt=\"\" />\n";
   return;
 }
 
   return;
 }
 
@@ -480,7 +480,6 @@ function save_status()
 
 /*****************  M A I N **************************/
 
 
 /*****************  M A I N **************************/
 
-
 $history=array();
 
 /* check for status file and read it, if possible */
 $history=array();
 
 /* check for status file and read it, if possible */
@@ -539,7 +538,7 @@ if( isset($_REQUEST["PlayerA"]) &&
     else
       die("no random file");
  
     else
       die("no random file");
  
-    $randomNR = explode( ":", $random[2] );
+    $randomNR = explode( ":", $random[4] );
     
     /* write initial status into file */
     $output = fopen("status.txt","w");
     
     /* write initial status into file */
     $output = fopen("status.txt","w");
@@ -918,11 +917,11 @@ else
                 
                 /* found old trick, display it */
                 if(sizeof($trick)==5)
                 
                 /* found old trick, display it */
                 if(sizeof($trick)==5)
-                  echo "  <li onclick=\"hl('$j');\"><a href=\"#\">Trick $j</a>\n    <div class=\"table\" id=\"trick".$j."\">\n      <img class=\"table\" src=\"pics/table".$play[0].".png\" alt=\"table\" />\n";
+                  echo "  <li onclick=\"hl('$j');\"><a href=\"#\">Trick $j</a>\n    <div class=\"table\" id=\"trick".$j."\">\n      <img class=\"table\" src=\"".$base."pics/table".$play[0].".png\" alt=\"table\" />\n";
                 else
                   {
                     /* display current trick */
                 else
                   {
                     /* display current trick */
-                    echo "<li onclick=\"hl('$j');\"><a href=\"#\">Current Trick</a>\n  <div class=\"table\" id=\"trick".$j."\">\n      <img class=\"table\" src=\"pics/table".$play[0].".png\" alt=\"table\" />";
+                    echo "<li onclick=\"hl('$j');\"><a href=\"#\">Current Trick</a>\n  <div class=\"table\" id=\"trick".$j."\">\n      <img class=\"table\" src=\"".$base."pics/table".$play[0].".png\" alt=\"table\" />";
                   }
                 for($i=0;$i<sizeof($trick)-1;$i++)
                   {
                   }
                 for($i=0;$i<sizeof($trick)-1;$i++)
                   {
@@ -955,7 +954,7 @@ else
                 
                 echo "    </div>\n  </li>\n";
               }
                 
                 echo "    </div>\n  </li>\n";
               }
-            echo "</ul>\n";
+            echo "</ul> <hr />\n";
 
             echo "<div class=\"line\"></div>";
 
 
             echo "<div class=\"line\"></div>";
 
@@ -1083,7 +1082,14 @@ else
                 if(strlen($player[$hash[0]]["cards"]))
                   $history[] = "\n".$win.":\n"; /* not sure why I need the first \n here */
 
                 if(strlen($player[$hash[0]]["cards"]))
                   $history[] = "\n".$win.":\n"; /* not sure why I need the first \n here */
 
+                /* check if game is done */
+                $end = 1;
+                for($i=0;$i<4;$i++)
+                  if(strlen(trim($player[$hash[$i]]["cards"]))!=0)
+                    $end = 0;
+
                 /* email the player who needs to move next*/
                 /* email the player who needs to move next*/
+                if(!$end)
                 for($i=0;$i<4;$i++)
                   {
                     if((ereg("c",$player[$hash[$i]]["option"]) || $i==$win) )
                 for($i=0;$i<4;$i++)
                   {
                     if((ereg("c",$player[$hash[$i]]["option"]) || $i==$win) )