function import_data_files()
{
    $url = urldecode($_GET['url']);
    $type = urldecode($_GET['type']);
    $name = urldecode($_GET['name']);
    /*
     * Catch any warnings generated into an error message.
     */
    ob_start();
    $contents = WebTools::do_get_request($url);
    $msg = ob_get_contents();
    ob_end_clean();
    if ($msg == null) {
        // OK to proceed!
        if (is_google_spreadsheet($url, $type)) {
            scrape_google_spreadsheet($url, $type, $contents, $name);
        } else {
            if (is_json($type)) {
                scrape_json($url, $type, $contents, $name);
            } else {
                if (is_exhibit($type)) {
                    scrape_exhibit($url, $contents);
                } else {
                    $links = null;
                    $errors = array("Datapress could not determine the type of data file you are trying to add.");
                    $warnings = null;
                    send_back($links, $errors, $warnings);
                }
            }
        }
    } else {
        // There was an error!
        $links = null;
        $errors = array("Datapress was not able to read the contents of the URL you linked to. Please check it and try again.");
        $warnings = null;
        send_back($links, $errors, $warnings);
    }
    die;
}
Exemple #2
0
<?php

require_once '../../../../wp-load.php';
require_once 'web-tools.php';
function is_parrotable($url)
{
    global $wpdb;
    $table = WpExhibitConfig::table_name(WpExhibitConfig::$PARROTABLE_URLS_TABLE_KEY);
    $testurl = $wpdb->get_var($wpdb->prepare("SELECT url FROM {$table} where url = %s", $url));
    $testurl = stripslashes($testurl);
    return $url == $testurl;
}
$url = urldecode($_GET['url']);
if (is_parrotable($url)) {
    $contents = WebTools::do_get_request($url);
    //$contents = file_get_contents($url);
    echo "{$contents}";
} else {
    echo "URL not parrotable";
}