Automatically exported from code.google.com/p/planningalerts
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

17 роки тому
17 роки тому
17 роки тому
17 роки тому
17 роки тому
17 роки тому
17 роки тому
17 роки тому
17 роки тому
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. require_once ("config.php");
  3. require_once ("phpcoord.php");
  4. $api = new api;
  5. class api {
  6. //Properties
  7. var $warnings = "";
  8. var $easting = 0;
  9. var $northing = 0;
  10. var $area_size = 0;
  11. var $applications;
  12. //Constructor
  13. function api() {
  14. if (isset($_GET['howto'])){
  15. $this->howto();
  16. } else {
  17. $this->setup();
  18. $this->bind();
  19. }
  20. }
  21. //setup
  22. function setup (){
  23. //Grab the postcode and area size from the get string
  24. if (!isset($_GET['area_size'])){ //check is_numeric and isn't too big
  25. $this->warnings .= "No area size specified ";
  26. }
  27. if (!(isset($_GET['lat']) && isset($_GET['lng']))
  28. || !(isset($_GET['postcode'])) ) {
  29. $this->warmings .= "No location specified ";
  30. }
  31. if ($this->warnings == ""){
  32. //Get OS ref from postcode
  33. if (isset($_GET['postcode'])) {
  34. $xy = postcode_to_location($_GET['postcode']);
  35. } else {
  36. $latlng = new LatLng($_GET['lat'], $_GET['lng']);
  37. $xy = $latlng->toOSRef();
  38. }
  39. $this->easting = $xy->easting;
  40. $this->northing = $xy->northing;
  41. $this->area_size = $_GET['area_size'];
  42. $this->applications = Applications::query($this->easting, $this->northing, alert_size_to_meters($this->area_size));
  43. }
  44. }
  45. //Bind
  46. function bind () {
  47. //page vars
  48. $form_action = $_SERVER['PHP_SELF'];
  49. header("Content-Type: text/xml");
  50. //smarty
  51. $smarty = new Smarty;
  52. $smarty->force_compile = true;
  53. $smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
  54. $smarty->assign("warnings", $this->warnings);
  55. $smarty->assign("applications", $this->applications);
  56. //Render
  57. $smarty->display('rss.tpl');
  58. }
  59. //howto
  60. function howto() {
  61. $form_action = $_SERVER['PHP_SELF'];
  62. $smarty = new Smarty;
  63. $smarty->force_compile = true;
  64. $smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
  65. $smarty->assign("page_title","API");
  66. $smarty->assign("menu_item","api");
  67. $smarty->display('apihowto.tpl');
  68. }
  69. }
  70. ?>