Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2.  
  3. class Schattenjacht{
  4. function createArray(){
  5. $deuren = array();
  6. for ($i=0; $i < 7; $i++) {
  7. $deuren[$i] = 0;
  8. }
  9.  
  10. $randINT = rand(0,6);
  11. $deuren[$randINT] = 2;
  12.  
  13. return $deuren;
  14. }
  15.  
  16. function showDeuren($deuren= array(), $url){
  17. $toEcho = '';
  18. foreach ($deuren as $key => $value) {
  19. if ($value == 0 || $value == 2) {
  20. $toEcho .= '<a href="treasurehunt.php/?door='.$key.'&'.$url.'"><img src="http://172.16.36.251/test/door.png"></a>'.$value;
  21. }
  22. }
  23. return $toEcho;
  24. }
  25. }
  26.  
  27. if (!isset($_GET["door"])) {
  28.  
  29.  
  30. $deuren = new Schattenjacht;
  31. $arrayDeuren = $deuren->createArray();
  32.  
  33.  
  34. $url = '';
  35. foreach ($arrayDeuren as $key => $value) {
  36.  
  37. $url .= $key .'='.$value;
  38. if ($key < 6) {
  39. $url .= '&';
  40. }
  41. }
  42.  
  43. echo $url;
  44.  
  45. $toEcho = $deuren->showDeuren($arrayDeuren, $url);
  46.  
  47. }
  48.  
  49.  
  50. /*if ($_GET["reset"] == 1) {
  51. # code...
  52. }*/
  53.  
  54. /*if (isset($_GET["kiesdeur"])) {
  55. # code...
  56. }*/
  57.  
  58.  
  59. ?>
  60. <html>
  61. <head>
  62. <title>Schattenjacht</title>
  63. </head>
  64.  
  65. <body>
  66. <h1>Kies een deur</h1>
  67. <?=$toEcho?>
  68. <br>
  69. Klik <a href="treasurehunt.php?reset=1">hier</a> om een nieuw spel te beginnen.
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement