Location: PHPKode > projects > Trunk.net > casino2.php
<?php
//ob_start("ob_gzhandler");
require_once("include/functions.php");
dbconn(false);
loggedinorreturn();
parked();

//////////////////////////////////config
//////who is able to play just
//$player = UC_PEASANT;
//$player = UC_USER;
$player = UC_POWER_USER;
//$player = UC_VIP;
//$player = UC_UPLOADER;
//$player = UC_MODERATOR;
//$player = UC_ADMINISTRATOR;
//$player = UC_SYSOP;
$mb_basic=1024*1024;
$max_download_user = $mb_basic*1024*25; //// 25 GB
$max_download_global = $mb_basic*$mb_basic*2.5; //// 2.5 TB :-)
$required_ratio = 0.4; ///i think you know this
$max_trys = 50; ///50 games and no more

//////////////////this is the funny part
$user_everytimewin_mb = $mb_basic * 70; ////// means users that wins under 70 mb get a cheat_value of 0 -> win every time
$cheat_value = 1; // higher value -> less winner
$cheat_breakpoint = 2; ////very important value -> if (win MB > max_download_global/cheat_breakpoint)
$cheat_value_max = 5; ////// then cheat_value = cheat_value_max -->> i hope you know what i mean. ps: must be higher as cheat_value.
$cheat_ratio_user = 0.4; ///if casino_ratio_user > cheat_ratio_user -> $cheat_value = rand($cheat_value,$cheat_value_max)
$cheat_ratio_global = 0.4; /// same as user just global
$win_amount = 3; // how much do the player win in the first game eg. bet 300, win_amount=3 ---->>> 300*3= 900 win
$win_amount_on_number = 6; // same as win_amount for the number game
$show_real_chance = false; ///shows the user the real chance true or false
$bet_value1 = $mb_basic * 20; ///this is in MB but you can also choose gb or tb :-)
$bet_value2 = $mb_basic * 50;
$bet_value3 = $mb_basic * 100;
$bet_value4 = $mb_basic * 250;
$bet_value5 = $mb_basic * 500;
$bet_value6 = $mb_basic * 1024;
$bet_value7 = $mb_basic * 2048;

//////////////////////////////////config end

if (get_user_class >= $player)
 stderr("Sorry ".$CURUSER["username"], "The MODERATOR do not allow your class to play casino");

$query ="select * from casino2 where userid = '".$CURUSER["id"]."'";
$result = mysql_query($query) or die (mysql_error());
if(mysql_affected_rows()!=1)
{
 mysql_query("INSERT INTO casino2 (userid, win, lost, trys, date) VALUES(" . $CURUSER["id"] . ",0,0,0, '" . get_date_time() . "')") or mysql_error();
 //stderr("Hi ".$CURUSER["username"], "This is the first time you try to play at the Casino please refresh the site");
 $result = mysql_query($query); ///query another time to get the new user, if the stderr is uncomment
}

$row = mysql_fetch_array($result);
 $user_win = $row["win"];
 $user_lost = $row["lost"];
 $user_trys = $row["trys"];
 $user_date = $row["date"];
 $user_enableplay = $row["enableplay"];

if($user_enableplay=="no")
 stderr("Sorry ".$CURUSER["username"],"your banned from casino");

if($user_trys > $max_trys)
 stderr("Sorry ".$CURUSER["username"],"your playtime is over");
 
if(($user_win - $user_lost) > $max_download_user)
 stderr("Sorry ".$CURUSER["username"],"you have reached the max download for a single user");

 if ($CURUSER["downloaded"] > 0)
   $ratio = number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2);
 else
   if ($CURUSER["uploaded"] > 0)
     $ratio = 999;
   else
     $ratio = 0;
 if($ratio < $required_ratio)
  stderr("Sorry ".$CURUSER["username"],"your ratio is under ".$required_ratio);  

 $global_down2 = mysql_query(" select (sum(win)-sum(lost)) as globaldown, sum(win) as win, sum(lost) as lost from casino2") or die (mysql_error());
 $row = mysql_fetch_array($global_down2);
 $global_down = $row["globaldown"];
 $global_win = $row["win"];
 $global_lost = $row["lost"];
 
 if ($user_win > 0)
   $casino_ratio_user = number_format($user_lost / $user_win, 2);
 else
   if ($user_lost > 0)
     $casino_ratio_user = 999;
   else
     $casino_ratio_user = 0;
     
 if ($global_win > 0)
   $casino_ratio_global = number_format($global_lost / $global_win, 2);
 else
   if ($global_lost > 0)
     $casino_ratio_global = 999;
   else
     $casino_ratio_global = 0;
 
 //get users that bet the first time or win very less :-)
 if($user_win < $user_everytimewin_mb)
  $cheat_value = 0;
 else
 {
  //i think this is a god idea GLOBAL
  if($global_down > ($max_download_global / $cheat_breakpoint))
   $cheat_value = $cheat_value_max;
  if($casino_ratio_global < $cheat_ratio_global)
   $cheat_value = rand($cheat_value,$cheat_value_max);
 
  //i think this is a god idea for EACH USER
  if(($user_win - $user_lost) > ($max_download_user / $cheat_breakpoint))
   $cheat_value = $cheat_value_max;
  if($casino_ratio_user < $cheat_ratio_user)
   $cheat_value = rand($cheat_value,$cheat_value_max);
 }
 
if($global_down > $max_download_global)
 stderr("Sorry ".$CURUSER["username"],"but global max win is above ".mksize($max_download_global));


////////////////////////////////////////////////////////////////////////////////////////////////

