REKLAM ALANI

PHP Kelime Tahmin Oyunu (Basit ve Tatlı)

avatar CAN
Forum Üyesi
398
#1
Yorumu Paylaş

Php'de cookiler ile yapılmış bir cookie oyunu

Görüntü : 
[Resim: I_493_0_5ead6f939746c.jpg]
 
Kod:
<body>
<?php
       
        function karsilastir($a,$b,$c)
        {
                $uu = [url=http://www.php.net/strlen]strlen[/url]($b);
                $kk = $c;
                               
                for($i=0;$i<$uu;$i++)
                {
                        if($a==$b[$i])
                        {
                                if($kk[$i]=="-")
                                {
                                        $kk[$i] = $a;
                                }
                        }
                }
                [url=http://www.php.net/setcookie]setcookie[/url]('layout',NULL,-1);
                [url=http://www.php.net/setcookie]setcookie[/url]('layout',$kk,[url=http://www.php.net/time]time[/url]()+3600);
                $_SESSION['th'] = $_SESSION['th']-1;
        }
        function pgRf()
        {
                [url=http://www.php.net/echo]echo[/url] "<script language='javascript' type='text/javascript'>window.top.location='./index.php';</script>";
               
        }

        if(![url=http://www.php.net/empty]empty[/url]($_SERVER['QUERY_STRING']))
        {
                if($_SERVER['QUERY_STRING']=="yenile")
                {
                        [url=http://www.php.net/setcookie]setcookie[/url]('kelime',NULL,-1);
                        [url=http://www.php.net/setcookie]setcookie[/url]('layout',NULL,-1);
                        pgRf();
                }
        }
                       
        if([url=http://www.php.net/empty]empty[/url]($_COOKIE['kelime']))
        {
                $s = [url=http://www.php.net/rand]rand[/url](0,2);
               
                $kelimeler=[url=http://www.php.net/array]array[/url]("abuzittin","mozilla firefox","windows vista ultimate");
                $layoutlar = [url=http://www.php.net/array]array[/url]("---------","------- -------","------- ----- --------");
               
                $kullanilan = $kelimeler[$s];
                $ly = $layoutlar[$s];
               
                [url=http://www.php.net/setcookie]setcookie[/url]('kelime',$kullanilan,[url=http://www.php.net/time]time[/url]()+3600);
                [url=http://www.php.net/setcookie]setcookie[/url]('layout',$ly,[url=http://www.php.net/time]time[/url]()+3600);
                [url=http://www.php.net/unset]unset[/url]($_SESSION['th']);
               
                pgRf();
               
        }else{
                       
                if(![url=http://www.php.net/empty]empty[/url]($_POST))
                {
                        karsilastir($_POST['harf'],$_COOKIE['kelime'],$_COOKIE['layout']);
                }
                $uzunluk = [url=http://www.php.net/strlen]strlen[/url]($_COOKIE['kelime']);
               
                if([url=http://www.php.net/empty]empty[/url]($_SESSION['th']) && $_SESSION['th']!=1)        $_SESSION['th'] = ($uzunluk - [url=http://www.php.net/round]round[/url]($uzunluk/2))+1;
               
                if($_SESSION['th']==1)
                {
                        [url=http://www.php.net/echo]echo[/url] "Tahmin hakkiniz tükendi. Kelimemiz <strong>".$_COOKIE['kelime']."</strong> idi. Yazık!";
                        [url=http://www.php.net/echo]echo[/url] '<input type="button" id="hede" onclick="window.top.location='./index.php?yenile'" value="Yeniden başla" />';
                        [url=http://www.php.net/die]die[/url]();
                }
               
                [url=http://www.php.net/echo]echo[/url] '<div id="giris">Kelime seçildi. Seçilen kelime '.$uzunluk.' harfli. Buna göre toplam '.($_SESSION['th']-1).' tahmin hakkiniz atandi</div>
                <input type="button" onclick="window.top.location='./index.php?yenile'" id="hede" value="Çok zor oldu.Yeni kelime seçelim"/><br>';
               
                [url=http://www.php.net/echo]echo[/url] "<br><br>Buyrun baslayın: ".$_COOKIE['layout']."<br><br><br>";
                [url=http://www.php.net/echo]echo[/url] '( Tutulan Kelime '.$_COOKIE['kelime'].' )';
               
                [url=http://www.php.net/echo]echo[/url] '<br><br><form action="" method="post">';
               
                for($i=65;$i<91;$i++)
                {
                        [url=http://www.php.net/echo]echo[/url] '<input id="harf" type="submit" name="harf" value="'.[url=http://www.php.net/strtolower]strtolower[/url]([url=http://www.php.net/chr]chr[/url]($i)).'"/>';
                        if(($i-64)%6==0)        [url=http://www.php.net/echo]echo[/url] "<br>";
                }
               
                [url=http://www.php.net/echo]echo[/url] "</form>";
               
                if(![url=http://www.php.net/empty]empty[/url]($_POST))      pgRf();
        }
?>
</body>
</html>
deneme
Forum Üyesi

Konuda Ara

0 Yorum


Konuyu Okuyanlar: