예제 #1
0
<?php

$url = $_GET["url"];
if (!$url) {
    die("OOPS: You need to pass a URL!<br />");
}
require_once "../include/FOXGrabber.php";
$fetcher = new FOXGrabber();
$fetcher->grab(base64_encode($url));
echo $fetcher->return_response();
예제 #2
0
     }
     break;
 case "coordinate":
     echo json_encode(array('success' => true, 'url' => "cadastros/datasets.php?selected=1"));
     break;
 case "add":
     include_once 'urlgrabber.php';
     $iddataset = $user->getDatasetID();
     $url = isset($_POST["url"]) ? $_POST["url"] : '';
     if ($url == "" || !$iddataset) {
         die(json_encode(array('success' => false, 'message' => 'Error: no URL or dataset selected.')));
     }
     if (strpos($url, '://') === false) {
         $url = 'http://' . $url;
     }
     if (!FOXGrabber::parse_url($url, $segmentos)) {
         die(json_encode(array('success' => false, 'message' => 'Error: unable to parse URL.')));
     }
     $sql = sprintf("SELECT * FROM document WHERE dataset_id = %s AND url = '%s'", $iddataset, addslashes($url));
     if ($db->query($sql)) {
         if ($db->rows()) {
             die(json_encode(array('success' => false, 'message' => 'Error: document already exists.')));
         }
     } else {
         die(json_encode(array('success' => false, 'message' => 'Error: unable to execute query.')));
     }
     $sql = sprintf("INSERT INTO document (dataset_id, url) Values (%s,'%s');", $iddataset, addslashes($url));
     if ($db->query($sql)) {
         die(json_encode(array('success' => true, 'message' => 'Page added successfully.')));
     } else {
         die(json_encode(array('success' => false, 'message' => 'Error: unable to execute statement.')));