saving php5 version

This commit is contained in:
Hausmeister 2017-10-31 19:16:46 +01:00
commit c2c1ee7b9b
46 changed files with 817 additions and 0 deletions

BIN
design/holz_bg.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
design/holz_bg.psd Executable file

Binary file not shown.

BIN
design/karten.psd Executable file

Binary file not shown.

BIN
design/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
design/logo.psd Executable file

Binary file not shown.

BIN
design/main_menu.psd Executable file

Binary file not shown.

BIN
design/the_ring.psd Executable file

Binary file not shown.

102
edit_game.php Executable file
View 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>&nbsp;</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&uuml;ssen sich einloggen!<br>";
}
?>

168
functions.php Executable file
View 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&euro;";
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)."&euro;" : "0&euro;";
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
View 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>&nbsp;</td></tr>";
}
}
$BODY.=' </table>';
?>

34
globals.php Executable file
View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

BIN
icons/add.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

BIN
icons/arrow_in.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

BIN
icons/arrow_out.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

BIN
icons/asc.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

BIN
icons/desc.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

BIN
icons/disk.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

BIN
icons/new_game.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

BIN
icons/pencil.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

BIN
icons/user.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

BIN
images/holz_bg.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
images/main_menu_log_left.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

BIN
images/main_menu_log_mid_in.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
images/main_menu_log_mid_out.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
images/main_menu_log_right.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

BIN
images/main_menu_rl_left.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

BIN
images/main_menu_rl_mid.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
images/main_menu_rl_mid_hover.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/main_menu_rl_right.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/main_menu_sl_left.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

BIN
images/main_menu_sl_mid.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
images/main_menu_sl_mid_hover.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/main_menu_sl_right.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

BIN
images/main_menu_top.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
images/the_ring.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

57
index.php Executable file
View file

@ -0,0 +1,57 @@
<?php
//show all errors
error_reporting (E_ALL);
ini_set("display_errors","TRUE");
//standart includes, vars and constants
$page="";
if (isset($_GET['page'])) $page=$_GET['page'];
$BODY = ""; //the page content
$ERROR = ""; //error messages
$COMMENT = ""; //comments
if (isset($_GET['to_do'])) define ("TO_DO",$_GET['to_do']);
else define ("TO_DO","");
define ('DB',mysql_connect("localhost","poker","JuzFQK6rnNfx75v8"));
mysql_select_db("poker",DB);
include("globals.php");
include("functions.php");
//User Login
if (!session_start()) $ERROR.="Server Session kann nicht eingerichtet werden, kein login m&ouml;glich!<br>";
if (TO_DO=="login") {
$login=$_POST['login'];
$password=md5($_POST['password']);
$query=mysql_query("SELECT `password` FROM `player` WHERE `alias` = '$login' AND `password` IS NOT NULL LIMIT 0 , 30",DB);
$data=mysql_fetch_array($query);
if ($data['password']==$password) {
$_SESSION['login']=$login;
}
else $ERROR.="Login nicht erfolgreich!<br>";
}
if ($page=="logout") {
$_SESSION['login']="";
$page="";
}
if (isset($_SESSION['login'])) define ("LOGIN",$_SESSION['login']);
else define ("LOGIN","");
if (LOGIN!="") {
$BODY.='<table class="list" width="100%"><tr><th style="text-align:left">'.add_icon('user')."&nbsp;&nbsp;".LOGIN."&nbsp;&nbsp;&nbsp;&nbsp;";
$BODY.='<a class="list" href="index.php?page=edit_game&to_do=new_game">'.add_icon("new_game").'Neues Spiel</a>';
$BODY.="</th></tr></table>";
}
$BODY.="<br><br>";
//include the requestet page
if ($page=="login") include ("login.php");
elseif ($page=="rank" ) include ("rank.php" );
elseif ($page=="games" ) include ("games.php" );
elseif ($page=="edit_game" ) include ("edit_game.php" );
elseif ($page=="poker_pott") include("poker_pott.php");
else include ("main.php");
//include the Template
include ("template.php");
//End of Script
mysql_close(DB);
?>

21
index.php~ Executable file
View file

@ -0,0 +1,21 @@
<?php
//show all errors
error_reporting (E_ALL);
ini_set("display_errors","TRUE");
//standart vars and constants
$BODY=""; //the page content
$DB=mysql_connect("192.168.0.145","root","h07rn-f#");
mysql_select_db("poker",$DB);
//include the requestet page
$page="";
if (isset($_GET['page'])) $page=$_GET['page'];
if ($page=="rank") include ("rank.php");
//include the Template
include ("template.php");
//End of Script
mysql_close($DB);
?>

11
login.php Executable file
View file

@ -0,0 +1,11 @@
<?php
$BODY.='
<center><br><br><br><br>
<form action="index.php?to_do=login" method="post">
<input type="text" name="login"><br>
<input type="password" name="password"><br>
<input type="submit" value="login">
</form>
</center>
';
?>

16
main.php Executable file
View file

@ -0,0 +1,16 @@
<?php
$query=mysql_query("SELECT `first_id` FROM `games` WHERE `scoregame` = 'TRUE' ORDER BY `games`.`datetime` DESC LIMIT 0 , 1",DB);
$data=mysql_fetch_array($query);
$BODY.='<br><br><table class="the_ring" align="center">
<tr>
<td>
<img src="./images/the_ring.png" width="350" height="239" border="" alt="">
</td>
<td>
aktueller Ringtr&auml;ger ist:<br>
<br>'.user_id_to_alias($data['first_id']).'
</td>
</tr></table>';
$BODY.="<br><br>";
$BODY.='<a href="index.php?page=poker_pott" target="_top">Tabelle zur Aufteilung des Pott (Gewinnaussch&uuml;ttung)</a>';
?>

88
poker_pott.php Executable file
View file

@ -0,0 +1,88 @@
<?php
$FirstMoreThanSecond = (isset($_POST['FMTS']) && $_POST['FMTS']) ? $_POST['FMTS']:3;
$SecondMoreThanThird = (isset($_POST['FMTT']) && $_POST['FMTT']) ? $_POST['FMTT']:2;
$Stake = (isset($_POST['Stake']) && $_POST['Stake']) ? $_POST['Stake']:2;
function GetDotByPott ($Pott)
{
global $FirstMoreThanSecond;
global $SecondMoreThanThird;
$FMTS = $FirstMoreThanSecond;
$SMTT = $SecondMoreThanThird;
$a=$b=0; //1st and 2nd place
$c=$Pott; //3th starts with all the money
while (!( ($a>=($FMTS*$b)) && ($b>=$SMTT*$c) ))
{
//transport from c to b
if ($b<($SMTT*$c) && $c>0)
{
$b++;
$c--;
}
//transport from b to a
if ($a<($FMTS*$b) && $b>0)
{
$a++;
$b--;
}
}
$RetVal=array();
$RetVal[0]=0; //empty
$RetVal[1]=$a; //1st place
$RetVal[2]=$b; //2nd place
$RetVal[3]=$c; //3th place
return $RetVal;
}
$BODY.='<form action="index.php?page=poker_pott" method="post">';
$BODY.='<input type="hidden" name="page" value="poker_pott">';
$BODY.='Einsatz: ';
$BODY.='<select name="Stake">';
for ($i=1;$i<=10;$i++)
{
$BODY.='<option value="'.$i.'"'.(($Stake==$i)? "selected":"").'>'.$i.'&euro;</option>';
}
$BODY.="</select><br>";
$BODY.='Erster bekommt mindestens ';
$BODY.='<select name="FMTS">';
for ($i=1;$i<=10;$i++)
{
$BODY.='<option value="'.$i.'"'.(($FirstMoreThanSecond==$i)? "selected":"").'>'.$i.' mal</option>';
}
$BODY.="</select>mehr als der Zweite<br>";
$BODY.='Zweiter bekommt mindestens ';
$BODY.='<select name="FMTT">';
for ($i=1;$i<=10;$i++)
{
$BODY.='<option value="'.$i.'"'.(($SecondMoreThanThird==$i)? "selected":"").'>'.$i.' mal</option>';
}
$BODY.="</select>mehr als der Dritte<br>";
$BODY.='<input type="submit" value="Neu Berechnen">';
$BODY.='</form>';
$BODY.= "<table class=\"list\">";
$BODY.= "<tr>";
$BODY.= "<th>Spieler</th>";
$BODY.= "<th>Pott</th>";
$BODY.= "<th>1.Platz</th>";
$BODY.= "<th>2.Platz</th>";
$BODY.= "<th>3.Platz</th>";
$BODY.= "</tr>";
for ($i=4; $i<=20; $i++)
{
$Ret = GetDotByPott($Stake*$i);
$BODY.= "<tr>";
$BODY.= "<td>".$i."</td>";
$BODY.= "<td>".($i*$Stake)."&euro;</td>";
$BODY.= "<td><strong>".$Ret[1]."&euro;</strong></td>";
$BODY.= "<td><strong>".$Ret[2]."&euro;</strong></td>";
$BODY.= "<td><strong>".$Ret[3]."&euro;</strong></td>";
$BODY.= "</tr>";
}
$BODY.= "</table>";
?>

