NEW FEATURE: addicted people can turn of a lot of the email spam and just check...
[e-DoKo.git] / index.php
index 77c2c2270b739ead0ee4e0d0be7932ddd4f8033c..bf96982f7a61e653a13b43df8631d604d086fb9c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1048,7 +1048,7 @@ else if(myisset("me"))
              $who         = DB_get_userid_by_email($email);
              DB_set_player_by_gameid($gameid,$who);
 
              $who         = DB_get_userid_by_email($email);
              DB_set_player_by_gameid($gameid,$who);
 
-             if($hash!=$me)
+             if($hash!=$me && DB_get_email_pref_by_hash($hash)!="emailaddict")
                {
                  /* email startplayer) */
                  $message = "It's your turn now in game ".DB_format_gameid($gameid).".\n".
                {
                  /* email startplayer) */
                  $message = "It's your turn now in game ".DB_format_gameid($gameid).".\n".
@@ -1441,7 +1441,8 @@ else if(myisset("me"))
                  $message = "A card has been played in game ".DB_format_gameid($gameid).".\n\n".
                    "It's your turn  now.\n".
                    "Use this link to play a card: ".$host."?me=".$next_hash."\n\n" ;
                  $message = "A card has been played in game ".DB_format_gameid($gameid).".\n\n".
                    "It's your turn  now.\n".
                    "Use this link to play a card: ".$host."?me=".$next_hash."\n\n" ;
-                 mymail($email,$EmailName."a card has been played in game ".DB_format_gameid($gameid),$message);
+                 if( DB_get_email_pref_by_uid($who)!="emailaddict" )
+                   mymail($email,$EmailName."a card has been played in game ".DB_format_gameid($gameid),$message);
                }
              else /* send out final email */
                {
                }
              else /* send out final email */
                {
@@ -1547,7 +1548,7 @@ else if(myisset("me"))
 
                              if($re>$p-$offset)
                                mysql_query("INSERT INTO Score".
 
                              if($re>$p-$offset)
                                mysql_query("INSERT INTO Score".
-                                           " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'$p')");
+                                           " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'".(240-$p)."')");
                            }
 
                          /* re called something and won */
                            }
 
                          /* re called something and won */
@@ -1574,11 +1575,11 @@ else if(myisset("me"))
 
                              if($re>$p-$offset)
                                mysql_query("INSERT INTO Score".
 
                              if($re>$p-$offset)
                                mysql_query("INSERT INTO Score".
-                                           " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'$p')");
+                                           " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'".(240-$p)."')");
                            }
 
                            }
 
-                         /* re called something and won */
-                         if($call_re!=NULL)
+                         /* contra called something and won */
+                         if($call_contra!=NULL)
                            foreach(array(0,30,60,90,120) as $p)
                              {
                                if($call_contra<$p+1)
                            foreach(array(0,30,60,90,120) as $p)
                              {
                                if($call_contra<$p+1)
@@ -1603,7 +1604,8 @@ else if(myisset("me"))
                      $hash = DB_get_hash_from_gameid_and_userid($gameid,$user);
 
                      $link = "Use this link to have a look at game ".DB_format_gameid($gameid).": ".$host."?me=".$hash."\n\n" ;
                      $hash = DB_get_hash_from_gameid_and_userid($gameid,$user);
 
                      $link = "Use this link to have a look at game ".DB_format_gameid($gameid).": ".$host."?me=".$hash."\n\n" ;
-                     mymail($To,$EmailName."game over (game ".DB_format_gameid($gameid).") part 2(2)",$link);
+                     if( DB_get_email_pref_by_uid($user) != "emailaddict" )
+                       mymail($To,$EmailName."game over (game ".DB_format_gameid($gameid).") part 2(2)",$link);
                    }
                }
            }
                    }
                }
            }
@@ -1910,6 +1912,18 @@ else if( myisset("email","password") || isset($_SESSION["name"]) )
                                           DB_quote_smart($setpref).")");
                   echo "Ok, changed you preferences for the cards.\n";
                   break;
                                           DB_quote_smart($setpref).")");
                   echo "Ok, changed you preferences for the cards.\n";
                   break;
+                case "emailaddict":
+                case "emailnonaddict":
+                  $result = mysql_query("SELECT * from User_Prefs".
+                                        " WHERE user_id='$myid' AND pref_key='email'" );
+                  if( mysql_fetch_array($result,MYSQL_NUM))
+                    $result = mysql_query("UPDATE User_Prefs SET value=".DB_quote_smart($setpref).
+                                          " WHERE user_id='$myid' AND pref_key='email'" );
+                  else
+                    $result = mysql_query("INSERT INTO User_Prefs VALUES(NULL,'$myid','email',".
+                                          DB_quote_smart($setpref).")");
+                  echo "Ok, changed you preferences for sending out emails.\n";
+                  break;
                 }
             }
           else if(myisset("passwd"))
                 }
             }
           else if(myisset("passwd"))