Hello Guys,
I’m a bit new to coding stuff but I got whats enough for me, currently i’m looking for help about generate function that isn’t working with me.
I’m making a digital pilot card in the same page of the pilot badge, I did edit PilotData.Class.php , profile_badge.tpl in the skin , local.config.php & uploaded files in lib as /lib/dcards/background/background.png also made a blank index.php under /lib/dcards but it’s not generating anything even after filing a PIREP while the badge is working properly.
Base codes are copy rights to their owner (Pilot Badge template Author)*
PilotData.Class.php
public static function generateDcard($pilotid) { $pilot = self::getPilotData($pilotid); $pilotcode = self::getPilotCode($pilot-\>code, $pilot-\>pilotid); if(Config::Get('TRANSFER\_HOURS\_IN\_RANKS') === true) { $totalhours = $pilot-\>totalhours + $pilot-\>transferhours; } else { $totalhours = $pilot-\>totalhours; } # Configure what we want to show on each line $output = array(); $output[] = $pilot-\>firstname.' '.$pilot-\>lastname; $output[] = $pilotcode; $output[] = $pilot-\>rank; $output[] = $pilot-\>lastpirep; $output[] = $pilot-\>joindate; if(Config::Get('DCARD\_SHOW\_EARNINGS') == false) { $output[] = 'Total Earnings: ' . $pilot-\>totalpay; } # Load up our image # Get the background image the pilot selected if(empty($pilot-\>bgimage)) $bgimage = SITE\_ROOT.'/lib/dcards/background/background.png'; else $bgimage = SITE\_ROOT.'/lib/dcards/background/'.$pilot-\>bgimage; if(!file\_exists($bgimage)) { # Doesn't exist so use the default $bgimage = SITE\_ROOT.'/lib/dcards/background/background.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('DCARD\_TEXT\_COLOR')); $color = sscanf($txtcolor, '%2x%2x%2x'); $textcolor = imagecolorallocate($img, $color[0], $color[1], $color[2]); $font = 6; // Set the font-size $xoffset = Config::Get('DCARD\_X\_OFFSET'); # How many pixels, from left, to start $yoffset = Config::Get('DCARD\_Y\_OFFSET'); # How many pixels, from top, to start $font = Config::Get('DCARD\_FONT\_PATH'); $font\_size = Config::Get('DCARD\_FONT\_SIZE'); if(function\_exists('imageantialias')) { imageantialias($img, true); } /\* Font stuff \*/ if(!function\_exists('imagettftext')) { Config::Set('DCARD\_USE\_CUSTOM\_FONT', false); } # The line height of each item to fit nicely, dynamic if(Config::Get('DCARD\_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('DCARD\_FONT\_PADDING'); $fontwidth = $bb[2] - $bb[0]; } $currline = $yoffset; $total = count($output); for($i=0;$i\<$total;$i++) { if(Config::Get('DCARD\_USE\_CUSTOM\_FONT') == false) { imagestring($img, $font, $xoffset, $currline, $output[$i], $textcolor); } else { // Use TTF $tmp = imagettftext($img, $font\_size, 0, $xoffset, $currline, $textcolor, $font, $output[$i]); // 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 country flag, line it up with the first line, which is the # pilot code/name $country = strtolower($pilot-\>location); if(file\_exists(SITE\_ROOT.'/lib/images/countries/'.$country.'.png')) { $flagimg = imagecreatefrompng(SITE\_ROOT.'/lib/images/countries/'.$country.'.png'); if(Config::Get('DCARD\_USE\_CUSTOM\_FONT') == false) { $ret = imagecopy($img, $flagimg, strlen($output[0])\*$fontwidth, ($yoffset+($stepsize/2)-5.5), 0, 0, 16, 11); } else { # figure out where it would go $ret = imagecopy($img, $flagimg, $flag\_bb[4]+5, $flag\_bb[5]+2, 0, 0, 16, 11); } } # Add the Rank image if(Config::Get('DCARD\_SHOW\_RANK\_IMAGE') == false && $pilot-\>rankimage!='' && file\_exists($pilot-\>rankimage)) { $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 { $r\_width = imagesx($rankimg); $r\_height = imagesy($rankimg); imagecopy($img, $rankimg, $width-$r\_width-$xoffset, $yoffset, 0, 0, $r\_width, $r\_height); } } if(Config::Get('DCARD\_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.DCARD\_PATH.'/'.$pilotcode.'.png', 1); imagedestroy($img); }
profile_badge.tpl
\<h1 align="center"\>Pilot Digital Card\</h1\> \<p align="center"\> \<img src="\<?php echo $dcard\_url ?\>" /\> \</p\> \<p\> \<strong\>Direct Link:\</strong\> \<input onclick="this.select()" type="text" value="\<?php echo $dcard\_url ?\>" style="width: 100%" /\> \<br /\>\<br /\> \<strong\>Image Link:\</strong\> \<input onclick="this.select()" type="text" value='\<img src="\<?php echo $dcard\_url ?\>" /\>' style="width: 100%" /\> \<strong\>BBCode:\</strong\> \<input onclick="this.select()" type="text" value='[img]\<?php echo $dcard\_url ?\>[/img]' style="width: 100%" /\> \</p\>
local.config.php
# Options for the dcard that's generated Config::Set('DCARD\_TEXT\_COLOR', '#25275d'); Config::Set('DCARD\_USE\_CUSTOM\_FONT', true); Config::Set('DCARD\_FONT\_PATH', SITE\_ROOT.'/lib/fonts/candara.ttf'); Config::Set('DCARD\_FONT\_SIZE', '8.84'); Config::Set('DCARD\_X\_OFFSET', '89'); Config::Set('DCARD\_Y\_OFFSET', '172'); Config::Set('DCARD\_FONT\_PADDING', 4); Config::Set('DCARD\_SHOW\_EARNINGS', false); Config::Set('DCARD\_SHOW\_RANK\_IMAGE', false); Config::Set('DCARD\_SHOW\_COPYRIGHT', true);
Thanks