forked from luksm/PHP-Signature-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
192 lines (163 loc) · 7.35 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
if (!empty($_REQUEST['Sender'])):
$sender = $_REQUEST['Sender'];
$layout = file_get_contents('./layout.html', FILE_USE_INCLUDE_PATH);
foreach ($sender as $key => $value) {
$key = strtoupper($key);
$start_if = strpos($layout, '[[IF-' . $key . ']]');
$end_if = strpos($layout, '[[ENDIF-' . $key . ']]');
$length = strlen('[[ENDIF-' . $key . ']]');
if (!empty($value)) {
// Add the value at its proper location.
$layout = str_replace('[[IF-' . $key . ']]', '', $layout);
$layout = str_replace('[[ENDIF-' . $key . ']]', '', $layout);
$layout = str_replace('[[' . $key . ']]', $value, $layout);
} elseif (is_numeric($start_if)) {
// Remove the placeholder and brackets if there is an if-statement but no value.
$layout = str_replace(substr($layout, $start_if, $end_if - $start_if + $length), '', $layout);
} else {
// Remove the placeholder if there is no value.
$layout = str_replace('[[' . $key . ']]', '', $layout);
}
}
// Clean up any leftover placeholders. This is useful for booleans,
// which are not submitted if left unchecked.
$layout = preg_replace("/\[\[IF-(.*?)\]\]([\s\S]*?)\[\[ENDIF-(.*?)\]\]/u", "", $layout);
if (!empty($_REQUEST['download'])) {
header('Content-Description: File Transfer');
header('Content-Type: text/html');
header('Content-Disposition: attachment; filename=assinatura.html');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
echo $layout;
else: ?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Lucas Machado">
<title>Signature Generator</title>
<!-- Bootstrap core CSS -->
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<style type="text/css">
/* Sticky footer styles
-------------------------------------------------- */
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by its height */
margin: 0 auto -60px;
/* Pad bottom by footer height */
padding: 0 0 60px;
}
/* Set the fixed height of the footer here */
#footer {
height: 60px;
background-color: #f5f5f5;
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
#wrap > .container {
padding: 60px 15px 0;
}
.container .credit {
margin: 20px 0;
}
#footer > .container {
padding-left: 15px;
padding-right: 15px;
}
code {
font-size: 80%;
}
</style>
</head>
<body>
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Signature Generator</a>
</div>
</div>
</div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Simple Signature Generator</h1>
</div>
<form role="form" method="post" target="preview" id="form">
<div class="form-group">
<label for="Name">Name</label>
<input type="text" class="form-control" id="Name" name="Sender[name]" placeholder="Enter your name">
</div>
<div class="form-group">
<label for="Email">Email</label>
<input type="email" class="form-control" id="Email" name="Sender[email]" placeholder="Enter your email">
</div>
<div class="form-group">
<label for="Phone">Telefone</label>
<input type="phone" class="form-control" id="Phone" name="Sender[phone]" placeholder="+XX (XX) XXXX-XXXX">
</div>
<div class="form-group">
<label for="Mobile">Celular</label>
<input type="phone" class="form-control" id="Mobile" name="Sender[mobile]" placeholder="+XX (XX) XXXXX-XXXX">
</div>
<div class="form-group">
<label for="Website">Display website</label>
<input type="checkbox" class="form-control" id="Website" name="Sender[website]">
</div>
<button id="preview" type="submit" class="btn btn-default">Preview</button>
<button id="download" class="btn btn-default">Download</button>
<input type="hidden" name="download" id="will-download" value="">
</form>
</div>
<div class="container">
<iframe src="about:blank" name="preview" width="100%" height="200"></iframe>
</div>
</div>
<div id="footer">
<div class="container">
<p class="text-muted credit">developed by <a href="http://www.lucasms.net/">Lucas Machado</a>.</p>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$("#download").bind( "click", function() {
$('#will-download').val('true');
$('#form').removeAttr('target').submit();
});
$("#preview").bind( "click", function() {
$('#will-download').val('');
$('#form').attr('target','preview');
});
});
</script>
</body>
</html>
<?php endif;