Parašė Bruksnys· 2011 Rugp. 27 14:08:30
#15
<?php
/*--------------------------- ------+
+----------------------------------*/
require_once "../../maincore.php";
require_once "../../subheader.php";
require_once "../../side_left.php";
function addpts1($zaidejas, $pts)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas1 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas1 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, pts, kada) values ({$zaidejas['id']}, {$pts}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set pts = pts + {$pts} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
function addpts2($zaidejas, $pts)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas2 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas2 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, pts, kada) values ({$zaidejas['id']}, {$pts}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set pts = pts + {$pts} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
function addreb1($zaidejas, $reb)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas1 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas1 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, reb, kada) values ({$zaidejas['id']}, {$reb}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set reb = reb + {$reb} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
function addreb2($zaidejas, $reb)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas2 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas2 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, reb, kada) values ({$zaidejas['id']}, {$reb}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set reb = reb + {$reb} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
function addblk1($zaidejas, $blk)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas1 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas1 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, blk, kada) values ({$zaidejas['id']}, {$blk}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set blk = blk + {$blk} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
function addblk2($zaidejas, $blk)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas2 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas2 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, blk, kada) values ({$zaidejas['id']}, {$blk}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set blk = blk + {$blk} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
function addkof1($zaidejas, $kof)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas1 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas1 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, kof, kada) values ({$zaidejas['id']}, {$kof}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set kof = kof + {$kof} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
function addkof2($zaidejas, $kof)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas2 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas2 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, kof, kada) values ({$zaidejas['id']}, {$kof}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set kof = kof + {$kof} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
function addstl1($zaidejas, $stl)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas1 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas1 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, stl, kada) values ({$zaidejas['id']}, {$stl}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set stl = stl + {$stl} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
function addstl2($zaidejas, $stl)
{
$rez1 = mysql_query("SELECT t.id, t.zaidejas FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas2 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas2 = '$zaidejas' group by t.id");
$zaidejas = @mysql_fetch_array($rez1);
$rez1 = mysql_query("SELECT * FROM 1x1_mvp where zaidejas = {$zaidejas['id']} and kada = '" . date("Y-m-d") . "'");
$q = @mysql_num_rows($rez1);
if($q == 0)
{
dbquery("insert into 1x1_mvp (zaidejas, stl, kada) values ({$zaidejas['id']}, {$stl}, '" . date("Y-m-d") . "')");
}
else
{
dbquery("update 1x1_mvp set stl = stl + {$stl} where zaidejas = '{$zaidejas['id']}' and kada = '" . date("Y-m-d") . "'");
}
}
if(isset($status) && $status != '') {
if($status == 'pateikta') { /*kazkas jeigu pridejo*/ }
elseif($status == 'atmesta') { /*Kazkas jei nepridejo*/}
}
if (isset($_POST['submit'])) {
$ip = $_SERVER['REMOTE_ADDR'];
$_POST['zaidejas1'] = str_replace("\'", "", $_POST['zaidejas1']);
$_POST['zaidejas2'] = str_replace("\'", "", $_POST['zaidejas2']);
$result = dbquery("INSERT INTO 1x1_rez (zaidejas1, rez1, zaidejas2, rez2, ip, time, datea, date, pts1, pts2, reb1, reb2, stl1, stl2, ast1, ast2, blk1, blk2, kof1, kof2) VALUES ('{$_POST['zaidejas1']}', '".$_POST['rez1']."', '{$_POST['zaidejas2']}', '".$_POST['rez2']."', '".$ip."', '".time()."', '".date("H:i")."', '".date("Y-m-d")."', '".$_POST['pts1']."', '".$_POST['pts2']."', '".$_POST['reb1']."', '".$_POST['reb2']."', '".$_POST['stl1']."', '".$_POST['stl2']."', '".$_POST['ast1']."', '".$_POST['ast2']."', '".$_POST['blk1']."', '".$_POST['blk2']."', '".$_POST['kof1']."', '".$_POST['kof2']."')");
if($result) {
if($_POST['pts1'] != '')
{
dbquery("update fsb_1x1_zaidejai set pts = pts + {$_POST['pts1']} where zaidejas = '{$_POST['zaidejas1']}'");
addpts1($_POST['zaidejas1'], $_POST['pts1']);
}
if($_POST['pts2'] != '')
{
dbquery("update fsb_1x1_zaidejai set pts = pts + {$_POST['pts2']} where zaidejas = '{$_POST['zaidejas2']}'");
addpts2($_POST['zaidejas2'], $_POST['pts2']);
}
if($_POST['reb1'] != '')
{
dbquery("update fsb_1x1_zaidejai set reb = reb + {$_POST['reb1']} where zaidejas = '{$_POST['zaidejas1']}'");
addreb1($_POST['zaidejas1'], $_POST['reb1']);
}
if($_POST['reb2'] != '')
{
dbquery("update fsb_1x1_zaidejai set reb = reb + {$_POST['reb2']} where zaidejas = '{$_POST['zaidejas2']}'");
addreb2($_POST['zaidejas2'], $_POST['reb2']);
}
if($_POST['stl1'] != '')
{
dbquery("update fsb_1x1_zaidejai set stl = stl + {$_POST['stl1']} where zaidejas = '{$_POST['zaidejas1']}'");
addstl1($_POST['zaidejas1'], $_POST['stl1']);
}
if($_POST['stl2'] != '')
{
dbquery("update fsb_1x1_zaidejai set stl = stl + {$_POST['stl2']} where zaidejas = '{$_POST['zaidejas2']}'");
addstl2($_POST['zaidejas2'], $_POST['stl2']);
}
if($_POST['blk1'] != '')
{
dbquery("update fsb_1x1_zaidejai set blk = blk + {$_POST['blk1']} where zaidejas = '{$_POST['zaidejas1']}'");
addblk1($_POST['zaidejas1'], $_POST['blk1']);
}
if($_POST['blk2'] != '')
{
dbquery("update fsb_1x1_zaidejai set blk = blk + {$_POST['blk2']} where zaidejas = '{$_POST['zaidejas2']}'");
addblk2($_POST['zaidejas2'], $_POST['blk2']);
}
if($_POST['kof1'] != '')
{
dbquery("update fsb_1x1_zaidejai set kof = kof + {$_POST['kof1']} where zaidejas = '{$_POST['zaidejas1']}'");
addkof1($_POST['zaidejas1'], $_POST['kof1']);
}
if($_POST['kof2'] != '')
{
dbquery("update fsb_1x1_zaidejai set kof = kof + {$_POST['kof2']} where zaidejas = '{$_POST['zaidejas2']}'");
addkof2($_POST['zaidejas2'], $_POST['kof2']);
}
if($_POST['rez1'] != '')
{
dbquery("update fsb_1x1_zaidejai set imete = imete + {$_POST['rez1']} where zaidejas = '{$_POST['zaidejas1']}'");
}
if($_POST['rez2'] != '')
{
dbquery("update fsb_1x1_zaidejai set imete = imete + {$_POST['rez2']} where zaidejas = '{$_POST['zaidejas2']}'");
}
if($_POST['rez1'] != '')
{
dbquery("update fsb_1x1_zaidejai set praleido = praleido + {$_POST['rez2']} where zaidejas = '{$_POST['zaidejas1']}'");
}
if($_POST['rez2'] != '')
{
dbquery("update fsb_1x1_zaidejai set praleido = praleido + {$_POST['rez1']} where zaidejas = '{$_POST['zaidejas2']}'");
}
if($_POST['rez1'] == $_POST['rez2'])
{
dbquery("update fsb_1x1_zaidejai set suzaide = suzaide + 1, taskai = taskai + 1 where zaidejas = '{$_POST['zaidejas1']}'");
dbquery("update fsb_1x1_zaidejai set suzaide = suzaide + 1, taskai = taskai + 1 where zaidejas = '{$_POST['zaidejas2']}'");
}
elseif ($_POST['rez1'] > $_POST['rez2'])
{
dbquery("update 1x1_mvp set suzaide = suzaide + 1 where zaidejas = '{$_POST['zaidejas1']}' OR zaidejas = '{$_POST['zaidejas2']}'");
dbquery("update fsb_1x1_zaidejai set suzaide = suzaide + 1, pergales = pergales + 1, taskai = taskai + 2 where zaidejas = '{$_POST['zaidejas1']}'");
dbquery("update fsb_1x1_zaidejai set suzaide = suzaide + 1, pralaimejimai = pralaimejimai + 1, taskai = taskai + 1 where zaidejas = '{$_POST['zaidejas2']}'");
}
else
{
dbquery("update fsb_1x1_zaidejai set suzaide = suzaide + 1, pergales = pergales + 1, taskai = taskai + 2 where zaidejas = '{$_POST['zaidejas2']}'");
dbquery("update fsb_1x1_zaidejai set suzaide = suzaide + 1, pralaimejimai = pralaimejimai + 1 where zaidejas = '{$_POST['zaidejas1']}'");
dbquery("update 1x1_mvp set suzaide = suzaide + 1 where zaidejas = '{$_POST['zaidejas1']}' OR zaidejas = '{$_POST['zaidejas2']}'");
}
$zaidejas1 = mysql_query("SELECT zaidejas FROM fsb_1x1_zaidejai where name = '{$_POST['zaidejas1']}'");
$zaidejas1 = @mysql_fetch_array(1);
$zaidejas2 = mysql_query("SELECT zaidejas FROM fsb_1x1_zaidejai where name = '{$_POST['zaidejas2']}'");
$zaidejas2 = @mysql_fetch_array(2);
$played = 0;
$rez1 = mysql_query("SELECT t.zaidejas count(*) as played FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas1 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas1 = '{$_POST['zaidejas']}' group by t.zaidejas");
if(@mysql_num_rows($rez1) > 0)
{
$zaidejas = mysql_fetch_array($rez1);
$played += $zaidejas['suzaide'];
}
$rez1 = mysql_query("SELECT t.zaidejas, count(*) as played FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas2 = t.zaidejas) where s.date = '".date("Y-m-d")."' and s.zaidejas2 = '{$_POST['zaidejas']}' group by t.zaidejas");
if(mysql_num_rows($rez1) > 0)
{
$zaidejas = mysql_fetch_array($rez1);
$played += $zaidejas['suzaide'];
}
$rez1 = mysql_query("SELECT t.zaidejas, count(*) as played FROM `1x1_rez` s left join fsb_1x1_zaidejai t on (s.zaidejas2 = t.zaidjeas) where s.date = '".date("Y-m-d")."' and s.zaidejas2 = '{$_POST['zaidejas2']}' group by t.zaidejas");
if(@mysql_num_rows($rez1) > 0)
{
$zaidejas = mysql_fetch_array($rez1);
$played += $zaidejas['suzaide'];
}
opentable('Varþybø registravimas');
echo "<center><b>Dëkojame, varþybos sëkmingai uþregistruotos.</b></center>";
closetable();
}
else { echo "Varþybø uþregistruoti nepavyko."; }
}
else {
opentable('Varþybø registravimas');
$zaidejass = "";
$rez1 = mysql_query("SELECT zaidejas FROM fsb_1x1_zaidejai order by zaidejas");
while ($q = mysql_fetch_array($rez1))
{
$zaidejass .= "<option value=\"{$q['zaidejas']}\">{$q['zaidejas']}</option>";
}
$players = "<option value=\"0\" selected=\"selected\">-< Pasirinkite þaidëjà >-</option>";
$rez1 = mysql_query("SELECT zaidejas FROM fsb_1x1_zaidejai order by zaidejas");
while ($q = mysql_fetch_array($rez1))
{
$players .= "<option value=\"{$q['zaidejas']}\">{$q['zaidejas']}</option>";
}
echo "
<center><b>Varþybø registravimas</b></center><br><br>
<center>
<form method='POST' action='".FUSION_SELF."'>
<select class='textbox' name='zaidejas1'>
{$zaidejass}
</select>
<input format='NNN' class='textbox' name='rez1' size='12' maxlength='3'/> -
<input format='NNN' class='textbox' name='rez2' size='12' maxlength='3'/>
<select class='textbox' name='zaidejas2'>
{$zaidejass}
</select>
<br>
<br>
<table border='0' width='100%'>
</table>
<br>
<input type='submit' name='submit' value='Uþregistruoti varþybas'>
</form></center>
";
include_once "irasymas2.php";
closetable();
}
require_once "../../side_right.php";
require_once "../../footer.php";
?>
Dėkui.