summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db.php6
-rw-r--r--index.php31
2 files changed, 21 insertions, 16 deletions
diff --git a/db.php b/db.php
index 75cd8a0..a78afb6 100644
--- a/db.php
+++ b/db.php
@@ -705,12 +705,13 @@ function DB_get_hashes_by_session($session,$user)
return $r;
}
-function DB_get_ruleset($dullen,$schweinchen)
+function DB_get_ruleset($dullen,$schweinchen,$call)
{
$r = array();
$result = mysql_query("SELECT id FROM Rulesets WHERE".
" dullen=".DB_quote_smart($dullen)." AND ".
+ " call=".DB_quote_smart($call)." AND ".
" schweinchen=".DB_quote_smart($schweinchen));
if($result)
$r = mysql_fetch_array($result,MYSQL_NUM);
@@ -722,7 +723,8 @@ function DB_get_ruleset($dullen,$schweinchen)
/* create new one */
$result = mysql_query("INSERT INTO Rulesets VALUES (NULL, NULL, ".
DB_quote_smart($dullen).",".
- DB_quote_smart($schweinchen).
+ DB_quote_smart($schweinchen).",".
+ DB_quote_smart($call).
", NULL)");
if($result)
return mysql_insert_id();
diff --git a/index.php b/index.php
index 44a5d5f..eee9b46 100644
--- a/index.php
+++ b/index.php
@@ -61,7 +61,7 @@ if(myisset("new"))
output_form_for_new_game($names);
}
/*check if everything is ready to set up a new game */
- else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD","dullen","schweinchen" ))
+ else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD","dullen","schweinchen","call" ))
{
$PlayerA = $_REQUEST["PlayerA"];
$PlayerB = $_REQUEST["PlayerB"];
@@ -70,7 +70,8 @@ if(myisset("new"))
$dullen = $_REQUEST["dullen"];
$schweinchen = $_REQUEST["schweinchen"];
-
+ $call = $_REQUEST["call"];
+
$EmailA = DB_get_email_by_name($PlayerA);
$EmailB = DB_get_email_by_name($PlayerB);
$EmailC = DB_get_email_by_name($PlayerC);
@@ -92,17 +93,7 @@ if(myisset("new"))
/* create random numbers */
$randomNR = create_array_of_random_numbers($useridA,$useridB,$useridC,$useridD);
$randomNRstring = join(":",$randomNR);
-
- /* get ruleset information or create new one */
- $ruleset = DB_get_ruleset($dullen,$schweinchen);
- if($ruleset <0)
- {
- myerror("Error defining ruleset: $ruleset");
- output_footer();
- DB_close();
- exit();
- };
-
+
/* create game */
$followup = NULL;
if(myisset("followup") )
@@ -125,8 +116,20 @@ if(myisset("new"))
}
}
else
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre', ".
+ {
+ /* get ruleset information or create new one */
+ $ruleset = DB_get_ruleset($dullen,$schweinchen,$call);
+ if($ruleset <0)
+ {
+ myerror("Error defining ruleset: $ruleset");
+ output_footer();
+ DB_close();
+ exit();
+ };
+
+ mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre', ".
"'$ruleset',NULL ,NULL)");
+ }
$game_id = mysql_insert_id();
/* create hash */