This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgethtml.php
54 lines (43 loc) · 1.72 KB
/
gethtml.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
51
52
53
54
<?php
namespace Orderer;
include_once '../vendor/autoload.php';
$engine = new FlexiBeeEngine(['config' => '../config.json']);
$oPage = new \Ease\TWB\WebPage('HTML');
$embed = $oPage->getRequestValue('embed');
$id = $oPage->getRequestValue('id');
$evidence = $oPage->getRequestValue('evidence');
function deleteAllBetween($beginning, $end, $string)
{
$beginningPos = strpos($string, $beginning);
$endPos = strpos($string, $end);
if ($beginningPos === false || $endPos === false) {
return $string;
}
$textToDelete = substr($string, $beginningPos,
($endPos + strlen($end)) - $beginningPos);
return str_replace($textToDelete, '', $string);
}
$document = new \FlexiPeeHP\FlexiBeeRO(is_numeric($id) ? intval($id) : $id,
['evidence' => $evidence]);
if (!is_null($document->getMyKey())) {
$documentBody = $document->getInFormat('html');
$documentBody = str_replace(['src="/', 'href="/'],
['src="'.$document->url.'/', 'href="'.$document->url.'/'], $documentBody);
$documentBody = deleteAllBetween('FLEXIBEE:TOOLBAR:START',
'FLEXIBEE:TOOLBAR:END', $documentBody);
if ($embed != 'true') {
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename='.$document->getEvidence().'_'.$document.'.html');
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
} else {
header('Content-Type: text/html');
}
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.strlen($documentBody));
echo $documentBody;
} else {
die(_('Wrong call'));
}