exit; } if (!isset($_GET['action']) || !isset($_GET['title'])) { die('Invalid request'); } $action = $_GET['action']; $title = $_GET['title']; header('Content-type: application/json'); switch ($action) { case 'exists': try { $exists = $ct->pageExists($title); } catch (Exception $e) { echo json_encode(array('error' => $e->getMessage(), 'title' => $title)); exit; } echo json_encode(array('exists' => $exists, 'title' => $title)); exit; case 'metadata': echo json_encode($ct->fetchImage($title)); exit; case 'analyzepage': echo json_encode($ct->analyzePage($title)); exit; case 'locateBorder': $info = $ct->fetchImage($title); $bl = new BorderLocator($info['original']['name']); $area = $bl->selection; echo json_encode(array('area' => $area)); exit; }