save current state
This commit is contained in:
parent
c2c1ee7b9b
commit
64d4eeb85d
9 changed files with 116 additions and 97 deletions
|
|
@ -18,12 +18,12 @@ if (LOGIN!="") {
|
||||||
$edit_second_bill=money_to_bill($_POST['edit_second_bill']);
|
$edit_second_bill=money_to_bill($_POST['edit_second_bill']);
|
||||||
$edit_third_id=$_POST['edit_third_id'];
|
$edit_third_id=$_POST['edit_third_id'];
|
||||||
$edit_third_bill=money_to_bill($_POST['edit_third_bill']);
|
$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);
|
mysqli_query($db, "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 ; ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TO_DO=="new_game") {
|
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);
|
$query=mysqli_query($db, "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");
|
||||||
$data=mysql_fetch_row($query);
|
$data=mysqli_fetch_row($query);
|
||||||
$hit=0;
|
$hit=0;
|
||||||
if ($data){
|
if ($data){
|
||||||
foreach($data as $field) {
|
foreach($data as $field) {
|
||||||
|
|
@ -33,9 +33,10 @@ if (LOGIN!="") {
|
||||||
}
|
}
|
||||||
else $hit=1;
|
else $hit=1;
|
||||||
if ($hit) {
|
if ($hit) {
|
||||||
mysql_query("INSERT INTO `games` ( ) VALUES ( );",DB);
|
mysqli_query($db, "INSERT INTO `games` ( `location`, `datetime`, `player`, `base_bill`, `first_id`, `first_bill`, `second_id`, `second_bill`, `third_id`, `third_bill` ) VALUES ( 'Bei Wem?', '1989-10-03 12:00:00', '', '200', '0', '0', '0', '0', '0', '0' );");
|
||||||
$query=mysql_query("SELECT `id` FROM `games` ORDER BY `games`.`id` DESC LIMIT 0 , 1",DB);
|
echo "HERE" . mysqli_error($db);
|
||||||
$data=mysql_fetch_row($query);
|
$query=mysqli_query($db, "SELECT `id` FROM `games` ORDER BY `games`.`id` DESC LIMIT 0 , 1");
|
||||||
|
$data=mysqli_fetch_row($query);
|
||||||
$EDIT_ID=$data[0];
|
$EDIT_ID=$data[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -45,16 +46,16 @@ if (LOGIN!="") {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($EDIT_ID) {
|
if ($EDIT_ID) {
|
||||||
$query=mysql_query("SELECT * FROM `games` WHERE `id` = $EDIT_ID LIMIT 0 , 1",DB);
|
$query=mysqli_query($db, "SELECT * FROM `games` WHERE `id` = $EDIT_ID LIMIT 0 , 1");
|
||||||
$data =mysql_fetch_array($query);
|
$data =mysqli_fetch_array($query);
|
||||||
$BODY.='<form action="index.php?page=edit_game&to_do=save_edit&edit_id='.$EDIT_ID.'" method="post">';
|
$BODY.='<form action="index.php?page=edit_game&to_do=save_edit&edit_id='.$EDIT_ID.'" method="post">';
|
||||||
$BODY.='<table class="list">';
|
$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>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>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>';
|
$BODY.='<tr><th>Spieler:</th><td colspan="3"><select size="10" name="edit_player[]" multiple>';
|
||||||
$query=mysql_query("SELECT * FROM `player`",DB);
|
$query=mysqli_query($db, "SELECT * FROM `player` ORDER BY alias");
|
||||||
$player_of_game=player_of_game($EDIT_ID);
|
$player_of_game=player_of_game($EDIT_ID);
|
||||||
while ($playerlist=mysql_fetch_array($query)) {
|
while ($playerlist=mysqli_fetch_array($query)) {
|
||||||
$selected="";
|
$selected="";
|
||||||
foreach ($player_of_game as $player_in_game) $selected=($player_in_game==$playerlist['id']) ? " selected":$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.='<option value="'.$playerlist['id'].'," '.$selected.'>'.$playerlist['alias'].'</option>';
|
||||||
|
|
@ -65,22 +66,22 @@ if (LOGIN!="") {
|
||||||
$BODY.='<tr><th> </th><th>1. Platz</th><th>2. Platz</th><th>3. Platz</th></tr>';
|
$BODY.='<tr><th> </th><th>1. Platz</th><th>2. Platz</th><th>3. Platz</th></tr>';
|
||||||
$BODY.='<tr><th>Spieler:</th>';
|
$BODY.='<tr><th>Spieler:</th>';
|
||||||
$BODY.='<td><select size="1" name="edit_first_id">';
|
$BODY.='<td><select size="1" name="edit_first_id">';
|
||||||
$query=mysql_query("SELECT * FROM `player`",DB);
|
$query=mysqli_query($db, "SELECT * FROM `player` ORDER BY alias");
|
||||||
while ($playerlist=mysql_fetch_array($query)) {
|
while ($playerlist=mysqli_fetch_array($query)) {
|
||||||
$selected=($playerlist['id']==$data['first_id']) ? " selected":"";
|
$selected=($playerlist['id']==$data['first_id']) ? " selected":"";
|
||||||
$BODY.='<option value="'.$playerlist['id'].'"'.$selected.'>'.$playerlist['alias'].'</option>';
|
$BODY.='<option value="'.$playerlist['id'].'"'.$selected.'>'.$playerlist['alias'].'</option>';
|
||||||
}
|
}
|
||||||
$BODY.='</select></td>';
|
$BODY.='</select></td>';
|
||||||
$BODY.='<td><select size="1" name="edit_second_id">';
|
$BODY.='<td><select size="1" name="edit_second_id">';
|
||||||
$query=mysql_query("SELECT * FROM `player`",DB);
|
$query=mysqli_query($db, "SELECT * FROM `player` ORDER BY alias");
|
||||||
while ($playerlist=mysql_fetch_array($query)) {
|
while ($playerlist=mysqli_fetch_array($query)) {
|
||||||
$selected=($playerlist['id']==$data['second_id']) ? " selected":"";
|
$selected=($playerlist['id']==$data['second_id']) ? " selected":"";
|
||||||
$BODY.='<option value="'.$playerlist['id'].'"'.$selected.'>'.$playerlist['alias'].'</option>';
|
$BODY.='<option value="'.$playerlist['id'].'"'.$selected.'>'.$playerlist['alias'].'</option>';
|
||||||
}
|
}
|
||||||
$BODY.='</select></td>';
|
$BODY.='</select></td>';
|
||||||
$BODY.='<td><select size="1" name="edit_third_id">';
|
$BODY.='<td><select size="1" name="edit_third_id">';
|
||||||
$query=mysql_query("SELECT * FROM `player`",DB);
|
$query=mysqli_query($db, "SELECT * FROM `player` ORDER BY alias");
|
||||||
while ($playerlist=mysql_fetch_array($query)) {
|
while ($playerlist=mysqli_fetch_array($query)) {
|
||||||
$selected=($playerlist['id']==$data['third_id']) ? " selected":"";
|
$selected=($playerlist['id']==$data['third_id']) ? " selected":"";
|
||||||
$BODY.='<option value="'.$playerlist['id'].'"'.$selected.'>'.$playerlist['alias'].'</option>';
|
$BODY.='<option value="'.$playerlist['id'].'"'.$selected.'>'.$playerlist['alias'].'</option>';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,21 +26,26 @@ function money_to_bill($money) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_id_to_alias($id) {
|
function user_id_to_alias($id) {
|
||||||
$query=mysql_query("SELECT * FROM `player` WHERE `id` = $id LIMIT 0 , 30",DB);
|
global $db;
|
||||||
$data=mysql_fetch_array($query);
|
$query=mysqli_query($db, "SELECT * FROM `player` WHERE `id` = $id LIMIT 0 , 30");
|
||||||
return ($data['alias']);
|
$data=mysqli_fetch_array($query);
|
||||||
|
if ($data === FALSE) return NULL;
|
||||||
|
else if ($data === NULL) return NULL;
|
||||||
|
else return $data['alias'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function count_games () {
|
function count_games () {
|
||||||
$query=mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
global $db;
|
||||||
return (mysql_num_rows($query));
|
$query=mysqli_query($db, "SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'");
|
||||||
|
return (mysqli_num_rows($query));
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_count_last_missed_games($id)
|
function user_count_last_missed_games($id)
|
||||||
{
|
{
|
||||||
|
global $db;
|
||||||
$games = 0;
|
$games = 0;
|
||||||
$query = mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE' ORDER BY `datetime` DESC",DB);
|
$query = mysqli_query($db, "SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE' ORDER BY `datetime` DESC");
|
||||||
while ($data=mysql_fetch_array($query)) {
|
while ($data=mysqli_fetch_array($query)) {
|
||||||
$player_array = array();
|
$player_array = array();
|
||||||
$player_array = player_of_game($data['id']);
|
$player_array = player_of_game($data['id']);
|
||||||
$deposition=0;
|
$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
|
function user_count_games($id) { //counts the games wich are played by the user $id
|
||||||
|
global $db;
|
||||||
$games = 0;
|
$games = 0;
|
||||||
$query = mysql_query("SELECT `id` FROM `games`",DB);
|
$query = mysqli_query($db, "SELECT `id` FROM `games`");
|
||||||
while ($data=mysql_fetch_array($query)) {
|
while ($data=mysqli_fetch_array($query)) {
|
||||||
$player_array = array();
|
$player_array = array();
|
||||||
$player_array = player_of_game($data['id']);
|
$player_array = player_of_game($data['id']);
|
||||||
$deposition = 0;
|
$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
|
function user_count_point_games($id) { //counts the games wich are played by the user $id
|
||||||
|
global $db;
|
||||||
$games = 0;
|
$games = 0;
|
||||||
$query = mysql_query("SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
$query = mysqli_query($db, "SELECT `id` FROM `games` WHERE `scoregame` = 'TRUE'");
|
||||||
while ($data=mysql_fetch_array($query)) {
|
while ($data=mysqli_fetch_array($query)) {
|
||||||
$player_array = array();
|
$player_array = array();
|
||||||
$player_array = player_of_game($data['id']);
|
$player_array = player_of_game($data['id']);
|
||||||
$deposition = 0;
|
$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)
|
function user_count_place($id,$place) { //counts how often a user ($id) has made the place ($place)
|
||||||
|
global $db;
|
||||||
$games = 0;
|
$games = 0;
|
||||||
$query = mysql_query("SELECT `".$place."_id` FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
$query = mysqli_query($db, "SELECT `".$place."_id` FROM `games` WHERE `scoregame` = 'TRUE'");
|
||||||
while ($data=mysql_fetch_row($query)) {
|
while ($data=mysqli_fetch_row($query)) {
|
||||||
if ($data[0]==$id) $games++;
|
if ($data[0]==$id) $games++;
|
||||||
}
|
}
|
||||||
return ($games);
|
return ($games);
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_min_bill() {
|
function user_min_bill() {
|
||||||
|
global $db;
|
||||||
$minbill=0;
|
$minbill=0;
|
||||||
$query=mysql_query("SELECT `id` FROM `player`",DB);
|
$query=mysqli_query($db, "SELECT `id` FROM `player`");
|
||||||
while ($data=mysql_fetch_row($query)){
|
while ($data=mysqli_fetch_row($query)){
|
||||||
$helpvar=user_count_bill($data[0]);
|
$helpvar=user_count_bill($data[0]);
|
||||||
if ($helpvar<$minbill) $minbill=$helpvar;
|
if ($helpvar<$minbill) $minbill=$helpvar;
|
||||||
}
|
}
|
||||||
|
|
@ -100,9 +109,10 @@ function user_min_bill() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_max_bill() {
|
function user_max_bill() {
|
||||||
|
global $db;
|
||||||
$maxbill=0;
|
$maxbill=0;
|
||||||
$query=mysql_query("SELECT `id` FROM `player`",DB);
|
$query=mysqli_query($db, "SELECT `id` FROM `player`");
|
||||||
while ($data=mysql_fetch_row($query)){
|
while ($data=mysqli_fetch_row($query)){
|
||||||
$helpvar=user_count_bill($data[0]);
|
$helpvar=user_count_bill($data[0]);
|
||||||
if ($helpvar>$maxbill) $maxbill=$helpvar;
|
if ($helpvar>$maxbill) $maxbill=$helpvar;
|
||||||
}
|
}
|
||||||
|
|
@ -110,9 +120,10 @@ function user_max_bill() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_count_bill($id) {
|
function user_count_bill($id) {
|
||||||
|
global $db;
|
||||||
$bill=0;
|
$bill=0;
|
||||||
$query=mysql_query("SELECT * FROM `games` WHERE `scoregame` = 'TRUE'",DB);
|
$query=mysqli_query($db, "SELECT * FROM `games` WHERE `scoregame` = 'TRUE'");
|
||||||
while ($data=mysql_fetch_array($query)) {
|
while ($data=mysqli_fetch_array($query)) {
|
||||||
$playerlist=player_of_game($data['id']);
|
$playerlist=player_of_game($data['id']);
|
||||||
foreach ($playerlist as $player) {
|
foreach ($playerlist as $player) {
|
||||||
if ($player==$id) $bill-=$data['base_bill'];
|
if ($player==$id) $bill-=$data['base_bill'];
|
||||||
|
|
@ -125,10 +136,11 @@ function user_count_bill($id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function player_of_game($game_id) {
|
function player_of_game($game_id) {
|
||||||
|
global $db;
|
||||||
$player_array=array();
|
$player_array=array();
|
||||||
|
|
||||||
$query =mysql_query("SELECT `player` FROM `games` WHERE `id` = $game_id",DB);
|
$query =mysqli_query($db, "SELECT `player` FROM `games` WHERE `id` = $game_id");
|
||||||
$data =mysql_fetch_array($query);
|
$data =mysqli_fetch_array($query);
|
||||||
$player=$data['player'];
|
$player=$data['player'];
|
||||||
|
|
||||||
while (strlen($player)>0) {
|
while (strlen($player)>0) {
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ $BODY.=' <th>Datum, Zeit</th>
|
||||||
<th>Dritter</th>
|
<th>Dritter</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
$query=mysql_query("SELECT * FROM `games` ORDER BY `datetime` ASC",DB);
|
$query=mysqli_query($db, "SELECT * FROM `games` ORDER BY `datetime` ASC");
|
||||||
while ($data=mysql_fetch_array($query)) {
|
while ($data=mysqli_fetch_array($query)) {
|
||||||
$id=$data['id'];
|
$id=$data['id'];
|
||||||
$BODY.="<tr><td>";
|
$BODY.="<tr><td>";
|
||||||
if (LOGIN!="")
|
if (LOGIN!="")
|
||||||
|
|
|
||||||
18
index.php
18
index.php
|
|
@ -11,8 +11,7 @@
|
||||||
$COMMENT = ""; //comments
|
$COMMENT = ""; //comments
|
||||||
if (isset($_GET['to_do'])) define ("TO_DO",$_GET['to_do']);
|
if (isset($_GET['to_do'])) define ("TO_DO",$_GET['to_do']);
|
||||||
else define ("TO_DO","");
|
else define ("TO_DO","");
|
||||||
define ('DB',mysql_connect("localhost","poker","JuzFQK6rnNfx75v8"));
|
$db = mysqli_connect("localhost","poker","*******", "poker");
|
||||||
mysql_select_db("poker",DB);
|
|
||||||
include("globals.php");
|
include("globals.php");
|
||||||
include("functions.php");
|
include("functions.php");
|
||||||
|
|
||||||
|
|
@ -20,13 +19,13 @@
|
||||||
if (!session_start()) $ERROR.="Server Session kann nicht eingerichtet werden, kein login möglich!<br>";
|
if (!session_start()) $ERROR.="Server Session kann nicht eingerichtet werden, kein login möglich!<br>";
|
||||||
if (TO_DO=="login") {
|
if (TO_DO=="login") {
|
||||||
$login=$_POST['login'];
|
$login=$_POST['login'];
|
||||||
$password=md5($_POST['password']);
|
$query=mysqli_query($db, "SELECT `password` FROM `player` WHERE `alias` = '$login' AND `password` IS NOT NULL LIMIT 0 , 30");
|
||||||
$query=mysql_query("SELECT `password` FROM `player` WHERE `alias` = '$login' AND `password` IS NOT NULL LIMIT 0 , 30",DB);
|
$data=mysqli_fetch_array($query);
|
||||||
$data=mysql_fetch_array($query);
|
if ($data!==NULL && $data!==False && password_verify($_POST['password'], $data['password'])) {
|
||||||
if ($data['password']==$password) {
|
|
||||||
$_SESSION['login']=$login;
|
$_SESSION['login']=$login;
|
||||||
|
} else {
|
||||||
|
$ERROR.="Login nicht erfolgreich!<br>";
|
||||||
}
|
}
|
||||||
else $ERROR.="Login nicht erfolgreich!<br>";
|
|
||||||
}
|
}
|
||||||
if ($page=="logout") {
|
if ($page=="logout") {
|
||||||
$_SESSION['login']="";
|
$_SESSION['login']="";
|
||||||
|
|
@ -36,7 +35,8 @@
|
||||||
else define ("LOGIN","");
|
else define ("LOGIN","");
|
||||||
if (LOGIN!="") {
|
if (LOGIN!="") {
|
||||||
$BODY.='<table class="list" width="100%"><tr><th style="text-align:left">'.add_icon('user')." ".LOGIN." ";
|
$BODY.='<table class="list" width="100%"><tr><th style="text-align:left">'.add_icon('user')." ".LOGIN." ";
|
||||||
$BODY.='<a class="list" href="index.php?page=edit_game&to_do=new_game">'.add_icon("new_game").'Neues Spiel</a>';
|
$BODY.='<a class="list" href="index.php?page=edit_game&to_do=new_game">'.add_icon("new_game").'Neues Spiel</a> ';
|
||||||
|
$BODY.='<a class="list" href="index.php?page=rank&to_do=update_rank">'.add_icon("arrow_out").'Rangliste Aktualisieren</a> ';
|
||||||
$BODY.="</th></tr></table>";
|
$BODY.="</th></tr></table>";
|
||||||
}
|
}
|
||||||
$BODY.="<br><br>";
|
$BODY.="<br><br>";
|
||||||
|
|
@ -53,5 +53,5 @@
|
||||||
include ("template.php");
|
include ("template.php");
|
||||||
|
|
||||||
//End of Script
|
//End of Script
|
||||||
mysql_close(DB);
|
mysqli_close($db);
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
21
index.php~
21
index.php~
|
|
@ -1,21 +0,0 @@
|
||||||
<?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);
|
|
||||||
?>
|
|
||||||
4
main.php
4
main.php
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
$query=mysql_query("SELECT `first_id` FROM `games` WHERE `scoregame` = 'TRUE' ORDER BY `games`.`datetime` DESC LIMIT 0 , 1",DB);
|
$query=mysqli_query($db, "SELECT `first_id` FROM `games` WHERE `scoregame` = 'TRUE' ORDER BY `games`.`datetime` DESC LIMIT 0 , 1");
|
||||||
$data=mysql_fetch_array($query);
|
$data=mysqli_fetch_array($query);
|
||||||
$BODY.='<br><br><table class="the_ring" align="center">
|
$BODY.='<br><br><table class="the_ring" align="center">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
||||||
17
password.php
Executable file
17
password.php
Executable file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<form action="password.php" method="post">
|
||||||
|
<input type="password" name="generated_password" value=""/>
|
||||||
|
<button type="submit">Generate</button>
|
||||||
|
<br>
|
||||||
|
<?php
|
||||||
|
if (isset($_POST['generated_password'])) {
|
||||||
|
$pw_hash = password_hash($_POST['generated_password'], PASSWORD_DEFAULT);
|
||||||
|
echo "Generated password: '$pw_hash'<br>";
|
||||||
|
echo "password algorithm: " . password_get_info($pw_hash)['algoName'] . "<br>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
59
rank.php
59
rank.php
|
|
@ -1,19 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
//Create player statistics
|
|
||||||
$query = mysql_query("SELECT * FROM `player`",DB);
|
// Update player statistics (only when someone is logged in)
|
||||||
$user_min_bill=-1*user_min_bill();
|
if (LOGIN!="" && TO_DO == "update_rank") {
|
||||||
while ($data=mysql_fetch_array($query)) {
|
$query = mysqli_query($db, "SELECT * FROM `player`");
|
||||||
$cnt_games = user_count_games($data['id']);
|
$user_min_bill=-1*user_min_bill();
|
||||||
$cnt_point_games = user_count_point_games($data['id']);
|
while ($data=mysqli_fetch_array($query)) {
|
||||||
$cnt_first = user_count_place($data['id'],"first");
|
$cnt_games = user_count_games($data['id']);
|
||||||
$cnt_second = user_count_place($data['id'],"second");
|
$cnt_point_games = user_count_point_games($data['id']);
|
||||||
$cnt_third = user_count_place($data['id'],"third");
|
$cnt_first = user_count_place($data['id'],"first");
|
||||||
$points = 3*$cnt_first + 2*$cnt_second + $cnt_third;
|
$cnt_second = user_count_place($data['id'],"second");
|
||||||
$rate = ($cnt_games) ? (1000 * $points)/ ($cnt_games):0;
|
$cnt_third = user_count_place($data['id'],"third");
|
||||||
$bill = user_count_bill($data['id']);
|
$points = 3*$cnt_first + 2*$cnt_second + $cnt_third;
|
||||||
$missed_games = user_count_last_missed_games($data['id']);
|
$rate = ($cnt_games) ? (1000 * $points)/ ($cnt_games):0;
|
||||||
$rank = calculate_rank($rate,$bill+$user_min_bill,$missed_games);
|
$bill = user_count_bill($data['id']);
|
||||||
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);
|
$missed_games = user_count_last_missed_games($data['id']);
|
||||||
|
$rank = calculate_rank($rate,$bill+$user_min_bill,$missed_games);
|
||||||
|
mysqli_query($db, "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 ;");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Determine Sort Order
|
//Determine Sort Order
|
||||||
|
|
@ -32,12 +35,12 @@ if (TO_DO=="insert_player" && LOGIN!="") {
|
||||||
$failure="";
|
$failure="";
|
||||||
if (!($alias=$_POST['alias'])) $failure.="Spitznamen angeben!<br>";
|
if (!($alias=$_POST['alias'])) $failure.="Spitznamen angeben!<br>";
|
||||||
if (!$failure) {
|
if (!$failure) {
|
||||||
$query=mysql_query("SELECT `alias` FROM `player` WHERE `alias` = '$alias' LIMIT 0 , 30",DB);
|
$query=mysqli_query($db, "SELECT `alias` FROM `player` WHERE `alias` = '$alias' LIMIT 0 , 30");
|
||||||
$data=mysql_fetch_array($query);
|
$data=mysqli_fetch_array($query);
|
||||||
if ($data['alias']==$alias) $failure.="Spitzname existiert bereits!<br>";
|
if ($data!==NULL && $data!==False && $data['alias']==$alias) $failure.="Spitzname existiert bereits!<br>";
|
||||||
}
|
}
|
||||||
if (!$failure) {
|
if (!$failure) {
|
||||||
mysql_query("INSERT INTO `player` ( `alias` ) VALUES ( '$alias' );",DB);
|
mysqli_query($db, "INSERT INTO `player` ( `alias`, `password`, `cnt_games`, `cnt_first`, `cnt_second`, `cnt_third`, `points`, `rate`, `bill`, `rank`) VALUES ( '$alias', '', '0', '0', '0', '0', '0', '0', '0', '0');");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$value_ip_alias = $alias;
|
$value_ip_alias = $alias;
|
||||||
|
|
@ -49,12 +52,12 @@ if (TO_DO=="save_edit_player" && LOGIN!="" && ($player=$_GET['player'])) {
|
||||||
$failure="";
|
$failure="";
|
||||||
if (!($alias=$_POST['alias'])) $failure.="Spitznamen angeben!<br>";
|
if (!($alias=$_POST['alias'])) $failure.="Spitznamen angeben!<br>";
|
||||||
if (!$failure) {
|
if (!$failure) {
|
||||||
$query=mysql_query("SELECT `id`,`alias` FROM `player` WHERE `alias` = '$alias' LIMIT 0 , 30",DB);
|
$query=mysqli_query($db, "SELECT `id`,`alias` FROM `player` WHERE `alias` = '$alias' LIMIT 0 , 30");
|
||||||
while ($data=mysql_fetch_array($query))
|
while ($data=mysqli_fetch_array($query))
|
||||||
if ($data['id']!=$player) $failure.="Spitzname existiert bereits!<br>";
|
if ($data['id']!=$player) $failure.="Spitzname existiert bereits!<br>";
|
||||||
}
|
}
|
||||||
if (!$failure) {
|
if (!$failure) {
|
||||||
mysql_query("UPDATE `player` SET `alias` = '$alias' WHERE `id` = '$player' LIMIT 1 ;",DB);
|
mysqli_query($db, "UPDATE `player` SET `alias` = '$alias' WHERE `id` = '$player' LIMIT 1 ;");
|
||||||
}
|
}
|
||||||
$ERROR.=$failure;
|
$ERROR.=$failure;
|
||||||
}
|
}
|
||||||
|
|
@ -62,6 +65,7 @@ if (TO_DO=="save_edit_player" && LOGIN!="" && ($player=$_GET['player'])) {
|
||||||
$BODY.='
|
$BODY.='
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
<th> </th>
|
<th> </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=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_games&sortorder='.$SORTNOORD.'">'.(($SORTBY=="cnt_games") ? add_icon($SORTORDER):"").'Spiele</a></th>
|
||||||
|
|
@ -74,19 +78,20 @@ $BODY.='
|
||||||
<th><a href="index.php?page=rank&sortby=rank&sortorder='.$SORTNOORD.'">'.(($SORTBY=="rank") ? add_icon($SORTORDER):"").'Rang</a></th>
|
<th><a href="index.php?page=rank&sortby=rank&sortorder='.$SORTNOORD.'">'.(($SORTBY=="rank") ? add_icon($SORTORDER):"").'Rang</a></th>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
$query=mysql_query("SELECT * FROM `player` $SORTSTRING",DB);
|
$query=mysqli_query($db, "SELECT * FROM `player` $SORTSTRING");
|
||||||
while ($data=mysql_fetch_array($query)) {
|
$position = 1;
|
||||||
|
while ($data=mysqli_fetch_array($query)) {
|
||||||
$id = $data['id'];
|
$id = $data['id'];
|
||||||
$alias = $data['alias'];
|
$alias = $data['alias'];
|
||||||
if (TO_DO=="edit_player" && LOGIN!="" && $_GET['player']==$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.="<form action=\"index.php?page=rank&to_do=save_edit_player&player=$id\" method=\"post\">";
|
||||||
$BODY.="<tr><td></td>";
|
$BODY.="<tr><td></td><td></td>";
|
||||||
$BODY.="<td><input type=\"text\" size=\"8\" name=\"alias\" value=\"$alias\"></td>\n";
|
$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.="<td><input type=\"submit\" value=\"\" class=\"submit_save\"></td>\n";
|
||||||
$BODY.="</form>";
|
$BODY.="</form>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$BODY.="<tr><td>";
|
$BODY.="<tr><td>$position</td><td>";
|
||||||
if (LOGIN!="")
|
if (LOGIN!="")
|
||||||
$BODY.="<a href=\"index.php?page=rank&to_do=edit_player&player=$alias\" target=\"_top\">".add_icon("pencil")."</a>";
|
$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><td>$alias</td>";
|
||||||
|
|
@ -101,6 +106,8 @@ while ($data=mysql_fetch_array($query)) {
|
||||||
$BODY.="<td>".$data['rank']."</td>";
|
$BODY.="<td>".$data['rank']."</td>";
|
||||||
$BODY.="</tr>\n";
|
$BODY.="</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++$position;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOGIN!="") {
|
if (LOGIN!="") {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ table.list {
|
||||||
}
|
}
|
||||||
table.list td {
|
table.list td {
|
||||||
text-align:center;
|
text-align:center;
|
||||||
|
border-bottom-color:#fffe;
|
||||||
|
border-bottom-width:1px;
|
||||||
|
border-bottom-style:dotted;
|
||||||
}
|
}
|
||||||
table.list th{
|
table.list th{
|
||||||
padding-left:3px;
|
padding-left:3px;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue