-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
69 lines (66 loc) · 2.16 KB
/
index.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
if( trim(file_get_contents("php://input")) !== "" )
{
$json = json_decode(trim(file_get_contents("php://input")), true);
if( isset( $json["MarkDownData"] ) )
{
if(session_status() == PHP_SESSION_NONE)
session_start();
$_SESSION["MarkDownData"] = $json["MarkDownData"];
}
}
if (isset($_GET["getIframe"])) {
if(session_status() == PHP_SESSION_NONE)
session_start();
if (isset($_SESSION["MarkDownData"]))
{
require_once "MDEditor.php";
$mde = new MDEditor;
$mde->setDocumentStyle("light");
echo $mde->mddata2html($_SESSION["MarkDownData"]);
}
else echo file_get_contents("./assets/html/iframe.html");
}
else if (isset($_GET["getPDF"])) {
if(session_status() == PHP_SESSION_NONE)
session_start();
if (isset($_SESSION["MarkDownData"]))
{
require_once "MDEditor.php";
$mde = new MDEditor;
$mde->setDocumentStyle("light");
$pdf = $mde->mddata2pdf($_SESSION["MarkDownData"]);
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=\"MDEditor_output.pdf\"");
header('Content-Length: ' . strlen($pdf));
echo $pdf;
}
else echo "Error: No markdown is set.";
}
else if (isset($_GET["getHTML"])) {
if(session_status() == PHP_SESSION_NONE)
session_start();
if (isset($_SESSION["MarkDownData"]))
{
require_once "MDEditor.php";
$mde = new MDEditor;
$mde->setDocumentStyle("light");
header('Content-Type: text/html');
header('Content-Disposition: attachment; filename="MDEditor_output.html"');
echo $mde->mddata2html($_SESSION["MarkDownData"]);
}
else echo "Error: No markdown is set.";
}
else if (isset($_GET["getMarkdown"])) {
if(session_status() == PHP_SESSION_NONE)
session_start();
if (isset($_SESSION["MarkDownData"]))
{
header('Content-Type: text/markdown');
header('Content-Disposition: attachment; filename="MDEditor_output.md"');
echo $_SESSION["MarkDownData"];
}
else echo "Error: No markdown is set.";
}
else echo file_get_contents("./GUI.html");
?>