403Webshell
Server IP : 188.151.22.197  /  Your IP : 216.73.217.74
Web Server : Apache/2.4.62 (Rocky Linux) OpenSSL/3.5.5
System : Linux wsten.se 5.14.0-687.30.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 13:09:21 UTC 2026 x86_64
User : apache ( 48)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/eric/vhost/wsten/wp-content/plugins/wsprod/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/eric/vhost/wsten/wp-content/plugins/wsprod/includes/pdf.php
<?php

use setasign\Fpdi\Tcpdf\Fpdi;

require_once('external/TCPDF/tcpdf.php');
require_once('external/FPDI/src/autoload.php');
/** 
$dir = wp_upload_dir();
$pdf = new Fpdi();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile($dir['basedir']."/2024/03/ao-inskription-3.pdf");
// import page 1
$tplId = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplId, 0, 0, 210);

$pdf->SetFont('courier', '', 14);
//$pdf->TextField('date', 50, 5, array(), array('v'=>date('Y-m-d'), 'dv'=>date('Y-m-d')));
//$pdf->TextField('firstname', 50, 5);
$pdf->setFormDefaultProp(array('vertical-align'=> 'middle','lineWidth'=>12,'borderStyle'=>'none'));// 'fillColor'=>array(255, 255, 200), 'strokeColor'=>array(255, 128, 128)));

$pdf->setFontSize(16);
$pdf->setCellMargins(null, 3, null, null);
// Last name
$pdf->TextField('date', 65.8, 12.7, array( 'charLimit'=>20, 'multiline'=>false, 'alignment'=>'right', 'margin-top' => 10), array('v'=>"Datum", 'dv'=>"Datuum"), 38.7, 16.0);

$pdf->setFontSize(12);
$pdf->TextField('desc-grave', 85.4, 28.7, array('multiline'=>true,'alignment'=>'left', 'alignment'=>'left','charLimit'=>100), array('v'=>"En bit lövbiff", 'dv'=>"En bit lövbiff"), 19.0, 37.9);

$pdf->TextField('current-grave', 85.4, 34.6, array(), array(), 19.0, 75.9);
$pdf->TextField('size', 85.4, 17.5, array(), array(), 19.0, 120.0);
$pdf->TextField('front', 85.4, 18.6, array(), array(), 19.0, 146.7);
$pdf->TextField('other_services', 172.1, 17.6, array(), array(), 19.0, 173.8);
$pdf->TextField('inscription', 172.1, 47.3, array(), array(), 19.0, 201.5);

$pdf->TextField('graveyard', 50, 12.55, array(), array('v'=>"En bit lövbiff", 'dv'=>"En bit lövbiff"), 141.1, 16.0);
$pdf->TextField('loc', 50, 12.5, array(), array(), 141.1, 29.1);
$pdf->TextField('invoice-details', 84.7, 45.9, array(), array(), 106.3, 50.8);
$pdf->TextField('text', 84.7, 23.7, array(), array(), 106.3, 106.3);
$pdf->TextField('decor', 84.7, 25.7, array(), array(), 106.3, 139.7);
$pdf->TextField('price', 92.2, 18.5, array(), array(), 98.9, 261.3);
//$pdf->Output('Hej.pdf');         */

class WsPdf {
    
}

class WsPdfFiller {

    private $tcpdf;
    private $name;
    private $drawing;
    private $qr;

    public static function load($name, $font, $border, $template, $drawing, $qr) {

        if (!is_string($name)) {
            return false;
        }

        if (!file_exists(plugin_dir_path('wsprod'). '/include/external/TCPDF/'.$font.'.php')) {
            return false;
        }

        if (!is_string($border)) {
            return false;
        }

        if (!file_exists($template)) {
            return false;
        }

        if (!is_array($drawing)) {
            return false;
        }
        else {
            if (@is_int($drawing['enabled']) && $drawing['enabled'] > 0) {
                if (isset($drawing['box']) && is_array($drawing['box'])) {
                    $keys = array_keys($drawing['box']);
                    $compare = array('size_x', 'size_y', 'pos_x', 'pos_y');

                    $diff = array_diff($keys, $compare);

                    if (sizeof($diff) == 0) {
                        foreach ($keys as $key) {
                            if (!is_float($drawing['box'][$key])) {
                                return false;
                            }
                        }
                    }
                    else {
                        return false;
                    }
                }
            }
            else {
                $drawing = false;
            }
        }

        if (!is_array($qr)) {
            return false;
        }
        else {
            if (@is_int($qr['enabled']) && $qr['enabled'] > 0) {
                if (isset($qr['box']) && is_array($qr['box'])) {
                    $keys = array_keys($qr['box']);
                    $compare = array('size_x', 'size_y', 'pos_x', 'pos_y');

                    $diff = array_diff($keys, $compare);

                    if (sizeof($diff) == 0) {
                        foreach ($keys as $key) {
                            if (!is_float($qr['box'][$key])) {
                                return false;
                            }
                        }
                    }
                    else {
                        return false;
                    }
                }
            }
            else {
                $qr = false;
            }
        }
        return new wsPdfFiller($name, $font, $border, $template, $drawing, $qr);
    }

