query( 'SELECT * FROM feedentries WHERE fe_url = ' . $db->quote($url) ); $urlRow = $res->fetch(PDO::FETCH_OBJ); if ($urlRow === false) { header('HTTP/1.0 404 Not Found'); echo "Url not found\n"; exit(1); } $json = (object) array( 'url' => $urlRow->fe_url, 'updated' => $urlRow->fe_updated, 'needsUpdate' => (bool) $urlRow->fe_needs_update, 'links' => array() ); $res = $db->query( 'SELECT * FROM feedentryurls' . ' WHERE feu_fe_id = ' . $db->quote($urlRow->fe_id) ); while ($linkRow = $res->fetch(\PDO::FETCH_OBJ)) { $status = null; if (!$linkRow->feu_pinged) { $status = 'queued'; } else if ($linkRow->feu_retry && $linkRow->feu_tries < 5) { $status = 'pinging'; } else if ($linkRow->feu_error) { $status = 'error'; } else { $status = 'ok'; } $json->links[] = (object) array( 'url' => $linkRow->feu_url, 'pinged' => (bool) $linkRow->feu_pinged, 'updated' => $linkRow->feu_updated, 'status' => $status, 'error' => (object) array( 'code' => $linkRow->feu_error_code, 'message' => $linkRow->feu_error_message ), 'tries' => $linkRow->feu_tries ); } header('Content-type: application/json'); echo json_encode($json) . "\n"; ?>