Simple Machines Community Forum

General Community => Scripting Help => Topic started by: Scareface on June 06, 2013, 10:22:32 AM

Title: PHP GD Image Dynamic Signature Help
Post by: Scareface on June 06, 2013, 10:22:32 AM
Hey guys can someone help me with creating dynamic signatures ?

<?php

header('Content-type: image/png');
$img = imageCreateFromPNG('bg2.png');
$fontcolor = ImageColorAllocate ($img, 0, 0, 0);
ImageString ($img, 5, 40, 11, 'ssi_latestMember()', $fontcolor);
ImagePng ($img);
?>

I want to display some information for example, latest user. So can someone explain me how to get the latest user ?
Title: Re: PHP GD Image Dynamic Signature Help
Post by: Will Sabransky on June 07, 2013, 01:47:21 PM
A few issues:


With that in mind, try something like this:


$mem_info = ssi_latestMember(null);
ImageString ($img, 5, 40, 11, $mem_info['name'], $fontcolor);
Title: Re: PHP GD Image Dynamic Signature Help
Post by: Scareface on June 08, 2013, 12:02:43 AM
Thank you it works. But few questions, why are we using Null ? and is it same like this for all functions ?
Title: Re: PHP GD Image Dynamic Signature Help
Post by: Will Sabransky on June 08, 2013, 12:11:58 AM
If you take a look at the API documentation, you'll see that ssi_latestMember() takes a single parameter that controls output type. If the string 'echo' is passed to the function, it will print the information to the user. If any other value is passed, it will return an array with the info. However, the default value for this parameter is "echo," so if you don't pass any value, it won't return anything. This is why we pass a null parameter instead.
Title: Re: PHP GD Image Dynamic Signature Help
Post by: Scareface on June 08, 2013, 04:39:00 AM
Thanks for you help. Created a script :)
Title: Re: PHP GD Image Dynamic Signature Help
Post by: Will Sabransky on June 08, 2013, 11:06:45 AM
No problem!