View file 21/index.php

File size: 8.69Kb
<?php

ini_set('session.use_cookies','0');

ini_set('session.use_trans_sid','0');

ini_set('url_rewriter.tags','');

session_name("stw");

session_start();



header("Cache-Control: no-cache");

header("Content-type:text/vnd.wap.wml");   

if(!session_is_registered("session")){

$session['round']=0;

$session['money']=100;

$session['con']=0;

$session['histuser']="";

session_register("session");

}

$ref=rand(100,99999);

$ses=SID;

$ses="$ses&amp;$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($session['round']==0){

$max = $session['money'];

if($max==0){

session_unregister("session");

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";

echo "<wml>\n";

echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";

echo "<card id=\"index\" title=\"21\">\n";

echo "<p align=\"center\"><small>\n";

echo "У Вас на счету не осталось средств для продолжения текущей игры!<br/>\n";

echo "<a href=\"index.php\">начать новую игру</a><br/>\n";

echo "или<br/><a href=\"out.php?$ses\">выйти</a><br/></small>\n";



echo "</p>\n";

echo "</card>\n";

echo "</wml>\n";

exit;

}

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";

echo "<wml>\n";

echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";

echo "<card id=\"index\" title=\"21\">\n";

echo "<p><small>\n";

echo "У Вас $max\$\$<br/>\n";

$ru = rand(1,36);

if($session['histuser']!=="")$ru=trim(str_replace("|","", $session['histuser']));  

echo "<b>Ваши карты:</b><br/><img src=\"cards/$ru.gif\" alt=\"cards\"/><br/>\n";

$uscore=cards_score($ru);

$pstr = "очков";

if($uscore==2||$uscore==3||$uscore==4)$pstr = "очка";

echo "$uscore $pstr<br/>\n";

$maxlen=strlen($max);

echo "Ваша ставка(1-$max):</small><br/>\n";

echo "<input name=\"mn$ref\" maxlength=\"$maxlen\" title=\"pass\" format=\"*N\"/><br/>\n";

echo "<small><anchor title=\"go\">играть<go href=\"index.php?$ses\" method=\"post\">\n";

echo "<postfield name=\"mn\" value=\"$(mn$ref)\"/>\n";

echo "</go></anchor><br/>\n"; 

echo "*******<br/>\n";

echo "<a href=\"faq.php?$ses\">правила игры</a><br/>\n";

echo "<a href=\"out.php?$ses\">выход</a><br/></small>\n";

echo "</p>\n";

echo "</card>\n";

echo "</wml>\n";

$session['histuser']="|$ru";

$session['round']=1;

} else {

if($session['con']==0){

if($mn>$session['money']||$mn===""||!isset($mn)||$mn<1){

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";

echo "<wml>\n";

echo "<card id=\"error\" title=\"error\" ontimer=\"index.php?$ses\"><timer value=\"15\"/>\n";

echo "<p align=\"center\">\n";

if($mn===""||$mn<1)echo "Вы не указали ставку!\n";

else echo "На Вашем счету недостаточно средств для подобной ставки!\n";

echo "</p>\n";

echo "</card>\n";

echo "</wml>\n";

$session['round']=0;

exit;

}   



$session['con']=round($mn);

$session['money']=$session['money']-$session['con'];

}

$rate=$session['con']*2;

$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;



echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";

echo "<wml>\n";

echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";

echo "<card id=\"index\" title=\"21\">\n";

echo "<p><small>\n";

$max = $session['money'];

echo "У Вас $max\$\$<br/>\n";

if(isset($close))echo "<b>перебор!</b><br/>\n";

$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/>\n";

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/>\n";

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/>\n";

$f=fopen("lost.dat","a+");

flock($f,LOCK_EX);

$data=file("lost.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);

$session['con']=0;

} else {

echo "<b>Вы выиграли!</b><br/>\n";

$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);

$session['con']=0;

echo "Ваш выигрыш $rate\$\$<br/>\n";

}

echo "<a href=\"index.php?$ses\">сыграть ещё</a><br/>\n";

} else {

echo "на кону $rate\$\$<br/><a href=\"index.php?$ses\">ещё</a>&lt;или&gt;<a href=\"index.php?$ses&amp;end\">открыть</a><br/>\n";

}

echo "*******<br/>\n";

echo "<a href=\"out.php?$ses\">выход</a><br/></small>\n";

echo "</p>\n";

echo "</card>\n";

echo "</wml>\n";



}

?>