PK Default page
One Hat Cyber Team
  • Dir : ~/home/regallub/public_html/vendor/mpdf/mpdf/src/
  • Edit File: Mpdf.php
    $thereistextarea = preg_match_all('#(.*?)#si', $html, $temp2); $html = preg_replace('/[\n]/', ' ', $html); // replace linefeed by spaces $html = preg_replace('/[\t]/', ' ', $html); // replace tabs by spaces // Converts < to < when not a tag $html = preg_replace('/<([^!\/a-zA-Z_:])/i', '<\\1', $html); // mPDF 5.7.3 $html = preg_replace("/[ ]+/", ' ', $html); $html = preg_replace('/\/li>\s+<\/(u|o)l/i', '/li>\s+<\/li/i', '/\\1l>\s+<\/(u|o)l/i', '/li>\s+
  • ]*)>[ ]+/i', '<\\1l\\2>', $html); $html = preg_replace('/[ ]+<(u|o)l/i', '<\\1l', $html); // Make self closing tabs valid XHTML // Tags which are self-closing: 1) Replaceable and 2) Non-replaced items $selftabs = 'input|hr|img|br|barcode|dottab'; $selftabs2 = 'indexentry|indexinsert|bookmark|watermarktext|watermarkimage|column_break|columnbreak|newcolumn|newpage|page_break|pagebreak|formfeed|columns|toc|tocpagebreak|setpageheader|setpagefooter|sethtmlpageheader|sethtmlpagefooter|annotation'; // Fix self-closing tags which don't close themselves $html = preg_replace('/(<(' . $selftabs . '|' . $selftabs2 . ')[^>\/]*)>/i', '\\1 />', $html); // Fix self-closing tags that don't include a space between the tag name and the closing slash $html = preg_replace('/(<(' . $selftabs . '|' . $selftabs2 . '))\/>/i', '\\1 />', $html); $iterator = 0; while ($thereispre) { // Recover
    content
    $temp[2][$iterator] = preg_replace('/<([^!\/a-zA-Z_:])/', '<\\1', $temp[2][$iterator]); // mPDF 5.7.2 // mPDF 5.7.3 $temp[2][$iterator] = preg_replace_callback("/^([^\n\t]*?)\t/m", [$this, 'tabs2spaces_callback'], $temp[2][$iterator]); // mPDF 5.7+ $temp[2][$iterator] = preg_replace('/\t/', str_repeat(" ", $tabSpaces), $temp[2][$iterator]); $temp[2][$iterator] = preg_replace('/\n/', "
    ", $temp[2][$iterator]); $temp[2][$iterator] = str_replace('\\', "\\\\", $temp[2][$iterator]); // $html = preg_replace('#(.*?)#si',''.$temp[2][$iterator].'',$html,1); $html = preg_replace('#(.*?)#si', '' . str_replace('$', '\$', $temp[2][$iterator]) . '', $html, 1); // mPDF 5.7+ $thereispre--; $iterator++; } $iterator = 0; while ($thereistextarea) { // Recover $temp2[2][$iterator] = preg_replace('/\t/', str_repeat(" ", $tabSpaces), $temp2[2][$iterator]); $temp2[2][$iterator] = str_replace('\\', "\\\\", $temp2[2][$iterator]); $html = preg_replace('#(.*?)#si', '' . trim($temp2[2][$iterator]) . '', $html, 1); $thereistextarea--; $iterator++; } // Restore original tag names $html = str_replace("", "", $html); $html = str_replace("", "", $html); $html = str_replace("]*)><\/textarea>/si', ' ', $html); $html = preg_replace('/(]*>)\s*()(.*?<\/table>)/si', '\\2 position="top"\\3\\1\\4\\2 position="bottom"\\3', $html); // *TABLES* if ($this->use_kwt) { $returnHtml = preg_replace('/<(h[1-6])([^>]*(?[^>]*<\/\\1>\s*

    which browser copes with even though it is wrong! $html = preg_replace("/(&#[x]{0,1}[0-9a-f]{1,5})tabSpaces - (mb_strlen(stripslashes($matches[1])) % $this->tabSpaces))); } // mPDF 5.7+ function date_callback($matches) { return date($matches[1]); } // ========== OVERWRITE SEARCH STRING IN A PDF FILE ================ function OverWrite($file_in, $search, $replacement, $dest = Destination::DOWNLOAD, $file_out = "mpdf") { $pdf = file_get_contents($file_in); if (!is_array($search)) { $x = $search; $search = [$x]; } if (!is_array($replacement)) { $x = $replacement; $replacement = [$x]; // mPDF 5.7.4 } if (!$this->onlyCoreFonts && !$this->usingCoreFont) { foreach ($search as $k => $val) { $search[$k] = $this->writer->utf8ToUtf16BigEndian($search[$k], false); $search[$k] = $this->writer->escape($search[$k]); $replacement[$k] = $this->writer->utf8ToUtf16BigEndian($replacement[$k], false); $replacement[$k] = $this->writer->escape($replacement[$k]); } } else { foreach ($replacement as $k => $val) { $replacement[$k] = mb_convert_encoding($replacement[$k], $this->mb_enc, 'utf-8'); $replacement[$k] = $this->writer->escape($replacement[$k]); } } // Get xref into array $xref = []; preg_match("/xref\n0 (\d+)\n(.*?)\ntrailer/s", $pdf, $m); $xref_objid = $m[1]; preg_match_all('/(\d{10}) (\d{5}) (f|n)/', $m[2], $x); for ($i = 0; $i < count($x[0]); $i++) { $xref[] = [(int) $x[1][$i], $x[2][$i], $x[3][$i]]; } $changes = []; preg_match("/<<\s*\/Type\s*\/Pages\s*\/Kids\s*\[(.*?)\]\s*\/Count/s", $pdf, $m); preg_match_all("/(\d+) 0 R /s", $m[1], $o); $objlist = $o[1]; foreach ($objlist as $obj) { if ($this->compress) { preg_match("/" . ($obj + 1) . " 0 obj\n<<\s*\/Filter\s*\/FlateDecode\s*\/Length (\d+)>>\nstream\n(.*?)\nendstream\n/s", $pdf, $m); } else { preg_match("/" . ($obj + 1) . " 0 obj\n<<\s*\/Length (\d+)>>\nstream\n(.*?)\nendstream\n/s", $pdf, $m); } $s = $m[2]; if (!$s) { continue; } $oldlen = $m[1]; if ($this->encrypted) { $s = $this->protection->rc4($this->protection->objectKey($obj + 1), $s); } if ($this->compress) { $s = gzuncompress($s); } foreach ($search as $k => $val) { $s = str_replace($search[$k], $replacement[$k], $s); } if ($this->compress) { $s = gzcompress($s); } if ($this->encrypted) { $s = $this->protection->rc4($this->protection->objectKey($obj + 1), $s); } $newlen = strlen($s); $changes[($xref[$obj + 1][0])] = ($newlen - $oldlen) + (strlen($newlen) - strlen($oldlen)); if ($this->compress) { $newstr = ($obj + 1) . " 0 obj\n<>\nstream\n" . $s . "\nendstream\n"; } else { $newstr = ($obj + 1) . " 0 obj\n<>\nstream\n" . $s . "\nendstream\n"; } $pdf = str_replace($m[0], $newstr, $pdf); } // Update xref in PDF krsort($changes); $newxref = "xref\n0 " . $xref_objid . "\n"; foreach ($xref as $v) { foreach ($changes as $ck => $cv) { if ($v[0] > $ck) { $v[0] += $cv; } } $newxref .= sprintf('%010d', $v[0]) . ' ' . $v[1] . ' ' . $v[2] . " \n"; } $newxref .= "trailer"; $pdf = preg_replace("/xref\n0 \d+\n.*?\ntrailer/s", $newxref, $pdf); // Update startxref in PDF preg_match("/startxref\n(\d+)\n%%EOF/s", $pdf, $m); $startxref = $m[1]; $startxref += array_sum($changes); $pdf = preg_replace("/startxref\n(\d+)\n%%EOF/s", "startxref\n" . $startxref . "\n%%EOF", $pdf); // OUTPUT switch ($dest) { case Destination::INLINE: if (isset($_SERVER['SERVER_NAME'])) { // We send to a browser header('Content-Type: application/pdf'); header('Content-Length: ' . strlen($pdf)); header('Content-disposition: inline; filename=' . $file_out); } echo $pdf; break; case Destination::FILE: if (!$file_out) { $file_out = 'mpdf.pdf'; } $f = fopen($file_out, 'wb'); if (!$f) { throw new \Mpdf\MpdfException('Unable to create output file: ' . $file_out); } fwrite($f, $pdf, strlen($pdf)); fclose($f); break; case Destination::STRING_RETURN: return $pdf; case Destination::DOWNLOAD: // Download file default: if (isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { header('Content-Type: application/force-download'); } else { header('Content-Type: application/octet-stream'); } header('Content-Length: ' . strlen($pdf)); header('Content-disposition: attachment; filename=' . $file_out); echo $pdf; break; } } function Thumbnail($file, $npr = 3, $spacing = 10) { // $npr = number per row $w = (($this->pgwidth + $spacing) / $npr) - $spacing; $oldlinewidth = $this->LineWidth; $this->SetLineWidth(0.02); $this->SetDColor($this->colorConverter->convert(0, $this->PDFAXwarnings)); $h = 0; $maxh = 0; $x = $_x = $this->lMargin; $_y = $this->tMargin; if ($this->y == 0) { $y = $_y; } else { $y = $this->y; } $pagecount = $this->setSourceFile($file); for ($n = 1; $n <= $pagecount; $n++) { $tplidx = $this->importPage($n); $size = $this->useTemplate($tplidx, $x, $y, $w); $this->Rect($x, $y, $size['width'], $size['height']); $h = max($h, $size['height']); $maxh = max($h, $maxh); if ($n % $npr == 0) { if (($y + $h + $spacing + $maxh) > $this->PageBreakTrigger && $n != $pagecount) { $this->AddPage(); $x = $_x; $y = $_y; } else { $y += $h + $spacing; $x = $_x; $h = 0; } } else { $x += $w + $spacing; } } $this->SetLineWidth($oldlinewidth); } function SetPageTemplate($tplidx = '') { if (!isset($this->importedPages[$tplidx])) { $this->pageTemplate = ''; return false; } $this->pageTemplate = $tplidx; } function SetDocTemplate($file = '', $continue = 0, $continue2pages = 0) { $this->docTemplate = $file; $this->docTemplateContinue = $continue; $this->docTemplateContinue2pages = $continue2pages; if ($this->docTemplateContinue2pages) { // Enable continue when continue2pages is set $this->docTemplateContinue = $this->docTemplateContinue2pages; } } /* -- END IMPORTS -- */ // JAVASCRIPT function _set_object_javascript($string) { $this->writer->object(); $this->writer->write('<<'); $this->writer->write('/S /JavaScript '); $this->writer->write('/JS ' . $this->writer->string($string)); $this->writer->write('>>'); $this->writer->write('endobj'); } function SetJS($script) { $this->js = $script; } /** * This function takes the last comma or dot (if any) to make a clean float, ignoring thousand separator, currency or any other letter * * @param string $num * @see http://php.net/manual/de/function.floatval.php#114486 * @return float */ public function toFloat($num) { $dotPos = strrpos($num, '.'); $commaPos = strrpos($num, ','); $sep = (($dotPos > $commaPos) && $dotPos) ? $dotPos : ((($commaPos > $dotPos) && $commaPos) ? $commaPos : false); if (!$sep) { return floatval(preg_replace('/[^0-9]/', '', $num)); } return floatval( preg_replace('/[^0-9]/', '', substr($num, 0, $sep)) . '.' . preg_replace('/[^0-9]/', '', substr($num, $sep+1, strlen($num))) ); } public function getFontDescriptor() { return $this->fontDescriptor; } /** * Temporarily return the method to preserve example 44 yearbook */ public function _out($s) { $this->writer->write($s); } /** * @param string $html * @param string $PAGENO * @param string $NbPgGp * @param string $NbPg * @return string */ protected function aliasReplace($html, $PAGENO, $NbPgGp, $NbPg) { // Replaces for header and footer $html = str_replace('{PAGENO}', $PAGENO, $html); $html = str_replace($this->aliasNbPgGp, $NbPgGp, $html); // {nbpg} $html = str_replace($this->aliasNbPg, $NbPg, $html); // {nb} // Replaces for the body $html = str_replace(mb_convert_encoding('{PAGENO}', 'UTF-16BE', 'UTF-8'), mb_convert_encoding($PAGENO, 'UTF-16BE', 'UTF-8'), $html); $html = str_replace(mb_convert_encoding($this->aliasNbPgGp, 'UTF-16BE', 'UTF-8'), mb_convert_encoding($NbPgGp, 'UTF-16BE', 'UTF-8'), $html); // {nbpg} $html = str_replace(mb_convert_encoding($this->aliasNbPg, 'UTF-16BE', 'UTF-8'), mb_convert_encoding($NbPg, 'UTF-16BE', 'UTF-8'), $html); // {nb} // Date replace $html = preg_replace_callback('/\{DATE\s+(.*?)\}/', [$this, 'date_callback'], $html); // mPDF 5.7 return $html; } }