Members Vangelis Posted July 10, 2013 Members Report Posted July 10, 2013 Hello For the needs of my VA i created a Pilot badge with a modiefied version of signature function This is the code this is for users that do know a litle bit of php and because it is a litle complicated i will NOT provide any support on that the picture will be saved in the same folder as your signatures in the format id-PILOTID Below is a screenshot where i use it as a possible use for you and the code. The Name the rank and the date are coming dynamic from the database the picture above the name comes dynamic from the avatar that the user has selected if none is selected then the default will show the picture of the rank comes dynamic from the rank that you have as a pilot YOU MUST USE RELATIVE PATH in your admin section or else no pic will come on like with the signature you must have a template so that everything comes to place you have to put it in /lib/signatures/backround/ with the name id.png When you have done everything you need to call the function where ever you think for example whenever you send a pirep . Good luck modiefing it public function generateid($pilotid) { $pilot = PilotData::getPilotData($pilotid); $pilotcode = PilotData::getPilotCode($pilot->code, $pilot->pilotid); if(Config::Get('TRANSFER_HOURS_IN_RANKS') === true) { $totalhours = $pilot->totalhours + $pilot->transferhours; } else { $totalhours = $pilot->totalhours; } $mysqldate = date( 'Y-m-d ', $pilot->joindate ); # Configure what we want to show on each line $output = array(); $output[] = $pilot->firstname.' '.$pilot->lastname; $output[] = $pilotcode; $output[] = $pilot->rank; $output[] = $pilot->retired; $output[] = $mysqldate; if(Config::Get('SIGNATURE_SHOW_EARNINGS') == true) { $output[] = 'Total Earnings: ' . $pilot->totalpay; } # Load up our image # Get the background image the pilot selected if(empty($pilot->bgimage)) $bgimage = SITE_ROOT.'/lib/signatures/background/id.png'; else $bgimage = SITE_ROOT.'/lib/signatures/background/id.png'; if(!file_exists($bgimage)) { # Doesn't exist so use the default $bgimage = SITE_ROOT.'/lib/signatures/background/id.png'; if(!file_exists($bgimage)) { return false; } } $img = @imagecreatefrompng($bgimage); if(!$img) { $img = imagecreatetruecolor(300, 50); } $height = imagesy($img); $width = imagesx($img); $txtcolor = str_replace('#', '', Config::Get('SIGNATURE_TEXT_COLOR')); $color = sscanf($txtcolor, '%2x%2x%2x'); $textcolor = imagecolorallocate($img, $color[0], $color[1], $color[2]); $font = 3; // Set the font-size $xoffset = "150"; # How many pixels, from left, to start $yoffset = "200"; # How many pixels, from top, to start $font = Config::Get('SIGNATURE_FONT_PATH'); $font_size = Config::Get('SIGNATURE_FONT_SIZE'); if(function_exists('imageantialias')) { imageantialias($img, true); } /* Font stuff */ if(!function_exists('imagettftext')) { Config::Set('SIGNATURE_USE_CUSTOM_FONT', false); } # The line height of each item to fit nicely, dynamic if(Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) { $stepsize = imagefontheight($font); $fontwidth = imagefontwidth($font); } else { // get the font width and step size $bb = imagettfbbox ( $font_size, 0, $font, 'A'); $stepsize = $bb[3] - $bb[5] + Config::Get('SIGNATURE_FONT_PADDING'); $fontwidth = $bb[2] - $bb[0]; } $currline = $yoffset; $total = count($output); if(Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) { imagestring($img, $font, $xoffset, $currline, $output[$i], $textcolor); } else { // Use TTF $tmp = imagettftext($img, $font_size, 0, 30, 220, $textcolor, $font, $output[0]); $tmp = imagettftext($img, $font_size, 0, 265, 335, $textcolor, $font, $output[2]); $tmp = imagettftext($img, $font_size, 0, 215, 390, $textcolor, $font, $output[4]); if ($output[3]==1) { $tmp = imagettftext($img, $font_size, 0, 240, 230, $textcolor, $font, 'Pilot Retired'); $tmp = imagettftext($img, 40, 50, 130, 300, $textcolor, $font, 'INVALID ID'); } else { $tmp = imagettftext($img, $font_size, 0, 240, 230, $textcolor, $font,'Active Pilot'); } // Flag is placed at the end of of the first line, so have that bounding box there if($i==0) { $flag_bb = $tmp; } } $currline+=$stepsize; # Add the Avatar Picture, line it up with the first line, which is the # pilot code/name if(file_exists(SITE_ROOT.'/lib/avatars/'.$pilotcode.'.png')) { $avatarimg = imagecreatefrompng(SITE_ROOT.'/lib/avatars/'.$pilotcode.'.png'); if(Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) { $ret = imagecopy($img, $avatarimg, strlen($output[0])*$fontwidth, ($yoffset+($stepsize/2)-5.5), 0, 0, 50, 50); } else { # figure out where it would go $ret = imagecopy($img, $avatarimg, 70, 100, 0, 0, 50, 60); } } else $avatarimg = imagecreatefrompng(SITE_ROOT.'/lib/images/noavatar.png'); if(Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) { $ret = imagecopy($img, $avatarimg, strlen($output[0])*$fontwidth, ($yoffset+($stepsize/2)-5.5), 0, 0, 50, 50); } else { # figure out where it would go $ret = imagecopy($img, $avatarimg, 70, 100, 0, 0, 50, 50); } # Add the Rank image $ext = substr($pilot->rankimage, strlen($pilot->rankimage)-3, 3); # Get the rank image type, just jpg, gif or png if($ext == 'png') $rankimg = @imagecreatefrompng($pilot->rankimage); elseif($ext == 'gif') $rankimg = @imagecreatefromgif($pilot->rankimage); else $rankimg = @imagecreatefromjpg($pilot->rankimage); if(!$rankimg) { echo '';} else { $ret = imagecopy($img, $rankimg, 250, 260, 0, 0, 100, 60); // imagecopy($img, $rankimg, $width-$r_width-$xoffset, $yoffset, 0, 0, $r_width, $r_height); } if(Config::Get('SIGNATURE_SHOW_COPYRIGHT') == true) { # # DO NOT remove this, as per the phpVMS license $font = 1; $text = 'powered by phpvms, '. SITE_NAME.' '; imagestring($img, $font, $width-(strlen($text)*imagefontwidth($font)), $height-imagefontheight($font), $text, $textcolor); } imagepng($img, SITE_ROOT.SIGNATURE_PATH.'/id-'.$pilotcode.'.png', 1); imagedestroy($img); echo $pilot->retired; } 1 Quote
Gabriel Fernandez Posted September 19, 2014 Report Posted September 19, 2014 its possible use this module and the default bagde? Quote
Members Vangelis Posted September 19, 2014 Author Members Report Posted September 19, 2014 What do mean do you want to write an example ? Quote
Gabriel Fernandez Posted September 20, 2014 Report Posted September 20, 2014 Well, we have the default one bagde. It's possible use your module lke a avatar, but with the informations like, ID, name, Rank... without deleting de dafault bagde? I understand that to use your module, you must override the old pilot bagde, the default one. That is it ?? Quote
Members Vangelis Posted September 21, 2014 Author Members Report Posted September 21, 2014 There is no default badge you can add it in any module that you want and then call it Quote
Miggel Posted February 26, 2019 Report Posted February 26, 2019 hmm dosent word... i habe a blanc page Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.