public function downloadImage() { $urlSource = $_POST['url']; $crawlerId = $_POST['crawler']; if (empty($urlSource)) { return false; } if (empty($crawlerId)) { return false; } $crawlerModel = new CrawlerModel(); $crawlerInfo = $crawlerModel->getCrawlerInfo($crawlerId); $source = $crawlerModel->getSourceById($crawlerInfo['source_type']); if (!$source) { echo 'Crawler source not found'; header("HTTP/1.0 404 Not Found"); exit; } $class = '\\Krikke\\Crawler\\Controller\\Crawlers\\' . ucfirst($source['source']); $controller = new $class(); $imgSrc = $controller->getImage(false); $imagePath = $controller->downloadImage($imgSrc, $crawlerId); $model = new GalleryModel(); $itemId = $model->insertTempFetchedImage(array('path' => $imagePath, 'crawler_id' => $crawlerId, 'url_source' => $urlSource)); if (isset($imgSrc['more-sources']) && !empty($imgSrc['more-sources'])) { $this->saveSources($imgSrc['more-sources'], $crawlerId, $source['id']); } exit; }