Skip to content

Commit

Permalink
use iframe viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Aug 8, 2024
1 parent 350bb50 commit eae619b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/SparkPostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function sent_emails(HTTPRequest $req)
$logFolder = SparkPostHelper::getLogFolder();
$view = $req->getVar('view');
$download = $req->getVar('download');
$iframe = $req->getVar('iframe');
$base = Director::baseFolder();

if ($download) {
Expand All @@ -89,6 +90,15 @@ public function sent_emails(HTTPRequest $req)
return HTTPRequest::send_file($fileData, $fileName);
}

if ($iframe) {
$file = $logFolder . '/' . $view;
if (!is_file($file) || dirname($file) != $logFolder) {
return $this->httpError(404);
}
$content = file_get_contents($file);
return $content;
}

if ($view) {
$file = $logFolder . '/' . $view;
if (!is_file($file) || dirname($file) != $logFolder) {
Expand All @@ -100,7 +110,8 @@ public function sent_emails(HTTPRequest $req)
$content = str_replace($base, '', $content);

$customFields = [
'Email' => $content
'Email' => $content,
'Name' => $view,
];
} else {
$emails = new ArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<% if Email %>
<a href="/__sparkpost/sent_emails">Back</a>
<hr>
$Email.RAW
<iframe style="min-width:600px;max-width:100%;min-height:480px;border:0;resize:both;border:1px dashed" src="?view=$Name&iframe=1"></iframe>
<% else %>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sakura.css/css/sakura.css" type="text/css">
<h1>Sent emails</h1>
Expand Down

0 comments on commit eae619b

Please sign in to comment.