PHP Code:
<?php
/**
* @Copyright wizard <mc_jayrulez@yahoo.com.au>
* @File: rps.php
* @param: $sid
*/
session_start();
header('Content-type: text/vnd.wap.wml');
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">';
echo '<wml>';
include("config.php");
include("core.php");
$bcon = connectdb();
$sid = $_GET['sid'];
$uid = getuid_sid($sid);
$action = $_GET['action'];
function canplay_rps($uid)
{
$sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
if($sql[0]>=15)
{
return true;
}else{
return false;
}
}
function gup($uid)
{
$sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
return $sql[0];
}
function get_winner($x,$y)
{
if($x==1&&$y==2)
{
$win = 2;
}else if($x==1&&$y==3)
{
$win = 1;
}else if($x==2&&$y==1)
{
$win = 1;
}else if($x==3&&$y==1)
{
$win = 2;
}else if($x==2&&$y==3)
{
$win = 2;
}else if($x==3&&$y==2)
{
$win = 1;
}else{
$win = 0;
}
return $win;
}
function get_left($x)
{
switch($x)
{
case 1:
$ret = 'rock_l';
break;
case 2:
$ret = 'paper_l';
break;
case 3:
$ret = 'scissor_l';
break;
}
return $ret;
}
function get_right($x)
{
switch($x)
{
case 1:
$ret = 'rock_r';
break;
case 2:
$ret = 'paper_r';
break;
case 3:
$ret = 'scissor_r';
break;
}
return $ret;
}
if(!$bcon)
{
echo '<card id="main" title="Database Error">';
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo 'Database Connection Error, please try again later!';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
echo '</wml>';
exit();
}
if(!islogged($sid))
{
echo '<card id="main" title="Login Error">';
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo 'You are not logged in or your session has expired!';
echo '
';
echo 'Login';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
echo '</wml>';
exit();
}
if(isbanned($uid))
{
echo '<card id="main" title="Login Error">';
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo '';
echo 'You are Banned
';
echo '
';
$sql = "SELECT timeto, pnreas, exid
FROM ibwf_parusa
WHERE uid='".$uid."'
AND penalty='1' OR uid='".$uid."'
AND penalty='2'
";
$banto = mysql_fetch_array(mysql_query($sql));
$banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
$remain = $banto[0] - time();
$rmsg = gettimemsg($remain);
echo 'Time Left: '.$rmsg.'';
echo '
';
$nick = getnick_uid($banto[2]);
echo 'By: '.$nick.'';
echo '
';
echo 'Reason: '.$banto[1].'';
echo '';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
echo '</wml>';
exit();
}
if(!canplay_rps($uid))
{
echo '<card id="main" title="Error">';
echo '<p align="center">';
echo '[img]images/notok.gif[/img]';
echo '
';
echo 'You must have atleast 15 plusses to play Rock-Paper-Scissors!';
echo '
';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
echo '</wml>';
exit();
}
if($action=='play')
{
echo '<card id="main" title="Rock-Paper-Scissors">';
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo 'Call: ';
echo '<select name="op">';
echo '<option value="1">Rock</option>';
echo '<option value="2">Paper</option>';
echo '<option value="3">Scissors</option>';
echo '</select>';
echo '
';
echo '<anchor>[Shoot]<go href="rps.php?action=go&sid='.$sid.'" method="post">';
echo '<postfield name="op" value="$(op)"/>';
echo '<postfield name="init" value="1"/>';
echo '</go></anchor>';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
}else if($action=='go')
{
if(isset($_POST['init'])&&$_POST['init']==1)
{
$op = $_POST['op'];
$ac = rand(1,3);
$res = get_winner($op,$ac);
$_SESSION['turn'] = isset($_SESSION['turn']) ? $_SESSION['turn'] : 1;
$turn = $_SESSION['turn'];
$imgl = get_left($op);
$imgr = get_right($ac);
$_SESSION['w'] = isset($_SESSION['w']) ? $_SESSION['w'] : 0;
$_SESSION['l'] = isset($_SESSION['l']) ? $_SESSION['l'] : 0;
$_SESSION['d'] = isset($_SESSION['d']) ? $_SESSION['d'] : 0;
echo '<card id="main" title="Rock-Paper-Scissors">';
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo '[img]images/'.$imgl.'.png[/img][img]images/vs.png[/img][img]images/'.$imgr.'.png[/img]';
echo '
';
if($res==1)
{
$_SESSION['w']++;
echo 'You Won!';
echo '
';
}else if($res==2)
{
$_SESSION['l']++;
echo 'You Lost!';
echo '
';
}else{
$_SESSION['d']++;
$_SESSION['turn']--;
echo 'Draw!';
echo '
';
}
echo '
';
if($_SESSION['turn']<3)
{
echo 'Call: ';
echo '<select name="op">';
echo '<option value="1">Rock</option>';
echo '<option value="2">Paper</option>';
echo '<option value="3">Scissors</option>';
echo '</select>';
echo '
';
echo '<anchor>[Shoot]<go href="rps.php?action=go&sid='.$sid.'" method="post">';
echo '<postfield name="op" value="$(op)"/>';
echo '<postfield name="init" value="1"/>';
echo '</go></anchor>';
$_SESSION['turn']++;
}else{
echo ''.$_SESSION['w'].':'.$_SESSION['l'].'';
echo '
';
echo '
';
$xup = gup($uid);
if($_SESSION['w']>$_SESSION['l'])
{
$plus = $xup + 15;
$add = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
if($add)
{
echo 'You Won: $15';
echo '
';
echo 'You Plusses: '.$plus.'';
}
}
if($_SESSION['w']<$_SESSION['l']){
$plus = $xup - 15;
if($plus<0)
{
$plus = 0;
}
$min = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
if($min)
{
echo 'You Lost: $15';
echo '
';
echo 'You Plusses: '.$plus.'';
}
}
unset($_SESSION['turn']);
unset($_SESSION['w']);
unset($_SESSION['l']);
unset($_SESSION['d']);
echo '
';
echo '
';
echo 'Play Again';
echo '
';
}
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
}else{
echo '<card id="main" title="Rock-Paper-Scissors">';
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo 'Do not try to cheat here!!!';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
}
}else{
echo '<card id="main" title="Rock-Paper-Scissors">';
echo '<p align="center">';
echo '[img]images/rockps.gif[/img]';
echo '
';
echo 'Think you can outmatch [bot name] at Rock Paper Scissors? Well wage 15 plusses with a payout to match to find out. The best 2 out of 3 wins!!';
echo '
';
echo 'If you think you got what it takes, click below:';
echo '
';
echo 'Play Now';
echo '</p>';
echo '<p align="center">';
echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
echo 'Fun Menu</a>';
echo '
';
echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
echo 'Home</a>';
echo '</p>';
echo '</card>';
}
echo '</wml>';
?>
Comment