125
rank.php Executable file
View file

@ -0,0 +1,125 @@
<?php
//Create player statistics
$query = mysql_query("SELECT * FROM `player`",DB);
$user_min_bill=-1*user_min_bill();
while ($data=mysql_fetch_array($query)) {
$cnt_games = user_count_games($data['id']);
$cnt_point_games = user_count_point_games($data['id']);
$cnt_first = user_count_place($data['id'],"first");
$cnt_second = user_count_place($data['id'],"second");
$cnt_third = user_count_place($data['id'],"third");
$points = 3*$cnt_first + 2*$cnt_second + $cnt_third;
$rate = ($cnt_games) ? (1000 * $points)/ ($cnt_games):0;
$bill = user_count_bill($data['id']);
$missed_games = user_count_last_missed_games($data['id']);
$rank = calculate_rank($rate,$bill+$user_min_bill,$missed_games);
mysql_query("UPDATE `player` SET `rank` = '$rank', `cnt_games` = '$cnt_games', `cnt_first` = '$cnt_first', `cnt_second` = '$cnt_second', `cnt_third` = '$cnt_third', `points` = '$points', `rate` = '$rate', `bill` = '$bill' WHERE `id` =".$data['id']." LIMIT 1 ;",DB);
}
//Determine Sort Order
if (isset($_GET['sortby'])) $_SESSION['sortby']=$_GET['sortby'];
if (isset($_GET['sortorder'])) $_SESSION['sortorder']=$_GET['sortorder'];
$SORTBY = (isset($_SESSION['sortby'])) ? $_SESSION['sortby']:"rank";
$SORTORDER = (isset($_SESSION['sortorder'])) ? $_SESSION['sortorder']:"desc";
$SORTNOORD = ($SORTORDER=="asc") ? "desc":"asc";
$SORTSTRING = "ORDER BY `$SORTBY` ".strtoupper($SORTORDER);
//variablen definieren
$value_ip_alias = "";
if (TO_DO=="insert_player" && LOGIN!="") {
$failure="";
if (!($alias=$_POST['alias'])) $failure.="Spitznamen angeben!<br>";
if (!$failure) {
$query=mysql_query("SELECT `alias` FROM `player` WHERE `alias` = '$alias' LIMIT 0 , 30",DB);
$data=mysql_fetch_array($query);
if ($data['alias']==$alias) $failure.="Spitzname existiert bereits!<br>";
}
if (!$failure) {
mysql_query("INSERT INTO `player` ( `alias` ) VALUES ( '$alias' );",DB);
}
else {
$value_ip_alias = $alias;
}
$ERROR.=$failure;
}
if (TO_DO=="save_edit_player" && LOGIN!="" && ($player=$_GET['player'])) {
$failure="";
if (!($alias=$_POST['alias'])) $failure.="Spitznamen angeben!<br>";
if (!$failure) {
$query=mysql_query("SELECT `id`,`alias` FROM `player` WHERE `alias` = '$alias' LIMIT 0 , 30",DB);
while ($data=mysql_fetch_array($query))
if ($data['id']!=$player) $failure.="Spitzname existiert bereits!<br>";
}
if (!$failure) {
mysql_query("UPDATE `player` SET `alias` = '$alias' WHERE `id` = '$player' LIMIT 1 ;",DB);
}
$ERROR.=$failure;
}
$BODY.='
<table class="list">
<tr>
<th>&nbsp;</th>
<th><a href="index.php?page=rank&sortby=alias&sortorder='.$SORTNOORD.'">'.(($SORTBY=="alias") ? add_icon($SORTORDER):"").'Spitzname</a></th>
<th><a href="index.php?page=rank&sortby=cnt_games&sortorder='.$SORTNOORD.'">'.(($SORTBY=="cnt_games") ? add_icon($SORTORDER):"").'Spiele</a></th>
<th><a href="index.php?page=rank&sortby=cnt_first&sortorder='.$SORTNOORD.'">'.(($SORTBY=="cnt_first") ? add_icon($SORTORDER):"").'#1</a></th>
<th><a href="index.php?page=rank&sortby=cnt_second&sortorder='.$SORTNOORD.'">'.(($SORTBY=="cnt_second") ? add_icon($SORTORDER):"").'#2</a></th>
<th><a href="index.php?page=rank&sortby=cnt_third&sortorder='.$SORTNOORD.'">'.(($SORTBY=="cnt_third") ? add_icon($SORTORDER):"").'#3</a></th>
<th><a href="index.php?page=rank&sortby=points&sortorder='.$SORTNOORD.'">'.(($SORTBY=="points") ? add_icon($SORTORDER):"").'Punkte</a></th>
<th><a href="index.php?page=rank&sortby=rate&sortorder='.$SORTNOORD.'">'.(($SORTBY=="rate") ? add_icon($SORTORDER):"").'Quote</a></th>
<th><a href="index.php?page=rank&sortby=bill&sortorder='.$SORTNOORD.'">'.(($SORTBY=="bill") ? add_icon($SORTORDER):"").'Umsatz</a></th>
<th><a href="index.php?page=rank&sortby=rank&sortorder='.$SORTNOORD.'">'.(($SORTBY=="rank") ? add_icon($SORTORDER):"").'Rang</a></th>
</tr>';
$query=mysql_query("SELECT * FROM `player` $SORTSTRING",DB);
while ($data=mysql_fetch_array($query)) {
$id = $data['id'];
$alias = $data['alias'];
if (TO_DO=="edit_player" && LOGIN!="" && $_GET['player']==$alias) {
$BODY.="<form action=\"index.php?page=rank&to_do=save_edit_player&player=$id\" method=\"post\">";
$BODY.="<tr><td></td>";
$BODY.="<td><input type=\"text\" size=\"8\" name=\"alias\" value=\"$alias\"></td>\n";
$BODY.="<td><input type=\"submit\" value=\"\" class=\"submit_save\"></td>\n";
$BODY.="</form>";
}
else {
$BODY.="<tr><td>";
if (LOGIN!="")
$BODY.="<a href=\"index.php?page=rank&to_do=edit_player&player=$alias\" target=\"_top\">".add_icon("pencil")."</a>";
$BODY.="</td><td>$alias</td>";
$BODY.="<td>".$data['cnt_games']."</td>";
$BODY.="<td>".$data['cnt_first']."</td>";
$BODY.="<td>".$data['cnt_second']."</td>";
$BODY.="<td>".$data['cnt_third']."</td>";
$BODY.="<td>".$data['points']."</td>";
$rate=$data['rate'];
$BODY.="<td>".print_percent($data['rate'])."</td>";
$BODY.="<td>".print_bill($data['bill'])."</td>";
$BODY.="<td>".$data['rank']."</td>";
$BODY.="</tr>\n";
}
}
if (LOGIN!="") {
$BODY.='
<form action="index.php?page=rank&to_do=insert_player" method="post">
<tr>
<td>'.add_icon("add").'</td>
<td><input type="text" size="8" name="alias" value="'.$value_ip_alias.'"></td>
<td><input type="submit" value="" class="submit_save"></td>
</tr>
</form>
';
}
$BODY.=' </table>';
$COMMENT.='
<b>Punkte</b> F&uuml;r jeden Sieg gibt es drei Punkte, f&uuml;r jeden zweiten Platz zwei Punkte und f&uuml;r jeden dritten Platz einen Punkt.<br>
<b>Quote:</b> Die Punktequote, wie oft man pro Spiel einen Punkt erreicht. 100% geben an, dass man jedes teilgenomme Spiel einen Punkt gemacht hat. (maximal 300%, wenn man alle Spiele gewonnen hat)<br>
<b>Rang:</b> Er ist abh&auml;ngig von der Quote, dem Umsatz und der Teilnahmeh&auml;ufigkeit an Rangspielen. Maximal kann ein Rang von 10000 erreicht werden.
';
?>

