<?php

session_start();

include "../config.php";
include "../header.php";
include "../style.php";

if( isset($_SESSION["ulogin"]) )
   	{  // members only stuff!
		include("navigation.php");
        include("../banners.php");

        echo "<font size=2 face='$fonttype' color='$fontcolour'><p><b><center>";
        
		$tickets = $userrecord['tickets'];
				
		if($_POST['spin'] AND $tickets) {
		
			mysql_query("UPDATE members SET tickets=tickets-1 WHERE userid='$userid'");
			$tickets--;
			
			$number = rand(0,10000);
			if($number <= 6000) {
			
				echo "Try Again";
			
			
			} elseif($number <=6400) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='1 Traffic Link w/50 views'");
				mysql_query("insert into tlinks (userid,paid) values('$userid','50')");
					
					
				echo "You just won 1 Traffic Link w/50 views";
			
			
			} elseif($number<=6600) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='1 Solo'");
				mysql_query("INSERT INTO `solos` (`id` ,`userid` ,`approved` ,`subject` ,`adbody` ,`sent` ,`added`) VALUES (NULL , '".$userid."', '0', '', '', '0', '0')");
					
					
				echo "You just won 1 Solo";	
				
			} elseif($number<=7000) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='5,000 Points'");
				mysql_query("UPDATE members SET points=points+5000 WHERE userid='$userid'");
					
					
				echo "You just won 5,000 Points";
				
			} elseif($number<=7200) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='10,000 Points'");
				mysql_query("UPDATE members SET points=points+10000 WHERE userid='$userid'");
					
					
				echo "You just won 10,000 Points";
				
			} elseif($number<=7300) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='25,000 Points'");
				mysql_query("UPDATE members SET points=points+25000 WHERE userid='$userid'");
					
					
				echo "You just won 25,000 Points";
				
			} elseif($number<=7400) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='50,000 Points'");
				mysql_query("UPDATE members SET points=points+50000 WHERE userid='$userid'");
					
					
				echo "You just won 50,000 Points";
				
			} elseif($number<=7425) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='100,000 Points'");
				mysql_query("UPDATE members SET points=points+100000 WHERE userid='$userid'");
				
				echo "You just won 100,000 Points";
				
				
			} elseif($number<=7825) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='1 PTC w/50 views'");
				mysql_query("insert into ptcads (userid,paid) values('$userid','50')");
					
					
				echo "You just won 1 PTC w/50 views";	
				
			} elseif($number<=8825) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='1 Login Ad'");
				mysql_query("insert into loginads (userid,max) values('$userid','1000')");
					
					
				echo "You just won 1 Login Ad";	
				
			} elseif($number<=9225) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='1 Banner Ad'");
				mysql_query("insert into banners (userid,max) values('$userid','1000')");
					
					
				echo "You just won 1 Banner Ad";	
				
			} elseif($number<=9425) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='1 Button Banner'");
				mysql_query("insert into buttons (userid,max) values('$userid','1000')");
					
					
				echo "You just won 1 Button Banner";	
				
			} elseif($number<=9625) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='1 Cash Solo'");
				mysql_query("insert into cashsolos (userid) values('$userid')");
					
					
				echo "You just won 1 Button Banner";	
				

			} elseif($number<=9800) {
			
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='\$0.10'");
				mysql_query("UPDATE members SET commission=commission+0.10 WHERE userid='$userid'");
					
					
				echo "You just won \$0.10";					

			} elseif($number<=9850) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='\$0.25'");
				mysql_query("UPDATE members SET commission=commission+0.25 WHERE userid='$userid'");
					
					
				echo "You just won \$0.25";		

			} elseif($number<=9900) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='\$0.50'");
				mysql_query("UPDATE members SET commission=commission+0.50 WHERE userid='$userid'");
					
					
				echo "You just won \$0.50";	
				
			} elseif($number<=9940) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='\$0.75'");
				mysql_query("UPDATE members SET commission=commission+0.75 WHERE userid='$userid'");
					
					
				echo "You just won \$0.75";	
				
			} elseif($number<=9970) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='\$1.00'");
				mysql_query("UPDATE members SET commission=commission+1.00 WHERE userid='$userid'");
					
					
				echo "You just won \$1.00";		
				
				
			} elseif($number<=9980) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='\$2.50'");
				mysql_query("UPDATE members SET commission=commission+2.50 WHERE userid='$userid'");
					
					
				echo "You just won \$2.50";	

				
			} elseif($number<=9990) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='\$5.00'");
				mysql_query("UPDATE members SET commission=commission+5.00 WHERE userid='$userid'");
					
					
				echo "You just won \$5.00";		

				
			} elseif($number<=10000) {
				mysql_query("INSERT INTO game_winners SET userid='$userid', date='".time()."', won='\$10.00'");
				mysql_query("UPDATE members SET commission=commission+10.00 WHERE userid='$userid'");
					
					
				echo "You just won \$10.00";						
				
				
			}
			
         //$start=intval(rand(0,20));
		 $start = 1;
        $flashurl = "Movie1.swf?start=1&castigator=".$start."&nbTickets=".$tickets."";

		 
			?>
			<br><br>
			
<object>
<param name="movie" value="<? echo $flashurl; ?>">
<embed src="<? echo $flashurl; ?>">
</embed>
</object><br><br>
			<?
			
			
			if($tickets>0) {
				echo "<br><br><br>You have $tickets tickets now.<br><br><form method=post><input type=\"submit\" name=\"spin\" value=\"Play Again\"></form>";
			}

		
		} elseif(!$tickets) {
			echo "You do not have any tickets to play.  To earn tickets, please click on advertising.<br><br>";
		
		} else {
		
			echo "You have $tickets tickets<br><br><form method=post><input type=\"submit\" name=\"spin\" value=\"Play the game\"></form>";
		
		
		
		}
		
		
        echo "</font></td></tr></table>";
	}

else
  { ?>

  <font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><p><b><center>You must be logged in to access this site. Please <a href="<? echo $domain; ?>/memberlogin.php">click here</a> to login.</p></b></font><center>

  <? }

include "../footer.php";
mysql_close($dblink);
?>