[wap] Rock-paper-scissors For Lavalair

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [wap] Rock-paper-scissors For Lavalair

    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&amp;sid='.$sid.'">[img]images/roll.gif[/img]';
        echo 'Fun Menu</a>';
        echo '
    ';
        echo '<a href="index.php?action=main&amp;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&amp;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&amp;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&amp;sid='.$sid.'">[img]images/roll.gif[/img]';
        echo 'Fun Menu</a>';
        echo '
    ';
        echo '<a href="index.php?action=main&amp;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&amp;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&amp;sid='.$sid.'">[img]images/roll.gif[/img]';
        echo 'Fun Menu</a>';
        echo '
    ';
        echo '<a href="index.php?action=main&amp;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&amp;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&amp;sid='.$sid.'">[img]images/roll.gif[/img]';
            echo 'Fun Menu</a>';
            echo '
    ';
            echo '<a href="index.php?action=main&amp;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&amp;sid='.$sid.'">[img]images/roll.gif[/img]';
            echo 'Fun Menu</a>';
            echo '
    ';
            echo '<a href="index.php?action=main&amp;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&amp;sid='.$sid.'">[img]images/roll.gif[/img]';
        echo 'Fun Menu</a>';
        echo '
    ';
        echo '<a href="index.php?action=main&amp;sid='.$sid.'">[img]images/home.gif[/img]';
        echo 'Home</a>';
        echo '</p>';
        echo '</card>';
    }
    
    echo '</wml>';
    
    ?>
    Attached Files
    Last edited by metulj; 09.08.09, 06:32. Reason: adding [ php ] ... [ / php ] tag

    #2
    Nice share dont mind i use it ;)

    Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
    Visit: WapMasterz Coming Back Soon!
    _______
    SCRIPTS FOR SALE BY SUBZERO
    Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
    FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
    _______
    Info & Tips
    php.net
    w3schools.com

    Comment


      #3
      Nice share dont mind i use it ;)[/b]

      no prob at all

      Comment


        #4
        cool m8 thanks :D




        Comment


          #5
          hi it dont work l get 

          The requested URL /web/rps.php was not found on this server.


          Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.



          Comment


            #6
            pls name that game to rps.php

            so it will work
            Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
            Visit: WapMasterz Coming Back Soon!
            _______
            SCRIPTS FOR SALE BY SUBZERO
            Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
            FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
            _______
            Info & Tips
            php.net
            w3schools.com

            Comment


              #7
              pls name that game to rps.php

              so it will work[/b]



              echo "<a href=\"rps.php?action=rps&amp;sid=$sid\">»paper game</a>
              ";


              still dnt work subz

              Comment


                #8
                <div class='quotetop'>QUOTE (bluebell @ Jul 9 2008, 11:27 AM) <{POST_SNAPBACK}></div>
                echo "<a href=\"rps.php?action=rps&amp;sid=$sid\">»paper game</a>
                ";
                still dnt work subz[/b]

                where did u upload it to?

                Comment


                  #9
                  echo "<a href=\"rps.php?action=rps&amp;sid=$sid\">»paper game</a>
                  ";


                  still dnt work subz[/b]
                  When you copyed the coding to notpad and then clicked save as.. what did you name it? because it has to be named rps.php

                  //
                  thanks for the share Wizard :-)

                  Comment


                    #10
                    hi it dont work l get 

                    The requested URL /web/rps.php was not found on this server.
                    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.[/b]
                    From the looks of it, you didn&#39;t copy the file into your web folder

                    Comment


                      #11
                      From the looks of it, you didn&#39;t copy the file into your web folder[/b]

                      sortd now oopz l didnt rename the file sorry guys itz workin now


                      Comment


                        #12
                        wow nice update for lava script
                        thanks wizard :D
                        It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt.
                        ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ !
                        ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.
                        キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

                        Comment


                          #13
                          Nice Tanx bro :P

                          Comment


                            #14
                            Good game. x)

                            Comment


                              #15
                              thank you for this wonderful game bro...

                              WapCHAT Forum Currenltly changing over to xhtml

                              My Dowloads Site

                              Comment

                              Working...
                              X