|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- require_once ("include/config.php");
- require_once ("phpcoord.php");
-
- $api = new api;
-
- class api {
-
- //Properties
- var $warnings = "";
- var $easting = 0;
- var $northing = 0;
- var $area_size = 0;
- var $applications;
-
- //Constructor
- function api() {
- $this->setup();
- $this->bind();
- }
-
- //setup
- function setup (){
-
- //Grab the postcode and area size from the get string
-
- if (!isset($_GET['area_size'])){ //check is_numeric and isn't too big
- $this->warnings .= "No area size specified ";
- }
- if (!(isset($_GET['lat']) && isset($_GET['lng']))
- || !(isset($_GET['postcode'])) ) {
- $this->warmings .= "No location specified ";
- }
-
- if ($this->warnings == ""){
-
- //Get OS ref from postcode
- if (isset($_GET['postcode'])) {
- $xy = postcode_to_location($_GET['postcode']);
- } else {
- $latlng = new LatLng($_GET['lat'], $_GET['lng']);
- $xy = $latlng->toOSRef();
- }
-
- $this->easting = $xy->easting;
- $this->northing = $xy->northing;
- $this->area_size = $_GET['area_size'];
-
- $this->applications = Applications::query($this->easting, $this->northing, alert_size_to_meters($this->area_size));
- }
-
- }
-
- //Bind
- function bind () {
-
- //page vars
- $form_action = $_SERVER['PHP_SELF'];
-
- header("Content-Type: text/xml");
-
- //smarty
- $smarty = new Smarty;
- $smarty->force_compile = true;
- $smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
-
- $smarty->assign("warnings", $this->warnings);
- $smarty->assign("applications", $this->applications);
-
- //Render
- $smarty->display('rss.tpl');
-
- }
-
- }
-
-
-
- ?>
|