45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
function getHtmlFiles($dir) {
|
|
$htmlFiles = [];
|
|
if (!is_dir($dir)) {
|
|
return $htmlFiles;
|
|
}
|
|
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
|
|
|
|
foreach ($iterator as $file) {
|
|
if ($file->isDir()) continue; // Dizinleri atla
|
|
|
|
$fileName = $file->getFilename();
|
|
if (pathinfo($fileName, PATHINFO_EXTENSION) === 'html') {
|
|
$htmlFiles[] = $file->getPathname();
|
|
}
|
|
}
|
|
|
|
return $htmlFiles;
|
|
}
|
|
|
|
$folderName = get("path");
|
|
$pdfFolderName = "$folderName-PDF";
|
|
$htmlDirectory = "$folderName/";
|
|
$pdfDirectory = "$pdfFolderName/";
|
|
$htmlFiles = getHtmlFiles($htmlDirectory);
|
|
|
|
|
|
foreach($htmlFiles AS $htmlFile) {
|
|
|
|
$pdfFile = str_replace($folderName, $pdfFolderName, $htmlFile);
|
|
$pdfFile = str_replace(".html", ".pdf", $pdfFile);
|
|
$pdfDirName = dirname($pdfFile);
|
|
//dump($pdfFile);
|
|
//dump($htmlFile);
|
|
@mkdir($pdfDirName, 0777, true);
|
|
|
|
(html_to_pdf(
|
|
$htmlFile,
|
|
$pdfFile,
|
|
get("paper")
|
|
));
|
|
}
|
|
|
|
?>
|
|
@include("admin-ajax.create-zip-file")
|