90
style.css Executable file
View file

@ -0,0 +1,90 @@
body {
color:#fff;
font-weight:bold;
}
.list {
color:#ffffff;
font-family:verdana;
font-size:10pt;
font-weight:normal;
}
table.list {
border-spacing:0px;
}
table.list td {
text-align:center;
}
table.list th{
padding-left:3px;
padding-right:3px;
font-weight:bold;
border-bottom-color:#ffffff;
border-bottom-width:1px;
border-bottom-style:solid;
text-align:center;
vertical-align:middle;
}
.list a {
padding-left:3px;
padding-right:3px;
color:#ffffff;
font-weight:bold;
text-decoration:none;
}
.list a:hover {
text-decoration:underline;
}
a {
color:#fff;
font-weight:bold;
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
table.the_ring {
text-align:center;
font-family:verdana;
color:#ffffff;
font-size:16pt;
font-weight:bold;
}
table.the_ring th {
text-decoration:underline;
}
input {
color:#000000;
background-color:#ffffff;
border-color:#000000;
border-width:1px;
border-style:solid;
text-align:center;
}
.submit_save {
background-image:url(./icons/disk.png);
background-color:transparent;
display:block;
border-width:0px;
width:16px;
height:16px;
}
.errormessage {
color:#ff0000;
background-color:#eeeeee;
font-weight:bold;
}
.comment {
color:#ffffff;
font-size:8pt;
font-family:verdana;
font-weight:normal;
font-style:italic;
}

57
template.php Executable file
View file

@ -0,0 +1,57 @@
<hml>
<head>
<title>Plessa Poker</title>
<link rel="stylesheet" type="text/css" href="style.css">
<style type="text/css">
<!--
a.navi_rl { background-image:url(./images/main_menu_rl_mid.png); display:block; width:248; height:60; }
a.navi_rl:hover { background-image:url(./images/main_menu_rl_mid_hover.png); display:block; width:248; height:60; }
a.navi_sl { background-image:url(./images/main_menu_sl_mid.png); display:block; width:248; height:60; }
a.navi_sl:hover { background-image:url(./images/main_menu_sl_mid_hover.png); display:block; width:248; height:60; }
a.navi_login { background-image:url(./images/main_menu_log_mid_in.png); display:block; width:248; height:43; }
a.navi_login:hover { background-image:url(./images/main_menu_log_mid_in_hover.png); display:block; width:248; height:43; }
a.navi_logout { background-image:url(./images/main_menu_log_mid_out.png); display:block; width:248; height:43; }
a.navi_logout:hover { background-image:url(./images/main_menu_log_mid_out_hover.png); display:block; width:248; height:43; }
-->
</style>
</head>
<body style="background-image:url(./images/holz_bg.jpg);margin:0px;">
<table border="0" width="97%" cellspacing="0" cellpadding="0"><tr>
<td width="336" valign="top">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3"><a href="index.php" target="_top"><img src="./images/main_menu_top.png" width="336" height="243" alt="" border="0"></a></td>
</tr>
<tr>
<td><img src="./images/main_menu_rl_left.png" width="32" height="60" alt=""></td>
<td><a href="index.php?page=rank" target="_top" class="navi_rl"></a></td>
<td><img src="./images/main_menu_rl_right.png" width="56" height="60" alt=""></td>
</tr>
<tr>
<td><img src="./images/main_menu_sl_left.png" width="32" height="60" alt=""></td>
<td><a href="index.php?page=games" target="_top" class="navi_sl"></a></td>
<td><img src="./images/main_menu_sl_right.png" width="56" height="60" alt=""></td>
</tr>
<tr>
<td><img src="./images/main_menu_log_left.png" width="32" height="43" alt=""></td>
<?php if (LOGIN!="") : ?>
<td><a href="index.php?page=logout" target="_top" class="navi_logout"></a></td>
<?php else : ?>
<td><a href="index.php?page=login" target="_top" class="navi_login"></a></td>
<?php endif ?>
<td><img src="./images/main_menu_log_right.png" width="56" height="43" alt=""></td>
</tr>
</table>
</td>
<td align="left" valign="top">
<div class="errormessage"><?php echo $ERROR ?></div>
<!--BODY-->
<?php echo $BODY ?>
</td>
</tr>
<tr><td colspan="2"><br><br><div class="comment"><?php echo $COMMENT ?></comment></td></tr>
</table>
</body>
</html>