/** * Сачати картинку за вказану дату * @param $timestamp * */ function getOneMap($timestamp) { ini_set("allow_url_fopen", 1); $dYear = date('Y', $timestamp); $dMonth = date('m', $timestamp); $dDay = date('d', $timestamp); // http://mediarnbo.org/wp-content/uploads/2014/08/13-08.jpg // http://mediarnbo.org/wp-content/uploads/2014/08/15-08.jpg $url = SOURCE_LINK . $dYear . '/' . $dMonth . '/'; $imgName = $dDay . '-' . $dMonth . '.jpg'; $handle = fopen(ERRORS_FILE, 'w'); // file to write errors $source = getFilenameOnDiskBig($timestamp); $target = getFilenameOnDiskSml($timestamp); try { copy($url . $imgName, PATH_SAVE . $source); } catch (Exception $e) { $s = "Not exist: " . $url . $imgName . "\n"; fwrite($handle, $s); } // wln($url.$imgName); sleep(1); if (file_exists(PATH_SAVE . $source)) { resize(SML_IMG_WIDTH, PATH_SAVE . $target, PATH_SAVE . $source); echo '<img src="' . HOST . 'img/photos/' . $target . '"/>'; } else { print_r("Not exist: " . $url . $imgName . "\n"); } fclose($handle); }
<?php /** * Created by PhpStorm. * User: xain * Date: 28.02.2016 * Time: 23:25 * * The Script check the photos for last week and upload missed */ require "lib.php"; $weekAgo = time() - ONE_DAY * 7; print_r(">>>file: check-maps.php >>> \r\n <br>"); print_r("ATO MAP. Сheck downloaded images" . "\r\n <br>"); for ($i = 0; $i < 7; $i++) { $timestamp = $weekAgo + ONE_DAY * $i; $bigMapFile = getFilenameOnDiskBig($timestamp); $smlMapFile = getFilenameOnDiskSml($timestamp); //print_r(PATH_SAVE.$bigMapFile . "\n"); if (!file_exists(PATH_SAVE . $bigMapFile)) { $sourceMapFile = getLinkToSourceFile($timestamp); copy($sourceMapFile, PATH_SAVE . $bigMapFile); resize(SML_IMG_WIDTH, PATH_SAVE . $smlMapFile, PATH_SAVE . $bigMapFile); print_r($i . '. Save img: ' . $bigMapFile . "\n <br>"); } else { print_r($i . '. File exist: ' . $bigMapFile . "\n <br>"); } }