PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/xml_data_provider.php

https://bitbucket.org/leow/openautoclassifieds-14-stable
PHP | 66 lines | 31 code | 8 blank | 27 comment | 6 complexity | eb8913a7f85c9686ed5761c815322cc4 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?PHP
  2. //================================================================================
  3. // PLEASE DO NOT REMOVE THIS HEADER!!!
  4. //
  5. // COPYRIGHT NOTICE
  6. // This script is licensed under the GPL
  7. //
  8. // Copyright 2007-2008 Alias 454 Studios and Brandon Keep (c) All rights reserved.
  9. // Created 11/18/2007
  10. // Brandon Keep, http://www.openautoclassifieds.com
  11. // http://www.alias454studios.com/scripts/
  12. //
  13. // Last Modified 10-11-2008 by
  14. // Brandon Keep, http://alias454studios.com
  15. //================================================================================
  16. // This software IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. // OTHER DEALINGS IN THE SOFTWARE.
  23. //================================================================================
  24. require_once './Includes/configs/functions.php';
  25. header("Content-type: text/xml");
  26. // get query string params
  27. if (!empty($_GET['filter'])) {
  28. $filter = codeClean($_GET['filter']);
  29. $manufacturer = $filter;
  30. $haystack = getSearchList("make");
  31. }
  32. $xml = '';
  33. if (!empty($haystack)) {
  34. $xml = $xml . "<manufacturer name=\"$manufacturer\">";
  35. $xml = $xml . "<model id=\"\">Choose Model</model>";
  36. // loop through the haystack that has been passed in
  37. foreach ($haystack as $key => $arr) {
  38. // check to make sure that the element is an array
  39. if(is_array($arr)) {
  40. if (in_array("$filter",$arr)) {
  41. // build xml content for client JavaScript
  42. $sql = "SELECT DISTINCT model FROM listings WHERE make = '" . $manufacturer . "' ";
  43. $res = mysql_query($sql) or die(mysql_error());
  44. while ($a_row = mysql_fetch_array($res)) {
  45. $xml = $xml . "<model id=\"$a_row[model]\">$a_row[model]</model>";
  46. }
  47. }
  48. }
  49. }
  50. $xml = $xml . "</manufacturer>";
  51. } else {
  52. $xml = $xml . "<manufacturer name=\"$manufacturer\">";
  53. $xml = $xml . "<model id=\"\">Choose Model</model>";
  54. $xml = $xml . "</manufacturer>";
  55. }
  56. // send xml to client
  57. print "$xml";
  58. ?>