forked from cryptii/cryptii
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·298 lines (259 loc) · 7.38 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?php
//
// AVAILABLE CONVERSIONS
//
$interpret = array(
'text',
'htmlentities',
'morsecode',
'navajo',
'decimal',
'binary',
'octal',
'hexadecimal',
'roman-numerals',
'atbash',
'caesar',
'vigenere',
'ita2',
'rot13',
'base64',
'select');
$convert = array(
'text',
'flipped',
'htmlentities',
'morsecode',
'leetspeak',
'navajo',
'decimal',
'binary',
'octal',
'hexadecimal',
'roman-numerals',
'atbash',
'caesar',
'vigenere',
'ita2',
'pigpen',
'rot13',
'base64',
'md5',
'sha1',
'select');
$formats = array(
'text' => 'Text',
'flipped' => 'Flipped',
'htmlentities' => 'HTML Entities',
'morsecode' => 'Morsecode',
'leetspeak' => 'Leetspeak',
'navajo' => 'Navajo code',
'decimal' => 'Decimal',
'binary' => 'Binary',
'octal' => 'Octal',
'hexadecimal' => 'Hexadecimal',
'roman-numerals' => 'Roman numerals',
'atbash' => 'Atbash Roman',
'caesar' => 'Caesar Cipher',
'vigenere' => 'Vigenère Cipher',
'ita2' => 'ITA2 / CCITT-2',
'pigpen' => 'Pigpen cipher',
'rot13' => 'ROT13',
'base64' => 'Base 64',
'md5' => 'MD5',
'sha1' => 'SHA-1',
'select' => 'Multiple Systems');
// create conversions
$conversions = array();
// list possible conversions
// go through interpret formats
foreach ($interpret as $interpret_format)
// go through convert formats of this interpret format
foreach ($convert as $convert_format)
if (
// exclude conversions with the
// same interpret and convert formats
$interpret_format != $convert_format
// exclude current formats
&& !(
$_interpret_format == $interpret_format
&& $_convert_format == $convert_format))
{
// collect information
$url = sprintf('/%s/%s',
$interpret_format,
$convert_format);
$name = sprintf('%s to %s',
$formats[$interpret_format],
$formats[$convert_format]);
// add to list
$conversions[$url] = $name;
}
//
// ROUTE URL
//
// read url
list($url) = explode('?', $_SERVER['REQUEST_URI']);
if ($url == '/sitemap.xml')
{
// header
header('Content-Type: text/xml');
// xml
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\r\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\r\n";
// iterate through conversions
foreach ($conversions as $url => $name)
{
$loc_url = 'http://' . $_SERVER['SERVER_NAME'] . $url;
echo "\t" . '<url><loc>' . $loc_url . '</loc></url>' . "\r\n";
}
echo '</urlset>' . "\r\n";
// cancel here
die();
}
else if ($url != '/')
{
$url_parts = explode('/', $url);
// add formats to title
list($_interpret_format) = explode(';', $url_parts[1]);
list($_convert_format) = explode(';', $url_parts[2]);
$title = null;
if (!$_convert_format)
$_convert_format = 'select';
// interpret url
if ($formats[$_interpret_format]
&& $formats[$_convert_format])
// add title
$title =
$formats[$_interpret_format]
. ' to '
. $formats[$_convert_format];
else
{
// redirect to homepage
header('Location: /');
header('HTTP/1.1 301 Moved Permanently');
// cancel here
die();
}
}
else
{
// title for index page
$title = 'Fast converting, encrypting and decrypting';
}
$title = $title . ' — Cryptii';
?>
<!--
Hi there!
Thank you for your interest in the source code of Cryptii.
Perhaps it would be easyer to browse the code on GitHub.
https://github.com/the2f/Cryptii
-->
<!DOCTYPE html>
<html>
<head prefix="og: http://ogp.me/ns#">
<meta charset="utf-8">
<base href="/">
<title><?= $title ?></title>
<meta property="og:title" content="<?= $title ?>">
<meta property="og:site_name" content="Cryptii">
<meta property="og:type" content="website">
<meta property="og:url" content="http://<?= $_SERVER['SERVER_NAME'] ?><?= $url ?>">
<meta property="og:description" content="
Cryptii is an OpenSource web application under the MIT license where you can convert,
encrypt and decrypt content between different format systems.">
<meta name="keywords" content="
Cryptii, convert, converter, text converter, encode, encrypt, decode, decrypt,
paper tape, geo caching, mit license, open source, javascript, js">
<meta property="og:image" content="http://cryptii.com/images/cryptii.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="277">
<meta property="og:image:height" content="277">
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
<link rel="stylesheet" href="css/default.css" media="screen">
<link rel="stylesheet" href="css/jquery.ui.slider.min.css" media="screen">
</head>
<body>
<div id="frame">
<div id="wrapper">
<hgroup>
<h1>
<a href="/">Cryptii</a>
<span class="format"><?= $title ?></span>
</h1>
<h2>Convert, encode, encrypt, decode and decrypt your content online</h2>
</hgroup>
<div id="about">
<p>
Designed and coded with <3<br>
Brought to you by <a href="http://fraenz.frieder.es/" target="_blank">ffraenz</a>
</p>
<div id="social">
<a class="facebook" href="https://facebook.com/thetwof" target="_blank">
<span>Find the2f on Facebook</span></a>
<a class="twitter" href="https://twitter.com/ffraenz" target="_blank">
<span>Follow @ffraenz on Twitter</span></a>
<a class="gittip" href="https://www.gittip.com/ffraenz/" target="_blank">
<span>Find ffraenz on Gittip</span></a>
</div>
</div>
<p class="intro">
Don't leave your messages plaintext on public places.
Cryptii is an OpenSource web application under the
<a href="https://github.com/the2f/Cryptii#license" target="_blank">MIT license</a>
where you can convert, encrypt and decrypt content between different format systems.
This happens fully in your browser using
<a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>,
no content will be sent to any kind of server.
Any feedback appreciated, just leave me a tweet or contribute to this project
— <a href="http://fraenz.frieder.es/portfolio/cryptii/" target="_blank">Read more</a>
</p>
<!-- this sitemap mentions other possible conversions -->
<nav id="sitemap">
<h2>Possible conversions</h2>
<ul><?php
// list possible conversions
// go through interpret formats
foreach ($conversions as $url => $name)
// add to list
echo "\r\n\t\t\t\t\t\t"
. '<li>'
. '<a href="' . $url . '">'
. $name
. '</a>'
. '</li>';
// add new line at beginning
echo "\r\n\t\t\t\t\t";
?></ul>
</nav>
<div id="application"></div>
</div>
</div>
<!-- fork me -->
<a href="https://github.com/the2f/Cryptii" id="forkme" target="_blank">Fork me on GitHub</a>
<!-- include jquery and plugins -->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
// fallback if jQuery is not available
if (typeof jQuery == 'undefined')
document.write('<script src="js/jquery.min.js"></scr' + 'ipt>');
</script>
<script src="js/jquery.ui.slider.min.js"></script>
<script src="js/jquery.history.js"></script>
<!-- include analytics -->
<script src="http://www.google-analytics.com/ga.js"></script>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-4208952-24']);
_gaq.push(['_setCampSourceKey', 'ref']);
_gaq.push(['_trackPageview']);
</script>
<!-- include main application -->
<script src="js/cryptii.min.js"></script>
<script>
// start application
cryptii.init();
</script>
</body>
</html>