İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
function docx_to_html($docx, $html_dir) {
|
||||
// Ensure the LANG environment variable is set
|
||||
putenv('LANG=ru_RU.UTF-8');
|
||||
|
||||
// Ensure the output directory exists
|
||||
if (!is_dir($html_dir)) {
|
||||
mkdir($html_dir, 0777, true);
|
||||
}
|
||||
|
||||
// Construct the command
|
||||
$command = "libreoffice --headless --convert-to html --outdir " . escapeshellarg($html_dir) . " " . escapeshellarg($docx);
|
||||
// Execute the command
|
||||
$output = shell_exec($command);
|
||||
$output = extract_between_markers_docx($output);
|
||||
|
||||
update_src_paths($output, $html_dir);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function extract_between_markers_docx($input_str) {
|
||||
// Define the regular expression pattern to match the content between the markers
|
||||
$pattern = '/->\s*(.*?)\s*using filter : HTML \(StarWriter\)/';
|
||||
|
||||
// Perform the regex match
|
||||
if (preg_match($pattern, $input_str, $matches)) {
|
||||
// Return the matched content
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
// Return null if no match is found
|
||||
return null;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user