-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsan_pb.php
50 lines (37 loc) · 1.06 KB
/
san_pb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* CLI utility
* sanitize odt file (delete page-breakers)
* 22-24/10/2019
*/
use OdtHelper\xmlTreeSearch;
require_once ('vendor/autoload.php');
$options = getopt("s:d:v:");
print_r($options);
if(empty($options)){
echo "-s <path to source> -d <path to dst> \n";
die;
}
if(!empty($options["v"])){
echo "version 0.1 18-10-2019 \n";
die;
}
$file_path_src = $options["s"]??null;
$file_path_dest = $options["d"]??null;
if(empty($file_path_src)){echo "Error! source is null!\n"; die;}
//if(empty($file_path_dest)){echo "Error! dest is null!"; die;}
$dataFile = "content.xml";
$zipFile = $options["s"];
$zip = new clsTbsZip();
$zip->Open($zipFile);
$ok = $zip->FileExists($dataFile);
if($ok){
$xml = $zip->FileRead($dataFile);
//echo $xml;
$xmlNew=preg_replace('/\<text:soft-page-break\/>/', '', $xml);
$res = $zip->FileReplace('content.xml', $xmlNew, TBSZIP_STRING); // replace the file by giving the content
$zip->Flush(TBSZIP_FILE, $file_path_dest );
echo "res: ".$res." \n";
}
$zip->Close();