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;
}
function utils_scrub_url($url)
{
    $parts = utils_parse_url($url);
    $query = array();
    foreach (explode("&", $parts['query']) as $q) {
        list($key, $value) = explode("=", $q);
        $query[$key] = $value;
    }
    $url = "{$parts['scheme']}://{$parts['host']}{$parts['path']}?";
    $url .= http_build_query($query);
    return $url;
}
Beispiel #3
0
                $pre_process['errors'] = $_errors;
            }
            $GLOBALS['smarty']->assign_by_ref("pre_process", $pre_process);
            # store the file somewhere in a pending bin?
        }
    }
} else {
    if ($crumb_ok && post_str('url')) {
        $url = post_str('url');
        # Can I even upload by URL?
        if (!$GLOBALS['cfg']['enable_feature_import_by_url']) {
            $GLOBALS['error']['uploads_by_url_disabled'] = 1;
            $smarty->display("page_upload_disabled.txt");
            exit;
        }
        $parsed = utils_parse_url($url);
        $ok = $parsed['ok'];
        # dumper($parsed);
        $error_details = '';
        if ($ok && !in_array($parsed['scheme'], array('http', 'https'))) {
            $error_details = 'Invalid scheme. Only http and https are currently supported.';
            $ok = 0;
        }
        if ($ok && !$parsed['host']) {
            $error_details = 'Missing or invalid hostname.';
            $ok = 0;
        }
        # Check to make sure there is a path ?
        if ($ok && is_array($GLOBALS['cfg']['import_by_url_blacklist'])) {
            if (in_array($parsed['host'], $GLOBALS['cfg']['import_by_url_blacklist'])) {
                $error_details = 'Uploads not allowed from host.';
    exit;
}
#
$url = request_str("url");
$loggedin_url = "{$GLOBALS['cfg']['abs_root_url']}upload/flickr/";
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 (!preg_match("/(www\\.)?flickr\\.com/", $parsed_url['host'])) {
        $GLOBALS['error']['not_flickr'] = 1;
        $ok = 0;
    }
    $GLOBALS['smarty']->assign("url", $url);
    $GLOBALS['smarty']->assign("parsed_url", $parsed_url);
}
if ($url && $ok) {
    $feed_url = flickr_get_georss_feed($url);
    if (!$feed_url) {
        $GLOBALS['error']['no_feed_url'] = 1;
        $ok = 0;
    }
}
#