forked from maizzle/maizzle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
77 lines (61 loc) · 1.92 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
70
71
72
73
74
75
76
77
<?php
header('Content-Type: text/html; charset=utf-8');
require_once 'vendor/autoload.php';
// use DOMWrap\Document;
/*/ ======================================================================
Multi-Environment Twig Loader
====================================================================== /*/
$env = "live";
$host = $_SERVER["HTTP_HOST"];
$settings = [
'cache' => false,
'debug' => true
];
$loader = new \Twig\Loader\FilesystemLoader('./');
$twig = new \Twig\Environment($loader, $settings);
/*/ ======================================================================
Load Site and Data
====================================================================== /*/
$pathname = $_GET['p'] ?? 'index';
$slug = basename($pathname);
$data = [
'ip' => $_SERVER["REMOTE_ADDR"],
'env' => $env,
'url' => $_SERVER["HTTP_HOST"],
'query' => $_GET,
'slug' => $slug,
'pathname' => $pathname,
'site' => [
'name' => 'MWG Email System',
'gtag' => '',
'designer' => [
'contributors' => 'Stephen Ginn',
'company' => 'Crema Design Studio',
'url' => 'https://cremadesignstudio.com'
]
],
'company' => [
'name' => 'Crema Design Studio',
'street' => '1107 Highland Colony Parkway, Suite 205',
'city' => 'Ridgeland',
'state' => 'MS',
'zip' => '39157'
]
];
/*/ ======================================================================
Render Pages
====================================================================== /*/
$home = `printf ~`;
putenv("HOME=$home");
putenv('PATH=$PATH:/bin:/usr/bin:/usr/local/bin:$HOME/bin');
try {
// Render MJML Template
// $src = $twig->render("src/templates/promotional.html");
$src = file_get_contents('./src/templates/promotional.html');
$src = str_replace('"', '\"', $src);
$html = shell_exec('. ~/.bashrc; node index.js ' . '"' . $src . '"');
echo $html;
} catch (Exception $e) {
echo $twig->render('404.twig', $data);
}
?>