Automatically exported from code.google.com/p/planningalerts
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

17 anos atrás
17 anos atrás
17 anos atrás
17 anos atrás
17 anos atrás
17 anos atrás
17 anos atrás
17 anos atrás
17 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. $this->easting = $xy[0];
  36. $this->northing = $xy[1];
  37. } else {
  38. $latlng = new LatLng($_GET['lat'], $_GET['lng']);
  39. $xy = $latlng->toOSRef();
  40. $this->easting = $xy->easting;
  41. $this->northing = $xy->northing;
  42. }
  43. $this->area_size = $_GET['area_size'];
  44. $this->applications = Applications::query($this->easting, $this->northing, alert_size_to_meters($this->area_size));
  45. }
  46. }
  47. //Bind
  48. function bind () {
  49. //page vars
  50. $form_action = $_SERVER['PHP_SELF'];
  51. header("Content-Type: text/xml");
  52. //smarty
  53. $smarty = new Smarty;
  54. $smarty->force_compile = true;
  55. $smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
  56. $smarty->assign("warnings", $this->warnings);
  57. $smarty->assign("applications", $this->applications);
  58. //Render
  59. $smarty->display('rss.tpl');
  60. }
  61. //howto
  62. function howto() {
  63. $form_action = $_SERVER['PHP_SELF'];
  64. $smarty = new Smarty;
  65. $smarty->force_compile = true;
  66. $smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
  67. $smarty->assign("page_title","API");
  68. $smarty->assign("menu_item","api");
  69. $smarty->display('apihowto.tpl');
  70. }
  71. }
  72. ?>