Advertisement
plirof2

gpt_get_swf_url v006f

Mar 28th, 2024 (edited)
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I want to make a program in php that takes the parameters gamenick and passcode. I will have a file with a list of gamenick and URL .
  2. eg file will be like this:
  3. thepacman=mypage.com/swf/pacman.swf
  4. jetpack=mypage.com/swf/myjetpack.swf
  5. If the passcode is correct, I want the script to open the url . What I want though is to hide the real file url from the user.
  6.  
  7. <?php
  8. /*
  9.  
  10. v006_240327f -
  11. v004_240327c -
  12.  
  13. */
  14. $debug=true;
  15.  
  16. if($debug) { echo "http://192.168.1.200/img/gpt_get_swf_url.php?gamenick=stick2&passcode=1234 <hr>http://192.168.1.200/img/gpt_get_swf_url.php?gamenick=artpad&passcode=1234  <hr><hr> <hr>";}
  17. // ?gamenick=stick2&passcode=1234
  18. //http://192.168.1.200/img/gpt_get_swf_url.php?gamenick=stick2&passcode=1234
  19. $gamecodeURL = array(
  20.     "pacman" => "https://www.example.com/pacman",
  21.     "stick2" => "https://stick2.example.com/",
  22.     "tortuga"=> "https://tortuga.example.com/",
  23.     // Add more gamecode/url pairs as needed
  24. );
  25. echo "aaa";
  26. @$gamenick = $_REQUEST['gamenick'];
  27. @$passcode = $_REQUEST['passcode'];
  28. $my_passcode = "1234";
  29.  
  30. // Check if the passcode is correct
  31. if($passcode != $my_passcode) {  echo "<br>wrong gamecode"; exit; }
  32. //http://192.168.1.200/swf/opengame_ruffle.php?file=./graphics_/comic_design__garfield_comic_creator_y8.swf
  33. $url_prefix="http://192.168.1.200/swf/opengame_ruffle.php?file=" ;//used only when we read the file
  34.  
  35.  
  36.  
  37. if(array_key_exists($gamenick, $gamecodeURL)) {
  38.     $url = $gamecodeURL[$gamenick];
  39.     // Check if the passcode is correct
  40.     if($passcode == $my_passcode) {
  41.         header("Location: $url");
  42.         exit;
  43.     } else {
  44.         echo "Invalid passcode";
  45.     }
  46. } else {    
  47.     $file = "gamefile.txt"; // File containing list of gamenick and URL
  48.     $data = file_get_contents($file);
  49.     $lines = explode("\n", $data);
  50.  
  51.     foreach($lines as $line) {
  52.         list($nick, $url) = explode("=", $line);
  53.         if(trim($nick) == $gamenick) {
  54.                 header("Location: ".$url_prefix."$url");
  55.         }
  56.     }
  57.  
  58.     echo "Game not found";
  59. }
  60. ?>
  61.  
  62.  
  63.  
  64.  
  65.  
  66. ___
  67. gamefile.txt  :
  68. [coding]
  69. Rover_nasa=coding/Rover_nasa_GREEK1_ruffle.swf
  70. lightbot-codehour-gr=coding/lightbot-codehour-gr_NoNavUrl.swf
  71. Tiny-explorers=coding/Tiny-explorers__nice_puzzle_education_unencr_noAds_ok.swf
  72. TurtlePond=coding/TurtlePond__illuminations.nctm.org.swf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement