
Member
 
Group: Members
Posts: 16
Member No.: 2,679
Joined: 29-January 05

|
| QUOTE (LucianBoy @ May 2 2005, 02:17 PM) | Ho has the all code ??? can someone post the all code for the MOD CASINO ??? plz |
In this code I fix something for my Tracker.
My Table
| CODE | -- -- โครงสร้างตาราง `casino` --
CREATE TABLE `casino` ( `userid` int(10) NOT NULL default '0', `win` bigint(20) default NULL, `lost` bigint(20) default NULL, `trys` int(11) NOT NULL default '0', `date` datetime NOT NULL default '0000-00-00 00:00:00', `enableplay` enum('yes','no') NOT NULL default 'yes', PRIMARY KEY (`userid`) ) TYPE=MyISAM;
|
casino.php
| CODE | <?php //ob_start("ob_gzhandler"); require_once("include/bittorrent.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"]," Do not allow your class to play casino");
$query ="select * from casino where userid = '".$CURUSER["id"]."'"; $result = mysql_query($query) or die (mysql_error()); if(mysql_affected_rows()!=1) {
mysql_query("INSERT INTO casino (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 casino") 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; $winner_was = $_POST["number"]; } else $winner_was = $_POST["color"];
$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)."
because <font
color=\"".$winner_was."\"><b>".$winner_was."</b></font>
is the winner. <p><a href=casino.php><b>เล่นต่อ
ติดลม!!!</b></a></p>"); mysql_query("UPDATE users SET uploaded = uploaded + ".$win." WHERE id=".$CURUSER["id"]) or sqlerr();
mysql_query("UPDATE casino SET date = '".get_date_time()."', trys =
trys + 1, win = win + ".$win." WHERE userid=".$CURUSER["id"]) or
sqlerr(); } else { if($_POST["number"]) { do { $fake_winner = rand(1,6); } while($_POST["number"]==$fake_winner); } else { if($_POST["color"]=="black") $fake_winner= "red"; else $fake_winner= "black"; }
stdmsg("Sorry ".$CURUSER["username"],"You lost ".mksize($betmb)."
because <font
color=\"".$fake_winner."\"><b>".$fake_winner."</b></font>
and not <font
color=\"".$winner_was."\"><b>".$winner_was."</b></font>
was the winner. <p><a href=casino.php><b>เล่นต่อ
ติดลม!!!</b></a></p>"); mysql_query("UPDATE users SET uploaded = uploaded - ".$betmb." WHERE id=".$CURUSER["id"]) or sqlerr();
mysql_query("UPDATE casino 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=10 width=500>\n"); print("<tr><td colspan=2 cellspacing=0 cellpadding=5>"); echo("<h1>Game 1:</h1>");
print("<form name=casino 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("<font color=red>Red</font>",'<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 <input name="number" type="radio"
value="2">2 <input name="number" type="radio"
value="3">3<br><input name="number" type="radio"
value="4">4 <input name="number" type="radio"
value="5">5 <input name="number" type="radio"
value="6">6',1); //tr("",'<input name="number"
type="radio" value="4">4 <input name="number"
type="radio" value="5">5 <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=10>\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>');
echo('<p><center><a
href="casino_player.php"><b>แสดงรายชื่อผู้เล่นทั้งหมด
และอัตราได้เสีย</b></a></center></p>');
} stdfoot(); ?>
|
casino_player.php
| CODE | <?
require "include/bittorrent.php"; dbconn(false); loggedinorreturn(); ob_start("ob_gzhandler");
if (get_user_class() >= UC_ADMINISTRATOR) $edit = 1;
$res2 = mysql_query("select count(*) from casino") or die(mysql_error()); $row2 = mysql_fetch_array($res2); $count = $row2[0];
$perpage = 50;
list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $_SERVER["PHP_SELF"] ."?" );
$res
= mysql_query("select users.id as userid,users.username,
users.downloaded,users.uploaded,casino.win,casino.lost from casino
inner join users on casino.userid = users.id ORDER BY (casino.win
- casino.lost) DESC $limit") or sqlerr();
stdhead("Players");
if (mysql_num_rows($res) == 0) print("<p align=center><b>No players</b></p>\n"); else { print("<p align=center><b><h1>Results</h1></b></p>\n"); print("<p align=center><a href=casino.php>Back to casino</a></p>\n"); echo $pagertop; print("<table border=1 cellspacing=0 cellpadding=5>\n");
if($edit==0) print("<tr><td
class=colhead>Username</td><td class=colhead
align=left>Uploaded</td><td class=colhead
align=left>Downloaded</td><td class=colhead
align=left>Ratio</td><td class=colhead
align=left>Won</td><td class=colhead
align=left>Lost</td><td class=colhead
align=left>Tries</td><td class=colhead
align=left>Total</td>\n"); else print("<tr><td
class=colhead>Username</td><td class=colhead
align=left>Uploaded</td><td class=colhead
align=left>Downloaded</td><td class=colhead
align=left>Ratio</td><td class=colhead
align=left>Won</td><td class=colhead
align=left>Lost</td><td class=colhead
align=left>Tries</td><td class=colhead
align=left>Total</td><td class=colhead align=left>edit
user</td>\n");
while ($arr = mysql_fetch_assoc($res)) { $rez = mysql_query("select * from casino where userid=$arr[userid]"); $arz = mysql_fetch_array($rez); if ($arr["downloaded"] > 0) { $ratio = number_format($arr["uploaded"] / $arr["downloaded"], 3); $ratio = "<font color=" . get_ratio_color($ratio) . ">$ratio</font>"; } else if ($arr["uploaded"] > 0) $ratio = "Inf."; else $ratio = "---"; $uploaded =mksize($arr["uploaded"]); $downloaded = mksize($arr["downloaded"]); if ($CURUSER[id] == $arr[userid]) $bg = "bgcolor=#c0c0c0"; else $bg = "";
$all = $arz[win]-$arz[lost]; if($all < 0) { $all = $all * -1; $minus = "-"; }
if($edit==0) print("<tr><td
$bg><a
href=userdetails.php?id=$arr[userid]><b>$arr[username]</b></a></td><td
align=left $bg>$uploaded</td><td align=left
$bg>$downloaded</td><td align=left
$bg>$ratio</td><td align=left
$bg>".mksize($arz[win])."</td><td align=left
$bg>".mksize($arz[lost])."</td><td align=left
$bg>$arz[trys]</td><td align=left $bg>
$minus".mksize($all)."</td></tr>\n"); else print("<tr><td
$bg><a
href=userdetails.php?id=$arr[userid]><b>$arr[username]</b></a></td><td
align=left $bg>$uploaded</td><td align=left
$bg>$downloaded</td><td align=left
$bg>$ratio</td><td align=left
$bg>".mksize($arz[win])."</td><td align=left
$bg>".mksize($arz[lost])."</td><td align=left
$bg>$arz[trys]</td><td align=left $bg>
$minus".mksize($all)."</td><td align=left $bg><form
name=edit-player method=post action=casino_player_edit.php><input
type=hidden name=userid value=$arr[userid]> <input class=btn
type=submit value=edit ></form></td></tr>\n");
} print("</table>\n"); }
stdfoot();
?>
|
casino_player_edit.php
| CODE | <?
require "include/bittorrent.php"; dbconn(false); loggedinorreturn(); ob_start("ob_gzhandler");
if (get_user_class() <= UC_ADMINISTRATOR) stderr("Sorry ".$CURUSER["username"]," Do not allow your class to edit the casino play");
$result = mysql_query("select * from casino where userid = '".$userid."'") or die(mysql_error()); if (mysql_num_rows($result) == 0) stderr("Sorry","No players with the userid $userid</b></p>\n"); else { $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"]; stdhead();
if($_POST["userid"]!=NULL&&$_POST["won"]!=NULL&&$_POST["lost"]!=NULL&&$_POST["trys"]!=NULL&&$_POST["date"]!=NULL&&$_POST["enableplay"]!=NULL) { $dif_win = $won - $user_win; ///// this is tricky $dif_lost = $lost - $user_lost; ///// this is tricky $up = $dif_win - $dif_lost; ///// this is tricky mysql_query("UPDATE users SET uploaded = uploaded + ".$up." WHERE id=".$userid) or sqlerr();
mysql_query("UPDATE casino SET date = '".$date."', trys = ".$trys."
,lost = ".$lost.",win = ".$won.",enableplay= '".$enableplay."' WHERE
userid=".$userid) or sqlerr();
stdmsg("Stats for user ".$userid." are now updated" ,"sorry but no problems occured :-)");
} else { 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($user_enableplay=="yes") { $select="<option value=yes checked >yes</option>"; $select.="<option value=no>no</option>"; } else { $select="<option value=yes >yes</option>"; $select.="<option value=no checked>no</option>"; }
print("<h1>Welcome, you are now able to edit user nr. <a
href=userdetails.php?id=$userid>$userid</a>!</h1>\n"); print("<p align=center><a href=casino.php>Back</a></p>\n"); print("<form name=edit-player method=post action=$phpself><input type=hidden name=userid value=$userid>"); print("<table cellspacing=0 cellpadding=3 width=400>\n"); tr("user ratio:",$casino_ratio_user,1); tr("user won:","<input type=text name=won value='$user_win' > ".mksize($user_win),1); tr("user lost:","<input type=text name=lost value='$user_lost' > ".mksize($user_lost),1); tr("user play ","<input type=text name=trys value='$user_trys' > <b>games</b>",1); tr("last access:","<input type=text name=date value='$user_date' >",1); tr("allow user to play:",'<select name="enableplay">'.$select.'</select> ',1); print("<tr><td colspan=2 align=center><input type=submit value='change user stats'></td></tr>"); print("</table>\n"); print("</form>"); } } stdfoot(); ?>
|
My Tracker is ForStudent Bittorrent Tracker This post has been edited by tape on May 4 2005, 05:31 AM
--------------------
|