Dynamische signature
Dynamische signature
Ik wil een signature gaan maken die elke keer veranderd.
Het gaat mij erop dat ik mooie quote's random kan afwisselen in mijn signature.
Ben aan het zoeken geweest naar dynamische signatures maar dan kom je al snel op die WoW signatures die laten zien hoe je game erbij staat en daar heb ik weinig aan.
Hoe kan ik zoiets realiseren?
P.S. Beetje het idee van JJapie zijn avatar en signature maar dan zonder de invoer mogelijkheid.
Het gaat mij erop dat ik mooie quote's random kan afwisselen in mijn signature.
Ben aan het zoeken geweest naar dynamische signatures maar dan kom je al snel op die WoW signatures die laten zien hoe je game erbij staat en daar heb ik weinig aan.
Hoe kan ik zoiets realiseren?
P.S. Beetje het idee van JJapie zijn avatar en signature maar dan zonder de invoer mogelijkheid.
Namasté
Dit is de mijne:
Ik heb "babelfish.ttf" en "avantgarde.ttf" in dezelfde map gezet.
En de volgende tabel in mn database
hierbij is ip,host en date niet echt nodig, dat was voor het invullen (zoals bij jjapie)
sig.php
En dan gebruik je de volgende url in phpbb:
Thats it
Ik heb "babelfish.ttf" en "avantgarde.ttf" in dezelfde map gezet.
En de volgende tabel in mn database
Code: Select all
CREATE TABLE `forum_sig` (
`id` int(11) NOT NULL auto_increment,
`sig` varchar(255) default NULL,
`ip` varchar(16) default NULL,
`host` varchar(255) default NULL,
`date` int(15) NOT NULL default '0',
KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
sig.php
Code: Select all
// eerst mysql database connecten
$link = mysql_connect("localhost", "naam", "ww");
mysql_select_db("db", $link);
//settings
$colors[0] = "#EE9999";
$colors[1] = "#99EE99";
$colors[2] = "#9999EE";
$colors[3] = "#EEEE99";
$colors[4] = "#99EEEE";
$colors[5] = "#EE99EE";
$fonts[0] = array("babelfish",18);
$fonts[4] = array("avantgarde",12);
$start_colour = "#EEEEEE";
$end_colour = "#CCCCCC";
$width = 350;
$height = 30;
//random font en grootte
srand ((float) microtime() * 10000000);
$fontNr = array_rand($fonts);
$fontFile = "./".$fonts[$fontNr][0].".ttf";
$fontSize = $fonts[$fontNr][1];
function parseColor($hex) {
$r = substr($hex,1,2);
$g = substr($hex,3,2);
$b = substr($hex,5,2);
return array(hexdec($r),hexdec($g),hexdec($b));
}
function getRandomColor() {
global $colors, $im;
srand ((float) microtime() * 10000000);
$rand_keys = array_rand($colors);
$color = $colors[$rand_keys];
list($r,$g ,$b) = parseColor($color);
return imagecolorallocate($im, $r, $g, $b);
}
// get signatures
$sql = "SELECT sig FROM forum_sig ORDER BY date DESC"; //LIMIT 10 OFFSET 0
$result = mysql_query($sql) or die ("Mysql error: ".mysql_error());
if(mysql_num_rows($result) > 0) {
while($data = mysql_fetch_array($result)) {
$sig[] = $data;
}
}
// get random out of latest ten //
srand ((float) microtime() * 10000000);
$rand_key = array_rand($sig);
$sigText = $sig[$rand_key]['sig'];
// build image //
$im = imagecreate($width, $height);
$bgc = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, $width, $height, $bgc);
// create fade
list($start_r,$start_g,$start_b) = parseColor($start_colour);
list($end_r,$end_g,$end_b) = parseColor($end_colour);
//LOOP THROUGH ALL THE PIXELS
for($y=0; $y < $height; $y++) {
//CALCULATE THIS ROWS RGB COLOURS
$new_r = $start_r - intval((($start_r - $end_r)/$height)*$y);
$new_g = $start_g - intval((($start_g - $end_g)/$height)*$y);
$new_b = $start_b - intval((($start_b - $end_b)/$height)*$y);
//ALLOCATE THE COLOR
$row_color = imagecolorresolve($im, $new_r, $new_g, $new_b);
for($x=0; $x < $width; $x++) {
//CREATE ROW OF THIS COLOR
imagesetpixel($im, $x, $y, $row_color);
}
}
// write text //
//imagestring($im, 5, 0, 0, $sigText, $color1);
list($r,$g,$b) = parseColor("#222222");
$color1 = imagecolorallocate($im,$r,$g,$b); //getRandomColor();
list($r,$g,$b) = parseColor("#BBBBBB");
$color3 = imagecolorallocate($im,$r,$g,$b);
$color2 = getRandomColor();
imagettftext($im, $fontSize, 0, 11, 26, $color3, $fontFile, $sigText);
imagettftext($im, $fontSize, 0, 6, 23, $color1, $fontFile, $sigText);
imagettftext($im, $fontSize, 0, 6, 21, $color1, $fontFile, $sigText);
imagettftext($im, $fontSize, 0, 4, 21, $color1, $fontFile, $sigText);
imagettftext($im, $fontSize, 0, 4, 23, $color1, $fontFile, $sigText);
imagettftext($im, $fontSize, 0, 5, 22, $color2, $fontFile, $sigText);
imagejpeg($im,"",98);
imagedestroy($im);
flush();
Code: Select all
[img]http://www.jaybro.nl/forum/sig.php/.png[/img]
Dat kan simpeler:
sig.php
In sigs.txt zet je de quotes:
en verder moet je nog verdana.ttf in dezelfde map gooien (of een ander lettertype, maar dan moet je het script iets aanpassen).
That's all, lekker simpel, geen gedoe moet databases..
sig.php
Code: Select all
$textfile = "sigs.txt";
srand((double)microtime()*1000000);
$sigs=file($textfile);
$nummer=rand(0, count($sigs)-1);
$text = $sigs[$nummer];
$hoeveel = strlen($text); // hoeveel letters is de tekst?
$heigth = 18;
//width berekenen
$bbox = imagettfbbox( 12, 0, "Verdana.TTF", $text);
$bbwidth = ($bbox[4] - $bbox[6]);
$width = $bbwidth + 5;
mt_srand((double)microtime() * 1000000); //Maak nieuwe random getallen
$nr1 = mt_rand(0, 254); //Nummers voor kleur, random
$nr2 = mt_rand(0, 254);
$nr3 = mt_rand(0, 254);
$im = ImageCreate($width, $heigth);
$bgcolor = imagecolorallocate ($im, 255, 255, 255);
$textcolor = imagecolorallocate ($im, $nr1, $nr2, $nr3);
ImageColorTransparent($im, $bgcolor);
imagettftext ($im, 12, 0, 0, 12, $textcolor, "Verdana.TTF", $text);
header ("Content-type: image/png");
imagepng ($im);
imagedestroy ($im);
Code: Select all
Quote 1
quote 2
quote3
That's all, lekker simpel, geen gedoe moet databases..
Last edited by JJapie on 15 Nov 2007, 21:12, edited 1 time in total.
ok thanks guys...ga er mee aan de slag
-edit-
Krijg foutmelding dat ie font niet kan openen
Heb de font netjes in folder van Signature gezet
P.S. JJapie, waarom maak je $hoeveel aan. zie die nergens terug komen.
-edit-
Krijg foutmelding dat ie font niet kan openen
Heb de font netjes in folder van Signature gezet
Code: Select all
Warning: imagettfbbox(): Could not find/open font in /var/www/vhosts/squizle.nl/httpdocs/Signature/sig.php on line 13
Namasté
Je mist de font-file, download hier. (.edit: niet dus, niet goed gelezen) Bestandsnaam kan case-sensitive zijn, dus let daarop.
Het lijkt idd alsof ik met $hoeveel niks doe, denk dat die regel er nog staat van een vorige versie toen ik nog niet met imagettfbbox() werkte..
Het lijkt idd alsof ik met $hoeveel niks doe, denk dat die regel er nog staat van een vorige versie toen ik nog niet met imagettfbbox() werkte..
Ok..zit een foutje in het script.
maar wanneer ik die } weg haal krijg ik deze melding:
Code: Select all
Parse error: syntax error, unexpected '}' in /var/www/vhosts/squizle.nl/httpdocs/Signature/sig.php on line 32
Code: Select all
Warning: imagettfbbox(): Could not find/open font in /var/www/vhosts/squizle.nl/httpdocs/Signature/sig.php on line 13
Warning: imagettftext(): Could not find/open font in /var/www/vhosts/squizle.nl/httpdocs/Signature/sig.php on line 27
Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/squizle.nl/httpdocs/Signature/sig.php:13) in /var/www/vhosts/squizle.nl/httpdocs/Signature/sig.php on line 28
�PNG ��� IHDR����������r�����PLTE����Ñ
Namasté
nee, die } moet weg.. Ik heb dit stukje script uit mijn eigen signature-script geknipt maar niet helemaal zorgvuldig dus
Script werkt hier prima, dus er gaat echt iets mis bij jou. Nogmaals, klopt de naam van het font-bestand wel? Probeer het anders eens met de absolute-url (hoofdlettergevoelig!) naar het font-bestand.
Script werkt hier prima, dus er gaat echt iets mis bij jou. Nogmaals, klopt de naam van het font-bestand wel? Probeer het anders eens met de absolute-url (hoofdlettergevoelig!) naar het font-bestand.
Code: Select all
$font = "/var/www/vhosts/squizle.nl/httpdocs/Signature/verdana.ttf";
$bbox = imagettfbbox( 12, 0, $font, $text);
nu werkt het wel. Zat hem dus toch in de naam van het font. Heb simpel verdana geprobeerd en tahoma. Met en zonder hoofdletters...alles...maar goed
nogmaals bedankt. Ga hem nu maar eens vullen
nu nog een andere vraag
graag zou ik de quote's met de volgende opmaak noteren
quote blaabla ••• auteur
hoe krijg ik dat erin? gewoon met html color tags in txt bestand werkt niet
nogmaals bedankt. Ga hem nu maar eens vullen
nu nog een andere vraag
graag zou ik de quote's met de volgende opmaak noteren
quote blaabla ••• auteur
hoe krijg ik dat erin? gewoon met html color tags in txt bestand werkt niet
Namasté
Ik heb hem even snel iets aangepast:
sig.php
sigs.txt
[img:120:18]http://www.vandonselaar.eu/test/sig2.php/.png[/img]
sig.php
Code: Select all
$textfile = "sigs.txt";
srand((double)microtime()*1000000);
$sigs=file($textfile);
$nummer=rand(0, count($sigs)-1);
$text = $sigs[$nummer];
$text = explode("|", $text);
$heigth = 18;
$width = array();
for($i=0;$i<3;$i++) //width berekenen per deel
{
$bbox = imagettfbbox( 12, 0, "Verdana.TTF", $text[$i]);
$bbwidth = ($bbox[4] - $bbox[6]);
$width[$i] = $bbwidth + 5;
}
$total_width = $width[0] + $width[1] + $width[2] + 10;
$im = ImageCreate($total_width, $heigth);
$bgcolor = imagecolorallocate ($im, 255, 255, 255);
$nr1 = array();
$nr2 = array();
$nr3 = array();
$textcolor = array();
for($i=0;$i<3;$i++)
{
mt_srand((double)microtime() * 1000000); //Maak nieuwe random getallen
$nr1[$i] = mt_rand(0, 254); //Nummers voor kleur, random
$nr2[$i] = mt_rand(0, 254);
$nr3[$i] = mt_rand(0, 254);
$textcolor[$i] = imagecolorallocate ($im, $nr1[$i], $nr2[$i], $nr3[$i]);
}
ImageColorTransparent($im, $bgcolor);
imagettftext ($im, 12, 0, 0, 12, $textcolor[0], "Verdana.TTF", $text[0]);
imagettftext ($im, 12, 0, $width[0]+3, 12, $textcolor[1], "Verdana.TTF", $text[1]);
imagettftext ($im, 12, 0, $width[0]+3+$width[1]+3, 12, $textcolor[2], "Verdana.TTF", $text[2]);
header ("Content-type: image/png");
imagepng ($im);
imagedestroy ($im);
Code: Select all
een|twee|drie
vier|vijf|zes
zeven|acht|negen
omdat ik gek ben
Code: Select all
$textfile = "sigs.txt";
srand((double)microtime()*1000000);
$sigs=file($textfile);
$nummer=rand(0, count($sigs)-1);
$text = $sigs[$nummer];
$text = explode("|", $text);
$heigth = 18;
$width = array();
for($i=0;$i<3;$i++) //width berekenen per deel
{
$bbox = imagettfbbox( 12, 0, "Verdana.TTF", $text[$i]);
$bbwidth = ($bbox[4] - $bbox[6]);
$width[$i] = $bbwidth + 5;
}
$total_width = $width[0] + $width[1] + $width[2] + 10;
$im = ImageCreate($total_width, $heigth);
$bgcolor = imagecolorallocate ($im, 255, 255, 255);
$color1r = "0";
$color1g = "128";
$color1b = "0";
$color2r = "255";
$color2g = "165";
$color2b = "0";
$color3r = "0";
$color3g = "0";
$color3b = "0";
$textcolor1 = imagecolorallocate ($im, $color1r, $color1g, $color1b);
$textcolor2 = imagecolorallocate ($im, $color2r, $color2g, $color2b);
$textcolor3 = imagecolorallocate ($im, $color3r, $color3g, $color3b);
ImageColorTransparent($im, $bgcolor);
imagettftext ($im, 12, 0, 0, 12, $textcolor1, "Verdana.TTF", $text[0]);
imagettftext ($im, 12, 0, $width[0]+3, 12, $textcolor2, "Verdana.TTF", $text[1]);
imagettftext ($im, 12, 0, $width[0]+3+$width[1]+3, 12, $textcolor3, "Verdana.TTF", $text[2]);
header ("Content-type: image/png");
imagepng ($im);
imagedestroy ($im);
<img src="http://www.squizle.nl/Signature/sig.php/.png">
Gaat prima, maar je moet een kleiner font of kortere quotes gebruiken. Je knoeit nu met de opmaak.
Kun je niet vanaf een bepaald aantal tekens een nieuwe regel doen? Of dat je dat zelf opgeeft in je text file (\n\r)?
Gaat prima, maar je moet een kleiner font of kortere quotes gebruiken. Je knoeit nu met de opmaak.
Kun je niet vanaf een bepaald aantal tekens een nieuwe regel doen? Of dat je dat zelf opgeeft in je text file (\n\r)?
Ben al op zoek naar kortere quote's. Heb de extreem langde nu verwijderd.
Snap nu ook waarom mijn sig geresized werd. Gebruikte [] ipv </>
Snap nu ook waarom mijn sig geresized werd. Gebruikte [] ipv </>
Last edited by Squizle on 16 Nov 2007, 11:04, edited 1 time in total.
Namasté