Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 .
- eg file will be like this:
- thepacman=mypage.com/swf/pacman.swf
- jetpack=mypage.com/swf/myjetpack.swf
- 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.
- <?php
- /*
- v006_240327f -
- v004_240327c -
- */
- $debug=true;
- 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>";}
- // ?gamenick=stick2&passcode=1234
- //http://192.168.1.200/img/gpt_get_swf_url.php?gamenick=stick2&passcode=1234
- $gamecodeURL = array(
- "pacman" => "https://www.example.com/pacman",
- "stick2" => "https://stick2.example.com/",
- "tortuga"=> "https://tortuga.example.com/",
- // Add more gamecode/url pairs as needed
- );
- echo "aaa";
- @$gamenick = $_REQUEST['gamenick'];
- @$passcode = $_REQUEST['passcode'];
- $my_passcode = "1234";
- // Check if the passcode is correct
- if($passcode != $my_passcode) { echo "<br>wrong gamecode"; exit; }
- //http://192.168.1.200/swf/opengame_ruffle.php?file=./graphics_/comic_design__garfield_comic_creator_y8.swf
- $url_prefix="http://192.168.1.200/swf/opengame_ruffle.php?file=" ;//used only when we read the file
- if(array_key_exists($gamenick, $gamecodeURL)) {
- $url = $gamecodeURL[$gamenick];
- // Check if the passcode is correct
- if($passcode == $my_passcode) {
- header("Location: $url");
- exit;
- } else {
- echo "Invalid passcode";
- }
- } else {
- $file = "gamefile.txt"; // File containing list of gamenick and URL
- $data = file_get_contents($file);
- $lines = explode("\n", $data);
- foreach($lines as $line) {
- list($nick, $url) = explode("=", $line);
- if(trim($nick) == $gamenick) {
- header("Location: ".$url_prefix."$url");
- }
- }
- echo "Game not found";
- }
- ?>
- ___
- gamefile.txt :
- [coding]
- Rover_nasa=coding/Rover_nasa_GREEK1_ruffle.swf
- lightbot-codehour-gr=coding/lightbot-codehour-gr_NoNavUrl.swf
- Tiny-explorers=coding/Tiny-explorers__nice_puzzle_education_unencr_noAds_ok.swf
- TurtlePond=coding/TurtlePond__illuminations.nctm.org.swf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement