function google_get_mymaps_kml_feed($url) { $cache_key = "mymaps_kml_" . md5($url); $cache = cache_get($cache_key); if ($cache['ok']) { return $cache['data']; } $parts = utils_parse_url($url); if (!google_is_mymaps_hostname($parts['host'])) { return null; } if ($parts['path'] != '/maps/ms') { return null; } $query = array(); foreach (explode("&", $parts['query']) as $q) { list($key, $value) = explode("=", $q, 2); $query[$key] = $value; } if (!$query['msid']) { return null; } $query['output'] = 'kml'; $feed_url = "http://{$parts['host']}{$parts['path']}?" . http_build_query($query); # cache_set($cache_key, $feed_url, "cache locally"); return $feed_url; }
$GLOBALS['smarty']->display('page_upload3.txt'); exit; } # # Confirmation and/or remote fetching # $ok = 1; $GLOBALS['smarty']->assign_by_ref('parsed_url', $parsed); $GLOBALS['smarty']->assign('url', $url); # Is this remote URL special? $is_flickr = 0; $is_google = 0; if (preg_match("/(www\\.)?flickr\\.com/", $parsed['host'])) { $is_flickr = 1; } else { if (google_is_mymaps_hostname($parsed['host'])) { $is_google = 1; } else { } } $GLOBALS['smarty']->assign("is_flickr", $is_flickr); $GLOBALS['smarty']->assign("is_google", $is_google); # If it's from Flickr then parse out what kind of Flickr URL # we're parsing because we only support sets right now. if ($is_flickr) { list($flickr_type, $ignore) = import_flickr_url_type($url); $GLOBALS['smarty']->assign_by_ref("flickr_url_type", $flickr_type); if ($flickr_type != 'set') { $ok = 0; $GLOBALS['error']['invalid_flickr_type'] = 1; }
} # $url = request_str("url"); $loggedin_url = "{$GLOBALS['cfg']['abs_root_url']}upload/mymaps/"; if ($url) { $loggedin_url .= "?url=" . urlencode($url); } login_ensure_loggedin($loggedin_url); # $crumb_key = 'upload'; $GLOBALS['smarty']->assign("crumb_key", $crumb_key); # $ok = 1; if ($url) { $parsed_url = utils_parse_url($url); if (!google_is_mymaps_hostname($parsed_url['host'])) { $GLOBALS['error']['not_mymaps'] = 1; $ok = 0; } $GLOBALS['smarty']->assign("url", $url); $GLOBALS['smarty']->assign("scrubbed_url", utils_scrub_url($url)); $GLOBALS['smarty']->assign("parsed_url", $parsed_url); } if ($url && $ok) { $feed_url = google_get_mymaps_georss_feed($url); # Note: this is a place where things may break if the GOOG # takes too long to return data. Just something to keep in # mind. if ($feed_url) { $feed_title = google_get_mymaps_title($feed_url); $GLOBALS['smarty']->assign("feed_title", $feed_title);