if((($_POST["color"]=="red"||$_POST["color"]=="black")||($_POST["number"]=="1"||$_POST["number"]=="2"||$_POST["number"]=="3"||$_POST["number"]=="4"||
$_POST["number"]=="5"||$_POST["number"]=="6"))&&($_POST["betmb"]==$bet_value1||$_POST["betmb"]==$bet_value2||$_POST["betmb"]==$bet_value3||$_POST["betmb"]==$bet_value4||
$_POST["betmb"]==$bet_value5||$_POST["betmb"]==$bet_value6||$_POST["betmb"]==$bet_value7))  
{
if($_POST["number"])
{
 $win_amount = $win_amount_on_number;
 $cheat_value = $cheat_value+5;
}

$win = $win_amount*$betmb;

if($CURUSER["uploaded"] < $betmb)
 stderr("Sorry ".$CURUSER["username"],"but you have not uploaded ".mksize($betmb));

stdhead();
 
if(rand(0,$cheat_value)==$cheat_value)
{
 stdmsg("Yes ".$CURUSER["username"],"you got it and win ".mksize($win));
 mysql_query("UPDATE users SET uploaded = uploaded + ".$win." WHERE id=".$CURUSER["id"]) or sqlerr();
 mysql_query("UPDATE casino2 SET date = '".get_date_time()."', trys = trys + 1, win = win + ".$win." WHERE userid=".$CURUSER["id"]) or sqlerr();
}
else
{
 stdmsg("Sorry ".$CURUSER["username"],"you lost ".mksize($betmb));
 mysql_query("UPDATE users SET uploaded = uploaded - ".$betmb." WHERE id=".$CURUSER["id"]) or sqlerr();
 mysql_query("UPDATE casino2 SET date = '".get_date_time()."', trys = trys + 1 ,lost = lost + ".$betmb." WHERE userid=".$CURUSER["id"]) or sqlerr();
}
 
}
else
{

stdhead();
print("<h1>Welcome, <a href=userdetails.php?id=$CURUSER[id]>$CURUSER[username]</a>!</h1>\n");

print("<table  cellspacing=0 cellpadding=3 width=400>\n");
print("<tr><td colspan=2 cellspacing=0 cellpadding=5>");
echo("<h1>game 1:</h1>");

print("<form name=casino2 method=post action=$phpself>");
 print("<table class=message width=100% cellspacing=0 cellpadding=5>\n");
  tr("bet on color:","<input type=submit value='Do it!' >",1);
  tr("black",'<input name="color" type="radio" checked value="black">',1);
  tr("red",'<input name="color" type="radio" value="red">',1);
  tr("how much",'
  <select name="betmb">
  <option value="'.$bet_value1.'">'.mksize($bet_value1).'</option>
<option value="'.$bet_value2.'">'.mksize($bet_value2).'</option>
<option value="'.$bet_value3.'">'.mksize($bet_value3).'</option>
<option value="'.$bet_value4.'">'.mksize($bet_value4).'</option>
<option value="'.$bet_value5.'">'.mksize($bet_value5).'</option>
<option value="'.$bet_value6.'">'.mksize($bet_value6).'</option>
<option value="'.$bet_value7.'">'.mksize($bet_value7).'</option>
  </select>',1);
 
 if($show_real_chance)
  $real_chance=$cheat_value+1;
 else
  $real_chance=2;
 tr("your chance","1 : ".$real_chance,1);
 tr("you can win",$win_amount." * stake",1);
 echo('</table><br>');
 print("</form>");

 echo("<h1>game 2:</h1>");
 print("<form name=casino2 method=post action=$phpself>");
 print("<table class=message width=100% cellspacing=0 cellpadding=5>\n");
  tr("bet on number:","<input type=submit value='Do it!' >",1);
  tr("number",'<input name="number" type="radio" checked value="1">1&nbsp;&nbsp;<input name="number" type="radio" value="2">2&nbsp;&nbsp;<input name="number" type="radio" value="3">3',1);
  tr("",'<input name="number" type="radio" value="4">4&nbsp;&nbsp;<input name="number" type="radio" value="5">5&nbsp;&nbsp;<input name="number" type="radio" value="6">6',1);
  tr("how much",'
  <select name="betmb">
  <option value="'.$bet_value1.'">'.mksize($bet_value1).'</option>
<option value="'.$bet_value2.'">'.mksize($bet_value2).'</option>
<option value="'.$bet_value3.'">'.mksize($bet_value3).'</option>
<option value="'.$bet_value4.'">'.mksize($bet_value4).'</option>
<option value="'.$bet_value5.'">'.mksize($bet_value5).'</option>
<option value="'.$bet_value6.'">'.mksize($bet_value6).'</option>
<option value="'.$bet_value7.'">'.mksize($bet_value7).'</option>
  </select>',1);
 
 if($show_real_chance)
  $real_chance=$cheat_value+5;
 else
  $real_chance=6;
 tr("your chance","1 : ".$real_chance,1);
 tr("you can win",$win_amount_on_number." * stake",1);
 echo('</table><br>');
 print("</form>");
print("</td></tr></table><br>");

print("<table  cellspacing=0 cellpadding=3>\n");
print("<tr><td>");
 print("<h1>user stats</h1>\n");
 print("<table class=message  cellspacing=0 cellpadding=5>\n");
  tr("you can win",mksize($max_download_user),1);
  tr("won",mksize($user_win),1);
  tr("lost",mksize($user_lost),1);
  tr("ratio",$casino_ratio_user,1);
 echo('</table>');
print("</td><td>");
 print("<h1>global stats</h1>\n");
 print("<table class=message  cellspacing=0 cellpadding=5>\n");
  tr("users can win",mksize($max_download_global),1);
  tr("won",mksize($global_win),1);
  tr("lost",mksize($global_lost),1);
  tr("ratio",$casino_ratio_global,1);
 echo('</table>');
print("</td></tr>");
echo('</table>');



}
stdfoot();
?>
Return current item: Trunk.net