<?php require "commonlib.php"; require "wdllib.php"; //main $site = $_REQUEST["site"]; $rawdatafile = $site . "/clientraw.txt"; $csv = uwe_get_file($rawdatafile); $data = explode(' ', $csv); // generate the RSS print <<<EOT <?xml version="1.0"?> <rss version="2.0"> <channel> <title>{$data[STATION]}</title> <link>{$site}</link> <item> <title>Weather at {$data[TIMEHH]}:{$data[TIMEMM]}</title> <description> {$data[SUMMARY]} . Wind {$data[WINDSPEED]} knots from {$data[WINDDIRECTION]} degrees. Temperature {$data[TEMPERATURE]} °C. </description> </item> </channel> </rss> EOT; ?>
//search and replace '/' with %252F $input = str_replace(" ", "%20", $input); //search and replace " " with %20 $input = str_replace("?", "%3F", $input); //search and replace '?' with %3F return $input; } //url used for retrieving JSON feed. Includes POST data for ['artist'] and ['radius'], also includes client ip ($_SERVER['REMOTE_ADDR']) to localise data. $jsonurl = "http://api.bandsintown.com/artists/" . urlencode_s($_POST['artist']) . "/events/search.json?api_version=2.0&app_id=housemd&location=" . $_SERVER['REMOTE_ADDR'] . "&radius=" . $_POST['radius']; //error handling if (uwe_get_file($jsonurl) === false) { //if JSON output empty $json = NULL; } else { //if JSON has data $json = uwe_get_file($jsonurl); } echo '<div id="events-container">'; if ($json != NULL) { $json_output = json_decode($json, true); //json_decode($json, true) converts object data in JSON output to arrays if (is_array($json_output) && count($json_output) > 1) { //if JSON output contains + 0 arrays foreach ($json_output as $item) { //foreach element in $json_output as $item echo '<div id="' . $item['id'] . '" class="event">'; echo $item['formatted_datetime'] . '<br />'; //print datetime echo $item['formatted_location'] . '<br />'; //print location if ($item['ticket_status'] == 'available') {