コード例 #1
0
 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.')));
     }
     break;
 case "evaluate":
     $datasetID = $user->getDatasetID();
     if (!$datasetID) {