Semnatura dinamica (PHP)

O semnatura dinamica pentru forum, email sau unde este nevoie.. poate chiar si ca banner.

Cum functioneaza?

Fisierul .htaccess ii spune Apache-ului ca in folderul respectiv orice fisier cu extensia PNG il va rula ca fiind unul PHP. Scriptul foloseste libraria GD2 din PHP. Asa ca faci un fisier signature.txt, dai copy / paste la scriptul PHP, salvezi si apoi modifici extensia din TXT in PNG.

.htaccess

<Files *.png>
ForceType application/x-httpd-php
</Files>

signature.png

<?php
mysql_connect('localhost', 'utilizator', 'parola');
mysql_select_db('numele_bazei_de_date');

header("Content-type: image/png");
header("Content-Disposition: inline; filename=sig.png;");

$image = imagecreatefrompng('sig.png'); 
$clr_black = imagecolorallocate($image, 0, 0, 0); 
$query = "SELECT post_title 
		  FROM wp_posts 
		  WHERE post_status = 'publish' 
		  ORDER BY id DESC 
		  LIMIT 5"; 
$result = mysql_query($query); 
$font = 3; 
$font2 = 2;
$font3 = 2;
$x_pos = 10; 
$y_inc = 3;
$x_pos2 = 285; 
$y_inc2 = 3; 
$x_pos3 = 10; 
$y_inc3 = 12; 
$line_number = 1; 
imagestring($image, $font, $x_pos, $y_inc, 'ADRESA_WEBSITE_PERSONAL', $clr_black); 
while ($row = mysql_fetch_array($result)) 
{ 
	$line_number++; 
	imagestring($image, $font3, $x_pos3, $y_inc3 * $line_number, $row['post_title'], $clr_black); 
} 
imagepng($image);
imagedestroy($image);

De aici descarci imaginea sig.png.

Intrebari / sugestii?!

3 thoughts on “Semnatura dinamica (PHP)”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.