function CreateLabelPic($picid, $firstname, $lastname, $title) { $w = 590; $h = 712; $loc = 'badgelib.php->CreateLabelPic'; $img = imagecreatetruecolor($w, $h); $black = ImageColorAllocate($img, 0x0, 0x0, 0x0); $white = ImageColorAllocate($img, 0xff, 0xff, 0xff); $red = ImageColorAllocate($img, 0xff, 0x0, 0x0); $blue = ImageColorAllocate($img, 0x0, 0x0, 0xff); imagefilledrectangle($img, 0, 0, $w, $h, $white); $picid = intval($picid); if ($picid > 0) { // We have a image to put on the badge! // It should be placed at (124x117 and sized to be 350x350 $picfile = PicPathName($picid, 'orig'); // Get the original. $imginfo = @getimagesize($picfile); if ($imginfo === false) { log_error($loc, 'Getimagesize() failed on our image: ' . $picfile); return false; } $picwidth = $imginfo[0]; $picheight = $imginfo[1]; $picimg = @imagecreatefromjpeg($picfile); if ($picimg === false) { log_error($loc, 'imagecreatefromjpeg() failed on our image: ' . $picfile); return false; } $result = @imagecopyresampled($img, $picimg, 124, 117, 0, 0, 350, 350, $picwidth, $picheight); if ($result === false) { log_error($loc, 'imagecopyresized() failed for PidId=' . $picid); return false; } } // Now we slap the entire badge image with the hole over the headshot. $backfile = 'img/label_with_hole.png'; if (file_exists($backfile)) { $backimg = @imagecreatefrompng($backfile); if ($backimg === false) { log_error($loc, 'imagecreatefrompng() failed on our image: ' . $backfile); } else { $xsz = imagesx($img); $ysz = imagesy($img); $result = @imagecopyresampled($img, $backimg, 0, 0, 0, 0, $w, $h, $xsz, $ysz); } } $iparam['image'] = $img; $iparam['fontsize'] = 60.0; $iparam['color'] = $red; $iparam['angle'] = 0.0; $iparam['fontfile'] = 'fonts/prototype.ttf'; if (!empty($nickname)) { $fn = $nickname; } else { $fn = $firstname; } $ink = ImageColorAllocate($img, 0x0, 0x0, 0x66); if (empty($title)) { $p = 0.02; } else { $p = 0.0; } $iparam['fontsize'] = 60.0; $iparam['color'] = $ink; DrawTextCentered($iparam, $fn, 0.5, 0.87); $iparam['fontsize'] = 45.0; DrawTextCentered($iparam, $lastname, 0.5, 0.9399999999999999); $iparam['fontsize'] = 25.0; $iparam['color'] = $black; if (!empty($title)) { DrawTextCentered($iparam, $title, 0.5, 0.97); } return $img; }
function PicResizeAll($id, $width, $height) { $loc = "piclib.php->PicResizeAll"; $origfile = PicPathName($id, "orig"); if (!file_exists($origfile)) { log_error($loc, array("Original file does not exist!", "Origfile= " . $origfile)); return false; } // Read the original image $img = @imagecreatefromjpeg($origfile); if ($img === FALSE) { log_error($loc, array("Unable to Resize Image!", "Origfile= " . $origfile, "imagecreatefromjpeg failed.")); return false; } // Now we resize the pic into all the possibile sizes. $folders = PicFolderList(); foreach ($folders as $f) { if (substr($f, 0, 1) != "w") { continue; } // Resize each file here. $new_width = intval(substr($f, 1)); if ($new_width < 10 || $new_width > 2000) { continue; } $ratio = $new_width / $width; $new_height = intval($height * $ratio); $new_file = PicPathName($id, $f); $new_img = @imagecreatetruecolor($new_width, $new_height); if ($new_img === false) { log_error($loc, array("Unable to Resize Image!", "Origfile= " . $origfile, "imagecreatetruecolor failed.")); return false; } $result = @imagecopyresampled($new_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); if ($result === false) { log_error($loc, array("Unable to Resize Image!", "Origfile= " . $origfile, "Resize Folder=" . $f)); return false; } $result = @imagejpeg($new_img, $new_file, 100); if ($result === false) { log_error($loc, array("Unable to Saved Resized Image!", "Origfile= " . $origfile, "NewFile=" . $new_file)); return false; } // Optimization trick: Use the new image next time as the original // instead of always starting over with the super sized original. // This saves about 1/3 of the processing time. $img = $new_img; $width = $new_width; $height = $new_height; } return true; }
$picurl = ""; if ($_SERVER["REQUEST_METHOD"] == "GET") { if (empty($_GET["wid"])) { DieWithMsg($loc, "No WID given."); } if (empty($_GET["picid"])) { DieWithMsg($loc, "No picid given."); } $wid = intval($_GET["wid"]); $wo = GetWO($wid); $picid = intval($_GET["picid"]); $pagetabtitle = "Epic " . $wo["WIDStr"]; $pagetitle = "Picture for Work Order"; $piccaption = GetPicCaption($wid, $picid); if ($picid > 0) { $picfile = PicPathName($picid, "orig"); if (file_exists($picfile)) { $picurl = PicUrl($picid, "orig"); } } if (empty($picurl)) { $error_msg = "Unable to find Pic... Sorry."; } goto GenerateHtml; } if ($_SERVER["REQUEST_METHOD"] == "POST") { $error_msg = "You should not be able to access this page in this way."; goto GenerateHtml; } GenerateHtml: $stylesheet = array("../css/global.css", "../css/nav.css", "../css/wo_head.css", "../css/display_image.css");
function RenderAppendedData($a) { global $wid; $author = ""; $date = ""; $text = ""; $picid = 0; $picurl_thumb = ""; $sys = false; if (!empty($a["AuthorName"])) { $author = $a["AuthorName"]; } if (!empty($a["DateCreated"])) { $date = $a["DateCreated"]; } if (!empty($a["TextInfo"])) { $text = $a["TextInfo"]; } if (!empty($a["PicID"])) { $picid = intval($a["PicID"]); } if (empty($a["UserID"])) { $sys = true; } if ($picid > 0) { $picfile_thumb = PicPathName($picid, "thumb"); if (file_exists($picfile_thumb)) { $picurl_thumb = PicUrl($picid, "thumb"); } } echo '<div class="wo_ap_block">'; echo '<div class="wo_ap_header">'; if (!$sys) { echo '<div class="wo_ap_author">' . $author . '</div>' . "\n"; } echo '<div class="wo_ap_date">' . $date . '</div>' . "\n"; echo '</div>' . "\n"; echo '<div class="wo_ap_body">'; if (!empty($picurl_thumb)) { echo '<div class="wo_ap_image">'; echo '<a href="display_image.php?picid=' . $picid . "&wid=" . $wid . '"><img src="' . $picurl_thumb . '"></a>'; echo '</div>'; echo '<div class="wo_ap_text_i">' . $text . '</div>' . "\n"; } else { if (!$sys) { echo '<div class="wo_ap_text">' . $text . '</div>' . "\n"; } else { echo '<div class="wo_ap_text_sys">' . $text . '</div>' . "\n"; } } echo '</div>' . "\n"; echo '</div>' . "\n"; echo '<div style="clear: both;"></div>' . "\n"; }
} $wo = GetWO($wid, $override); if (!$wo) { $doform = false; $error_msg = "This Work Order doesn't seem to exist."; goto GenerateHtml; } $pagetabtitle = "Epic " . $wo["WIDStr"]; $pagetitle = "Work Order"; $ap = GetAppendedData($wid); $assigned_workers = GetAssignedWorkers($wid); $wo["Description"] = wordwrap($wo["Description"], 65, "\n", true); $picinfo = GetPrimaryPicInfo($wid); if ($picinfo) { $picid = $picinfo["PicID"]; $primarypic = PicPathName($picid, "tiny"); if (file_exists($primarypic)) { $primarypic_url = PicUrl($picid, "tiny"); $primarypic_ref = 'display_image.php?picid=' . $picid . '&wid=' . $wid; } } goto GenerateHtml; } if ($_SERVER["REQUEST_METHOD"] == "POST") { goto GenerateHtml; } GenerateHtml: $stylesheet = array("../css/global.css", "../css/nav.css", "../css/wo_head.css", "../css/wo_display.css"); include "forms/header.php"; include "forms/nav_form.php"; include "forms/wo_display_menubar.php";