4 * Fetch the list of links in the given URL as well as their ping status.
5 * Tells you if it was pinged, and what result it had.
8 require_once '../www-header.php';
9 header('Access-Control-Allow-Origin: *');
11 if (!isset($_GET['url'])) {
12 header('HTTP/1.0 400 Bad Request');
19 'SELECT * FROM feedentries WHERE fe_url = ' . $db->quote($url)
21 $urlRow = $res->fetch(PDO::FETCH_OBJ);
22 if ($urlRow === false) {
23 header('HTTP/1.0 404 Not Found');
24 echo "Url not found\n";
27 $json = (object) array(
28 'url' => $urlRow->fe_url,
29 'updated' => $urlRow->fe_updated,
30 'needsUpdate' => (bool) $urlRow->fe_needs_update,
35 'SELECT * FROM feedentryurls'
36 . ' WHERE feu_fe_id = ' . $db->quote($urlRow->fe_id)
38 while ($linkRow = $res->fetch(\PDO::FETCH_OBJ)) {
40 if (!$linkRow->feu_pinged) {
42 } else if ($linkRow->feu_retry && $linkRow->feu_tries < 5) {
44 } else if ($linkRow->feu_error) {
45 if ($linkRow->feu_error_code == 200) {
46 $status = 'unsupported';
53 $json->links[$linkRow->feu_url] = (object) array(
54 'url' => $linkRow->feu_url,
55 'pinged' => (bool) $linkRow->feu_pinged,
56 'updated' => $linkRow->feu_updated,
58 'error' => (object) array(
59 'code' => $linkRow->feu_error_code,
60 'message' => $linkRow->feu_error_message
62 'tries' => $linkRow->feu_tries
66 header('HTTP/1.0 200 OK');
67 header('Content-type: application/json');
68 echo json_encode($json) . "\n";