]+>[^>]+>([^<]+)[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>([^<]+)[^>]+>[^>]+>([^<]+)#i"; preg_match_all($pattern, $content, $out, PREG_SET_ORDER); $dollar = ""; $euro = ""; foreach($out as $cur) { if($cur[2] == 840) $dollar = str_replace(",",".",$cur[4]); if($cur[2] == 978) $euro = str_replace(",",".",$cur[4]); } function get_content() { // Формируем сегодняшнюю дату $date = date("d/m/Y"); // Формируем ссылку $link = "http://www.cbr.ru/scripts/XML_daily.asp?date_req=$date"; // Загружаем HTML-страницу $fd = fopen($link, "r"); $text=""; if (!$fd) echo "Запрашиваемая страница не найдена"; else { // Чтение содержимого файла в переменную $text while (!feof ($fd)) $text .= fgets($fd, 4096); } // Закрыть открытый файловый дескриптор fclose ($fd); return $text; } #echo("{$date}: 1USD={$rate}RUR ({$delta})
"); $string = date("d/m/Y").": 1USD={$dollar}RUR"; $h = ImageFontHeight(2)+2; $w = ImageFontWidth(2)*strlen($string)+2; header("Content-type: image/png"); # Отдаем HTTP-заголовок с типом данных # Создаем пустое изображение $im = @ImageCreate($w, $h) or die("Cannot do ImageCreate()"); # Создаем всякие цвета $bg = ImageColorAllocate($im, 255, 255, 255); $fg = ImageColorAllocate($im, 0, 0, 0); $fg2 = ImageColorAllocate($im, 120, 0, 0); $bdr = ImageColorAllocate($im, 224,224,224); $bdr2 = ImageColorAllocate($im, 160,160,160); ImageColorTransparent($im, $bg); ImageString($im, 2, 1, 1, $string, $fg); # Отдаем изображение на выход ImagePNG($im); # Освобождаем память из-под ImageDestroy($im); ?>