Файл: region_clean/games/21.php
Строк: 331
<?php
#######################################
## Mod By KoT (borispol) [76-75-072] ##
#######################################
require_once "../start.php";
require_once "../sid.php";
header("Cache-Control: no-cache");
if ($ver == "wml")header ("Content-type:text/vnd.wap.wml; charset=utf-8");
else header("Content-Type:text/html; charset=UTF-8");
require_once "../inc.php";
$link = connect_db();
list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);
require_once "../version.php";
$posts = $row['gposts'];
$guposts = $row['gposts'];
$gposts = $row['gposts'];
if (!session_is_registered("session")) {
$session['round'] = 0;
$session['money'] = $gposts;
$session['con'] = 0;
$session['histuser'] = "";
session_register("session");
}
$ses2=SID;
$ses="$ses2&$ses&ref=$ref";
function cards_score($str) {
if ($str == 1 || $str == 2 || $str == 3 || $str == 4) { $num = 6; }
if ($str == 5 || $str == 6 || $str == 7 || $str == 8) { $num = 7; }
if ($str == 9 || $str == 10 || $str == 11 || $str == 12) { $num = 8; }
if ($str == 13 || $str == 14 || $str == 15 || $str == 16) { $num = 9; }
if ($str == 17 || $str == 18 || $str == 19 || $str == 20) { $num = 10; }
if ($str == 21 || $str == 22 || $str == 23 || $str == 24) { $num = 2; }
if ($str == 25 || $str == 26 || $str == 27 || $str == 28) { $num = 3; }
if ($str == 29 || $str == 30 || $str == 31 || $str == 32) { $num = 4; }
if ($str == 33 || $str == 34 || $str == 35 || $str == 36) { $num = 11; }
return $num;
}
if ($posts < 100) {
if ($ver == "wml") {
echo $xml;
echo $dtd;
echo "<wml>n
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>n
<card id="index" title="Стоп!" ontimer="../enter.php?$ses"><timer value="15"/>n
<p align="center">n";
} else {
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="stylesheet" type="text/css" href="../css/$css.css"/>
<title>Стоп!</title>
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=../enter.php?$ses">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>
<div align="center">";
}
echo $fsize1;
echo 'У тебя недостаточно кредитов для игры!<br/>
Необходимо не менее 100 кредитов<br/>';
echo $fsize2;
echo $divide;
echo "<a href="../enter.php?$ses&ref=$ref">Прихожая</a><br/>n";
include_once '../foot.php';
mysql_close($link);
exit;
} else {
if ($session['round'] == 0) {
$max = $session['money'];
if ($max == 0) {
session_unregister("session");
if ($ver == "wml") {
echo $xml;
echo $dtd;
echo "<wml>n
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>n
<card id="index" title="21">n
<p align="center">n";
} else {
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="stylesheet" type="text/css" href="../css/$css.css"/>
<title>21</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>
<div align="center">";
}
echo $fsize1;
echo 'У тебя не достаточно кредитов для продолжения текущей игры!<br/>';
echo "<a href="out.php?$ses">Выйти</a><br/>";
echo $fsize2;
include_once '../foot.php';
mysql_close($link);
exit;
}
if ($ver == "wml") {
echo $xml;
echo $dtd;
echo "<wml>n
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>n
<card id="index" title="21">n
<p align="center">n";
} else {
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="stylesheet" type="text/css" href="../css/$css.css"/>
<title>21</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>
<div align="center">";
}
echo $fsize1;
echo 'У тебя ' . $max . ' кредитов<br/>';
echo $fsize2;
$ru = rand(1,36);
if ($session['histuser'] !== '') $ru = trim(str_replace("|","", $session['histuser']));
echo $fsize1;
echo '<b>Твои карты:</b><br/>';
echo $fsize2;
echo "<img src="cards/$ru.gif" alt="cards"/><br/>n";
$uscore = cards_score($ru); $pstr = "очков";
if ($uscore == 2 || $uscore == 3 || $uscore == 4) $pstr = "очка";
echo $fsize1;
echo "$uscore $pstr<br/>n";
$maxlen = strlen($max);
echo "Твоя ставка(1-$max):<br/>n";
echo $fsize2;
if ($ver == "wml") {
echo "<input name="mn$ref" maxlength="$maxlen" title="pass" format="*N"/><br/>n";
echo $fsize1;
echo "<anchor title="go">Играть<go href="21.php?$ses" method="post">n
<postfield name="mn" value="$(mn$ref)"/>n
</go></anchor>n";
echo $fsize2;
echo '<br/>';
} else {
echo "<form method="POST" action="21.php?$ses" name="auth">n
<input name="mn" maxlength="$maxlen" title="pass"/><br/>n
<input type="submit" class="ibutton" value="Играть" name="enter"><br/>n";
}
echo $fsize1;
echo $divide;
echo "<div class = 'd1'><a href="faq.php?$ses">Правила игры</a><br/>n
<a href="out.php?$ses">Выход</a></div>n";
echo $fsize2;
include_once '../foot.php';
$session['histuser'] = "|$ru";
$session['round'] = 1;
} else {
if ($session['con'] == 0) {
if ($mn > $session['money'] || $mn === "" || !isset($mn) || $mn < 1) {
if ($ver == "wml") {
echo $xml;
echo $dtd;
echo "<wml>n
<card id="error" title="Ошибка!" ontimer="21.php?$ses"><timer value="15"/>n
<p align="center">n";
} else {
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="stylesheet" type="text/css" href="../css/$css.css"/>
<title>Ошибка!</title>
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=21.php?$ses">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>
<div align="center">";
}
echo $fsize1;
$mn = abs(intval($mn));
if ($mn === "" || $mn < 1) echo 'Не указана ставка!';
else echo 'У тебя недостаточно кредитов для подобной ставки!';
echo $fsize2;
include_once '../foot.php';
$session['round'] = 0;
mysql_close($link);
exit;
}
$session['con'] = round($mn);
$session['money'] = $session['money']-$session['con'];
}
$rate = $session['con']*2;
$stavka = $session['con'];
$histuser = split("|",$session['histuser']);
if (!isset($end)) {
do
{
$randgen=1; $ru = rand(1,36); for($i=1;$i < count($histuser);$i++) {
if ($ru == $histuser[$i]) { $randgen=0; break; } } }
while($randgen == 0);
$session['histuser']=$session['histuser']."|$ru";
$countus = count($histuser);
$histuser[$countus] = $ru;
}
for($i=1;$i < count($histuser);$i++) {
$ustemp = cards_score($histuser[$i]); @$uscore=@$uscore+$ustemp;
}
$udoublet=0;
if ((count($histuser) == 3) && ($uscore == 22)) {
$tone = 0;
$ttwo = 0;
if ($histuser[1] == 33 || $histuser[1] == 34 || $histuser[1] == 35 || $histuser[1] == 36) $tone=1;
if ($histuser[2] == 33 || $histuser[2] == 34 || $histuser[2] == 35 || $histuser[2] == 36) $ttwo=1;
if ($tone == 1 && $ttwo == 1) $udoublet = 1;
}
if ($uscore > 21 && $udoublet == 0) $close = 1;
if ($udoublet == 1 || $uscore == 21 || $uscore == 20) $end=1;
if ($ver == "wml") {
echo $xml;
echo $dtd;
echo "<wml>n
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>n
<card id="index" title="21">n
<p align="center">";
} else {
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="stylesheet" type="text/css" href="../css/$css.css"/>
<title>21</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body>
<div align="center">";
}
echo $fsize1;
$max = $session['money'];
echo 'У тебя ' . $max . ' кредитов<br/>';
if (isset($close))
echo '<b>Перебор!</b><br/>';
$win = 0;
if (isset($end)) {
$histbot[0] = "";
$hist = $histuser;
for($i=1; $i < 10; $i++) {
do
{
$randgen=1; $rb = rand(1,36);
for($i=1; $i < count($hist); $i++) {
if ($rb == $hist[$i]) {
$randgen = 0;
break;
}
}
}
while($randgen == 0);
$histbot[] = $rb;
$hist[] = $rb;
$btemp = cards_score($rb);
@$bcore = @$bcore+$btemp;
if ($bcore == 20)
break;
if ($bcore == 21
)break;
if ($bcore == $uscore)
break;
if ($bcore > $uscore)
break;
if ($bcore > 21)
break;
}
echo '<b>Банкир открылся:</b><br/>';
for($i=1; $i < count($histbot); $i++) {
echo "<img src="cards/$histbot[$i].gif" alt="cards"/>";
}
$pstr = "очков";
if ($bcore == 2 || $uscore == 3 || $bcore == 4 || $bcore == 22 || $bcore == 23 || $bcore == 24) $pstr = "очка";
if ($bcore == 21) $pstr = "<b>очко!!!</b>";
echo "<br/>$bcore $pstr<br/>n";
$bdoublet=0;
if ((count($histbot) == 3) && ($bcore == 22)) {
$tone = 0;
$ttwo = 0;
if ($histbot[1] == 33 || $histbot[1] == 34 || $histbot[1] == 35 || $histbot[1] == 36) $tone=1;
if ($histbot[2] == 33 || $histbot[2] == 34 || $histbot[2] == 35 || $histbot[2] == 36) $ttwo=1;
if ($tone == 1 && $ttwo == 1) $bdoublet = 1;
}
if ($bcore > 21 && $bdoublet == 0) $win=1;
if ($bcore < $uscore) $win=1;
if ($udoublet == 1) $win=1;
if ($bdoublet == 1) $win=0;
if ($uscore == 21) $win=1;
if ($bcore == 21) $win=0;
$close=1;
}
echo '<b>Твои карты:</b><br/>';
for($i=1; $i < count($histuser); $i++) {
echo "<img src="cards/$histuser[$i].gif" alt="cards"/>";
}
$pstr = "очков";
if ($uscore == 2 || $uscore == 3 || $uscore == 4 || $uscore == 22 || $uscore == 23 || $uscore == 24) $pstr = "очка";
if ($uscore == 21) $pstr = "<b>очко!!!</b>";
echo "<br/>$uscore $pstr<br/>n";
if(isset($close)){
$session['round'] = 0;
$session['histuser'] = "";
if ($win == 0) {
echo '<b>Проигрыш :(</b><br/>';
$f=fopen("lost.dat","a+");
flock($f,LOCK_EX);
$data=file("lost.dat");
@$data[0]=trim($data[0])+1;
$stavka=$session['con'];
@$data[1]=trim($data[1])+$session['con'];
ftruncate($f,0);
fwrite($f,"$data[0]n");
fwrite($f,"$data[1]n");
flock($f,LOCK_UN);
fclose($f);
$stavka = abs(intval($stavka));
mysql_query ("Update users set gposts=gposts-'".$stavka."' where id ='".$id."';");
$guposts = $row["gposts"];
$session['con'] = 0;
echo 'Твой проигрыш составил: <b>' . $stavka . '</b> кредитов!<br/>
Игровой баланс до игры был: <b>' . $guposts . '</b> кредитов<br/>';
} else {
echo '<b>Удача =)</b><br/>';
$session['money'] = $session['money']+$rate;
$f=fopen("win.dat","a+");
flock($f,LOCK_EX);
$data=file("win.dat");
@$data[0]=trim($data[0])+1;
@$data[1]=trim($data[1])+$session['con'];
ftruncate($f,0);
fwrite($f,"$data[0]n");
fwrite($f,"$data[1]n");
flock($f,LOCK_UN);
fclose($f);
$rate = abs(intval($rate));
mysql_query ("Update users set gposts=gposts+'".$rate."' where id ='".$id."';");
$guposts = $row["gposts"];
$session['con']=0;
echo 'Твой выигрыш составил: <b>' . $rate . '</b> кредитов<br/>
Игровой баланс до игры был: <b>' . $guposts . '</b> кредитов<br/>';
}
echo "<a href="21.php?$ses">Сыграть ещё</a><br/>n";
} else {
echo 'На кону ' . $rate . ' кредитов<br/>';
echo "<a href="21.php?$ses">Ещё</a>n";
echo "<или>n";
echo "<a href="21.php?$ses&end">Открыть</a><br/>n";
}
echo $divide;
echo "<div class = 'd1'><a href="out.php?$ses">Выход</a></div>n";
echo $fsize2;
include_once "../foot.php";
mysql_close($link);
}
}
?>