<?php
+function config_check()
+{
+ global $EmailName,$EMAIL_REPLY,$ADMIN_NAME,$ADMIN_EMAIL,$DB_work;
+
+ /* check if some variables are set in the config file, else set defaults */
+ if(!isset($EmailName))
+ $EmailName="[DoKo] ";
+ if(isset($EMAIL_REPLY))
+ {
+ ini_set("sendmail_from",$EMAIL_REPLY);
+ }
+ if(!isset($ADMIN_NAME))
+ {
+ output_header();
+ echo "<h1>Setup not completed</h1>";
+ echo "You need to set \$ADMIN_NAME in config.php.";
+ output_footer();
+ exit();
+ }
+ if(!isset($ADMIN_EMAIL))
+ {
+ output_header();
+ echo "<h1>Setup not completed</h1>";
+ echo "You need to set \$ADMIN_EMAIL in config.php. ".
+ "If something goes wrong an email will be send to this address.";
+ output_footer();
+ exit();
+ }
+ if(!isset($DB_work))
+ {
+ output_header();
+ echo "<h1>Setup not completed</h1>";
+ echo "You need to set \$DB_work in config.php. ".
+ "If this is set to 1, the game will be suspended and one can work safely on the database.".
+ "The default should be 0 for the game to work.";
+ output_footer();
+ exit();
+ }
+ if($DB_work)
+ {
+ output_header();
+ echo "Working on the database...please check back later.";
+ output_footer();
+ exit();
+ }
+
+ return;
+}
+
function mymail($To,$Subject,$message,$header="")
{
- global $debug;
+ global $debug,$EMAIL_REPLY;
+
+ if(isset($EMAIL_REPLY))
+ $header .= "From: e-DoKo daemon <$EMAIL_REPLY>\r\n";
if($debug)
{
return 0;
}
+function display_table ()
+{
+ global $gameid, $GT, $debug,$host;
+
+ $result = mysql_query("SELECT User.fullname as name,".
+ " Hand.position as position, ".
+ " User.id, ".
+ " Hand.party as party, ".
+ " Hand.sickness as sickness, ".
+ " Hand.point_call, ".
+ " User.last_login, ".
+ " Hand.hash ".
+ "FROM Hand ".
+ "LEFT JOIN User ON User.id=Hand.user_id ".
+ "WHERE Hand.game_id='".$gameid."' ".
+ "ORDER BY position ASC");
+
+ echo "<div class=\"table\">\n".
+ " <img src=\"pics/table.png\" alt=\"table\" />\n";
+ while($r = mysql_fetch_array($result,MYSQL_NUM))
+ {
+ $name = $r[0];
+ $pos = $r[1];
+ $user = $r[2];
+ $party = $r[3];
+ $sickness = $r[4];
+ $call = $r[5];
+ $lastlogin = strtotime($r[6]);
+ $hash = $r[7];
+
+ $offset = DB_get_user_timezone($user);
+ $zone = return_timezone($offset);
+ date_default_timezone_set($zone);
+
+ echo " <div class=\"table".($pos-1)."\">\n";
+ if(!$debug)
+ echo " $name \n";
+ else
+ echo " <a href=\"".$host."?me=".$hash."\">$name</a>\n";
+
+ /* add hints for poverty, wedding, solo, etc */
+ if($GT=="poverty" && $party=="re")
+ if($sickness=="poverty")
+ {
+ $userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
+ $cards = DB_get_all_hand($userhash);
+ $trumpNR = count_trump($cards);
+ if($trumpNR)
+ echo " <img src=\"pics/button/poverty_trump_button.png\" class=\"button\" alt=\"poverty < trump back\" />";
+ else
+ echo " <img src=\"pics/button/poverty_notrump_button.png\" class=\"button\" alt=\"poverty <\" />";
+ }
+ else
+ echo " <img src=\"pics/button/poverty_partner_button.png\" class=\"button\" alt=\"poverty >\" />";
+
+ if($GT=="dpoverty")
+ if($party=="re")
+ if($sickness=="poverty")
+ {
+ $userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
+ $cards = DB_get_all_hand($userhash);
+ $trumpNR = count_trump($cards);
+ if($trumpNR)
+ echo " <img src=\"pics/button/poverty_trump_button.png\" class=\"button\" alt=\"poverty < trump back\" />";
+ else
+ echo " <img src=\"pics/button/poverty_notrump_button.png\" class=\"button\" alt=\"poverty <\" />";
+ }
+ else
+ echo " <img src=\"pics/button/poverty_partner_button.png\" class=\"button\" alt=\"poverty >\" />";
+ else
+ if($sickness=="poverty")
+ {
+ $userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
+ $cards = DB_get_all_hand($userhash);
+ $trumpNR = count_trump($cards);
+ if($trumpNR)
+ echo " <img src=\"pics/button/poverty2_trump_button.png\" class=\"button\" alt=\"poverty2 < trump back\" />";
+ else
+ echo " <img src=\"pics/button/poverty2_notrump_button.png\" class=\"button\" alt=\"poverty2 <\" />";
+ }
+ else
+ echo " <img src=\"pics/button/poverty2_partner_button.png\" class=\"button\" alt=\"poverty2 >\" />";
+
+ if($GT=="wedding" && $party=="re")
+ if($sickness=="wedding")
+ echo " <img src=\"pics/button/wedding_button.png\" class=\"button\" alt=\"wedding\" />";
+ else
+ echo " <img src=\"pics/button/wedding_partner_button.png\" class=\"button\" alt=\"wedding partner\" />";
+
+ if(ereg("solo",$GT) && $party=="re")
+ {
+ if(ereg("queen",$GT))
+ echo " <img src=\"pics/button/queensolo_button.png\" class=\"button\" alt=\"$GT\" />";
+ else if(ereg("jack",$GT))
+ echo " <img src=\"pics/button/jacksolo_button.png\" class=\"button\" alt=\"$GT\" />";
+ else if(ereg("club",$GT))
+ echo " <img src=\"pics/button/clubsolo_button.png\" class=\"button\" alt=\"$GT\" />";
+ else if(ereg("spade",$GT))
+ echo " <img src=\"pics/button/spadesolo_button.png\" class=\"button\" alt=\"$GT\" />";
+ else if(ereg("heart",$GT))
+ echo " <img src=\"pics/button/heartsolo_button.png\" class=\"button\" alt=\"$GT\" />";
+ else if(ereg("trumpless",$GT))
+ echo " <img src=\"pics/button/notrumpsolo_button.png\" class=\"button\" alt=\"$GT\" />";
+ else if(ereg("trump",$GT))
+ echo " <img src=\"pics/button/trumpsolo_button.png\" class=\"button\" alt=\"$GT\" />";
+ }
+
+ /* add point calls */
+ if($call!=NULL)
+ {
+ if($party=="re")
+ echo " <img src=\"pics/button/re_button.png\" class=\"button\" alt=\"re\" />";
+ else
+ echo " <img src=\"pics/button/contra_button.png\" class=\"button\" alt=\"contra\" />";
+ switch($call)
+ {
+ case "0":
+ echo " <img src=\"pics/button/0_button.png\" class=\"button\" alt=\"0\" />";
+ break;
+ case "30":
+ echo " <img src=\"pics/button/30_button.png\" class=\"button\" alt=\"30\" />";
+ break;
+ case "60":
+ echo " <img src=\"pics/button/60_button.png\" class=\"button\" alt=\"60\" />";
+ break;
+ case "90":
+ echo " <img src=\"pics/button/90_button.png\" class=\"button\" alt=\"90\" />";
+ break;
+ }
+ }
+
+ echo " <br />\n";
+ echo " <span title=\"".date("Y-m-d H:i:s")."\">local time</span>\n";
+ echo " <span title=\"".date("Y-m-d H:i:s",$lastlogin)."\">last login</span>\n";
+ echo " </div>\n";
+
+ }
+ echo "</div>\n"; /* end output table */
+
+
+ return;
+}
+
+
+function display_user_menu()
+{
+ global $wiki,$myid,$host;
+ echo "<div class=\"usermenu\">\n".
+ "<a href=\"index.php\"> go to my user page </a>";
+
+ $result = mysql_query("SELECT Hand.hash,Hand.game_id,Game.player from Hand".
+ " LEFT JOIN Game On Hand.game_id=Game.id".
+ " WHERE Hand.user_id='$myid'".
+ " AND Game.player='$myid'".
+ " AND Game.status<>'gameover'" );
+ if(mysql_num_rows($result))
+ echo "<hr />It's your turn in these games:<br />\n";
+
+ while( $r = mysql_fetch_array($result,MYSQL_NUM))
+ {
+ echo "<a href=\"".$host."?me=".$r[0]."\">game ".DB_format_gameid($r[1])." </a><br />\n";
+ }
+
+ echo "<hr /> <a href=\"".$host."?new\">start a new game</a>\n";
+
+
+ echo
+ "<hr />Report bugs in the <a href=\"". $wiki."\">wiki</a>\n";
+ echo "</div>\n";
+ return;
+}
+
?>