$image = curl_exec($ch); curl_close($ch); // Echo Image header('Content-Length: ' . count($image)); echo $image; }); // Synchronize sites.xml to Database $app->get('/synchronize', function () use($app, $entityManager) { checkAdmin(); SitesXMLManager::synchronize($entityManager); echo json_encode(array('error' => 'success')); }); // Delete everything from database $app->get('/deleteAll', function () use($app, $entityManager) { checkAdmin(); SitesXMLManager::deleteAll($entityManager); echo json_encode(array('error' => 'success')); }); // Create $app->post('/whitelist', function () use($app, $entityManager) { checkLoggedIn($app, $entityManager); $fullUrl = $app->request->params('url'); if (!preg_match("/\\b[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $fullUrl)) { // Wrong URL Format $app->response->setStatus(400); die(json_encode(array('error' => 'wrong url format'))); } if ($fullUrl == NULL || trim($fullUrl) === '') { // Insufficient Parameters $app->response->setStatus(400); die(json_encode(array('error' => 'insufficient paramters')));