HEX
Server: Apache/2.4.59 (Debian)
System: Linux keymana 4.19.0-21-cloud-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64
User: lijunjie (1003)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/keytest/wp-content/themes/ormedia/page-generate.php
<?php
/* Template Name: Generate Files */

// ini_set('display_errors', 1); //错误信息
// ini_set('display_startup_errors', 1); //php启动错误信息
// error_reporting(-1);


function html2docx($filename, $html, $generator = "html2docx")
{
    require_once "/home/lijunjie/vendor/autoload.php";
    $generator = strtolower($generator);
    if ($generator == "phpword") {
        $phpWord = new \PhpOffice\PhpWord\PhpWord();
        $section = $phpWord->addSection();

        \PhpOffice\PhpWord\Shared\Html::addHtml($section, $html, false, false);

        header("Content-Description: File Transfer");
        header('Content-Disposition: attachment; filename="' . $filename . '.docx' . '"');
        header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
        header('Content-Transfer-Encoding: binary');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Expires: 0');

        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
        $objWriter->save('php://output');
    } else {
        require_once('html2docx.class.php');
        $htd = new HTML_TO_DOCX();
        $htd->createDoc($html, $filename, 1);
    }
}

function html2pdf($filename, $html, $generator = "Mpdf", $orientation = "P")
{
    require_once "/home/lijunjie/vendor/autoload.php";
    $generator = strtolower($generator);
    if ($generator == "dompdf") {
        $dompdf = new Dompdf\Dompdf();
        $dompdf->loadHtml($html);
        $dompdf->setPaper('A4');
        $dompdf->render();
        $dompdf->stream($filename . ".pdf");
    } else {
        $mpdf = new \Mpdf\Mpdf([
            'mode'    => 'zh-CN', // utf-8不能解决中文符号乱码
            'format'  => 'A4',
            'tempDir' => '/tmp',
            'orientation' => $orientation
        ]);

        $mpdf->allow_charset_conversion = true;
        $mpdf->autoScriptToLang         = true;
        $mpdf->autoLangToFont           = true;
        $mpdf->autoVietnamese           = true;
        $mpdf->autoArabic               = true;
        $mpdf->useFixedNormalLineHeight = false;
        $mpdf->useFixedTextBaseline     = false;
        $mpdf->adjustFontDescLineheight = 1.50;
        $mpdf->ignore_invalid_utf8      = true;
        $mpdf->shrink_tables_to_fit     = 1;
        $mpdf->keep_table_proportions   = true;

        $mpdf->WriteHTML($html);
        $mpdf->Output($filename . ".pdf", \Mpdf\Output\Destination::DOWNLOAD);
    }
}

function require_xlsx_helper()
{
    require_once('xlsxHelper.class.php');
}

// 生成" in ('a','b','c') "字符串
function get_sql_in_str($string)
{
    $tmp = explode(",", $string);
    $tmp_string = "";
    foreach ($tmp as $k => $item) {
        $tmp_string .= "'" . $item . "'";
        if ($k != count($tmp) - 1) $tmp_string .= ",";
    }
    return $tmp_string;
}

$type = $_REQUEST['path'];
$filename = $_REQUEST['file'];

$dir = get_template_directory_uri();
$file = $dir . '/fileTemplate/' . $type . '/' . $filename . '.php?checking_api_file=true';

$file_headers = @get_headers($file); //检测是否存在此文件
if (strpos($file_headers[0], 'OK') > -1) {
    global $wpdb;
    include 'fileTemplate/' . $type . '/' . $filename . '.php';
    exit();
} else {
    exit("file not found");
}