File size: 8.36Kb
<?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&$ref";
$sid = $_GET["sid"];
$mn = $_GET["mn"];
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=\"21Cards\">\n";
echo "<p align=\"center\">\n";
echo "(!) on your account does not remain money to continue.<br/>\n";
echo "<a href=\"/index.php?action=main&sid=$sid\">HOME</a><br/>";
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";
$sid = $_GET["sid"];
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"index\" title=\"PLAY 21\">\n";
echo "<p align=\"center\">\n";
echo "Your credit $max\$\$<br/>\n";
$ru = rand(1,36);
if($session['histuser']!=="")$ru=trim(str_replace("|","", $session['histuser']));
echo "Your card <img src=\"cards/$ru.gif\" alt=\"$ru\"/><br/>\n";
$uscore=cards_score($ru);
$pstr = "glasses";
if($uscore==2||$uscore==3||$uscore==4)$pstr = "spots";
echo "Means $uscore $pstr<br/>\n";
$maxlen=strlen($max);
echo "Bet from 1 to $max<br/>\n";
echo "<input name=\"mn$ref\" maxlength=\"$maxlen\" title=\"pass\" format=\"*N\"/><br/>\n";
echo "<anchor title=\"go\">continue<go href=\"index.php?$ses\" method=\"post\">\n";
echo "<postfield name=\"mn\" value=\"$(mn$ref)\"/>\n";
echo "</go></anchor>(<a href=\"faq.php?$ses\">?</a>)\n";
echo "<br/>";
echo "<a href=\"/index.php?action=main&sid=$sid\">HOME</a><br/>";
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";
$sid = $_GET["sid"];
echo "<card id=\"error\" title=\"ERROR\" ontimer=\"index.php?$ses\"><timer value=\"15\"/>\n";
echo "<p align=\"center\">\n";
if($mn===""||$mn<1)echo "(!) you have not specified a bet.\n";
else echo "(!) on your account has not enough money to bet.\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";
$sid = $_GET["sid"];
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"index\" title=\" PLAY 21\">\n";
echo "<p align=\"center\">\n";
$max = $session['money'];
echo "Your credit $max\$\$<br/>\n";
if(isset($close))echo "\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 "Banker cards<br/>\n";
for($i=1;$i < count($histbot);$i++){
echo "<img src=\"cards/$histbot[$i].gif\" alt=\"histbot[$i]\"/>";
}
$pstr = "glasses";
if($bcore==2||$uscore==3||$bcore==4||$bcore==22||$bcore==23||$bcore==24)$pstr = "spots";
if($bcore==21)$pstr = "spots";
echo "<br/>Means $bcore $pstr<br/><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 "Your cards<br/>\n";
for($i=1;$i < count($histuser);$i++){
echo "<img src=\"cards/$histuser[$i].gif\" alt=\"$histuser[$i]\"/>";
}
$pstr = "glasses";
if($uscore==2||$uscore==3||$uscore==4||$uscore==22||$uscore==23||$uscore==24)$pstr = "spots";
if($uscore==21)$pstr = "spots";
echo "<br/>Means $uscore $pstr<br/>\n";
if(isset($close)){
$session['round']=0;
$session['histuser']="";
if($win==0){
echo "(!) sorry but you lost.<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 "(!) you win \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\">continue?</a>\n";
} else {
echo "Banker bet $rate\$\$<br/><a href=\"index.php?$ses\">handle</a> or <a href=\"index.php?$ses&end\">open</a>\n";
}
echo "<br/>\n";
echo "<a href=\"/index.php?action=main&sid=$sid\">HOME</a><br/>";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
}
?>