Banner Signature / Dynamic Banner

Discussion in 'Help/Support' started by shoebox, Aug 22, 2004.

  1. shoebox

    shoebox Administrator Staff Member

    Joined:
    Jan 1, 1970
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    [HOW TO]: Using Our Dynamic Banners/Forum Signatures



    I. The Banner Templates: Here is a list of our banner templates:

    http://www.dnbradio.com/img/banner_templates/



    II. Syntax: Here is a the URL syntax for accessing the banner
    (with listener count and track info on it).

    Code:
    http://www.dnbradio.com/banners/hex<HEX_COLOR_CODE>/<TEMPLATE_FILENAME>
    
    * HEX_COLOR_CODE will designate what foreground color the script
    should use for the text.

    * TEMPLATE_FILENAME is the name of the template you want to use
    (get from list above)

    III. URL Example: Click the following link to see the banner in action.

    http://www.dnbradio.com/banner/hexfffff ... nner01.png
    *(note: ffffff = white)

    IV. BBCode Example: Code sample for a forum signature.

    The Code:
    Code:
    [url=http://www.dnbradio.com][img]http://www.dnbradio.com/banner/hexCCFFFF/dnbrBanner01.png[/img][/url]
    Tune in: [url=http://www.dnbradio.com/lo.pls]24k[/url] |  [url=http://www.dnbradio.com/med.pls]64k[/url]  | [url=http://www.dnbradio.com/hi.pls]128k[/url] 
    
    The Result:
    [​IMG]
    Tune in: 24k | 64k | 128k


    V. HTML Code Example Code sample for a HTML page.
    Code:
    <a href="http://www.dnbradio.com"><img src="http://www.dnbradio.com/banner/hexCCFFFF/dnbrBanner01.png" style="border: 0px;"></a><br>
    Tune in: <a href="http://www.dnbradio.com/lo.pls">24k</a> |  <a href="http://www.dnbradio.com/med.pls">64k</a>  | <a href="http://www.dnbradio.com/hi.pls">128k</a> 

    VI. Making your own template:
    If you would like to make your own template feel free. Be sure to
    leave room for the now playing info. Take a look at the other templates
    to get an idea of the space you need to leave open.

    Save as PNG and email to me when you are done.


    VII. Advanced info you probably don't need to know (unless you're curious):
    If you are looking for the php source that does the image manipulation. here is a snippet from the script I wrote..
    Code:
    <?php
    header("Content-Type: image/png");
    
    include('../conf.php');
    require_once(ECLIPSE_ROOT.'MyDatabase.php');
    require_once(ECLIPSE_ROOT.'FileIterator.php');
    require_once(MODEL_ROOT.'SAMHistoryList.php');
    
    /**
    * Formats string ($str) to specified length ($maxlength)
    * and removes or replaces special chars.
    **/
    function prepareString($str, $maxlength)
    {
    	if (strlen($str) > $maxlength) {
    		$str = substr(str_replace('  ', ' ', $str), 0, $maxlength)."...";
    	}
    	$str = str_replace('&amp;', '&', $str);
    	$str = str_replace(''', "'", $str);
    	$str = str_replace("\\", '', $str);
    	return $str;
    }
    
    // connect to db and get song data
    $Database =& new MyDatabase(SAMDB, SAMDBHOST);
    $Database->connect(SAMDBUSER, SAMDBPASS);
    $historyList = new SAMHistoryList($Database);
    $song = $historyList->getCurrentSong();
    $title = prepareString($song['title'], 100);
    $artist = prepareString($song['artist'], 100);
    $album = ($song['album']) ? prepareString($song['album'], 100) : 'n/a';
    $year = ($song['albumyear']) ? prepareString($song['albumyear'], 100) : 'n/a';
    
    // used if text does not exceed 40 chars
    $shortTemplate = APP_ROOT.'img/banner_templates/'.$_GET['png_template'];
    
    // used if text exceeds 40 chars
    $longTemplate = $shortTemplate;
    
    // pick the template according to length of longest song info string
    $strLength = (strlen($songStr) > strlen($listenerStr)) ? strlen($songStr) : strlen($listenerStr);
    
    // choose which image to use based on string length
    $img = ($strLength > 40) ? $shortTemplate : $longTemplate;
    
    // create the img.
    $im = imagecreatefrompng($img);
    
    if ($im)
    {
    	// read in the hex values from HTTP GET (if provided)
    	// use white as default
    	if (isset($_GET['customFColor']) && $_GET['customFColor'] == 1) {
    		if (isset($_GET['hex'])) {
    			$hexcode = str_replace('#', '', $_GET['hex']);
    			sscanf($hexcode, "%2x%2x%2x", $red, $green, $blue);			
    		} elseif (is_int($_GET['r']) && is_int($_GET['g']) && is_int($_GET['b'])) {
    			$red = $_GET['r'];
    			$green = $_GET['g'];
    			$blue = $_GET['b'];
    		} else {
    			$hexcode = $_GET['r'].$_GET['g'].$_GET['b'];
    			sscanf($hexcode, "%2x%2x%2x", $red, $green, $blue);
    		}
    		$color = imagecolorallocate($im, $red, $green, $blue);
    
    	} else {
    		$white = imagecolorallocate($im, 255, 255, 255);
    		$color = $white;
    	}
    
    	// write text to PNG template and output PNG
    	ImageString($im,  2,  170,  8,  " title: '$title'",  $color);
    	ImageString($im,  2,  170,  23,  "artist: $artist",  $color);
    	ImageString($im,  2,  170,  38,  " album: $album  year: $year",  $color);
    	ImageString($im,  2,  100,  38,  $listenerStr,  $color);
    	ImagePNG($im);
    }
    ?>
    
    The key things in this script are the header() declaration at the top
    of the script and then the imagecreatefrompng(), imagecolorallocate(),
    ImageString(), ImagePNG() built-in php functions. You can find info on
    those directly on http://www.php.net

    Hope this helps.. :)
     
  2. elusid

    elusid New Member

    Joined:
    Aug 20, 2004
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Portland,ME
    Nice one! thanks man definetly a great help!
     
  3. chelle

    chelle New Member

    Joined:
    Jan 1, 1970
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    network engineer
    Location:
    houston, tx, usa
    bigup shoe for the help <3
     
  4. Guest

    Guest Guest

    thx very very much!!! :))))))))
     
  5. Guest

    Guest Guest

    pretty nice code
     
  6. Anonymous

    Anonymous Guest

    yay booshox <3
     
  7. Agent Europe

    Agent Europe New Member

    Joined:
    May 11, 2005
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Public Relations / Executive Manager
    Location:
    Europe
    i need sometin like this but don't get it :?
     
  8. shoebox

    shoebox Administrator Staff Member

    Joined:
    Jan 1, 1970
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    what do you need? maybe i can show you an example.
     
  9. Agent Europe

    Agent Europe New Member

    Joined:
    May 11, 2005
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Public Relations / Executive Manager
    Location:
    Europe
    well,i need such dynamic banner for myself :cool:
     
  10. DJ Toxin

    DJ Toxin New Member

    Joined:
    Jan 1, 1970
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
  11. shoebox

    shoebox Administrator Staff Member

    Joined:
    Jan 1, 1970
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
  12. Hibbert

    Hibbert New Member

    Joined:
    May 23, 2006
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student!!
    Location:
    Leeds, UK
    How do i get the image with the stats on my myspace? :(
     
  13. shoebox

    shoebox Administrator Staff Member

    Joined:
    Jan 1, 1970
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    Use the HTML Code Example shown int he first post.
     
  14. Hibbert

    Hibbert New Member

    Joined:
    May 23, 2006
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student!!
    Location:
    Leeds, UK
    Hey Shoo soz but i still can't get the code right..

    All i want is one of the banners with the stats on and for me to have it on my myspace, think u could help me out?
     
  15. shoebox

    shoebox Administrator Staff Member

    Joined:
    Jan 1, 1970
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    Try this code:

    Code:
    <a href="http://www.dnbradio.com"><img src="http://www.dnbradio.com/banner/hexCCFFFF/dnbrBanner01.png" style="border: 0px;"></a><br>
    Tune in: <a href="http://www.dnbradio.com/lo.pls">24k</a> |  <a href="http://www.dnbradio.com/med.pls">64k</a>  | <a href="http://www.dnbradio.com/hi.pls">128k</a>
    
     
  16. Canis Major

    Canis Major New Member

    Joined:
    Dec 30, 2005
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    G-Town Lincs UK
    If you use the other banners it doesnt come up with whats playing nad how many listeners there are!
     
  17. Canis Major

    Canis Major New Member

    Joined:
    Dec 30, 2005
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    G-Town Lincs UK
    right ive figured it out... no worries!!!
     
  18. Hibbert

    Hibbert New Member

    Joined:
    May 23, 2006
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student!!
    Location:
    Leeds, UK
    thx sh00 worked perfect <3
     
  19. dj_apc

    dj_apc New Member

    Joined:
    Sep 13, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Blackhole of Europe
    OK..this is really noice and cool, but I have one problem...I don't have my signature space in the profile and i was wondering how to make my signature shown?! :roll:
     
  20. salman

    salman New Member

    Joined:
    Jul 12, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi, This post is very informative, however I would like some specific information. If someone can help me then please send me a private message. Best Regards,
     

Share This Page