SimplePortal
Customization => Custom Coding => Topic started by: Malibuz0r on August 30, 2012, 07:50:45 PM
-
So this is my code right now:
<?php
global $memberContext, $user_info;
loadMemberData($user_info['id']);
loadMemberContext($user_info['id'], true);
$member_info = $memberContext[$user_info['id']];
echo $member_info['name'];
$s_query = ""; // My query (Works fine)
$s_result = mysql_query($s_query) or die(mysql_error());
if(mysql_num_rows($s_result) == 1)
{
$s_info = mysql_fetch_assoc($s_result);
$kills = $row['Kills'];
$deaths = $row['Deaths'];
if (($kills == 0) && ($deaths != 0)) $ratio = "-" . $deaths . ".00";
elseif (($deaths == 0) && ($kills != 0)) $ratio = $kills . ".00";
elseif (($deaths == 0) && ($kills == 0)) $ratio = "0.00";
else
{
$ratio = $kills / $deaths;
$ratio = round($ratio, 2);
$ratio = number_format($ratio, 2);
}
$status = $row['Online'];
$lastonl = $row['Last Online'];
$pname = $row['Username'];
$string1 = "Username:";
$string2 = "Kills: " . $kills;
$string3 = "Deaths: " . $deaths;
$string4 = "Ratio: " . $ratio;
if ($status == Yes) $string7 = "Online Now";
else if ($status == No) $string7 = "Last Online: " . $lastonl;
header("content-type: image/png");
$im = imagecreatefrompng("/Sources/msub.png");
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 156, 248, 101);
$white = imagecolorallocate($im, 255, 255, 255);
$px2 = (imagesx($im) - 0 * strlen($string2) + 45) / 2;
imagettftext($im, 8, 0, 35, 22, $green, "/Sources/Fonts/Visitor-TT1--BRK-.ttf", $string1);
imagettftext($im, 8, 0, 92, 22, $white, "/Sources/Fonts/Visitor-TT1--BRK-.ttf", $pname);
imagettftext($im, 8, 0, 15, 55, $white, "/Sources/Fonts/Visitor-TT1--BRK-.ttf", $string2);
imagettftext($im, 8, 0, 15, 65, $white, "/Sources/Fonts/Visitor-TT1--BRK-.ttf", $string3);
imagettftext($im, 8, 0, 15, 75, $white, "/Sources/Fonts/Visitor-TT1--BRK-.ttf", $string4);
if ($status == Yes) imagettftext($im, 8, 0, 120, 75, $green, "/Sources/Fonts/Visitor-TT1--BRK-.ttf", $string7);
else if ($status == No) imagettftext($im, 8, 0, 120, 75, $white, "/Sources/Fonts/Visitor-TT1--BRK-.ttf", $string7);
imagepng($im);
imagedestroy($im);
}
?>
Ok, so my issue is, is that when I hit edit, nothing shows but the icon representing a broken image. I'm guessing it has something to do with the way I'm trying to define where the .png and the .ttf font are located. The .png is located inside "Sources", the .ttf font is located in another folder inside sources: "Sources/Fonts".
If I'm wrong, then could someone point out any errors you see up there? Thanks.
-
the main error that i see straight away it...
you say that this code is being put into a PHP Block in SP.. yes..??
then you don't need the first and last line; "<?php" and "?>" as these are part of the PHP block...