Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace App\CustomClass; use Illuminate\Support\Facades\Log; use App\CustomClass..

Decoded Output download

<?php 
 namespace App\CustomClass; use Illuminate\Support\Facades\Log; use App\CustomClass\TrueTypeFont; use Storage; use Imagick; class Websigning_Form { public $values_structure; public $pdf_structure; public $pdf_files; public $completed_values; public $fontSize; public $fontType; public $fontColor; public $form_title; public $form_id; public $pages = array(); public $images = array(); public $images_path = array(); public $pdf_path = ''; public $pdf_name = ''; public $pdf_base = ''; public $is_completed = false; public $isWorkflow = false; public $cid = 0; private $font; public function __construct($values_structure = '', $form = null, $completed = false, $workflow = false) { $this->values_structure = $values_structure; $this->pdf_structure = gettype($form["form_position"]) === "string" ? json_decode($form["form_position"], true) : $form["form_position"]; $this->completed_values = array(); $this->form_title = $form["title"]; $this->is_completed = $completed; $this->isWorkflow = $workflow; $this->cid = $form["cid"]; if ($this->isWorkflow) { $this->pdf_files = gettype($form["pngs"]) === "string" ? json_decode($form["pngs"], true) : $form["pngs"]; $this->form_id = $form["form_id"]; $this->fontSize = empty($form["font_size"]) ? intval(14) : intval($form["font_size"]); $this->fontType = empty($form["font_type"]) ? "OpenSans-Regular" : $form["font_type"]; $this->fontColor = empty($form["font_color"]) ? "#000000" : $form["font_color"]; } else { $this->pdf_files = gettype($form["file"]) === "string" ? json_decode($form["file"], true) : $form["file"]; $this->form_id = $form["id"]; $this->fontSize = empty($form["form_font_size"]) ? intval(14) : intval($form["form_font_size"]); $this->fontType = empty($form["form_font_type"]) ? "OpenSans-Regular" : $form["form_font_type"]; $this->fontColor = empty($form["form_font_size"]) ? "#000000" : $form["form_font_size"]; } $font_type = $_SERVER["DOCUMENT_ROOT"] . "/fonts/" . $this->fontType . ".ttf"; $this->font = new TrueTypeFont($font_type); } private function createImageFromFileSafe($file_path) { $content = ''; if ($this->isWorkflow) { if (strpos($file_path, "http") === false) { $full_path = $this->cid . "/files/pngs/" . $file_path; $content = Storage::disk("storage")->get($full_path); } else { $content = file_get_contents($file_path); } } else { if (strpos($file_path, "http") === false) { $content = Storage::disk("storage")->get($file_path); } else { $content = file_get_contents($file_path); } } $image1 = imagecreatefromstring($content); $width = imagesx($image1); $height = imagesy($image1); $image2 = imagecreatetruecolor($width, $height); $white = imagecolorallocate($image2, 255, 255, 255); imagefill($image2, 0, 0, $white); imagecopyresized($image2, $image1, 0, 0, 0, 0, $width, $height, $width, $height); return $image2; } public function generatePdf() { try { if ($this->pdf_files) { $i = 0; foreach ($this->pdf_files as $path) { try { $this->pages[$i] = $this->createImageFromFileSafe($path); $this->images[$i] = $path; $i++; } catch (\ErrorException $e) { Log::error(array("Get Image From Path" => $e->getMessage())); } catch (\Exception $e) { Log::error(array("Get Image From Path" => $e->getMessage())); } } } foreach ($this->pdf_structure as $element) { $affected = ''; try { if (isset($element["elements"])) { $aid = $element["id"]; $atitle = !empty($element["title"]) ? $element["title"] : ''; $atype = !empty($element["type"]) ? $element["type"] : ''; $affected = "form id: {$this->form_id}, form title: {$this->form_title}, field id: {$aid}, field type: {$atype}, field id: {$atitle}"; $values = null; if (array_key_exists($aid, $this->values_structure)) { $values = get_object_vars($this->values_structure[$aid]); } $newArray = array(); $newArray["id"] = $aid; $newArray["title"] = ''; $newArray["value"] = json_encode($values["value"]); $this->completed_values[] = $newArray; foreach ($element["elements"] as $sub_element) { $this->insertValueToImage($sub_element, $element); } } else { $this->insertValueToImage($element); $aid = !empty($element["id"]) ? $element["id"] : ''; $affected = "form id: {$this->form_id}, form title: {$this->form_title}, field id: {$aid}, field type: boxes"; } } catch (\ErrorException $e) { Log::error(array("PDF Element" => $affected)); Log::error(array("PDF Element Message" => $e->getMessage())); } catch (\Exception $e) { Log::error(array("PDF Element" => $affected)); Log::error(array("PDF Element Message" => $e->getMessage())); } } } catch (\ErrorException $e) { Log::error(array("PDF Structure" => $e->getMessage())); } catch (\Exception $e) { Log::error(array("PDF Structure" => $e->getMessage())); } try { $dir = Storage::disk("temps")->getAdapter()->getPathPrefix(); $i = 1; $pdf_page = 0; $filepath_array = array(); $imagepath_array = array(); $im = new Imagick(); ob_start(); foreach ($this->pages as $page) { $name = $this->form_id . "-" . $i++ . "-" . time(); $filepath = "{$dir}/" . $name . ".png"; imagepng($page, $filepath); $filepath_array[] = $filepath; $imagepath_array[] = $name . ".png"; imagedestroy($page); } $image = new Imagick($filepath_array); $image->setFormat("PDF"); $pdf_name = $this->form_id . "-" . time() . ".pdf"; $this->pdf_base = base64_encode($image->getImagesBlob()); $this->pdf_path = $pdf_name; $this->pdf_name = $pdf_name; $this->images_path = $imagepath_array; if ($this->is_completed) { Storage::disk("temps")->put($pdf_name, $image->getImagesBlob()); } $image->clear(); ob_end_clean(); } catch (\ErrorException $e) { Log::error(array("Imagick" => $e->getMessage())); } catch (\Exception $e) { Log::error(array("Imagick" => $e->getMessage())); } return true; } public function insertValueToImage($field, $parent = null) { $field = (array) $field; if (sizeof($this->pages) >= intval($field["page"])) { $currentImg = $this->pages[$field["page"] - 1]; $currentImgFile = $this->images[$field["page"] - 1]; $color = imagecolorallocate($currentImg, 20, 20, 20); $x = $field["left"]; $y = $field["top"]; $width = $field["width"]; $height = $field["height"]; $height_statement = 0.7 * $height; $current_type = null; $id = 0; if ($parent == null) { $id = $field["id"]; $values = null; if (array_key_exists($id, $this->values_structure)) { $values = get_object_vars($this->values_structure[$id]); } if ($id > 10000) { $current_type = "timestamp"; } else { if ($values) { $current_type = $values["type"]; } else { return false; } } switch ($current_type) { case "timestamp": $filepath = $_SERVER["DOCUMENT_ROOT"] . "/img/time_stamp.png"; list($src_w, $src_h) = getimagesize($filepath); $attach_image = imagecreatefrompng($filepath); imagecopyresampled($currentImg, $attach_image, $x, $y, 0, 0, $width, $height, $src_w, $src_h); imagedestroy($attach_image); $ts_title = $this->form_title; if (strlen($ts_title) > 15) { $ts_title = substr($ts_title, 0, 14); $ts_title .= "..."; } $string = $ts_title . "
" . "#" . $this->form_id . "\xa" . date("d/m/y H:i:s"); break; case "signature": $string = "signature"; break; case "file": case "image": $string = "file"; break; default: $string = $values["value"]; $newArray = array(); $newArray["id"] = $id; $newArray["title"] = $field["title"]; $newArray["value"] = $string; $this->completed_values[] = $newArray; } } else { $id = $parent["id"]; $values = null; if (array_key_exists($id, $this->values_structure)) { $values = get_object_vars($this->values_structure[$id]); $current_type = $values["type"]; } switch ($current_type) { case "checkbox": $array_values = (array) $values["value"]; $array_values = array_values($array_values); if (in_array($field["title"], array_filter($array_values))) { $black = imagecolorallocate($currentImg, 0, 0, 0); imagesetthickness($currentImg, 2); imageline($currentImg, $x + 1, $y + 1, $x + 1 + $width, $y + 1 + $height, $black); imageline($currentImg, $x + 1 + $width, $y + 1, $x + 1, $y + 1 + $height, $black); imagecolordeallocate($currentImg, $black); imagesetthickness($currentImg, 1); } $string = ''; break; case "radio": $radio = $values["value"]; if ($field["title"] == $radio) { $black = imagecolorallocate($currentImg, 0, 0, 0); imagesetthickness($currentImg, 2); imageline($currentImg, $x + 1, $y + 1, $x + 1 + $width, $y + 1 + $height, $black); imageline($currentImg, $x + 1 + $width, $y + 1, $x + 1, $y + 1 + $height, $black); imagecolordeallocate($currentImg, $black); imagesetthickness($currentImg, 1); } $string = ''; break; } } if (!empty($string)) { $this->font->setFontSize($this->fontSize); switch ($current_type) { case "timestamp": $this->setTimeStampFontSizeAndPosition($x, $y, $width, $height, $string, $currentImg); break; case "signature": $values = get_object_vars($this->values_structure[$id]); $exists = Storage::disk("temps")->exists($values["value"]); if ($exists) { $content = Storage::disk("temps")->get($values["value"]); $signature_image = imagecreatefromstring($content); $src_w = imagesx($signature_image); $src_h = imagesy($signature_image); imagecopyresampled($currentImg, $signature_image, $x, $y, 0, 0, $width, $height, $src_w, $src_h); imagedestroy($signature_image); $newArray = array(); $newArray["id"] = $id; $newArray["title"] = $field["title"]; $newArray["value"] = $values["value"]; Storage::disk("temps")->delete($values["value"]); $this->completed_values[] = $newArray; } break; case "file": case "image": $values = get_object_vars($this->values_structure[$id]); $exists = Storage::disk("temps")->exists($values["value"]); if ($exists) { $content = Storage::disk("temps")->get($values["value"]); $attach_image = imagecreatefromstring($content); $src_w = imagesx($attach_image); $src_h = imagesy($attach_image); imagecopyresampled($currentImg, $attach_image, $x, $y, 0, 0, $width, $height, $src_w, $src_h); imagedestroy($attach_image); $newArray = array(); $newArray["id"] = $id; $newArray["title"] = $field["title"]; $newArray["value"] = $values["value"]; Storage::disk("temps")->delete($values["value"]); $this->completed_values[] = $newArray; } break; default: $this->setFontSizeAndPosition($x, $y, $width, $height, $string, $currentImg, $current_type); } } } } private function imageTextToBoundingBox($width, $height, $source, $type) { $string_source = strip_tags($source); $font_size = round(intval($this->fontSize) - 6); $this->font->setFontSize($font_size); $cw = $this->font->getAverageCharacterWidth(); $maxChar = round(intval($width) / $cw); list($bw, $bh) = $this->font->getTextBoundingBox($string_source); $types = array("textarea", "paragraph", "address", "user_address", "readonly"); if (in_array($type, $types)) { $string = wordwrap($string_source, $maxChar, "
", TRUE); } else { $trimmed = substr($string_source, 0, $maxChar); $string = $bw > $width ? "{$trimmed}..." : $string_source; } $image = imagecreate($width, $height); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); $color = $this->hexColorAllocation($image, $this->fontColor); $trans = imagecolortransparent($image, $white); imagefilledrectangle($image, 0, 0, $width, $height, $white); imagettftext($image, $font_size, 0, 0, $font_size, $color, $this->font->getFontFile(), $string); return $image; } private function imageTimeStampToBoundingBox($width, $height, $string_source) { $w = intval(334.0 / 449 * $width); $h = intval(139.0 / 184 * $height); for ($font_size = 28; 7 < $font_size; $font_size -= 0.5) { $this->font->setFontSize($font_size); $cw = $this->font->getAverageCharacterWidth(); $string = wordwrap($string_source, floor($w / $cw), "\xa", true); list($bw, $bh) = $this->font->getTextBoundingBox($string); if ($bw <= $w && $bh <= $h) { break; } } $image = imagecreate($w, $h); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); $color = $this->hexColorAllocation($image, $this->fontColor); $trans = imagecolortransparent($image, $white); imagefilledrectangle($image, 0, 0, $w, $h, $white); imagettftext($image, $font_size, 0, 0, $font_size, $black, $this->font->getFontFile(), $string); return $image; } public function setTimeStampFontSizeAndPosition(&$x, &$y, $width, $height, $string, $currentImg) { $image = $this->imageTimeStampToBoundingBox($width, $height, $string); list($bw, $bh) = $this->font->getTextBoundingBox($string); $x += floor(($width - $bw) / 3.0); $y += floor(($height - $bh) / 2.0); imagecopy($currentImg, $image, $x, $y, 0, 0, $width, $height); } public function setFontSizeAndPosition(&$x, &$y, $width, $height, $string, $currentImg, $type) { $string = mb_convert_encoding($string, "UTF-8", "UTF-8"); $image = $this->imageTextToBoundingBox($width, $height, $string, $type); imagecopy($currentImg, $image, $x, $y + 5, 0, 0, $width, $height); } private function hexColorAllocation($img, $hex) { $hex = ltrim($hex, "#"); $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); return imagecolorallocate($img, $r, $g, $b); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace App\CustomClass; use Illuminate\Support\Facades\Log; use App\CustomClass\TrueTypeFont; use Storage; use Imagick; class Websigning_Form { public $values_structure; public $pdf_structure; public $pdf_files; public $completed_values; public $fontSize; public $fontType; public $fontColor; public $form_title; public $form_id; public $pages = array(); public $images = array(); public $images_path = array(); public $pdf_path = ''; public $pdf_name = ''; public $pdf_base = ''; public $is_completed = false; public $isWorkflow = false; public $cid = 0; private $font; public function __construct($values_structure = '', $form = null, $completed = false, $workflow = false) { $this->values_structure = $values_structure; $this->pdf_structure = gettype($form["\146\x6f\x72\155\x5f\160\157\163\x69\x74\x69\x6f\156"]) === "\x73\164\162\151\156\147" ? json_decode($form["\x66\x6f\162\x6d\x5f\160\157\x73\x69\164\151\157\x6e"], true) : $form["\x66\x6f\x72\155\137\160\157\163\151\164\x69\157\156"]; $this->completed_values = array(); $this->form_title = $form["\164\x69\x74\x6c\x65"]; $this->is_completed = $completed; $this->isWorkflow = $workflow; $this->cid = $form["\x63\x69\144"]; if ($this->isWorkflow) { $this->pdf_files = gettype($form["\x70\156\x67\x73"]) === "\163\x74\x72\x69\x6e\147" ? json_decode($form["\160\x6e\147\163"], true) : $form["\x70\x6e\147\x73"]; $this->form_id = $form["\x66\157\162\x6d\137\151\144"]; $this->fontSize = empty($form["\146\x6f\156\164\137\163\151\172\x65"]) ? intval(14) : intval($form["\x66\157\x6e\164\137\x73\151\172\145"]); $this->fontType = empty($form["\146\x6f\156\164\x5f\164\x79\x70\145"]) ? "\117\160\145\156\123\141\x6e\x73\x2d\x52\145\147\x75\154\x61\162" : $form["\x66\157\156\x74\137\x74\171\x70\x65"]; $this->fontColor = empty($form["\146\157\156\164\x5f\143\x6f\154\157\x72"]) ? "\43\x30\60\x30\x30\x30\x30" : $form["\146\157\x6e\164\x5f\x63\x6f\154\x6f\162"]; } else { $this->pdf_files = gettype($form["\146\151\154\145"]) === "\163\164\162\x69\x6e\x67" ? json_decode($form["\x66\151\x6c\x65"], true) : $form["\146\x69\154\145"]; $this->form_id = $form["\x69\x64"]; $this->fontSize = empty($form["\x66\157\x72\155\137\146\157\x6e\x74\x5f\x73\x69\x7a\145"]) ? intval(14) : intval($form["\146\157\162\x6d\x5f\146\x6f\156\x74\x5f\x73\x69\x7a\x65"]); $this->fontType = empty($form["\x66\157\x72\x6d\137\146\x6f\156\164\137\164\171\x70\145"]) ? "\x4f\x70\145\x6e\x53\x61\156\163\x2d\x52\x65\147\x75\x6c\141\x72" : $form["\x66\x6f\162\155\x5f\146\157\x6e\x74\x5f\x74\171\x70\x65"]; $this->fontColor = empty($form["\146\x6f\162\x6d\x5f\146\x6f\156\164\137\163\x69\x7a\x65"]) ? "\43\60\60\x30\60\60\60" : $form["\x66\x6f\x72\155\137\x66\157\156\164\137\x73\151\172\x65"]; } $font_type = $_SERVER["\104\117\x43\125\115\105\x4e\x54\x5f\122\117\x4f\124"] . "\x2f\146\157\x6e\164\x73\57" . $this->fontType . "\56\x74\164\146"; $this->font = new TrueTypeFont($font_type); } private function createImageFromFileSafe($file_path) { $content = ''; if ($this->isWorkflow) { if (strpos($file_path, "\150\x74\164\160") === false) { $full_path = $this->cid . "\x2f\146\151\154\x65\163\57\160\x6e\x67\163\x2f" . $file_path; $content = Storage::disk("\x73\x74\x6f\162\141\x67\145")->get($full_path); } else { $content = file_get_contents($file_path); } } else { if (strpos($file_path, "\x68\x74\164\160") === false) { $content = Storage::disk("\163\x74\x6f\162\141\147\x65")->get($file_path); } else { $content = file_get_contents($file_path); } } $image1 = imagecreatefromstring($content); $width = imagesx($image1); $height = imagesy($image1); $image2 = imagecreatetruecolor($width, $height); $white = imagecolorallocate($image2, 255, 255, 255); imagefill($image2, 0, 0, $white); imagecopyresized($image2, $image1, 0, 0, 0, 0, $width, $height, $width, $height); return $image2; } public function generatePdf() { try { if ($this->pdf_files) { $i = 0; foreach ($this->pdf_files as $path) { try { $this->pages[$i] = $this->createImageFromFileSafe($path); $this->images[$i] = $path; $i++; } catch (\ErrorException $e) { Log::error(array("\107\x65\164\x20\x49\155\141\x67\145\40\106\162\157\x6d\40\x50\141\x74\150" => $e->getMessage())); } catch (\Exception $e) { Log::error(array("\x47\x65\x74\40\111\155\141\x67\145\x20\x46\162\x6f\155\40\x50\141\x74\150" => $e->getMessage())); } } } foreach ($this->pdf_structure as $element) { $affected = ''; try { if (isset($element["\x65\154\145\x6d\145\156\164\163"])) { $aid = $element["\151\144"]; $atitle = !empty($element["\x74\151\x74\154\x65"]) ? $element["\164\x69\x74\154\145"] : ''; $atype = !empty($element["\164\171\x70\145"]) ? $element["\164\171\x70\x65"] : ''; $affected = "\x66\x6f\162\x6d\40\151\144\x3a\40{$this->form_id}\x2c\40\x66\157\x72\x6d\x20\x74\x69\x74\x6c\145\x3a\x20{$this->form_title}\x2c\x20\x66\151\x65\x6c\144\40\x69\144\72\40{$aid}\x2c\x20\x66\x69\145\154\x64\x20\164\171\160\145\x3a\40{$atype}\54\x20\x66\x69\x65\154\144\x20\x69\144\72\40{$atitle}"; $values = null; if (array_key_exists($aid, $this->values_structure)) { $values = get_object_vars($this->values_structure[$aid]); } $newArray = array(); $newArray["\151\x64"] = $aid; $newArray["\164\151\x74\154\145"] = ''; $newArray["\x76\141\154\165\145"] = json_encode($values["\166\141\154\x75\x65"]); $this->completed_values[] = $newArray; foreach ($element["\145\x6c\x65\x6d\x65\x6e\x74\x73"] as $sub_element) { $this->insertValueToImage($sub_element, $element); } } else { $this->insertValueToImage($element); $aid = !empty($element["\x69\x64"]) ? $element["\151\x64"] : ''; $affected = "\146\157\x72\155\x20\151\144\x3a\x20{$this->form_id}\54\x20\x66\x6f\162\x6d\x20\164\x69\164\154\145\x3a\40{$this->form_title}\54\x20\146\151\x65\154\144\x20\x69\144\x3a\x20{$aid}\54\40\146\x69\x65\x6c\x64\x20\164\171\160\x65\72\x20\x62\x6f\x78\x65\163"; } } catch (\ErrorException $e) { Log::error(array("\120\104\106\40\x45\x6c\x65\155\x65\x6e\x74" => $affected)); Log::error(array("\x50\104\x46\x20\105\154\x65\x6d\145\156\164\40\115\145\163\163\141\x67\145" => $e->getMessage())); } catch (\Exception $e) { Log::error(array("\120\104\106\40\105\154\145\155\x65\x6e\x74" => $affected)); Log::error(array("\120\x44\106\x20\105\154\x65\155\145\156\164\40\x4d\x65\163\x73\141\147\145" => $e->getMessage())); } } } catch (\ErrorException $e) { Log::error(array("\x50\104\x46\40\123\164\162\x75\143\164\165\162\145" => $e->getMessage())); } catch (\Exception $e) { Log::error(array("\120\x44\106\40\123\x74\x72\x75\143\164\165\x72\x65" => $e->getMessage())); } try { $dir = Storage::disk("\x74\x65\x6d\160\x73")->getAdapter()->getPathPrefix(); $i = 1; $pdf_page = 0; $filepath_array = array(); $imagepath_array = array(); $im = new Imagick(); ob_start(); foreach ($this->pages as $page) { $name = $this->form_id . "\55" . $i++ . "\55" . time(); $filepath = "{$dir}\x2f" . $name . "\x2e\x70\156\x67"; imagepng($page, $filepath); $filepath_array[] = $filepath; $imagepath_array[] = $name . "\x2e\x70\x6e\147"; imagedestroy($page); } $image = new Imagick($filepath_array); $image->setFormat("\120\104\106"); $pdf_name = $this->form_id . "\x2d" . time() . "\56\x70\144\x66"; $this->pdf_base = base64_encode($image->getImagesBlob()); $this->pdf_path = $pdf_name; $this->pdf_name = $pdf_name; $this->images_path = $imagepath_array; if ($this->is_completed) { Storage::disk("\x74\145\155\x70\163")->put($pdf_name, $image->getImagesBlob()); } $image->clear(); ob_end_clean(); } catch (\ErrorException $e) { Log::error(array("\x49\155\141\147\x69\143\153" => $e->getMessage())); } catch (\Exception $e) { Log::error(array("\x49\155\x61\x67\x69\x63\153" => $e->getMessage())); } return true; } public function insertValueToImage($field, $parent = null) { $field = (array) $field; if (sizeof($this->pages) >= intval($field["\160\x61\x67\x65"])) { $currentImg = $this->pages[$field["\160\141\x67\x65"] - 1]; $currentImgFile = $this->images[$field["\160\x61\147\145"] - 1]; $color = imagecolorallocate($currentImg, 20, 20, 20); $x = $field["\x6c\145\x66\164"]; $y = $field["\164\157\160"]; $width = $field["\167\x69\x64\x74\150"]; $height = $field["\150\145\x69\147\150\x74"]; $height_statement = 0.7 * $height; $current_type = null; $id = 0; if ($parent == null) { $id = $field["\x69\144"]; $values = null; if (array_key_exists($id, $this->values_structure)) { $values = get_object_vars($this->values_structure[$id]); } if ($id > 10000) { $current_type = "\164\151\155\145\x73\164\141\155\x70"; } else { if ($values) { $current_type = $values["\x74\171\160\x65"]; } else { return false; } } switch ($current_type) { case "\164\x69\x6d\x65\x73\x74\x61\x6d\160": $filepath = $_SERVER["\x44\x4f\x43\125\x4d\x45\x4e\124\x5f\122\x4f\x4f\x54"] . "\x2f\x69\155\x67\x2f\x74\151\x6d\x65\x5f\x73\164\x61\x6d\160\56\160\156\x67"; list($src_w, $src_h) = getimagesize($filepath); $attach_image = imagecreatefrompng($filepath); imagecopyresampled($currentImg, $attach_image, $x, $y, 0, 0, $width, $height, $src_w, $src_h); imagedestroy($attach_image); $ts_title = $this->form_title; if (strlen($ts_title) > 15) { $ts_title = substr($ts_title, 0, 14); $ts_title .= "\56\56\x2e"; } $string = $ts_title . "\12" . "\43" . $this->form_id . "\xa" . date("\x64\57\155\x2f\171\x20\x48\x3a\151\x3a\x73"); break; case "\163\x69\x67\x6e\141\x74\x75\x72\145": $string = "\163\x69\x67\x6e\x61\x74\165\162\145"; break; case "\x66\151\154\145": case "\151\x6d\141\147\145": $string = "\x66\x69\x6c\145"; break; default: $string = $values["\166\x61\x6c\x75\145"]; $newArray = array(); $newArray["\x69\x64"] = $id; $newArray["\x74\151\x74\x6c\x65"] = $field["\x74\x69\164\154\145"]; $newArray["\x76\141\x6c\165\x65"] = $string; $this->completed_values[] = $newArray; } } else { $id = $parent["\151\x64"]; $values = null; if (array_key_exists($id, $this->values_structure)) { $values = get_object_vars($this->values_structure[$id]); $current_type = $values["\x74\x79\x70\x65"]; } switch ($current_type) { case "\143\150\145\143\153\142\x6f\170": $array_values = (array) $values["\166\141\154\x75\145"]; $array_values = array_values($array_values); if (in_array($field["\x74\x69\x74\x6c\145"], array_filter($array_values))) { $black = imagecolorallocate($currentImg, 0, 0, 0); imagesetthickness($currentImg, 2); imageline($currentImg, $x + 1, $y + 1, $x + 1 + $width, $y + 1 + $height, $black); imageline($currentImg, $x + 1 + $width, $y + 1, $x + 1, $y + 1 + $height, $black); imagecolordeallocate($currentImg, $black); imagesetthickness($currentImg, 1); } $string = ''; break; case "\x72\x61\x64\151\x6f": $radio = $values["\166\x61\154\165\x65"]; if ($field["\164\151\164\x6c\145"] == $radio) { $black = imagecolorallocate($currentImg, 0, 0, 0); imagesetthickness($currentImg, 2); imageline($currentImg, $x + 1, $y + 1, $x + 1 + $width, $y + 1 + $height, $black); imageline($currentImg, $x + 1 + $width, $y + 1, $x + 1, $y + 1 + $height, $black); imagecolordeallocate($currentImg, $black); imagesetthickness($currentImg, 1); } $string = ''; break; } } if (!empty($string)) { $this->font->setFontSize($this->fontSize); switch ($current_type) { case "\164\x69\155\145\x73\x74\x61\155\x70": $this->setTimeStampFontSizeAndPosition($x, $y, $width, $height, $string, $currentImg); break; case "\x73\151\x67\156\141\164\x75\162\x65": $values = get_object_vars($this->values_structure[$id]); $exists = Storage::disk("\164\x65\155\160\x73")->exists($values["\166\141\x6c\x75\x65"]); if ($exists) { $content = Storage::disk("\x74\x65\x6d\x70\163")->get($values["\166\x61\154\x75\x65"]); $signature_image = imagecreatefromstring($content); $src_w = imagesx($signature_image); $src_h = imagesy($signature_image); imagecopyresampled($currentImg, $signature_image, $x, $y, 0, 0, $width, $height, $src_w, $src_h); imagedestroy($signature_image); $newArray = array(); $newArray["\151\144"] = $id; $newArray["\164\151\164\x6c\x65"] = $field["\x74\x69\x74\x6c\x65"]; $newArray["\x76\141\x6c\165\145"] = $values["\x76\141\154\x75\x65"]; Storage::disk("\164\x65\155\x70\x73")->delete($values["\166\141\154\165\x65"]); $this->completed_values[] = $newArray; } break; case "\146\x69\154\145": case "\151\155\141\147\x65": $values = get_object_vars($this->values_structure[$id]); $exists = Storage::disk("\164\x65\x6d\x70\x73")->exists($values["\x76\x61\x6c\165\145"]); if ($exists) { $content = Storage::disk("\164\x65\x6d\x70\x73")->get($values["\166\x61\x6c\165\145"]); $attach_image = imagecreatefromstring($content); $src_w = imagesx($attach_image); $src_h = imagesy($attach_image); imagecopyresampled($currentImg, $attach_image, $x, $y, 0, 0, $width, $height, $src_w, $src_h); imagedestroy($attach_image); $newArray = array(); $newArray["\x69\144"] = $id; $newArray["\x74\151\164\154\x65"] = $field["\164\x69\x74\x6c\x65"]; $newArray["\166\141\x6c\x75\145"] = $values["\x76\x61\x6c\165\x65"]; Storage::disk("\x74\x65\x6d\160\x73")->delete($values["\166\x61\x6c\165\145"]); $this->completed_values[] = $newArray; } break; default: $this->setFontSizeAndPosition($x, $y, $width, $height, $string, $currentImg, $current_type); } } } } private function imageTextToBoundingBox($width, $height, $source, $type) { $string_source = strip_tags($source); $font_size = round(intval($this->fontSize) - 6); $this->font->setFontSize($font_size); $cw = $this->font->getAverageCharacterWidth(); $maxChar = round(intval($width) / $cw); list($bw, $bh) = $this->font->getTextBoundingBox($string_source); $types = array("\164\145\x78\x74\x61\162\145\x61", "\x70\x61\162\141\x67\x72\141\x70\x68", "\x61\144\x64\x72\x65\x73\x73", "\165\x73\145\x72\x5f\x61\144\x64\x72\145\163\x73", "\x72\145\x61\x64\x6f\156\x6c\171"); if (in_array($type, $types)) { $string = wordwrap($string_source, $maxChar, "\12", TRUE); } else { $trimmed = substr($string_source, 0, $maxChar); $string = $bw > $width ? "{$trimmed}\x2e\56\56" : $string_source; } $image = imagecreate($width, $height); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); $color = $this->hexColorAllocation($image, $this->fontColor); $trans = imagecolortransparent($image, $white); imagefilledrectangle($image, 0, 0, $width, $height, $white); imagettftext($image, $font_size, 0, 0, $font_size, $color, $this->font->getFontFile(), $string); return $image; } private function imageTimeStampToBoundingBox($width, $height, $string_source) { $w = intval(334.0 / 449 * $width); $h = intval(139.0 / 184 * $height); for ($font_size = 28; 7 < $font_size; $font_size -= 0.5) { $this->font->setFontSize($font_size); $cw = $this->font->getAverageCharacterWidth(); $string = wordwrap($string_source, floor($w / $cw), "\xa", true); list($bw, $bh) = $this->font->getTextBoundingBox($string); if ($bw <= $w && $bh <= $h) { break; } } $image = imagecreate($w, $h); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); $color = $this->hexColorAllocation($image, $this->fontColor); $trans = imagecolortransparent($image, $white); imagefilledrectangle($image, 0, 0, $w, $h, $white); imagettftext($image, $font_size, 0, 0, $font_size, $black, $this->font->getFontFile(), $string); return $image; } public function setTimeStampFontSizeAndPosition(&$x, &$y, $width, $height, $string, $currentImg) { $image = $this->imageTimeStampToBoundingBox($width, $height, $string); list($bw, $bh) = $this->font->getTextBoundingBox($string); $x += floor(($width - $bw) / 3.0); $y += floor(($height - $bh) / 2.0); imagecopy($currentImg, $image, $x, $y, 0, 0, $width, $height); } public function setFontSizeAndPosition(&$x, &$y, $width, $height, $string, $currentImg, $type) { $string = mb_convert_encoding($string, "\125\x54\x46\x2d\70", "\125\x54\x46\55\70"); $image = $this->imageTextToBoundingBox($width, $height, $string, $type); imagecopy($currentImg, $image, $x, $y + 5, 0, 0, $width, $height); } private function hexColorAllocation($img, $hex) { $hex = ltrim($hex, "\43"); $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); return imagecolorallocate($img, $r, $g, $b); } }

Function Calls

None

Variables

None

Stats

MD5 15f604cc94d0618be680aee3503cdd34
Eval Count 0
Decode Time 90 ms