I think by not limiting the pool of files we are opening ourselves up (I was able to traverse the file system some using the file:/// syntax in place of the file.inc). Also, at the minimum I should be hiding the .inc extension in the URL parameter... that just makes sense.
I am still working on the news section and this problem is the same as it was, but I am also working on a googlemaps mashup (of sorts).
www.iel.spokane.edu/locations/default.php
Gammaster,
I looked at your last suggestion and think that's what I want to do. I was able to change the syntax some to match the situation, and the chosen default map include shows up each time, but referencing another include still brings up the default, obviously I missed something. If I give you a description of the setup do you think that you could change your previously posted code to fit my setup?
It's laid out like this:
default.php contains all the code and references to the includes
/maps/ contains all the actual includes
The default include should be lodge.inc
the others would be timbukto.inc, vandownbytheriver.inc, etc
I like the idea of hiding the actual .inc extension in the URL, that just makes sense so a URL would be:
default.php?location=lodge
I made some changes to what was posted, but like I said something is missing.
Actually, I think my confusion is in the first line, and where that is referenced.
<?php include("googlekey.inc"); ?>
<?php $_GET['location'] = 'lodge';
$pattern = '/^[a-zA-Z0-9]+$/';
$mapsDir = 'maps';
$default = $mapsDir.'/lodge';
if(
!isset($_GET['location']) ||
!preg_match($pattern, $_GET['location']) ||
!file_exists($mapsDir.'/'.$_GET['location'].'.inc')
)
include($defaultMap);
else
include($mapsDir.'/'.$_GET['location'].'.inc'); ?>
If anyone is interested, the includes for the maps are in the head of the page and contain some javascript edited to show the correct long/latitude with the pop-up bubble containing pictures, address info, links, etc. The googlekey is specific to the domain, so to keep it portable I included it as a seperate include.
You can do this with XML and all that... but usually those are multiple locations on the same map... I just want a close up view for each site with driving instructions, etc. Our locations are pretty fixed 😃 so I think getting the geocode info and making a custom location.inc for each won't be that big of a deal. I just want to have the one page and be able to reference through the URL the locale. 😉
Thanks for the ideas everyone...