From Ken Rice, 4 Years ago, written in PHP.
- go back
Embed
Viewing differences between and LaML Demo
  1. <?php
  2. session_id($_REQUEST['CallSid']);
  3.  
  4. if(!isset($_SESSION['game_on'])){
  5.         error_log("starting game");
  6.         $_SESSION['game_on'] = TRUE;
  7.         $_SESSION['the_number'] = rand(1,6);
  8.         $_SESSION['guess_count'] = 0;
  9.         $_SESSION['guesses'] = array();
  10.         echo '<Response>
  11.                <Say>Welcome to Baby Shark Roulette!</Say>
  12.                <Say>See if you can make it past round 5!</Say>
  13.                <Gather action="https://delta.tollfreegateway.com/cc2020/incoming.php" method="GET" timeout="10" numDigits="1" >
  14.                <Say>Guess a number 1 through 6.</Say>
  15.                </Gather>
  16.                </Response>';
  17.  
  18. } else {
  19.  
  20.         error_log("getting a guess");
  21.         $_SESSION['guess_count']++;
  22.         if ($_SESSION['the_number'] == $_REQUEST['Digits']) {
  23.                 error_log("You just Lost the game\n");
  24.                 lost();
  25.  
  26.         } elseif (in_array($_REQUEST['Digits'], $_SESSION['guesses'])) {
  27.                 error_log("You just Lost for guessing the same number twice\n");
  28.                 lost();
  29.  
  30.         } elseif ( $_SESSION['guess_count'] == 5 ) {
  31.                 error_log("Made 5 guesses without dying\n");
  32.                 echo '<Response>
  33.                        <Play>https://delta.tollfreegateway.com/cc2020/sounds/gotit.mp3</Play>
  34.                        <Say>You just won by surviving 5 rounds!! </Say>
  35.                        <Say>Have some Happy Music!</Say>
  36.                        <Play loop="5">https://delta.tollfreegateway.com/cc2020/sounds/babyshark.mp3</Play>
  37.                        <Hangup></Hangup>
  38.                        </Response>';
  39.                 die();
  40.         }
  41.         $_SESSION['guesses'][] = $_REQUEST['Digits'];
  42.         echo '<Response>
  43.                <Say>You have guessed ';
  44.                 echo  $_REQUEST['Digits'];
  45.                 echo ' and are safe for now.</Say>
  46.                <Gather action="https://delta.tollfreegateway.com/cc2020/incoming.php" method="GET"  timeout="10" numDigits="1">
  47.                <Say>Guess again.</Say>
  48.                </Gather>
  49.                </Response>';
  50. }
  51.  
  52. function lost(){
  53.         echo '<Response>
  54.                <Say>Sorry you Have lost.</Say>
  55.                <Play>https://delta.tollfreegateway.com/cc2020/sounds/order66.mp3</Play>
  56.                <Play loop="5">https://delta.tollfreegateway.com/cc2020/sounds/babyshark.mp3</Play>
  57.                <Hangup></Hangup>
  58.                </Response>';
  59.         die();
  60. }
  61. ?>
  62.  

Replies to LaML Demo rss

Title Name Language When
Re: LaML Demo Silly Leech php 4 Years ago.