/xml_data_provider.php
PHP | 66 lines | 31 code | 8 blank | 27 comment | 6 complexity | eb8913a7f85c9686ed5761c815322cc4 MD5 | raw file
Possible License(s): GPL-2.0
- <?PHP
- //================================================================================
- // PLEASE DO NOT REMOVE THIS HEADER!!!
- //
- // COPYRIGHT NOTICE
- // This script is licensed under the GPL
- //
- // Copyright 2007-2008 Alias 454 Studios and Brandon Keep (c) All rights reserved.
- // Created 11/18/2007
- // Brandon Keep, http://www.openautoclassifieds.com
- // http://www.alias454studios.com/scripts/
- //
- // Last Modified 10-11-2008 by
- // Brandon Keep, http://alias454studios.com
- //================================================================================
- // This software IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- // OTHER DEALINGS IN THE SOFTWARE.
- //================================================================================
-
- require_once './Includes/configs/functions.php';
- header("Content-type: text/xml");
-
- // get query string params
- if (!empty($_GET['filter'])) {
- $filter = codeClean($_GET['filter']);
- $manufacturer = $filter;
- $haystack = getSearchList("make");
- }
-
- $xml = '';
- if (!empty($haystack)) {
- $xml = $xml . "<manufacturer name=\"$manufacturer\">";
- $xml = $xml . "<model id=\"\">Choose Model</model>";
-
- // loop through the haystack that has been passed in
- foreach ($haystack as $key => $arr) {
- // check to make sure that the element is an array
- if(is_array($arr)) {
- if (in_array("$filter",$arr)) {
- // build xml content for client JavaScript
-
- $sql = "SELECT DISTINCT model FROM listings WHERE make = '" . $manufacturer . "' ";
- $res = mysql_query($sql) or die(mysql_error());
-
- while ($a_row = mysql_fetch_array($res)) {
- $xml = $xml . "<model id=\"$a_row[model]\">$a_row[model]</model>";
- }
- }
- }
- }
- $xml = $xml . "</manufacturer>";
- } else {
- $xml = $xml . "<manufacturer name=\"$manufacturer\">";
- $xml = $xml . "<model id=\"\">Choose Model</model>";
- $xml = $xml . "</manufacturer>";
- }
-
- // send xml to client
- print "$xml";
-
- ?>