-
Notifications
You must be signed in to change notification settings - Fork 0
/
maildemo.php
915 lines (450 loc) · 22.2 KB
/
maildemo.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<?php
session_start();
if(isset($_GET['v']) && $_GET['v'] == "tz") {
header('Content-Type: image/gif');
die();
} elseif (!isset($_SESSION['gmailuser']) && !isset($_GET['login']) && $_SERVER["REQUEST_METHOD"] != "POST") {
header('Location: /maildemo.php?login');
die();
}
if (isset($_GET['login'])) {
?>
<!DOCTYPE html>
<html>
<body>
<h1>gmail demo (proof of concept)</h1>
<form action="maildemo.php" method="post">
your gmail address:
<input name="email" id="email" type="text" size="20" value="">
your gmail app password (how to get one? do a google search on it):
<input name="password" id="password" type="password" size="20" value="">
<input type="submit" name="login" value="login">
</form>
</body>
</html>
<?
} elseif ($_SERVER["REQUEST_METHOD"] == "POST" && !isset($_SESSION['gmailuser'])) {
if(empty(trim($_POST["email"])) || empty(trim($_POST["password"]))){
die("email and password cannot be empty");
} elseif(!preg_match('/^[a-zA-Z0-9\.\_\-\=\@]+$/', trim($_POST["email"]))){
die("invalid email");
} else {
$mbox = imap_open("{imap.gmail.com:993/imap/ssl/novalidate-cert/readonly}INBOX", $_POST["email"], $_POST["password"])
or die("invalid password");
imap_close($mbox);
$_SESSION['gmailuser'] = $_POST["email"];
$_SESSION['gmailpass'] = $_POST["password"];
header('Location: /maildemo.php');
}
} else {
$mbox = imap_open("{imap.gmail.com:993/imap/ssl/novalidate-cert/readonly}INBOX", $_SESSION['gmailuser'], $_SESSION['gmailpass'])
or die("can't connect: " . imap_last_error());
$recentnum = imap_num_recent($mbox);
$MC = imap_check($mbox);
$msgsminus50 = $MC->Nmsgs - 50;
if($msgsminus50 < 1) {
$msgsminus50 = 1;
}
$result = imap_fetch_overview($mbox,"$msgsminus50:{$MC->Nmsgs}",0);
usort($result, function($a, $b) {
return($b->udate-$a->udate);
});
function shorten($text, $number, $symbols = '...') {
$new = (strlen($text) > $number) ? substr($text, 0, $number) . $symbols : $text;
return $new;
}
?>
<html lang="en">
<pre style="font-size: 0;display: none;visibility: hidden;">
</pre>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Gmail - Inbox</title><link rel="canonical" href="https://mail.google.com/mail/"/><link rel="shortcut icon" href="https://ssl.gstatic.com/ui/v1/icons/mail/rfr/gmail.ico" type="image/x-icon"><link rel="stylesheet" type="text/css" href="https://mail.google.com/mail/u/1/h/_//?&name=c&ver=6wrl3yi4mm9e&v=ss" nonce="boEx14cBlaMkkZGCxMW5kA"><style type="text/css" nonce="boEx14cBlaMkkZGCxMW5kA">
@import url("https://mail.google.com/mail/u/1/h/_//?&name=a&ver=1sthyqjwgl8hj&v=ss");
#gbar,
#guser {
font-size: 13px;
padding-right: 8px;
padding-top: 4px !important;
}
#gbar {
padding-left: 8px;
height: 22px
}
#guser {
padding-bottom: 7px !important;
text-align: right
}
.gbh,
.gbd {
border-top: 1px solid #c9d7f1;
font-size: 1px
}
.gbh {
height: 0;
position: absolute;
top: 24px;
width: 100%
}
@media all {
.gb1 {
height: 22px;
margin-right: 0.5em;
vertical-align: top
}
#gbar {
float: left
}
}
a.gb1,
a.gb4 {
text-decoration: underline !important
}
a.gb1,
a.gb4 {
color: #00c !important
}
.gbi .gb4 {
color: #dd8e27 !important
}
.gbf .gb4 {
color: #900 !important
}
</style><base href="/maildemo.php"><script type="text/javascript" nonce="fhoi2ywldN-yJ0o1YooxIw">
(function () {
try {
var win = this;
while (true) {
if (win.parent == win)
break;
win
.frameElement
.src
.substr(0, 1);
win = win.parent
}
if (win.frameElement != null)
throw "busted";
} catch (e) {
document.write("--\x3e\x3cplaintext style\x3ddisplay:none\x3e\x3c!--");
try {
if (!open(location, "_top"))
alert("This content cannot be framed");
top.location = location
} catch (d) {}
}
})();
</script>
<script type="text/javascript" nonce="fhoi2ywldN-yJ0o1YooxIw"></script>
</head>
<body bgcolor="#ffffff">
<div id="gbar">
<nobr>
<a target="_blank" class="gb1" href="https://www.google.com/webhp?tab=mw&authuser=1">Search</a>
<a target="_blank" class="gb1" href="https://www.google.com/imghp?hl=en&tab=mi&authuser=1">Images</a>
<a target="_blank" class="gb1" href="https://maps.google.com/maps?hl=en&tab=ml&authuser=1">Maps</a>
<a target="_blank" class="gb1" href="https://play.google.com/?hl=en&tab=m8&authuser=1">Play</a>
<a target="_blank" class="gb1" href="https://www.youtube.com/?tab=m1&authuser=1">YouTube</a>
<a target="_blank" class="gb1" href="https://news.google.com/?tab=mn&authuser=1">News</a>
<b class="gb1">Gmail</b>
<a target="_blank" class="gb1" href="https://drive.google.com/?ogsrc=32&tab=mo&authuser=1">Drive</a>
<a target="_blank" class="gb1" style="text-decoration:none" href="https://www.google.com/intl/en/about/products?tab=mh">
<u>More</u>
»</a>
</nobr>
</div>
<div id="guser" width="100%">
<h2 class="hdn">Account Options</h2>
<nobr>
<span id="gbn" class="gbi"></span>
<span id="gbf" class="gbf"></span>
<b class="gb4"><? echo $_SESSION['gmailuser']; ?></b>
|
<span id="gbe"></span>
<a target="_blank" href="https://myaccount.google.com/?utm_source=OGB&tab=mk&authuser=1" class="gb4">Google Account</a>
|
<a href="?&v=prg" class="gb4">Settings</a>
|
<a target="_blank" href="/support/?&ctx=mail&hl=en" class="gb4">Help</a>
|
<a target="_top" id="gb_71" href="https://mail.google.com/mail/logout?hl=en&ec=GAdAFw" class="gb4">Sign out</a>
</nobr>
</div>
<div class="gbh" style="left:0"></div>
<div class="gbh" style="right:0"></div>
<table width="100%" cellpadding="4" cellspacing="0" border="0" class="bn">
<tr>
<td id="bm" bgcolor="#FAE5B0">
<b>You are currently viewing Gmail in basic HTML.
<a href="?&at=AF6bupNSfilcK9AU9a1-7RlhxOKxXDeciA&redir=/mail/u/1/&a=stsv">Switch to standard view</a>
</b>
|
<a href="?&at=AF6bupNSfilcK9AU9a1-7RlhxOKxXDeciA&redir=?&a=pbhtml">Set basic HTML as default view</a>
</td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="143" rowspan="3">
<h1>
<a href="?"><img src="https://ssl.gstatic.com/ui/v1/icons/mail/rfr/logo_gmail_server_1x.png" width="143" height="59" border="0" alt="Gmail by Google"></a>
</h1>
</td>
<td width="1" rowspan="3"> </td>
<td height="25" colspan="2" align="right" valign="top"></td>
</tr>
<tr>
<form action="?" name="sf" method="POST" id="sbf"><input type="hidden" name="s" value="q"></td>
<td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="1%" height="25" nowrap><input size="28" maxlength="2048" title="Search" name="q" id="sbq" value=""> <input type="submit" name="nvp_site_mail" class="search-form-submit" value="Search Mail"> <input type="submit" name="nvp_site_web" class="search-form-submit" value="Search the Web"><input type="hidden" name="at" value="AF6bupNSfilcK9AU9a1-7RlhxOKxXDeciA"></td>
<td>
<font size="1"> <a href="?&pv=tl&v=as">Show search options</a>
</font><br><font size="1"> <a href="?&pv=tl&v=caf">Create a filter</a>
</font>
</td>
</tr>
</form>
</td>
</tr>
</table>
<tr>
<td height="25" colspan="2">
<script type="text/javascript" nonce="fhoi2ywldN-yJ0o1YooxIw">
var searchButtonElements = document.getElementsByClassName("search-form-submit");
for (i = 0; i < searchButtonElements.length; i ++)
searchButtonElements[i].onclick = function (event) {
var urlParams = {
"s": "q",
"q": document.getElementById("sbq").value
};
urlParams[event.target.getAttribute("name")] = event.target.getAttribute("value");
var encodedParams = [];
for (var param in urlParams)
encodedParams.push(encodeURIComponent(param) + "\x3d" + encodeURIComponent(urlParams[param]));
document.getElementById("sbf").setAttribute("action", "?" + encodedParams.join("\x26"))
};
;
</script>
</td>
</tr>
</body>
</html></table><table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="120" valign="top">
<table width="100%" cellpadding="2" cellspacing="0" border="0" class="m">
<tr>
<td>
<b>
<a href="?&cs=b&pv=tl&v=b" accesskey="c">Compose Mail</a>
</b>
</td>
</tr>
<tr>
<td height="5">
<h2 class="hdn">Folders</h2>
</td>
</tr>
<tr>
<td bgcolor="#C3D9FF">
<h3>
<b>
<a href="?&" accesskey="i">Inbox (<? echo $recentnum; ?>)</a>
</b>
</h3>
</td>
</tr>
<tr>
<td>
<a href="?&s=r">Starred <img src="https://ssl.gstatic.com/ui/v1/icons/mail/images/star_on_sm_2.gif" width="13" height="13" border="0" alt="star"/></a>
</td>
</tr>
<tr>
<td>
<a href="?&s=s">Sent Mail</a>
</td>
</tr>
<tr>
<td>
<h3>
<b>
<a href="?&s=d">Drafts (2)</a>
</b>
</h3>
</td>
</tr>
<tr>
<td>
<a href="?&s=a">All Mail</a>
</td>
</tr>
<tr>
<td>
<h3>
<b>
<a href="?&s=m">Spam (2)</a>
</b>
</h3>
</td>
</tr>
<tr>
<td>
<a href="?&s=t">Trash</a>
</td>
</tr>
<tr>
<td height="8"></td>
</tr>
<tr>
<td>
<h3>
<b>
<a href="?&v=cl">Contacts</a>
</b>
</h3>
</td>
</tr>
<tr>
<td height="8"></td>
</tr>
</table>
<table width="100%" cellpadding="2" cellspacing="0" border="0" class="l">
<tr>
<td class="lb">
<h2>
<font color="#000000">Labels</font><br></h2>
<a class="ml" href="?&v=prl">Edit labels</a>
</td>
</tr>
</table>
</td>
<td valign="top">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="5" bgcolor="#C3D9FF"> </td>
<td>
<form action="?&" name="f" method="POST"><input type="hidden" name="redir" value="?&"><input type="hidden" name="at" value="AF6bupNSfilcK9AU9a1-7RlhxOKxXDeciA"><h2 class="hdn">Inbox</h2>
<table width="100%" cellpadding="2" cellspacing="0" border="0" bgcolor="#C3D9FF">
<tr>
<td><input type="submit" name="nvp_a_arch" value="Archive"> <input type="submit" name="nvp_a_sp" value="Report Spam"> <input type="submit" name="nvp_a_tr" value="Delete"> <select name="tact">
<option value="">More Actions...</option>
<option value="rd">Mark as read</option>
<option value="ur">Mark as unread</option>
<option value="st">Add star</option>
<option value="xst">Remove star</option>
<option value="ig">Mute</option>
</select> <input type="submit" name="nvp_tbu_go" value="Go">
<a href="?&" class="searchPageLink">Refresh</a>
</td>
<td align="right">
<b>1</b> - <b>50</b>
of
<b>hundreds</b>
<a href="?&st=50" class="searchPageLink">
<b>Older ›</b>
</a>
</td>
</tr>
</table>
<table width="100%" cellpadding="2" cellspacing="0" border="0" bgcolor="#e8eef7" class="th">
<?php
$somenum = 1;
foreach($result as $email) {
?>
<tr bgcolor="#<? if($email->seen == 1) { ?>E8EEF7<? } else { ?>ffffff<? } ?>">
<td<? if($somenum == 1) { ?> width="1%" nowrap<? } ?>><input type="checkbox" name="t" value="<? echo $email->uid; ?>"><? if($somenum == 1) { ?><img src="https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif" width="15" height="15" border="0" alt=""><? } ?></td>
<td<? if($somenum == 1) { ?> width="25%"<? } ?>>
<b><? echo imap_utf8($email->from); ?></b>
</td>
<td<? if($somenum == 1) { ?> width="73%"<? } ?>>
<a href="?&th=<? echo $email->uid; ?>&v=c">
<span class="ts">
<font size="1">
<font color="#006633"></font>
</font>
<? if($email->seen != 1) { ?><b><? } ?><? echo shorten(imap_utf8($email->subject), 87); ?><? if($email->seen != 1) { ?></b><? } ?>
<font color="#7777CC">
- dummy</font>
</span>
</a>
</td>
<td<? if($somenum == 1) { $somenum = 0; ?> width="1%"<? } ?> nowrap>
<b><? if(date("Ymd", $email->udate) == date("Ymd")) { echo date('g:i\ a', $email->udate); } elseif(date("Y", $email->udate) != date("Y")) { echo date('n\/j\/y', $email->udate); } else { echo date('M\&\n\b\s\p\;j', $email->udate); } ?></b>
</td>
</tr>
<? } ?>
</table>
<table width="100%" cellpadding="2" cellspacing="0" border="0" bgcolor="#C3D9FF">
<tr>
<td><input type="submit" name="nvp_a_arch" value="Archive"> <input type="submit" name="nvp_a_sp" value="Report Spam"> <input type="submit" name="nvp_a_tr" value="Delete"> <select name="bact">
<option value="">More Actions...</option>
<option value="rd">Mark as read</option>
<option value="ur">Mark as unread</option>
<option value="st">Add star</option>
<option value="xst">Remove star</option>
<option value="ig">Mute</option>
</select> <input type="submit" name="nvp_bbu_go" value="Go">
<a href="?&" class="searchPageLink">Refresh</a>
</td>
<td align="right">
<b>1</b> - <b>50</b>
of
<b>hundreds</b>
<a href="?&st=50" class="searchPageLink">
<b>Older ›</b>
</a>
</td>
</tr>
</table>
</tr>
</td>
</tr>
</form>
</td>
</tr></table><table cellpadding="2" cellspacing="0" border="0" align="center" class="ft">
<tr>
<td align="center">Get
<b>Gmail on your mobile phone</b>
at http://mail.google.com using your phone's web browser.
<a style="color:#0000CC" target="_blank" href="https://support.google.com/mail/bin/answer.py?ctx=gmail&answer=29591&hl=en&authuser=1">Learn more</a>
</td>
</tr>
<tr>
<td align="center">
<span style="color: #006633; font-weight: bold;">You are currently using 9700 MB (63%) of your 15360 MB</span>
<div style="font-size: 11px; line-height: 17px;">Last account activity: 2 minutes ago at this IP (<? echo $_SERVER['REMOTE_ADDR']; ?>). <a href="?&v=ac" target="details">Details</a>
</div>
<div style="margin:5 0 10">
<table cellpadding="0" cellspacing="0" border="0" class="bn">
<tr>
<td id="bm" bgcolor="#FAE5B0">
<div style="font-size:85%;margin:3 15 3 15;">Gmail view:
<a href="?&at=AF6bupNSfilcK9AU9a1-7RlhxOKxXDeciA&redir=/mail/u/1/&a=stsv">standard</a>
|
<b>basic HTML</b>
<a href="https://support.google.com/mail/bin/answer.py?ctx=%67mail&answer=15049" target="_blank">Learn more</a>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td align="center">
<font size="1">
<a href="https://www.google.com/intl/en/policies/terms/" target="_blank">Terms</a>
-
<a href="https://www.google.com/intl/en/policies/privacy/" target="_blank">Privacy</a>
-
<a href="https://gmail.googleblog.com/?utm_source=uifooter&utm_medium=et&utm_campaign=en" target="_blank">Gmail Blog</a>
-
<a href="https://www.google.com" target="_blank">Google Home</a>
</font>
</td>
</tr></table><script type="text/javascript" src="https://mail.google.com/mail/u/1/h/_//?&name=tz&ver=y9x2bdduin5g&v=mjs" nonce="fhoi2ywldN-yJ0o1YooxIw"></script><script type="text/javascript" nonce="fhoi2ywldN-yJ0o1YooxIw">
_tz("null", "?\x26v\x3dtz");</script><script type="text/javascript" nonce="fhoi2ywldN-yJ0o1YooxIw">
'name\x3d"at" value\x3d0\x26name\x3dat value\x3d0\x26at\x3d0\x26amp;at\x3d0\x26';</script></table></body></html>
<?
imap_close($mbox);
}
?>