use QUERY_STRING and show reload icon
This commit is contained in:
parent
ff2e437138
commit
bfa4070c56
|
@ -51,8 +51,6 @@ function delete_email($mailid, $address) {
|
||||||
if (_load_one_email($mailid, $address) !== null) {
|
if (_load_one_email($mailid, $address) !== null) {
|
||||||
$mailbox->deleteMail($mailid);
|
$mailbox->deleteMail($mailid);
|
||||||
$mailbox->expungeDeletedMails();
|
$mailbox->expungeDeletedMails();
|
||||||
header('Content-type: application/json');
|
|
||||||
print(json_encode(array("success" => true)));
|
|
||||||
} else {
|
} else {
|
||||||
error(404, 'delete error: invalid username/mailid combination');
|
error(404, 'delete error: invalid username/mailid combination');
|
||||||
}
|
}
|
||||||
|
@ -140,8 +138,7 @@ function redirect_to_random($domains) {
|
||||||
$name = $word . $nr;
|
$name = $word . $nr;
|
||||||
|
|
||||||
$domain = $domains[array_rand($domains)];
|
$domain = $domains[array_rand($domains)];
|
||||||
|
header("location: ?$name@$domain");
|
||||||
header("location: ?address=$name@$domain");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,11 +154,6 @@ function delete_old_messages() {
|
||||||
$mailbox->expungeDeletedMails();
|
$mailbox->expungeDeletedMails();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
//// Never cache requests:
|
|
||||||
//header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
|
|
||||||
//header("Cache-Control: post-check=0, pre-check=0", false);
|
|
||||||
//header("Pragma: no-cache");
|
|
||||||
|
|
||||||
// run on every request
|
// run on every request
|
||||||
delete_old_messages();
|
delete_old_messages();
|
||||||
|
|
BIN
src/if_sync-01_186384.png
Normal file
BIN
src/if_sync-01_186384.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
413
src/index.php
413
src/index.php
|
@ -1,240 +1,247 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('backend.php');
|
require_once('backend.php');
|
||||||
|
|
||||||
|
// simple router:
|
||||||
if (isset($_GET['random'])) {
|
if (isset($_GET['username']) && isset($_GET['domain'])) {
|
||||||
redirect_to_random($config['domains']);
|
|
||||||
die();
|
|
||||||
} elseif (isset($_GET['username']) && isset($_GET['domain'])) {
|
|
||||||
$username = filter_input(INPUT_GET, 'username', FILTER_SANITIZE_EMAIL);
|
$username = filter_input(INPUT_GET, 'username', FILTER_SANITIZE_EMAIL);
|
||||||
$domain = filter_input(INPUT_GET, 'domain', FILTER_SANITIZE_EMAIL);
|
$domain = filter_input(INPUT_GET, 'domain', FILTER_SANITIZE_EMAIL);
|
||||||
header("location: ?address=$username@$domain");
|
header("location: ?$username@$domain");
|
||||||
die();
|
exit();
|
||||||
} elseif (!isset($_GET['address'])) {
|
} elseif (isset($_GET['download_email_id'])) {
|
||||||
redirect_to_random($config['domains']);
|
|
||||||
} else {
|
|
||||||
// perform common validation:
|
|
||||||
$address = filter_input(INPUT_GET, 'address', FILTER_SANITIZE_EMAIL);
|
$address = filter_input(INPUT_GET, 'address', FILTER_SANITIZE_EMAIL);
|
||||||
|
download_email($_GET['download_email_id'], $address);
|
||||||
|
exit();
|
||||||
|
} elseif (isset($_GET['delete_email_id'])) {
|
||||||
|
$address = filter_input(INPUT_GET, 'address', FILTER_SANITIZE_EMAIL);
|
||||||
|
$delete_email_id = filter_input(INPUT_GET, 'delete_email_id', FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
delete_email($delete_email_id, $address);
|
||||||
|
header("location: ?$address");
|
||||||
|
exit();
|
||||||
|
} elseif (isset($_GET['random'])) {
|
||||||
|
redirect_to_random($config['domains']);
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
// validate & print emails:
|
||||||
|
$address = filter_var($_SERVER['QUERY_STRING'], FILTER_SANITIZE_EMAIL);
|
||||||
$username = _clean_username($address);
|
$username = _clean_username($address);
|
||||||
$userDomain = _clean_domain($address);
|
$userDomain = _clean_domain($address);
|
||||||
if (strlen($address) === 0) {
|
if (empty($username) || empty($userDomain)) {
|
||||||
error(400, 'invalid username');
|
redirect_to_random($config['domains']);
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
if (strlen($userDomain) === 0 || !in_array($userDomain, $config['domains'])) {
|
|
||||||
error(400, 'invalid domain');
|
|
||||||
}
|
|
||||||
|
|
||||||
// simple router:
|
|
||||||
if (isset($_GET['download_email_id'])) {
|
|
||||||
download_email($_GET['download_email_id'], $address);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
if (isset($_GET['delete_email_id'])) {
|
|
||||||
$delete_email_id = filter_input(INPUT_GET, 'delete_email_id', FILTER_SANITIZE_NUMBER_INT);
|
|
||||||
delete_email($delete_email_id, $address);
|
|
||||||
}
|
|
||||||
// print emails:
|
|
||||||
$emails = get_emails($address);
|
$emails = get_emails($address);
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Mailbox <?php echo $address ?></title>
|
<title><?php echo $address ?></title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
<meta name="mobile-web-app-capable" content="yes">
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"
|
||||||
integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
|
integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi"
|
||||||
<meta charset="utf-8">
|
crossorigin="anonymous">
|
||||||
<link rel="stylesheet" href="style.css">
|
<meta charset="utf-8">
|
||||||
<link rel="stylesheet" href="spinner.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
<script src="turbolinks.js"></script>
|
<link rel="stylesheet" href="spinner.css">
|
||||||
<meta name="turbolinks-cache-control" content="no-preview">
|
<script src="turbolinks.js"></script>
|
||||||
|
<meta name="turbolinks-cache-control" content="no-preview">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// https://stackoverflow.com/a/44353026
|
// https://stackoverflow.com/a/44353026
|
||||||
var reloadWithTurbolinks = (function () {
|
var reloadWithTurbolinks = (function () {
|
||||||
var scrollPosition;
|
var scrollPosition;
|
||||||
|
|
||||||
function reload() {
|
function reload() {
|
||||||
scrollPosition = [window.scrollX, window.scrollY];
|
Turbolinks.visit(window.location.toString(), {action: 'replace'})
|
||||||
Turbolinks.visit(window.location.toString(), {action: 'replace'})
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('turbolinks:load', function () {
|
|
||||||
if (scrollPosition) {
|
|
||||||
window.scrollTo.apply(window, scrollPosition);
|
|
||||||
scrollPosition = null
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return reload
|
document.addEventListener('turbolinks:before-render', function () {
|
||||||
})();
|
scrollPosition = [window.scrollX, window.scrollY];
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('turbolinks:load', function () {
|
||||||
|
if (scrollPosition) {
|
||||||
|
window.scrollTo.apply(window, scrollPosition);
|
||||||
|
scrollPosition = null
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return reload
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
reloadWithTurbolinks();
|
reloadWithTurbolinks();
|
||||||
}, 10000)
|
}, 15000)
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
<body data-turbolinks="false">
|
<body data-turbolinks="false">
|
||||||
|
|
||||||
<header>
|
<header data-turbolinks-permanent id="header">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<small class="form-text text-muted">
|
<small class="form-text text-muted">
|
||||||
change username:
|
change username:
|
||||||
</small>
|
</small>
|
||||||
|
|
||||||
<form action="?" method="get">
|
<form action="?" method="get">
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input id="username" data-turbolinks-permanent class="form-control form-control-lg" name="username"
|
<input id="username" class="form-control form-control-lg" name="username"
|
||||||
value="<?php echo $username ?>">
|
value="<?php echo $username ?>">
|
||||||
</div>
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<select id="domain" data-turbolinks-permanent class="form-control form-control-lg" name="domain">
|
|
||||||
<?php
|
|
||||||
foreach ($config['domains'] as $domain) {
|
|
||||||
$selected = $domain === $userDomain ? ' selected ' : '';
|
|
||||||
print "<option value='$domain' $selected>@$domain</option>";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-sm-3 random-column">
|
|
||||||
<span>or </span>
|
|
||||||
<a role="button" href="?random=true" class="btn btn-outline-primary">generate random
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
|
|
||||||
<main>
|
|
||||||
<div class="container min-height">
|
|
||||||
|
|
||||||
<?php
|
|
||||||
if (empty($emails)) {
|
|
||||||
?>
|
|
||||||
<div>
|
|
||||||
<div class="card waiting-screen">
|
|
||||||
<div class="card-block">
|
|
||||||
<p class="lead">Your mailbox <strong
|
|
||||||
><?php echo $address ?></strong> is ready. </p>
|
|
||||||
<p>Emails will appear here automatically. They will be deleted after 30
|
|
||||||
days.</p>
|
|
||||||
<div class="spinner">
|
|
||||||
<div class="rect1"></div>
|
|
||||||
<div class="rect2"></div>
|
|
||||||
<div class="rect3"></div>
|
|
||||||
<div class="rect4"></div>
|
|
||||||
<div class="rect5"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-sm-3">
|
||||||
</div>
|
<select id="domain" class="form-control form-control-lg" name="domain">
|
||||||
<?php
|
|
||||||
} else {
|
|
||||||
|
|
||||||
foreach ($emails as $email) {
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="email-table">
|
|
||||||
|
|
||||||
<div class="card email">
|
|
||||||
<div class="card-block header-shadow sticky-header">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<h3 class="card-title">
|
|
||||||
<?php echo filter_var($email->subject, FILTER_SANITIZE_SPECIAL_CHARS); ?>
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-4 text-right">
|
|
||||||
<form class="form-inline float-xs-right">
|
|
||||||
|
|
||||||
<!-- <button class="btn btn-outline-info btn-sm">show html-->
|
|
||||||
<!-- </button>-->
|
|
||||||
|
|
||||||
<a class="btn btn-sm btn-outline-primary " download="true"
|
|
||||||
role="button"
|
|
||||||
href="?download_email_id=<?php echo filter_var($email->id, FILTER_VALIDATE_INT); ?>&address=<?php echo $address ?>">Download
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<!-- <button class="btn btn-sm btn-outline-danger" type="button">-->
|
|
||||||
<!-- Delete-->
|
|
||||||
<!-- </button>-->
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<h6 class="card-subtitle mt-1 text-muted">
|
|
||||||
<?php
|
|
||||||
echo filter_var($email->fromName, FILTER_SANITIZE_SPECIAL_CHARS);
|
|
||||||
echo ' <';
|
|
||||||
echo filter_var($email->fromAddress, FILTER_SANITIZE_SPECIAL_CHARS);
|
|
||||||
echo '>';
|
|
||||||
?>
|
|
||||||
</h6>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-4">
|
|
||||||
<h6 class="card-subtitle mt-1 text-muted"
|
|
||||||
style="text-align: right">
|
|
||||||
<?php echo filter_var($email->date, FILTER_SANITIZE_SPECIAL_CHARS); ?>
|
|
||||||
</h6>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card-block">
|
|
||||||
<h6 class="card-subtitle text-muted">
|
|
||||||
To: <?php echo filter_var($email->toString, FILTER_SANITIZE_SPECIAL_CHARS); ?></h6>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ($email->cc as $cc) {
|
foreach ($config['domains'] as $domain) {
|
||||||
print "<h6 class='card-subtitle text-muted'>CC: " . filter_var($cc, FILTER_SANITIZE_SPECIAL_CHARS) . "</h6>";
|
$selected = $domain === $userDomain ? ' selected ' : '';
|
||||||
|
print "<option value='$domain' $selected>@$domain</option>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-1">
|
||||||
|
<button type="submit" class="btn" style="background-color:transparent">
|
||||||
|
<img src="if_sync-01_186384.png" width="32" height="32" alt="submit"/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3 random-column">
|
||||||
|
<span>or </span>
|
||||||
|
<a role="button" href="?random=true" class="btn btn-outline-primary">generate random
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
<div class="mt-2 card-text">
|
<main>
|
||||||
<!-- TODO: switch between html and plaintext -->
|
<div class="container min-height">
|
||||||
<div>
|
|
||||||
<!-- TODO: applyAutolink
|
|
||||||
TODO: applyNewlines -->
|
|
||||||
<?php $text = filter_var($email->textPlain, FILTER_SANITIZE_SPECIAL_CHARS);
|
|
||||||
echo str_replace(' ', '<br />', $text);
|
|
||||||
?>
|
|
||||||
|
|
||||||
</div>
|
<?php
|
||||||
<div *ngIf="htmlTabActive">
|
if (empty($emails)) {
|
||||||
<!-- TODO: stripHtml(mail.textHtml) -->
|
?>
|
||||||
</div>
|
<div>
|
||||||
|
<div class="card waiting-screen">
|
||||||
|
<div class="card-block">
|
||||||
|
<p class="lead">Your mailbox <strong
|
||||||
|
><?php echo $address ?></strong> is ready. </p>
|
||||||
|
<p>Emails will appear here automatically. They will be deleted after 30
|
||||||
|
days.</p>
|
||||||
|
<div class="spinner">
|
||||||
|
<div class="rect1"></div>
|
||||||
|
<div class="rect2"></div>
|
||||||
|
<div class="rect3"></div>
|
||||||
|
<div class="rect4"></div>
|
||||||
|
<div class="rect5"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
} else {
|
||||||
|
|
||||||
|
foreach ($emails as $email) {
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="email-table">
|
||||||
|
|
||||||
|
<div class="card email">
|
||||||
|
<div class="card-block header-shadow sticky-header">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<h3 class="card-title">
|
||||||
|
<?php echo filter_var($email->subject, FILTER_SANITIZE_SPECIAL_CHARS); ?>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4 text-right">
|
||||||
|
<form class="form-inline float-xs-right">
|
||||||
|
|
||||||
|
<!-- <button class="btn btn-outline-info btn-sm">show html-->
|
||||||
|
<!-- </button>-->
|
||||||
|
|
||||||
|
<a class="btn btn-sm btn-outline-primary " download="true"
|
||||||
|
role="button"
|
||||||
|
href="?download_email_id=<?php echo filter_var($email->id, FILTER_VALIDATE_INT); ?>&address=<?php echo $address ?>">Download
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a class="btn btn-sm btn-outline-danger"
|
||||||
|
role="button"
|
||||||
|
href="?delete_email_id=<?php echo filter_var($email->id, FILTER_VALIDATE_INT); ?>&address=<?php echo $address ?>">Delete
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<h6 class="card-subtitle mt-1 text-muted">
|
||||||
|
<?php
|
||||||
|
echo filter_var($email->fromName, FILTER_SANITIZE_SPECIAL_CHARS);
|
||||||
|
echo ' <';
|
||||||
|
echo filter_var($email->fromAddress, FILTER_SANITIZE_SPECIAL_CHARS);
|
||||||
|
echo '>';
|
||||||
|
?>
|
||||||
|
</h6>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<h6 class="card-subtitle mt-1 text-muted"
|
||||||
|
style="text-align: right">
|
||||||
|
<?php echo filter_var($email->date, FILTER_SANITIZE_SPECIAL_CHARS); ?>
|
||||||
|
</h6>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-block">
|
||||||
|
<h6 class="card-subtitle text-muted">
|
||||||
|
To: <?php echo filter_var($email->toString, FILTER_SANITIZE_SPECIAL_CHARS); ?></h6>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
foreach ($email->cc as $cc) {
|
||||||
|
print "<h6 class='card-subtitle text-muted'>CC: " . filter_var($cc, FILTER_SANITIZE_SPECIAL_CHARS) . "</h6>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="mt-2 card-text">
|
||||||
|
<!-- TODO: switch between html and plaintext -->
|
||||||
|
<div>
|
||||||
|
<!-- TODO: applyAutolink
|
||||||
|
TODO: applyNewlines -->
|
||||||
|
<?php $text = filter_var($email->textPlain, FILTER_SANITIZE_SPECIAL_CHARS);
|
||||||
|
echo str_replace(' ', '<br />', $text);
|
||||||
|
?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div *ngIf="htmlTabActive">
|
||||||
|
<!-- TODO: stripHtml(mail.textHtml) -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
?>
|
||||||
?>
|
</div>
|
||||||
</div>
|
</main>
|
||||||
</main>
|
</body>
|
||||||
</body>
|
</html>
|
||||||
</html>
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user