Показать сообщение отдельно

  #58  
Старый 27.06.2008, 16:10
NOmeR1
Познавший АНТИЧАТ
Регистрация: 02.06.2006
Сообщений: 1,188
Провел на форуме:
6023777

Репутация: 2642


Отправить сообщение для NOmeR1 с помощью ICQ
По умолчанию

Рэндомную цитату с баша - в подпись! Была уже тема, но там ничего не работало =)
Код:
<?php
	define('MAX_HEIGHT', 50); // максимальная высота картинки
	header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
	header('Cache-Control: no-store, no-cache, must-revalidate'); 
	header('Cache-Control: post-check=0, pre-check=0', FALSE); 
	header('Pragma: no-cache');
	header('Content-Type: image/png');
	function win2uni($s) {
		$s = convert_cyr_string($s, 'w', 'i');
		for($result='', $i=0; $i < strlen($s); $i++) {
			$charcode = ord($s[$i]);
			$result .= ($charcode>175)?"&#".(1040+($charcode-176)).";":$s[$i];
		}
		return $result;
	}
	function my_rand() {
		global $quotes;
		$pattern = '~<div>(?!<)(.+)</div>~sU';
		preg_match_all($pattern, file_get_contents('http://bash.org.ru/random'), $quotes); $i = 0;
		while($quotes[1][$i]) {
			$rand = win2uni( wordwrap( htmlspecialchars_decode( preg_replace('~<br\s?/?>~i', "\n", $quotes[1][$i++])), 75, "\n") );
			$array = imagettfbbox(8, 0, "trebuc.ttf", $rand);
			if(($array[1] - $array[7])+10 > MAX_HEIGHT) {
				if($quotes[1][$i]) {
					continue;
				} else {
					return my_rand();
				}
			} else {
				return array($rand, $array[2] - $array[0], $array[1] - $array[7]);
			}
		}
	}
	$n = my_rand();
	$image = imagecreatetruecolor($n[1]+10, $n[2]+10);
	imagefill($image, 0, 0, 0xF3F3F3);
	$id_color = 0;
	for($x = 0; $x <= $n[1]+9; $x++) {
		if($id_color++%5!=2) {
			imagesetpixel($image, $x, 0, 0x999999);
			imagesetpixel($image, $x, $n[2]+9, 0x999999);
		}
	}
	$id_color = 0;
	for($y = 0; $y <= $n[2]+9; $y++) {
		if($id_color++%5!=2) {
			imagesetpixel($image, 0, $y, 0x999999);
			imagesetpixel($image, $n[1]+9, $y, 0x999999);
		}
	}
	imagettftext($image, 8, 0, 5, 15, 0x000000, "trebuc.ttf", $n[0]);
	imagepng($image);
	imagedestroy($image);
?>
Скачать шрифт

Последний раз редактировалось NOmeR1; 27.06.2008 в 16:14..
 
Ответить с цитированием