davidmeyer25
Gebruiker
- Lid geworden
- 16 feb 2013
- Berichten
- 95
PHP:
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="nl">
<head profile="http://gmpg.org/xfn/11">
<title>Tijden & Vertragingen van NS treinen</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link type="text/css" href="modules/jquery/css/ui-lightness/jquery-ui-1.8.11.custom.css" rel="stylesheet" />
<script type="text/javascript" src="modules/jquery/js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="modules/jquery/js/jquery-ui-1.8.11.custom.min.js"></script>
<script type="text/javascript">
$(function(){
var availableTags = [
<?php
// MySQL connection
$link = mysqli_connect("geheim", "geheim", "geheim", "geheim");
// Place the stations in a array for jQuery
$res = mysqli_query($link, "SELECT naam, land FROM stations");
$count = mysqli_num_rows($res);
$i = 1;
while($sel = mysqli_fetch_array($res)){
if($i == $count){
echo '"'.$sel['naam'].'"';
} else{
echo '"'.$sel['naam'].'", ';
}
$i++;
}
?>
];
$( ".station" ).autocomplete({
source: availableTags,
select: function(event, ui) {
$("#submit").attr("disabled", "disabled");
},
search: function(event, ui) {
$("#submit").attr("disabled", "");
}
});
});
</script>
</head>
<body style="padding: 10px 10px 10px 10px;">
<?php
if($_GET['a'] == "prices"){
if(strlen($_POST['from']) > 1 && strlen($_POST['to']) > 1){
$from = stripslashes($_POST['from']);
$to = stripslashes($_POST['to']);
} else if(strlen($_GET['from']) > 1 && strlen($_GET['to']) > 1){
$from = stripslashes($_GET['from']);
$to = stripslashes($_GET['to']);
}
?>
<h1>Prijzen NS</h1>
Met behulp van deze pagina kun je de prijzen van NS inzien.<br />
Als je op de naam van een station klikt worden de actuele vertrekkende treinen van dat station weergegeven.<br />
<a href="index.php">Klik hier</a> om naar de vertrektijden te gaan.<br /><br />
<form method="post">
<span style="font-size: 16px; font-weight: bold;">Van:</span> (vul hier het desbetreffende vertrek station in)<br />
<input type="text" name="from" class="station" value="<?php echo strip_tags(htmlspecialchars($from)); ?>" /><br /><br />
<span style="font-size: 16px; font-weight: bold;">Naar:</span> (vul hier het desbetreffende uitstap station in)<br />
<input type="text" name="to" class="station" value="<?php echo strip_tags(htmlspecialchars($to)); ?>" />
<input type="submit" name="submit" id="submit" value="Bekijk" <?php if(!strlen($_POST['station']) > 1){ ?> disabled <?php } ?>/>
</form><br />
<?php
if(strlen($from) > 1 && strlen($to) > 1){
// Strip HTML or other characters from the input string
$from = mysqli_real_escape_string($link, strip_tags(htmlspecialchars($from)));
$to = mysqli_real_escape_string($link, strip_tags(htmlspecialchars($to)));
echo '<h2>Resultaat voor reis "'.stripslashes($from).'" - "'.stripslashes($to).'"</h2>';
// Get the code from the inputs, because they always work
$resFrom = mysqli_query($link, "SELECT afkorting FROM stations WHERE naam='".$from."' LIMIT 1");
$resTo = mysqli_query($link, "SELECT afkorting FROM stations WHERE naam='".$to."' LIMIT 1");
$selFrom = mysqli_fetch_array($resFrom);
$selTo = mysqli_fetch_array($resTo);
// Include and start the OSPHPNS class
include("modules/OSPHPNS/OSPHPNS.php");
$NSPrijzen = new OSPHPNS();
// Get the station times
$sPrijzen = $NSPrijzen->getPrijzen($from, $selFrom['afkorting'], $to, $selTo['afkorting']);
echo $sPrijzen;
$NSReisadvies = new OSPHPNS();
# last number is number of results to show
$sReisadviezen = $NSReisadvies->getReisadvies($from, $to, 3);
echo $sReisadviezen;
}
} else if ($_GET['a'] == "reisadvies") {
# filter html tags
$from = str_replace("%20", "+", $_GET['from']);
$from = str_replace(" ", "+", $_GET['from']);
$to = str_replace("%20", "+", $_GET['to']);
$to = str_replace("", "+", $_GET['to']);
// Include and start the OSPHPNS class
include("modules/OSPHPNS/OSPHPNS.php");
$NS = new OSPHPNS();
# last number is number of results to show
$sReisadvies = $NS->getReisadvies($from, $to, 5);
echo $sReisadvies;
} else{
if(strlen($_GET['station']) > 1){
$station = stripslashes($_GET['station']);
} else if(strlen($_GET['station']) > 1){
$station = stripslashes($_GET['station']);
}
?>
<h1>Vertrektijden NS</h1>
Met behulp van deze pagina kun je de actuele vertrektijden van treinen op een bepaald station opzoeken.<br />
Er worden altijd de treinen in het komende uur weergegeven, indien dit er minder dan 10 zijn worden er ook treinen in de komende uren (t/m 10 treinen) weergegeven.<br />
Alle elementen (zoals spoor en treinsoort) gemarkeerd in het <span style="color: red;">rood</span> zijn gewijzigd en dus niet volgens dienstregeling.<br />
<a href="index.php?a=prices">Klik hier</a> om naar de prijzen en reisadvies te gaan.<br /><br />
<form method="get">
<span style="font-size: 16px; font-weight: bold;">Station:</span> (vul hier het desbetreffende station in)<br />
<input type="text" name="station" class="station" value="<?php echo strip_tags(htmlspecialchars($_GET['station'])); ?>" />
<input type="submit" name="submit" id="submit" value="Bekijk" <?php if(!strlen($station) > 1){ ?> disabled <?php } ?>/>
</form><br />
<?php
if(strlen($station) > 1){
// Strip HTML or other characters from the input string
$station = stripslashes(mysqli_real_escape_string($link, htmlspecialchars($station)));
echo '<h2>Resultaat voor station "'.$station.'"</h2>';
// Always use the code of a station
$resStation = mysqli_query($link, 'SELECT afkorting FROM stations WHERE naam="'.$station.'" LIMIT 1');
$selStation = mysqli_fetch_array($resStation);
// Include and start the OSPHPNS class
include("modules/OSPHPNS/OSPHPNS.php");
$NSPrijzen = new OSPHPNS();
// Get the station times
$sPrijzen = $NSPrijzen->getStationTimes($station, $selStation['afkorting']);
echo $sPrijzen;
}
}
?>
</body>
</html>
Als ik de afkorting wilt op vragen doet hij het niet wel de normale zo als Gouda Goverwelle
Laatst bewerkt: