save current state

This commit is contained in:
Thomas Weinhold 2025-10-03 17:19:35 +02:00
commit 64d4eeb85d
9 changed files with 116 additions and 97 deletions

View file

@ -26,21 +26,26 @@ function money_to_bill($money) {
}
function user_id_to_alias($id) {
$query=mysql_query("SELECT * FROM `player` WHERE `id` = $id LIMIT 0 , 30",DB);
$data=mysql_fetch_array($query);
return ($data['alias']);
global $db;
$query=mysqli_query($db, "SELECT * FROM `player` WHERE `id` = $id LIMIT 0 , 30");
$data=mysqli_fetch_array($query);
if ($data === FALSE) return NULL;
else if ($data === NULL) return NULL;
else return $data['alias'];
}
function count_games () {
$query=mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
return (mysql_num_rows($query));
global $db;
$query=mysqli_query($db, "SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'");
return (mysqli_num_rows($query));
}
function user_count_last_missed_games($id)
{
global $db;
$games = 0;
$query = mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE' ORDER BY `datetime` DESC",DB);
while ($data=mysql_fetch_array($query)) {
$query = mysqli_query($db, "SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE' ORDER BY `datetime` DESC");
while ($data=mysqli_fetch_array($query)) {
$player_array = array();
$player_array = player_of_game($data['id']);
$deposition=0;
@ -53,9 +58,10 @@ function user_count_last_missed_games($id)
}
function user_count_games($id) { //counts the games wich are played by the user $id
global $db;
$games = 0;
$query = mysql_query("SELECT `id` FROM `games`",DB);
while ($data=mysql_fetch_array($query)) {
$query = mysqli_query($db, "SELECT `id` FROM `games`");
while ($data=mysqli_fetch_array($query)) {
$player_array = array();
$player_array = player_of_game($data['id']);
$deposition = 0;
@ -67,9 +73,10 @@ function user_count_games($id) { //counts the games wich are played by the user
}
function user_count_point_games($id) { //counts the games wich are played by the user $id
global $db;
$games = 0;
$query = mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
while ($data=mysql_fetch_array($query)) {
$query = mysqli_query($db, "SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'");
while ($data=mysqli_fetch_array($query)) {
$player_array = array();
$player_array = player_of_game($data['id']);
$deposition = 0;
@ -81,18 +88,20 @@ function user_count_point_games($id) { //counts the games wich are played by the
}
function user_count_place($id,$place) { //counts how often a user ($id) has made the place ($place)
global $db;
$games = 0;
$query = mysql_query("SELECT `".$place."_id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
while ($data=mysql_fetch_row($query)) {
$query = mysqli_query($db, "SELECT `".$place."_id` FROM `games` WHERE `scoregame` = 'TRUE'");
while ($data=mysqli_fetch_row($query)) {
if ($data[0]==$id) $games++;
}
return ($games);
}
function user_min_bill() {
global $db;
$minbill=0;
$query=mysql_query("SELECT `id` FROM `player`",DB);
while ($data=mysql_fetch_row($query)){
$query=mysqli_query($db, "SELECT `id` FROM `player`");
while ($data=mysqli_fetch_row($query)){
$helpvar=user_count_bill($data[0]);
if ($helpvar<$minbill) $minbill=$helpvar;
}
@ -100,9 +109,10 @@ function user_min_bill() {
}
function user_max_bill() {
global $db;
$maxbill=0;
$query=mysql_query("SELECT `id` FROM `player`",DB);
while ($data=mysql_fetch_row($query)){
$query=mysqli_query($db, "SELECT `id` FROM `player`");
while ($data=mysqli_fetch_row($query)){
$helpvar=user_count_bill($data[0]);
if ($helpvar>$maxbill) $maxbill=$helpvar;
}
@ -110,9 +120,10 @@ function user_max_bill() {
}
function user_count_bill($id) {
global $db;
$bill=0;
$query=mysql_query("SELECT * FROM `games` WHERE `scoregame` = 'TRUE'",DB);
while ($data=mysql_fetch_array($query)) {
$query=mysqli_query($db, "SELECT * FROM `games` WHERE `scoregame` = 'TRUE'");
while ($data=mysqli_fetch_array($query)) {
$playerlist=player_of_game($data['id']);
foreach ($playerlist as $player) {
if ($player==$id) $bill-=$data['base_bill'];
@ -125,10 +136,11 @@ function user_count_bill($id) {
}
function player_of_game($game_id) {
global $db;
$player_array=array();
$query =mysql_query("SELECT `player` FROM `games` WHERE `id` = $game_id",DB);
$data =mysql_fetch_array($query);
$query =mysqli_query($db, "SELECT `player` FROM `games` WHERE `id` = $game_id");
$data =mysqli_fetch_array($query);
$player=$data['player'];
while (strlen($player)>0) {