    private function __construct($name, $font, $border, $template, $drawing, $qr) {
        $this->name = $name;
        $this->tcpdf = new Fpdi();
        $pageCount = $this->tcpdf->setSourceFile($template);

        if ($pageCount != 1) {
            // Do something
        }

        $templateId = $this->tcpdf->importPage(1);

        $this->tcpdf->AddPage();
        $this->tcpdf->useTemplate($templateId, ['adjustPageSize' => true]);
        $this->tcpdf->SetFont($font, '', 12);
        $this->tcpdf->setFormDefaultProp(array('vertical-align'=> 'middle','lineWidth'=>12,'borderStyle'=>$border));

        $this->drawing = $drawing;
        $this->qr = $qr;
    }

    private function check_field($field) {
        if (!(isset($field['var']) && (is_string(($field['var']) || is_array($field['var']))))) {
            return false;
        }

        if (!(isset($field['font-size']) && is_int($field['font-size']))) {
            return false;
        }

        if (!(isset($field['multiline']) && is_bool(($field['multiline'])))) {
            return false;
        }

        if (!(isset($field['align']) && is_string($field['align']))) {
            return false;
        }

        if (isset($field['margin']) && is_array($field['margin'])) {
            if (sizeof($field['margin']) == 4) {
                foreach ($field['margin'] as $int) {
                    if (!is_int($int)) {
                        return false;
                    }
                }
            }
        }
        else {
            return false;
        }

        if (!(isset($field['char_limit']) && is_int($field['char_limit']))) {
            return false;
        }

        if (!(isset($field['size_x']) && is_float($field['size_x']))) {
            return false;
        }

        if (!(isset($field['size_y']) && is_float($field['size_y']))) {
            return false;
        } 
        
        if (!(isset($field['pos_x']) && is_float($field['pos_x']))) {
            return false;
        }

        if (!(isset($field['pos_y']) && is_float($field['pos_y']))) {
            return false;
        } 

        return true;
    }

    private function set_image($src, $pos_x, $pos_y, $width, $height) {
        $upload_dir = wp_upload_dir();
        $base = $upload_dir['basedir'];

        $ext = explode('.',$src, 1);
        $full = $base.'/'.$src;
        $exif = exif_imagetype($full);

        if (!$exif) {
            return false;
        }

        switch (strtolower($ext)) {
            case 'png':
                $type = 'PNG';
                if ($exif != 3) {
                    return false;
                }
                break;
            case 'jpg':
                $type = 'JPG';
                if ($exif != 2) {
                    return false;
                }
                break; 
            case 'gif':
                $type = 'GIF';
                if ($exif != 1) {
                    return false;
                }
                break;
            default:
                $type = false;
                break;
        }

        if (!$type) {
            return false;
        }
        

        $this->tcpdf->Image($full, $pos_x, $pos_y, $width, $height, $type, '', '', true, 150, '', false, false, 1, false, false, false);
    }

    public function set_field($field, $value) {
        if ($this->check_field($field)) {
            $this->tcpdf->setFontSize($field['font-size']);
            $this->tcpdf->setCellMargins($field['margin'][0], $field['margin'][1], $field['margin'][2], $field['margin'][3]);
            $this->tcpdf->TextField($field['var'],
             $field['size_x'], 
             $field['size_y'], 
             array('multiline'=>$field['multiline'],'alignment'=>$field['align'], 'charLimit'=>$field['char_limit']), 
             array('v'=>$value, 'dv'=>$value), 
             $field['pos_x'], 
             $field['pos_y']);
        }
        else {
            return false;
        }
    }

    public function add_drawing($post_id) {

        if (!$this->drawing) {
            return false;
        }
        $drawing_loc = get_post_meta($post_id, 'drawing_loc');

        return $this->set_image($drawing_loc, $this->drawing['box']['pos_x'], $this->drawing['box']['pos_y'], $this->drawing['box']['size_x'], $this->drawing['box']['size_y']);
    }

    public function add_qr($post_id) {

        if (!$this->qr) {
            return false;
        }
        $qr_loc = get_post_meta($post_id, 'qr_loc');

        return $this->set_image($qr_loc, $this->qr['box']['pos_x'], $this->qr['box']['pos_y'], $this->qr['box']['size_x'], $this->qr['box']['size_y']);
    }

    public function save($post_id) {
        $stream = fopen('php://memory','r+');
        $this->tcpdf->Output($this->name.'.pdf');
        rewind($stream);
        $pdf_str = stream_get_contents($stream);
        $upload = wp_upload_bits( $this->name, null, $pdf_str, null );

        return $upload;
    }
}

?>

Youez - 2016 - github.com/yon3zu
LinuXploit