saving php5 version
BIN
design/holz_bg.jpg
Executable file
|
After Width: | Height: | Size: 44 KiB |
BIN
design/holz_bg.psd
Executable file
BIN
design/karten.psd
Executable file
BIN
design/logo.png
Executable file
|
After Width: | Height: | Size: 26 KiB |
BIN
design/logo.psd
Executable file
BIN
design/main_menu.psd
Executable file
BIN
design/the_ring.psd
Executable file
102
edit_game.php
Executable file
|
|
@ -0,0 +1,102 @@
|
||||||
|
<?php
|
||||||
|
$EDIT_ID=(isset($_GET['edit_id'])) ? $_GET['edit_id']:0;
|
||||||
|
|
||||||
|
if (LOGIN!="") {
|
||||||
|
if (TO_DO=="save_edit") {
|
||||||
|
$edit_location=$_POST['edit_location'];
|
||||||
|
$edit_datetime=$_POST['edit_datetime'];
|
||||||
|
$edit_player=$_REQUEST['edit_player'];
|
||||||
|
$edit_scoregame=(isset($_POST['edit_scoregame'])) ? $_POST['edit_scoregame']:"FALSE";
|
||||||
|
$help1="";$help2="";
|
||||||
|
foreach ($edit_player as $help1)
|
||||||
|
$help2.=$help1;
|
||||||
|
$edit_player=$help2;
|
||||||
|
$edit_base_bill=money_to_bill($_POST['edit_base_bill']);
|
||||||
|
$edit_first_id=$_POST['edit_first_id'];
|
||||||
|
$edit_first_bill=money_to_bill($_POST['edit_first_bill']);
|
||||||
|
$edit_second_id=$_POST['edit_second_id'];
|
||||||
|
$edit_second_bill=money_to_bill($_POST['edit_second_bill']);
|
||||||
|
$edit_third_id=$_POST['edit_third_id'];
|
||||||
|
$edit_third_bill=money_to_bill($_POST['edit_third_bill']);
|
||||||
|
mysql_query("UPDATE `games` SET `scoregame` = '$edit_scoregame', `location` = '$edit_location', `datetime` = '$edit_datetime', `player` = '$edit_player', `base_bill` = '$edit_base_bill', `first_id` = '$edit_first_id', `first_bill` = '$edit_first_bill', `second_id` = '$edit_second_id', `second_bill` = '$edit_second_bill', `third_id` = '$edit_third_id', `third_bill` = '$edit_third_bill' WHERE `games`.`id` =$EDIT_ID LIMIT 1 ; ",DB);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TO_DO=="new_game") {
|
||||||
|
$query=mysql_query("SELECT `location` , `datetime` , `player` , `base_bill` , `first_id` , `first_bill` , `second_id` , `second_bill` , `third_id` , `third_bill` FROM `games` ORDER BY `games`.`id` DESC LIMIT 0 , 1",DB);
|
||||||
|
$data=mysql_fetch_row($query);
|
||||||
|
$hit=0;
|
||||||
|
if ($data){
|
||||||
|
foreach($data as $field) {
|
||||||
|
if ($field=="0000-00-00 00:00:00") continue;
|
||||||
|
if ($field) $hit=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else $hit=1;
|
||||||
|
if ($hit) {
|
||||||
|
mysql_query("INSERT INTO `games` ( ) VALUES ( );",DB);
|
||||||
|
$query=mysql_query("SELECT `id` FROM `games` ORDER BY `games`.`id` DESC LIMIT 0 , 1",DB);
|
||||||
|
$data=mysql_fetch_row($query);
|
||||||
|
$EDIT_ID=$data[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$EDIT_ID=0;
|
||||||
|
$ERROR.="Ein neues Spiel wurde bereits angelegt!<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($EDIT_ID) {
|
||||||
|
$query=mysql_query("SELECT * FROM `games` WHERE `id` = $EDIT_ID LIMIT 0 , 1",DB);
|
||||||
|
$data =mysql_fetch_array($query);
|
||||||
|
$BODY.='<form action="index.php?page=edit_game&to_do=save_edit&edit_id='.$EDIT_ID.'" method="post">';
|
||||||
|
$BODY.='<table class="list">';
|
||||||
|
$BODY.='<tr><th>Location:</th><td colspan="3"><input type="text" name="edit_location" value="'.$data['location'].'"></td></tr>';
|
||||||
|
$BODY.='<tr><th>Datum/Zeit:</th><td colspan="3"><input type="text" name="edit_datetime" value="'.$data['datetime'].'"></td></tr>';
|
||||||
|
$BODY.='<tr><th>Spieler:</th><td colspan="3"><select size="10" name="edit_player[]" multiple>';
|
||||||
|
$query=mysql_query("SELECT * FROM `player`",DB);
|
||||||
|
$player_of_game=player_of_game($EDIT_ID);
|
||||||
|
while ($playerlist=mysql_fetch_array($query)) {
|
||||||
|
$selected="";
|
||||||
|
foreach ($player_of_game as $player_in_game) $selected=($player_in_game==$playerlist['id']) ? " selected":$selected;
|
||||||
|
$BODY.='<option value="'.$playerlist['id'].'," '.$selected.'>'.$playerlist['alias'].'</option>';
|
||||||
|
}
|
||||||
|
$BODY.='</select>';
|
||||||
|
$BODY.='<tr><th>Rangspiel:</th><td colspan="3"><input type="checkbox" name="edit_scoregame" value="TRUE" '.(($data['scoregame']=="TRUE") ? "checked":"").'></td></tr>';
|
||||||
|
$BODY.='<tr><th>Einsatz:</th><td colspan="3"><input type="text" name="edit_base_bill" value="'.print_bill($data['base_bill']).'"></td></tr>';
|
||||||
|
$BODY.='<tr><th> </th><th>1. Platz</th><th>2. Platz</th><th>3. Platz</th></tr>';
|
||||||
|
$BODY.='<tr><th>Spieler:</th>';
|
||||||
|
$BODY.='<td><select size="1" name="edit_first_id">';
|
||||||
|
$query=mysql_query("SELECT * FROM `player`",DB);
|
||||||
|
while ($playerlist=mysql_fetch_array($query)) {
|
||||||
|
$selected=($playerlist['id']==$data['first_id']) ? " selected":"";
|
||||||
|
$BODY.='<option value="'.$playerlist['id'].'"'.$selected.'>'.$playerlist['alias'].'</option>';
|
||||||
|
}
|
||||||
|
$BODY.='</select></td>';
|
||||||
|
$BODY.='<td><select size="1" name="edit_second_id">';
|
||||||
|
$query=mysql_query("SELECT * FROM `player`",DB);
|
||||||
|
while ($playerlist=mysql_fetch_array($query)) {
|
||||||
|
$selected=($playerlist['id']==$data['second_id']) ? " selected":"";
|
||||||
|
$BODY.='<option value="'.$playerlist['id'].'"'.$selected.'>'.$playerlist['alias'].'</option>';
|
||||||
|
}
|
||||||
|
$BODY.='</select></td>';
|
||||||
|
$BODY.='<td><select size="1" name="edit_third_id">';
|
||||||
|
$query=mysql_query("SELECT * FROM `player`",DB);
|
||||||
|
while ($playerlist=mysql_fetch_array($query)) {
|
||||||
|
$selected=($playerlist['id']==$data['third_id']) ? " selected":"";
|
||||||
|
$BODY.='<option value="'.$playerlist['id'].'"'.$selected.'>'.$playerlist['alias'].'</option>';
|
||||||
|
}
|
||||||
|
$BODY.='</select></td>';
|
||||||
|
$BODY.='</tr>';
|
||||||
|
$BODY.='<tr><th>Preisgeld:</th>';
|
||||||
|
$BODY.='<td><input size="4" type="text" name="edit_first_bill" value="'.print_bill($data['first_bill']).'"></td>';
|
||||||
|
$BODY.='<td><input size="4" type="text" name="edit_second_bill" value="'.print_bill($data['second_bill']).'"></td>';
|
||||||
|
$BODY.='<td><input size="4" type="text" name="edit_third_bill" value="'.print_bill($data['third_bill']).'"></td>';
|
||||||
|
$BODY.='</tr>';
|
||||||
|
$BODY.='<tr><th>Speichern:</th><td><input type="submit" value="" class="submit_save"</td></tr>';
|
||||||
|
|
||||||
|
$BODY.='</table></form>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ERROR.="Sie müssen sich einloggen!<br>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
168
functions.php
Executable file
|
|
@ -0,0 +1,168 @@
|
||||||
|
<?php
|
||||||
|
function add_icon ($icon) {
|
||||||
|
$path = "./icons/$icon.png";
|
||||||
|
$size = getimagesize($path);
|
||||||
|
$width = $size[0];
|
||||||
|
$height = $size[1];
|
||||||
|
return "<img src=\"$path\" width=\"$width\" height=\"$height\" alt=\"$icon\" border=\"0\">";
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_percent ($percent) {
|
||||||
|
while (strlen($percent)<2) $percent="0".$percent;
|
||||||
|
$return=($percent) ? substr($percent,0,strlen($percent)-1).",".substr($percent,strlen($percent)-1,1)."%" : "0€";
|
||||||
|
return ($return);
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_bill ($bill) {
|
||||||
|
while (strlen($bill)<3) $bill="0".$bill;
|
||||||
|
$return=($bill) ? substr($bill,0,strlen($bill)-2).",".substr($bill,strlen($bill)-2,2)."€" : "0€";
|
||||||
|
return ($return);
|
||||||
|
}
|
||||||
|
|
||||||
|
function money_to_bill($money) {
|
||||||
|
$money=str_replace("€","",$money);
|
||||||
|
$money=str_replace(",",".",$money);
|
||||||
|
return ($money*100);
|
||||||
|
}
|
||||||
|
|
||||||
|
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']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function count_games () {
|
||||||
|
$query=mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
||||||
|
return (mysql_num_rows($query));
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_count_last_missed_games($id)
|
||||||
|
{
|
||||||
|
$games = 0;
|
||||||
|
$query = mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE' ORDER BY `datetime` DESC",DB);
|
||||||
|
while ($data=mysql_fetch_array($query)) {
|
||||||
|
$player_array = array();
|
||||||
|
$player_array = player_of_game($data['id']);
|
||||||
|
$deposition=0;
|
||||||
|
foreach ($player_array as $player)
|
||||||
|
if ($player==$id) $deposition++;
|
||||||
|
if (!$deposition) $games++;
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
return ($games);
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_count_games($id) { //counts the games wich are played by the user $id
|
||||||
|
$games = 0;
|
||||||
|
$query = mysql_query("SELECT `id` FROM `games`",DB);
|
||||||
|
while ($data=mysql_fetch_array($query)) {
|
||||||
|
$player_array = array();
|
||||||
|
$player_array = player_of_game($data['id']);
|
||||||
|
$deposition = 0;
|
||||||
|
foreach ($player_array as $player)
|
||||||
|
if ($player==$id) $deposition++;
|
||||||
|
if ($deposition) $games++;
|
||||||
|
}
|
||||||
|
return ($games);
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_count_point_games($id) { //counts the games wich are played by the user $id
|
||||||
|
$games = 0;
|
||||||
|
$query = mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
||||||
|
while ($data=mysql_fetch_array($query)) {
|
||||||
|
$player_array = array();
|
||||||
|
$player_array = player_of_game($data['id']);
|
||||||
|
$deposition = 0;
|
||||||
|
foreach ($player_array as $player)
|
||||||
|
if ($player==$id) $deposition++;
|
||||||
|
if ($deposition) $games++;
|
||||||
|
}
|
||||||
|
return ($games);
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_count_place($id,$place) { //counts how often a user ($id) has made the place ($place)
|
||||||
|
$games = 0;
|
||||||
|
$query = mysql_query("SELECT `".$place."_id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
||||||
|
while ($data=mysql_fetch_row($query)) {
|
||||||
|
if ($data[0]==$id) $games++;
|
||||||
|
}
|
||||||
|
return ($games);
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_min_bill() {
|
||||||
|
$minbill=0;
|
||||||
|
$query=mysql_query("SELECT `id` FROM `player`",DB);
|
||||||
|
while ($data=mysql_fetch_row($query)){
|
||||||
|
$helpvar=user_count_bill($data[0]);
|
||||||
|
if ($helpvar<$minbill) $minbill=$helpvar;
|
||||||
|
}
|
||||||
|
return ($minbill);
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_max_bill() {
|
||||||
|
$maxbill=0;
|
||||||
|
$query=mysql_query("SELECT `id` FROM `player`",DB);
|
||||||
|
while ($data=mysql_fetch_row($query)){
|
||||||
|
$helpvar=user_count_bill($data[0]);
|
||||||
|
if ($helpvar>$maxbill) $maxbill=$helpvar;
|
||||||
|
}
|
||||||
|
return ($maxbill);
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_count_bill($id) {
|
||||||
|
$bill=0;
|
||||||
|
$query=mysql_query("SELECT * FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
||||||
|
while ($data=mysql_fetch_array($query)) {
|
||||||
|
$playerlist=player_of_game($data['id']);
|
||||||
|
foreach ($playerlist as $player) {
|
||||||
|
if ($player==$id) $bill-=$data['base_bill'];
|
||||||
|
}
|
||||||
|
if ($data['first_id']==$id) $bill+=$data['first_bill'];
|
||||||
|
if ($data['second_id']==$id) $bill+=$data['second_bill'];
|
||||||
|
if ($data['third_id']==$id) $bill+=$data['third_bill'];
|
||||||
|
}
|
||||||
|
return ($bill);
|
||||||
|
}
|
||||||
|
|
||||||
|
function player_of_game($game_id) {
|
||||||
|
$player_array=array();
|
||||||
|
|
||||||
|
$query =mysql_query("SELECT `player` FROM `games` WHERE `id` = $game_id",DB);
|
||||||
|
$data =mysql_fetch_array($query);
|
||||||
|
$player=$data['player'];
|
||||||
|
|
||||||
|
while (strlen($player)>0) {
|
||||||
|
while (substr($player,0,1)==",") $player=substr($player,1,strlen($player)-1); //delete leading commata
|
||||||
|
$position=0;
|
||||||
|
$deposition="";
|
||||||
|
for ($position=0;substr($player,$position,1)!="," && $position<strlen($player);$position++);
|
||||||
|
$deposition=trim(substr($player,0,$position));
|
||||||
|
if ($deposition) $player_array[count($player_array)]=$deposition;
|
||||||
|
$player=((strlen($player)-$position-1)>0) ? substr($player,$position,strlen($player)-$position):"";
|
||||||
|
}
|
||||||
|
return ($player_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
function gibmirzeit_von_datetime($format,$datetime) {
|
||||||
|
$yyyy= substr($datetime,0,4);
|
||||||
|
$yy = substr($datetime,2,2);
|
||||||
|
$mm = substr($datetime,5,2);
|
||||||
|
$dd = substr($datetime,8,2);
|
||||||
|
$HH = substr($datetime,11,2);
|
||||||
|
$MM = substr($datetime,14,2);
|
||||||
|
$SS = substr($datetime,17,2);
|
||||||
|
|
||||||
|
$format=str_replace("yyyy",$yyyy,$format);
|
||||||
|
$format=str_replace("jjjj",$yyyy,$format);
|
||||||
|
$format=str_replace("yy" ,$yy ,$format);
|
||||||
|
$format=str_replace("jj" ,$yy ,$format);
|
||||||
|
$format=str_replace("mm" ,$mm ,$format);
|
||||||
|
$format=str_replace("dd" ,$dd ,$format);
|
||||||
|
$format=str_replace("tt" ,$dd ,$format);
|
||||||
|
$format=str_replace("HH" ,$HH ,$format);
|
||||||
|
$format=str_replace("MM" ,$MM ,$format);
|
||||||
|
$format=str_replace("SS" ,$SS ,$format);
|
||||||
|
|
||||||
|
return ($format);
|
||||||
|
}
|
||||||
|
?>
|
||||||
48
games.php
Executable file
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
$expand_view=0;
|
||||||
|
if (isset($_GET['expand_view']))
|
||||||
|
$expand_view=$_GET['expand_view'];
|
||||||
|
|
||||||
|
$BODY.='<table class="list"><tr>';
|
||||||
|
if ($expand_view)
|
||||||
|
$BODY.='<th><a href="index.php?page=games" target="_top">'.add_icon("arrow_in").'</a></th>';
|
||||||
|
else
|
||||||
|
$BODY.='<th><a href="index.php?page=games&expand_view=1" target="_top">'.add_icon("arrow_out").'</a></th>';
|
||||||
|
$BODY.=' <th>Datum, Zeit</th>
|
||||||
|
<th>Spielerzahl</th>
|
||||||
|
<th>Rangspiel</th>
|
||||||
|
<th>Sieger</th>
|
||||||
|
<th>Zweiter</th>
|
||||||
|
<th>Dritter</th>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
$query=mysql_query("SELECT * FROM `games` ORDER BY `datetime` ASC",DB);
|
||||||
|
while ($data=mysql_fetch_array($query)) {
|
||||||
|
$id=$data['id'];
|
||||||
|
$BODY.="<tr><td>";
|
||||||
|
if (LOGIN!="")
|
||||||
|
$BODY.="<a href=\"index.php?page=edit_game&edit_id=$id\" target=\"_top\">".add_icon("pencil")."</a>";
|
||||||
|
$BODY.="</td>";
|
||||||
|
$BODY.="<td>".gibmirzeit_von_datetime(DATETIMEFORMAT,$data['datetime'])."</td>\n";
|
||||||
|
$BODY.="<td>".count(player_of_game($id))."</td>\n";
|
||||||
|
$BODY.="<td>".(($data['scoregame']=="TRUE") ? add_icon("accept"):"")."</td>\n";
|
||||||
|
$BODY.="<td style=\"align:right\">".user_id_to_alias($data['first_id']).(($expand_view)? "(".print_bill($data['first_bill']).")":"")."</td>\n";
|
||||||
|
$BODY.="<td style=\"align:right\">".user_id_to_alias($data['second_id']).(($expand_view)? "(".print_bill($data['second_bill']).")":"")."</td>\n";
|
||||||
|
$BODY.="<td style=\"align:right\">".user_id_to_alias($data['third_id']).(($expand_view)? "(".print_bill($data['third_bill']).")":"")."</td>\n";
|
||||||
|
$BODY.="</tr>";
|
||||||
|
if ($expand_view) {
|
||||||
|
$BODY.="<tr><td></td>";
|
||||||
|
$BODY.="<td valign=\"top\">".htmlentities(nl2br($data['location']))."</td>\n";
|
||||||
|
$BODY.="<td colspan=\"5\"><i>Spieler: ";
|
||||||
|
$player_array=player_of_game($id);
|
||||||
|
$i=0;
|
||||||
|
for ($i=0;$i<count($player_array);$i++) {
|
||||||
|
$BODY.=user_id_to_alias($player_array[$i]);
|
||||||
|
if ($i<(count($player_array)-1)) $BODY.=", ";
|
||||||
|
}
|
||||||
|
$BODY.=" (Pott: ".print_bill($data['base_bill']*$i).")</i></td>";
|
||||||
|
$BODY.="</tr><tr><td> </td></tr>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$BODY.=' </table>';
|
||||||
|
?>
|
||||||
34
globals.php
Executable file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
define("DATETIMEFORMAT","yyyy-mm-tt, HH:MM Uhr");
|
||||||
|
|
||||||
|
function calculate_rank($rate,$bill,$missed_games) {
|
||||||
|
$return=0;
|
||||||
|
$bill_factor=3000/(user_max_bill()-user_min_bill());
|
||||||
|
$return = ($rate+$bill_factor*$bill); //50% Quote, 50% max Bill
|
||||||
|
switch ($missed_games)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
$return *= 1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$return *= 0.8;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$return *= 0.6;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
$return *= 0.4;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
$return *= 0.2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$return *= 0;
|
||||||
|
}
|
||||||
|
//$return *= (-1/5)*(($missed_games<5)? $missed_games:5) + 1;
|
||||||
|
//$return *= exp ( -1 * $missed_games );
|
||||||
|
$return = ($return*10) / 6; //normalize to 10000
|
||||||
|
return ($return);
|
||||||
|
}
|
||||||
|
?>
|
||||||
BIN
icons/accept.png
Executable file
|
After Width: | Height: | Size: 643 B |
BIN
icons/add.png
Executable file
|
After Width: | Height: | Size: 331 B |
BIN
icons/arrow_in.png
Executable file
|
After Width: | Height: | Size: 546 B |
BIN
icons/arrow_out.png
Executable file
|
After Width: | Height: | Size: 565 B |
BIN
icons/asc.png
Executable file
|
After Width: | Height: | Size: 3 KiB |
BIN
icons/desc.png
Executable file
|
After Width: | Height: | Size: 3 KiB |
BIN
icons/disk.png
Executable file
|
After Width: | Height: | Size: 429 B |
BIN
icons/new_game.png
Executable file
|
After Width: | Height: | Size: 652 B |
BIN
icons/pencil.png
Executable file
|
After Width: | Height: | Size: 632 B |