<?php
include "globals.php";
if ($ir['location'] != 17){
die ("You need to be in Tokyo to visit Tokyo Racetrack!
[url='explore.php']Back [/url]");
}
$tresder = (int) (rand(100,999));
$maxbet=$ir['level']*150;
$_GET['tresde']=abs((int) $_GET['tresde']);
if(($_SESSION['tresde'] == $_GET['tresde']) || $_GET['tresde']<100){
die ("Error, you cannot refresh or go back on the slots, please use a side link to go somewhere else.
[url='horses.php?tresde=$tresder']> Back[/url]");
}
$_SESSION['tresde']=$_GET['tresde'];
$_GET['bet']=abs((int) $_GET['bet']);
$_GET['number']=abs((int) $_GET['number']);
if($_GET['bet']){if($_GET['bet'] > $ir['money']){
die("You are trying to bet more than you have.
[url='horses.php?tresde=$tresder']> Back[/url]");
}else if ($_GET['number'] > 8 or $_GET['number'] < 1 or $_GET['bet'] < 0){
die("There are only 8 horses in this race!
[url='horses.php?tresde=$tresder']> Back[/url]");
}
}
$hb=$_GET['bet'];
$horse[1]=(int) rand(1,125);
if ($horse[1] > 0 && $horse[1] < 50){
if ($_GET['number'] == 1){
$hwin=$_GET['bet']*1.5;
$hgain=($_GET['bet']*1.5)-($_GET['bet']);
print "
[b]<font color=green>You look over the crowds, and just about catch a glimpse of the number 1 on the side of the winning horse.</font>[/b]
You have won \$$hwin!";
$db->query("UPDATE users SET money=money+({$hgain}) where userid=$userid");
}else {
print "
[b]<font color=red>You have lost \$$hb on this race. The winner was horse 1.</font>[/b]";
$db->query("UPDATE users SET money=money-({$_GET['bet']}) where userid=$userid");
}
}else if ($horse[1] >= 50 && $horse[1] < 83){if ($_GET['number'] == 2){
$hwin=$_GET['bet']*2;$hgain=($_GET['bet']*2)-($_GET['bet']);
print "
[b]<font color=green>Horse number 2 gallops home with 4 lengths to spare. You go to collect your \$$hwin winnings.</font>[/b]";
$db->query("UPDATE users SET money=money+({$hgain}) where userid=$userid");
}else {
print "
[b]<font color=red>Horse 2 wins easy, losing you \$$hb.</font>[/b]";
$db->query("UPDATE users SET money=money-({$hb}) where userid=$userid");
}
}else if ($horse[1] >= 83 && $horse[1] < 98){
if ($_GET['number'] == 3){$hwin=$_GET['bet']*5;$hgain=($_GET['bet']*5)-($_GET['bet']);
print "
[b]<font color=green>Horse number 3 wins in a photo finish! You celebrate your \$$hwin winnings.</font>[/b]";
$db->query("UPDATE users SET money=money+({$hgain}) where userid=$userid");
}else {
print "
[b]<font color=red>Horse 3 nicks it, losing you \$$hb.</font>[/b]";
$db->query("UPDATE users SET money=money-({$hb}) where userid=$userid");
}
}else if ($horse[1] >= 98 && $horse[1] < 108){if ($_GET['number'] == 4){
$hwin=$_GET['bet']*8;$hgain=($_GET['bet']*8)-($_GET['bet']);
print "
[b]<font color=green>Horse number 4 wins after a sprint finish! You win \$$hwin!</font>[/b]";
$db->query("UPDATE users SET money=money+({$hgain}) where userid=$userid");
}else {
print "
[b]<font color=red>Horse 4 sprints to a win, losing you \$$hb.</font>[/b]";
$db->query("UPDATE users SET money=money-({$hb}) where userid=$userid");
}
}else if ($horse[1] >= 108 && $horse[1] < 116){
if ($_GET['number'] == 5){
$hwin=$_GET['bet']*12;
$hgain=($_GET['bet']*12)-($_GET['bet']);
print "
[b]<font color=green>Horse number 5 comes over the line in first! Your gamble pays you \$$hwin!</font>[/b]";$db->query("UPDATE users SET money=money+({$hgain}) where userid=$userid");
}else {
print "
[b]<font color=red>Horse 5 wins, losing you \$$hb.</font>[/b]";
$db->query("UPDATE users SET money=money-({$hb}) where userid=$userid");
}
}else if ($horse[1] >= 116 && $horse[1] < 121){if ($_GET['number'] == 6){
$hwin=$_GET['bet']*20;$hgain=($_GET['bet']*20)-($_GET['bet']);
print "
[b]<font color=green>Horse number 6 wins a head to head finish with horse 2! You gain \$$hwin!</font>[/b]";
$db->query("UPDATE users SET money=money+({$hgain}) where userid=$userid");
}else {
print "
[b]<font color=red>Horse 6 wins a close race, losing you \$$hb.</font>[/b]";
$db->query("UPDATE users SET money=money-({$hb}) where userid=$userid");
}
}else if ($horse[1] >= 121 && $horse[1] < 124){
if ($_GET['number'] == 7){
$hwin=$_GET['bet']*33;
$hgain=($_GET['bet']*33)-($_GET['bet']);
print "
[b]<font color=green>Horse number 7 races home for the win, for him and you! You go to collect your \$$hwin winnings.</font>[/b]";
$db->query("UPDATE users SET money=money+({$hgain}) where userid=$userid");
}else{
print "
[b]<font color=red>Horse 7 comes in first, losing you \$$hb.</font>[/b]";
$db->query("UPDATE users SET money=money-({$hb}) where userid=$userid");
}
}else if ($horse[1] >= 124 && $horse[1] < 125){
if ($_GET['number'] == 8){
$hwin=$_GET['bet']*100;
$hgain=($_GET['bet']*100)-($_GET['bet']);
print "
[b]<font color=green>Horse number 8 shocks the world and wins by 2 furlongs! Your ultimate gamble gains you \$$hwin winnings!</font>[/b]";
$db->query("UPDATE users SET money=money+({$hgain}) where userid=$userid");
}else {
print "
[b]<font color=red>Horse 8 shocks the world and wins by 2 furlongs, losing you \$$hb.</font>[/b]";
$db->query("UPDATE users SET money=money-({$hb}) where userid=$userid");
}
}else{
print "
Welcome to the Tokyo Racetrack! We have a number of horses for you to bet on today!
<table width=75% cellspacing=1 class='table'>
<tr style='background:gray'><th>Number</th><th>Horse Name</th><th>Odds</th></tr>
<tr><td>1</td><td>Lightning Thunder</td><td>[b]6/4[/b]</td></tr>
<tr><td>2</td><td>Eat My Dust</td><td>[b]2/1[/b]</td></tr>
<tr><td>3</td><td>Three Legged Wonder</td><td>[b]5/1[/b]</td></tr>
<tr><td>4</td><td>Galiant Loser</td><td>[b]8/1[/b]</td></tr>
<tr><td>5</td><td>Carl's Superstar</td><td>[b]12/1[/b]</td>
</tr><tr><td>6</td><td>Fat Donkey</td><td>[b]20/1[/b]</td>
</tr><tr><td>7</td><td>Galloping Granny</td><td>[b]33/1[/b]</td>
</tr><tr><td>8</td><td>Won't Need A Photo Finish</td><td>[b]100/1[/b]</td></tr>
</table>
Ready to try your luck? Bet today!
<form action='horses.php' method='get'>
Bet: \$<input type='text' name='bet' value='50' />
Pick (1-8): <input type='text' name='number' value='1' />
<input type='hidden' name='tresde' value='$tresder' />
<input type='submit' value='Play!!' />
</form>";
}
$h->endpage();
?>
Hope it helps someone