Файл: social12/total.php
Строк: 131
<?php
require 'sid.php';
require 'config.php';
$link = connect_db();
list($user, $id, $ps) = check_login($link);
whorm(0, 'total');
include 'head.php';
include 'navigator.php';
$do = isset($_GET['do']) ? $_GET['do'] : NULL;
switch($do) {
default:
echo $div_title . 'Спорт-Тотализатор' . $div_end . $div_left .
$div_menu . '• <a href="total.php?do=prizi">Призы</a>' . $div_end;
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `sport_razdel`"), 0);
if ($count != FALSE) {
$n = new navigator($count, 10, '?');
$view = mysql_query("SELECT `sport_razdel`.*,(SELECT COUNT(*) FROM `sport_match` WHERE `sport_match`.`uid` = `sport_razdel`.`id`) AS c FROM `sport_razdel` ORDER BY `sport_razdel`.`id` ASC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($view)) {
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '» <a href="total.php?do=match&m='.$a['id'].'">' . $a['name'] . '</a> (' . $a['c'] . ')' . $div_end;
}
echo $n->navi();
} else {
echo 'Разделы не созданы.<br/>';
}
echo $div_end;
break;
case match:
echo $div_title . 'Матчи' . $div_end . $div_left;
$m = my_int($_GET['m']);
$sql = mysql_query("SELECT `id` FROM `sport_razdel` WHERE `id` = '$m' LIMIT 1");
if (mysql_num_rows($sql) == FALSE) {
err('Раздел не найден!');
} else {
if (isset($_GET['ok'])) msg('Ставка принята.');
$num = mysql_result(mysql_query("SELECT COUNT(*) FROM `sport_match` WHERE `uid` = '$m'"), 0);
if ($num != FALSE) {
$n = new navigator($num, 10, '?do=match&m='.$m.'&');
$view = mysql_query("SELECT * FROM `sport_match` WHERE `uid` = '$m' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($view)) {
if ($a['year'] < date('Y') || $a['year'] <= date('Y') && $a['month'] < date('m') || $a['year'] <= date('Y') && $a['month'] <= date('m') && $a['day'] < date('d') || $a['year'] == date('Y') && $a['month'] == date('m') && $a['day'] == date('d') && $a['time_hour'] <= date('H') && $a['time_minuts'] <= date('i')) {
$lock = '(<b>Недоступен</b>)';
$view_info = '<br/><a href="total.php?do=results&r='.$a['id'].'">Смотреть результат</a> ';
} else {
$lock = '<br/>(<b>Доступен</b>)';
$view_info = '';
}
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<a href="total.php?do=stavka&s='.$a['id'].'">' . $a['command1'] . ' V.S. ' . $a['command2'] . '</a><br/>Окончание: ['.$a['day'].'.'.$a['month'].'.'.$a['year'].' в '.$a['time_hour'].':'.$a['time_minuts'].']' . $view_info . $lock . $div_end;
}
echo $n->navi();
} else {
echo 'Матчей нет.<br/>';
}
}
echo $div_end;
break;
case stavka:
echo $div_title . 'Ставка' . $div_end . $div_left;
$s = my_int($_GET['s']);
$sql = mysql_query("SELECT * FROM `sport_match` WHERE `id` = '$s' LIMIT 1");
if (mysql_num_rows($sql) == FALSE) {
err('Матч не найден!');
} else {
$inf = mysql_fetch_assoc($sql);
$double = mysql_query("SELECT `id` FROM `sport_stavka` WHERE `uid` = '$s' AND `user` = '$user[id]' LIMIT 1");
if ($inf['year'] < date('Y') || $inf['year'] <= date('Y') && $inf['month'] < date('m') || $inf['year'] <= date('Y') && $inf['month'] <= date('m') && $inf['day'] < date('d') || $inf['year'] == date('Y') && $inf['month'] == date('m') && $inf['day'] == date('d') && $inf['time_hour'] <= date('H') && $inf['time_minuts'] <= date('i')) {
err('Этот матч уже завершен!');
} elseif (mysql_num_rows($double) != FALSE) {
err('Вы уже ставили ставку на этот матч!');
} else {
if (isset($_POST['ok'])) {
$com1 = my_int($_POST['com1']);
$com2 = my_int($_POST['com2']);
$cards = my_int($_POST['cards']);
$min = my_int($_POST['min']);
mysql_query("INSERT INTO `sport_stavka` SET
`com1` = '$com1',
`com2` = '$com2',
`cards` = '$cards',
`min` = '$min',
`user` = '$user[id]',
`uid` = '$s'");
header('Location: total.php?do=match&m='.$inf['uid'].'&ok');
}
echo '<FORM method="POST" action="total.php?do=stavka&s='.$s.'">
<label>Голов у комманды: ' . $inf['command1'] . '</label><br/>
<input type="text" name="com1" size="3"/>
<br/>
<label>Голов у комманды: ' . $inf['command2'] . '</label><br/>
<input type="text" name="com2" size="3"/>
<br/>
<label>Число карточек:</label><br/>
<input type="text" name="cards" size="3"/>
<br/>
<label>Первый гол на </label>
<br/>
<input type="text" name="min" size="3"/>
минуте
<br/>
<input type="submit" name="ok" value="Сделать ставку"/>
</FORM>';
}
}
echo $div_end;
break;
case prizi:
echo $div_title . 'Ставка' . $div_end . $div_left;
$CountTotal = mysql_result(mysql_query("SELECT COUNT(*) FROM `sport_razdel`"), 0);
$select = mysql_query("SELECT sport_prizi .*,
(SELECT name FROM sport_razdel WHERE sport_prizi.uid = sport_razdel.id) AS s FROM sport_prizi");
if ($CountTotal != FALSE) {
$i = 0;
while($a = mysql_fetch_assoc($select)) {
$a['first'] = (empty($a['first'])) ? 0 : $a['first'];
$a['second'] = (empty($a['second'])) ? 0 : $a['second'];
$a['third'] = (empty($a['third'])) ? 0 : $a['third'];
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $a['s'] . '
<br/>
<span style="background: #D4EEFF;">
<img src="ico/1st.png" alt=""/> - ' . $a['first'] . ' <img src="ico/balls.png" alt=""/><br/>
<img src="ico/2nd.png" alt=""/> - ' . $a['second'] . ' <img src="ico/balls.png" alt=""/><br/>
<img src="ico/3rd.png" alt=""/> - ' . $a['third'] . ' <img src="ico/balls.png" alt=""/><br/>
</span>' . $div_end;
}
} else {
echo 'Призы не определены!<br/>';
}
echo $div_end;
break;
case results:
echo $div_title . 'Результат матча' . $div_end . $div_left;
$r = my_int($_GET['r']);
$match = mysql_query("SELECT * FROM `sport_match` WHERE `id` = '$r' LIMIT 1");
$inf = mysql_query("SELECT * FROM `sport_result` WHERE `uid` = '$r' LIMIT 1");
$res_1 = mysql_fetch_assoc($match);
$res_2 = mysql_fetch_assoc($inf);
if (mysql_num_rows($match) == FALSE) {
err('Матч не найден!');
} elseif (mysql_num_rows($inf) == FALSE) {
err('Результаты данного матча еще не определены!');
} else {
echo '<b>' . $res_1['command1'] . '</b>-<b>' . $res_1['command2'] . '</b>
<br/>
Голов у ' .$res_1['command1'] . ': <b>' . $res_2['com1'] . '</b>
<br/>
Голов у ' .$res_1['command2'] . ': <b>' . $res_2['com2'] . '</b>
<br/>
Кол-во карточек: <b>' . $res_2['cards'] . '</b>
<br/>
Первый гол на <b>' . $res_2['min'] . '</b> минуте';
}
echo $div_end;
break;
}
include 'foot.php';
?>