Location: PHPKode > scripts > Uda Iskariot > uda-iskariot/uda_iskariot.class.php
<?
/******************************************************************
This class is for free for any allowed by your low use.
During using link at author (http://trader.poltav.com) is required.
By "AS IS" license.
Copyright Kaurov Eugene (Ukraine) hide@address.com
*******************************************************************/

class uda_iskariot
{

	var $font_size  = 2; 		//size of fonr for output text
	var $ka_string 	= 'no text is specifed'; 		//output text
	var $img_type	= ""; 		// output image type: jpeg, jpg, png
	var $bg_color	='#ffffff'; //background color
	var $textcolor	='#000000'; // textcolor

	function uda_iskariot($string='',$fontsize=2,$bg='#ffffff', $color='#000000')
	{
		$this->font_size 	= $fontsize;
		if (!empty($string))
		   $this->ka_string	= $string;
		$this->bg_color  	= $this->hex2rgb($bg);
		$this->textcolor  	= $this->hex2rgb($color);
	}

	function uda_drow()
	{
		$img_width 		= imagefontwidth($this->font_size) * strlen($this->ka_string);
		$img_height 	= imagefontheight($this->font_size);
		$img_bolv 		= @imagecreate ($img_width,$img_height);
		$string_color 	= imagecolorallocate ($img_bolv, $this->textcolor[R], $this->textcolor[G], $this->textcolor[B]);
		$bg_color 		= imagecolorallocate ($img_bolv, $this->bg_color[R],  $this->bg_color[G],  $this->bg_color[B]);
		imagefill ( $img_bolv, 0, 0, $bg_color );
		imagestring ( $img_bolv, $this->font_size, 0, 0, $this->ka_string, $string_color );
		return $img_bolv;
		imagedestroy($img_bolv);
	}
	

	function display_mail($type='JPEG')
	{
		$this->img_type = strtolower($type);
		$this->img = $this->uda_drow();
		if (($this->img_type=='jpeg')||($this->img_type=='jpg'))
		{
			header("Content-type: image/jpeg");
			imagejpeg($this->img);
		}elseif ($this->img_type=='png')
			{
				header("Content-type: image/png");
				imagepng($this->img);
			}
	}

	function hex2rgb($color)
	{
		$color = str_replace('#', '', $color);
		$rgb_c = array
		(
			'R'=>hexdec(substr($color, 0, 2)),
			'G'=>hexdec(substr($color, 2, 2)),
			'B'=>hexdec(substr($color, 4, 2))
		);
		return $rgb_c;
	}

	
}
?>
<?
/*
sample of using:
I recommend to do it in such way
//****************** mysql table's structure
mysql_query("
			CREATE TABLE tr_firms
			(
                id int(12)   NOT NULL auto_increment,
 				f_mail       varchar(120) default NULL,
				PRIMARY KEY (id)
			)
			");
//*****************



//****************** html code at clien page:
<img src="hide_mail.php?id=10"> //only pictures width e-mail

//or (if you want allow send e-mail by one click)
print"<a href='./hide_mail.php?id=1&action=send' target=mailto_frame><img src='./hide_mail.php?id=1' border=0></a><IFRAME NAME='mailto_frame' width='0' height='0'></IFRAME>";
//******************

//****************** code of using class:
$tmp=@mysql_result(mysql_query("SELECT f_mail FROM tr_firms WHERE id='$id'"));
if ($tmp)
{
	//your variable $tmp is text, for example 'hide@address.com'
	include("uada_iskariot.class.php");
	$delo = new uda_iskariot($tmp,2,'#ffffff','#000000');
	$delo->display_mail();
}
//******************
*/

/*In Ukaraine
Äîðîã³ áðàòè-óêðà¿íö³! Öå ì³é ïåðøèé ñêðèïò íà php_classes, àëå ÿ ñïîä³âàþñÿ,
â³í áóäå âàì êîðèñíèé. Íàñ, óêðà¿íö³â, äóæå ìàëî ³ âíåñîê íàø ó ðîçâèòîê
²Ò-³íäóñò𳿠íàäçâè÷àéíî ìàëèé, ïðîòå ÿ ñïîä³âàþñÿ, ç Áîæîþ äîïîìîãîþ ³ ìè ñòàíåìî
â³äîìèìè ³ äîñÿãíåìî óñï³õó.

Äàíèé ñêðèïò çàõèùຠe-mail àäðåñè â³ä ñïàìåð³â-çáèðà÷³â áàç. Ñóòü ó òîìó, ùî
äóæå ÷àñòî íåîáõ³äí³ àäðåñè ìè çáåð³ãàºìî â mySQL-áàçàõ, â³äïîâ³äíî ìîæåìî
îòðèìóâàòè ¿õ çâ³äòè áåç â³äîìà ê볺íò³â. Çàëèøàºòüñÿ ëèøå çàáåçïå÷èòè â³äâ³äóâà÷à
çðó÷íèì ³ áåçïå÷í³ì â³ä ñïàìåð³â ñïîñîáîì. ß ïðîïîíóþ ïîêàçóâàòè éîãî ó âèãëÿä³
ìàëþíêó- òîä³ éîãî ìîæíà õ³áà â³äñêàíóâàòè (à öå äîñèòü âàæêî). Àëå ÿêùî ò³ëüêè
òàê ³ çàëèøèòè, òîä³ â³äâ³äóâà÷ó íåìຠìîæëèâîñò³ ïèñàòè ëèñòè îäíèì êë³êîì. Òîìó
ïðè êë³ö³ íà ë³íêó ÿ îêðåìèì ñêðèïòîì ôîðìóþ õ³äåð Header("Location: mailto:$tmp");
ùî ³ çàáåçïå÷óº çðó÷íå ïîñëàííÿ. Äëÿ òîãî, ùîá íå â³äêðèâàëîñÿ íîâå â³êíî, ïðîïèñóºìî
ôðåéì <IFRAME NAME='mailto_frame' width='0' height='0'></IFRAME>.
Ñàìå â³í ³ ñòàíîâèòü íà äàíèé ÷àñ íåáåçïåêó, ïðîòå íåçíà÷íó: ùîá çàõîïèòè e-mail
ñïàìåðó ñïî÷àòêó äîâåäåòüñÿ ïðî³í³ö³àë³çóâàòè êë³ê ïî ññèëö³.

Íåõàé çáåðåæå Ãîñïîäü íàøó äåðæàâó â³ä â³éíè!
15.11.2004ð.
************/
?>
Return current item: Uda Iskariot