"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; ?> "; echo ""; echo "
"; echo "
"; echo "

SeasonGenerator

"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo ""; echo "
"; echo "
"; echo "
"; echo ""; echo ""; //////////////////////////////////////////////// } //////////////////////////////////////////////// //////////////////////////////////////////////// if(!$error){ //////////////////////////////////////////////// if($_POST['url']){ $url = $_POST['url']; } // CURL WEBSITE HOLEN $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $html_sourcecode = curl_exec($ch); curl_close($ch); //echo $html_sourcecode; // BY ROW /* $explode = explode("\n", $html_sourcecode); echo "
";
print_r($explode);
echo "
"; $filename = $html_sourcecode; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); $rows = explode("\n",$contents); $data_array = array(); for($i=0;$iloadHTML($html_sourcecode); $imgs = $dom->getElementsByTagName('img'); // Store the list of image urls in an array - this will come in handy later $imgURLs = []; foreach($imgs as $img) { if (!$img->hasAttribute('src')) { continue; } $imgURLs[] = $img->getAttribute('src'); } // Step 2 - Save the image in a different location $newImgURLs = []; // new modified URLs where images were moved $newPath = './images'; // wherever you're saving the images foreach($imgURLs as $imgURL) { // Use parse_url and pathinfo to break down the URL parts and extract the filename/extension instead of the fragile implementation you used above $URLparts = parse_url($imgURL); $file = pathinfo($URLparts['path']); $fileName = $file['filename'] . '.' . $file['extension']; $newFileName = $newPath . '/' . $fileName; // SOURCECODE MIT NEUEN BILDERN TAUSCHEN //$newImgURLs[] = $URLparts['scheme'] . '://' . $URLparts['host'] . $file['dirname'] . '/' . $newFileName . (isset($URLparts['query']) ? ('?' . $URLparts['query']) : null) . (isset($URLparts['fragment']) ? ('#' . $URLparts['fragment']) : null); $newImgURLs[] = $newFileName . (isset($URLparts['query']) ? ('?' . $URLparts['query']) : null) . (isset($URLparts['fragment']) ? ('#' . $URLparts['fragment']) : null); // DOWNLOAD IMAGE file_put_contents($newFileName, file_get_contents($imgURL)); // EXISTS?? if (file_exists($newFileName)) { // SEASONING BILD switch($_POST['season']){ case 'spring' : $stamp = imagecreatefrompng('./spring_1.png'); break; case 'summer' : $stamp = imagecreatefrompng('./summer_1.png'); break; case 'autum' : $stamp = imagecreatefrompng('./autum_1.png'); break; case 'winter' : $stamp = imagecreatefrompng('./winter_1.png'); break; } // BILD ERSTELLEN switch($file['extension']){ case 'jpg' : $im = imagecreatefromjpeg($newFileName); break; case 'gif' : $im = imagecreatefromgif($newFileName); break; case 'png' : $im = imagecreatefrompng($newFileName); break; } // MASSE BESTIMMEN $marge_right = 0; $marge_bottom = imagesy($im) - imagesy($stamp); $watermark_x = imagesx($stamp); $watermark_y = imagesy($stamp); // SNOW AUF FOTO KOPIEREN imagecopy($im, $stamp, imagesx($im) - $watermark_x - $marge_right, imagesy($im) - $watermark_y - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp)); // BILD SPEICHERN switch($file['extension']){ case 'jpg' : imagejpeg($im, $newFileName); break; case 'gif' : imagegif($im, $newFileName); break; case 'png' : imagepng($im, $newFileName); break; } imagedestroy($im); } } // Step 3 - Modify the img src URLs to new path foreach($imgs as $i => $img) { $img->setAttribute('src', $newImgURLs[$i]); } echo $dom->saveHTML(); // new updated DOM // or just create a new $html string from scratch using the new URLs.