Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(__DIR__.'/globals.php');
- $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : '';
- switch($_GET['action'])
- {
- case 'travel': travel(); break;
- default: travel_agency(); break;
- }
- function travel_agency()
- {
- global $db,$ir,$h,$set;
- echo "
- <div style='text-align:center;'>
- <img src='images/ta.png' width='200px' height='200px' />
- <h3>Travel Agency</h3>
- <p>Welcome to the {$set['game_name']} travel agency how can we help you today?</p>
- <a href='monorail.php?action=travel'><button>Travel</button></a>
- <a href='monorail.php?insurance'><button>Travel Insurcance?</button></a><br /><br />";
- if(isset($_GET['buy']))
- {
- if($ir['insured'] >= 10)
- echo "You are insured already you can only renew it once its 10 days or less.";
- else if($ir['credits'] < 5)
- echo "Sorry you don't have enough credits you need ".(5 - $ir['credits'])." more.";
- else
- {
- $ir['credits'] -= 5;
- $ir['insured'] += 30;
- $db->query("UPDATE `users` SET `credits` = {$ir['credits']},`insured` = {$ir['insured']} WHERE `userid` = {$ir['userid']}");
- echo "You have purchased insurance for 5 credits this will last for 30 days.";
- }
- }
- else if(isset($_GET['insurance']))
- {
- echo "<hr width='50%' align='center'>
- <h4 style='color:red'>Insurance Support Team</h4>
- <span style='text-align:center;'>
- Hello {$ir['username']} Traveling can be dangerous you never know what might happen.
- If you take insurance out with us we will make sure you are well looked after.<br /><br />
- <h3>Package Includes</h3>
- • 20 Free Hospital Heals which you can sign yourself out of hospital.<br />
- • 50% of your travel cost returned if hurt in acident using our service.<br />
- • As a member you can heal a friend for 50% of cost.<br />
- </span>
- <a href='monorail.php?buy'><button>Pay 5 Credits for insurance</button></a>
- <a href='monorail.php'><button>Who needs insurance</button></a>";
- }
- echo "</div>";
- $h->endpage();
- }
- function travel()
- {
- global $db,$ir,$h;
- $ttype = array(
- 'Car',
- 'Boat',
- 'Bus',
- 'Plane'
- );
- if(isset($_POST['travel']))
- {
- $_POST['ttype'] = isset($_POST['ttype']) && ctype_alpha($_POST['ttype']) && in_array($_POST['ttype'], $ttype) ? $_POST['ttype'] : '';
- if(empty($_POST['ttype']))
- echo "Invalid Format.";
- else
- {
- $locations = $db->query("SELECT `ID`,`ttype`,`traveltime`,`travelcost`,`location` FROM `locations`
- WHERE `ttype` = '{$_POST['ttype']}' AND `levelreq` <= {$ir['level']} AND `cityid` != {$ir['location']}");
- if(!$db->num_rows($locations))
- {
- $db->free_result($locations);
- echo "There is no locations for this type of transport..";
- }
- else
- {
- echo "
- <table width='75%'>
- <tr>
- <th>Name</th>
- <th>Cost</th>
- <th>Travel Time</th>
- <th>Action</th>
- </tr>";
- while($tr = $db->fetch_row($locations))
- {
- if($tr['ttype'] == 'Car')
- {
- $tr['traveltime'] += $tr['traveltime'] / 100 * 60;
- $tr['travelcost'] -= $tr['travelcost'] / 100 * 50;
- }
- else if($tr['ttype'] == 'Boat')
- {
- $tr['traveltime'] += $tr['traveltime'] / 100 * 40;
- $tr['travelcost'] -= $tr['travelcost'] / 100 * 35;
- }
- else if($tr['ttype'] == 'Bus')
- {
- $tr['traveltime'] += $tr['traveltime'] / 100 * 75;
- $tr['travelcost'] -= $tr['travelcost'] / 100 * 45;
- }
- else if($tr['ttype'] == 'Plane')
- {
- $tr['traveltime'] -= $tr['traveltime'] / 100 * 15;
- $tr['travelcost'] += $tr['travelcost'] / 100 * 75;
- }
- echo "
- <tr>
- <td>{$tr['location']}</td>
- <td>".money_formatter($tr['travelcost'])."</td>
- <td>".money_formatter($tr['traveltime'], '')." minutes</td>
- <td><a href='monorail.php?action=travel&begin={$tr['ID']}'>Travel</a></td>
- </tr>";
- }
- echo "</table>";
- }
- }
- }
- else if(isset($_GET['begin']))
- {
- $_GET['begin'] = isset($_GET['begin']) && ctype_digit($_GET['begin']) ? abs(intval($_GET['begin'])) : 0;
- if(empty($_GET['begin']))
- echo "Invalid.";
- else
- {
- $check = $db->query("SELECT * FROM `locations` WHERE `ID` = {$_GET['begin']}");
- if(!$db->num_rows($check))
- {
- $db->free_result($check);
- echo "That's not a real location.";
- }
- else
- {
- $loc = $db->fetch_row($check);
- if($ir['location'] == $loc['cityid'])
- echo "You are already at this location.";
- else if($loc['ttype'] == 'Car')
- {
- $loc['traveltime'] += $loc['traveltime'] / 100 * 60;
- $loc['travelcost'] -= $loc['travelcost'] / 100 * 50;
- }
- else if($loc['ttype'] == 'Boat')
- {
- $loc['traveltime'] += $loc['traveltime'] / 100 * 40;
- $loc['travelcost'] -= $loc['travelcost'] / 100 * 35;
- }
- else if($loc['ttype'] == 'Bus')
- {
- $loc['traveltime'] += $loc['traveltime'] / 100 * 75;
- $loc['travelcost'] -= $loc['travelcost'] / 100 * 45;
- }
- else if($loc['ttype'] == 'Plane')
- {
- $loc['traveltime'] -= $loc['traveltime'] / 100 * 15;
- $loc['travelcost'] += $loc['travelcost'] / 100 * 75;
- }
- if($ir['traveling'])
- echo "Sorry but you are already traveling this page is blocked.";
- else if($ir['money'] < $loc['travelcost'])
- echo "You don't have enough money you need ".money_formatter($loc['travelcost'] - $ir['money'])." more.";
- else
- {
- # insert the data into a traveling table and make the users travel to int 1 update it when traveling
- $db->query("UPDATE `users` SET `money` = `money` - {$loc['travelcost']},`traveling` = 1 WHERE `userid` = {$ir['userid']}");
- $db->query("INSERT INTO `traveling` (`userid`,`time`,`location`,`ttype`)
- VALUES({$ir['userid']},{$loc['traveltime']},{$loc['cityid']},'{$loc['ttype']}')");
- echo "You have begin traveling to {$loc['location']} it will take {$loc['traveltime']} minutes.";
- }
- }
- }
- }
- else
- {
- echo "<h4>Travel Choices</h4>
- <p>Pick a transport type diffrent methods cost diffrent prices and diffent travel times.</p>
- <form method='post'>
- Transport Type:
- <select name='ttype' type='dropdown'>";
- foreach($ttype as $opt)
- printf("<option value='%1\$s'>%1\$s</option>", $opt); echo "
- </select>
- <input type='submit' name='travel' value='Show Locations' />
- </form>";
- }
- $h->endpage();
- }
Advertisement
Add Comment
Please, Sign In to add comment