1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Signature Badge Script

Discussion in 'Other Resources [Archive]' started by Floris, Jul 31, 2010.

  1. Floris

    Floris Guest

    Eric, I see you got inspired by my signature :D
  2. Erik

    Erik Well-Known Member

    Ah, but mine is special. Like my post and refresh the page. :D

    Edit: 10/21/2010: this post no longer makes sense because I no longer have the like counter in my signature. Originally, I had an image in my signature that displayed the number of likes I had, which refreshed on each pageview. So if you liked the post and refreshed the page, you would see the like count updated.
  3. jmurrayhead

    jmurrayhead Well-Known Member

    nice :D
  4. Erik

    Erik Well-Known Member

    Gonna have to up the ante, Floris. :D :D
    AlexandrosD and a legacy reborn like this.
  5. KURTZ

    KURTZ Well-Known Member

    give us the script!!! :D
    Caleb Spilchen likes this.
  6. jmurrayhead

    jmurrayhead Well-Known Member

    Or make it dynamic so that we can plugin our details to the image URL (like username or ID) :)
    KURTZ likes this.
  7. Erik

    Erik Well-Known Member

    If I hosted this it would probably bring my shared hosting account to its knees pretty quickly. :D (I do have a VPS, but it's not ready for a production environment). Feel free to host it yourself though:

    EDIT: Oh, should probably mention requirements: PHP 5.0.0 or greater for SimpleXML support, GD, and the ability to use cURL. If the font size looks weird you probably have a different version of GD so you may need to adjust the font size (try 35). :)

    // XenForo signature generator by Erik Swan :)

    function getPage($url){
    $ch curl_init();
    curl_setopt($chCURLOPT_USERAGENT'XenForo Signature Generator by Eriksrocks');

    $username   'eriksrocks';
    $userid     '103';

    $page getPage('http://xenforo.com/community/members/' $username '.' $userid '/mini-stats.xml');
    $xml simplexml_load_string($page);
    $likes $xml->total_likes;
    $trophies $xml->trophy_points;

    $font 'square.ttf';
    $size 27;
    $x1 45;
    $x2 136;
    $y 43;
    $width 198;
    $height 76;
    $kerning 3;

    // DRAW

    $final imagecreatefrompng("sigbackground.png");
    $black imagecolorallocate($final000);

    imagealphablending($finaltrue); // setting alpha blending on
    imagesavealpha($finaltrue); // save alphablending setting (important)

    $array str_split($likes);
    $hpos $x1;

    $i=0$i<count($array); $i++)
    $bbox imagettftext$final$size0$hpos$y$black$font$array[$i] );
    $hpos intval($bbox[2])+$kerning;

    $array str_split($trophies);
    $hpos $x2;

    $i=0$i<count($array); $i++)
    $bbox imagettftext$final$size0$hpos$y$black$font$array[$i] );
    $hpos intval($bbox[2])+$kerning;

    // OUTPUT

    header('Content-type: image/png');
    Here is the image you need:
    You'll have to get the XenForo font yourself, sorry. :)

    Enjoy! :D
  8. Kier

    Kier XenForo Developer Staff Member

    Good grief that's a lot of code to do something very simple... How about just fetching http://xenforo.com/community/members/kier.2/mini-stats.xml ? :D
  9. p4guru

    p4guru Well-Known Member

  10. Lawrence

    Lawrence Well-Known Member

    Actually, having the options to select certain elements to be displayed in ones signature is a pretty good idea. Admins can set which elements are allowed, and users can select from those. ie: trophies, likes.
  11. Kier

    Kier XenForo Developer Staff Member

    I just split this stuff into a new thread.
  12. Kevin

    Kevin Well-Known Member

    Michael Dance likes this.
  13. Kier

    Kier XenForo Developer Staff Member

    I don't see why not.
  14. Kevin

    Kevin Well-Known Member

    Excellent! For stuff like v3 Arcade it'd be nice to toss up the number of Arcade awards the member has into the results.
    Brandon Sheley likes this.
  15. Erik

    Erik Well-Known Member

    Thanks, Kier, I was kind of confused there for a second. :)
  16. Brogan

    Brogan XenForo Moderator Staff Member

    How do I embed the code into my sig?
  17. Erik

    Erik Well-Known Member

    Oh, sorry, we probably should have explained it better. The XML is only XML - you have to use the script I posted above (hosted on your own server). The script fetches the XML and then uses the image library GD to make an image out of it. :)

    Then all you do is add an image tag in your signature pointed to the script on your server. :)
    DFx and Brogan like this.
  18. Brogan

    Brogan XenForo Moderator Staff Member

    Aha, cheers Erik, I had just about worked that out from the comments but thanks for the clarification.
  19. Disjunto

    Disjunto Well-Known Member

    yup... that works, and takes in an id ;) now to make it look good :D
    AlexandrosD likes this.
  20. Erik

    Erik Well-Known Member

    I have a version that takes an ID too, but I didn't want to post it here for fear of the "OMG that is so cool I'm putting that in MY sig now!" kind of effect. And then my server would look like this:

    Keep in mind anytime the image is displayed, anywhere, by anyone, a request is being made to the server and it has to create an image. So, as more people start adding images to their signatures, the requests start multiplying very quickly. :)

    However, I'm actually considering turning this into a free hosted service where you can customize colors, designs, what you want displayed, etc. And it will have at least minimal caching. :) Development time! :D

Share This Page