Skip to content
Open
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ $ curl -s -X POST -d "secret=my secret&json=true" https://flashpaper.io
{"url":"https://flashpaper.io/?k=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
```

It is possible to submit a HTML secret through the API, to do so include the fields ``secret`` and ``select`` when submitting the data.

- `secret`: The secret **must** be ``HTML_FORM_SECRET``
- `select`: The name of the template that will be used to display the secret.

Include other fields present in the template as ``label=value``, for example to set a radio button called ``Radio`` to the value of ``Option B`` add ``Radio=Option B`` to the body of the post.

Altogether creating a secret to use an HTML template using the API looks like this:
```
curl -s -X POST -d "json=true&secret=HTML_FORM_SECRET&select=Example form&Radio=Option B" https://flashpaper.io
```

## Settings

### `prune`:
Expand All @@ -88,6 +100,20 @@ FlashPaper will try to generate the secret retrieval URL based on information pr
- `true`: The setting `site_title` will be displayed at the top of the page. If `display_logo` is enabled, the text will appear to the right of the logo.
- `false`: The setting `site_title` will not be displayed.

## HTML Templates
FlashPaper supports HTML forms to generate and display secrets. When creating a template that supports HTML elements. Define one element per line, and each element must have the following format `<label>: <element_type>(options)`.

- `Radio`: radio(Option A,Option B)
- `Combobox`: select(Option A, Option B, Option C)
- `Number`: number(min,max)
- `Checkbox`: checkbox
- `Date and time`: datetime
- `Date`: date
- `Time`: time
- `Textarea`: textarea

When viewing the secrets from an HTML template, each field can be copied individually, or you can copy the entire contents at once.

## Donations

PayPal: https://paypal.me/AndrewPaglusch
Expand Down
18 changes: 18 additions & 0 deletions ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
define("_DIRECT_ACCESS_CHECK", 1);
require_once("includes/sanitycheck.php"); # check everything before we proceed
require_once("includes/functions.php"); # load functions

if ( !empty($_GET["select"]) ) {
$template_path = "templates/" . urldecode(basename($_GET["select"])) . ".txt";
$templates = glob('templates/*.txt');

if ( ! in_array($template_path, $templates, true) ) {
echo "TEMPLATE_NOT_FOUND";
} else if ( file_exists($template_path) ) {
$template_text = file_get_contents($template_path);
$formdata["select"] = $_GET["select"];
echo get_template_html($formdata, true);
}
}
?>
63 changes: 63 additions & 0 deletions css/table.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
ul {
width: 100%;
list-style-type: none;
margin: 0;
padding: 0;
display: inline-flex;
}
ul li label {
margin: 0 10px 0 5px;
}

li select {
height: -webkit-fill-available;
}

.html_secret {
border: 1px solid var(--bs-border-color);
padding: 15px;
}
.html_secret > ul {
margin-bottom: 10px;
}

.icon {
margin: 0px 0px 0px 5px;
position:relative;
bottom: -3px;
}

.pulse {
-webkit-animation: pulse 1s ease-in-out infinite alternate;
animation: pulse 1s ease-in-out infinite alternate;
}

@-webkit-keyframes pulse {
0% {
}
50% {
color: var(--bs-success);
}
100% {
}
}
@keyframes pulse {
0% {
}
50% {
color: var(--bs-success);
}
100% {
}
}

.overlay {
position: absolute;
top: -20px;
width: 100%;
height: 100%;
display: none;
opacity: 0;
background-color: #000000ad !important;
transition: visibility 0s, opacity .30s linear;
}
42 changes: 24 additions & 18 deletions html/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<link rel="stylesheet" href="./css/solid.min.css" rel="stylesheet" />
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="./css/bootstrap.min.css" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="./css/table.css" rel="stylesheet" />
<style>
#form-div {
background-color:rgba(72,72,72,0.1);
Expand Down Expand Up @@ -71,22 +72,15 @@
}
</style>
<script src="./js/color-toggle.js" defer></script>
<script src="./js/templates.js" defer></script>
<script src="./js/flashpaper.js"></script>
</head>
<body onUnload="document.getElementById('secret').value = ''">
<script>
if (location.protocol != 'https:') {
document.write('<div style="padding-top: 1%" class="container"><div class="alert alert-danger"><strong>Danger!</strong> This site is not being accessed over an encrypted connection. Do NOT input any sensitive information!</div></div>');
}
function copyText() {
var textToCopy = document.getElementById("copy");
textToCopy.select();
document.execCommand("copy");
}
</script>

<header>
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<a class="navbar-brand" href="">
<div class="container-fluid">
<a class="navbar-brand" href="">
<?php
if ( $settings['site_logo'] != '' && $settings['display_logo'] == 'true' ) {
echo '<img src="'. $settings['site_logo'] .'" alt="Logo" width="200" class="d-inline-block align-middle">';
Expand All @@ -102,17 +96,29 @@ function copyText() {
<li class="nav-item align-items-center d-flex" >
<i class="fa-solid fa-sun"></i>
<!-- Default switch -->
<div class="ms-2 form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="themingSwitcher" />
</div>
<i class="fa-solid fa-moon"></i>
<div class="ms-2 form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="themingSwitcher" />
</div>
<i class="fa-solid fa-moon"></i>
</li>
</span>
</div>
</span>
</div>
</nav>
<?php
if ( $settings['announcement'] != '' ) {
echo '<div style="padding-top: 1%" class="container"><div class="alert alert-warning"><strong>Announcement:</strong> ' . $settings['announcement'] . '</div></div>';
}
?>
</header>

<div id="overlay" class="mx-auto overlay" style="z-index:-100;">
<fieldset style="text-align: center; height: 100%; display: grid; place-items: center;">
<div class="form-group row float-middle">
<div class="col">
<label style="font-family: 'Enriqueta', arial, serif; line-height: 1.25; margin: 0 0 15px; font-size: 30px; font-weight: bold; padding-bottom: 1%"><span id="errormsg"></span></label>
<br />
<a href="javascript:;" class="btn btn-primary w-20 mx-auto" onclick="close_overlay()">Home</a>
</div>
</div>
</fieldset>
</div>
12 changes: 6 additions & 6 deletions html/submit_secret.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<?php #defined('_DIRECT_ACCESS_CHECK') or exit(); ?>
<div id="form-div">
<form class="form-horizontal" action="" method="POST">
<form class="form-horizontal" action="/" method="POST">
<fieldset>
<div>
<label style="font-family: 'Enriqueta', arial, serif; line-height: 1.25; margin: 0 0 10px; font-size: 30px; font-weight: bold;"><?php echo $settings['messages']['submit_secret_header']; ?></label>
<div style="font-style: italic">
<label style="font-family: 'Enriqueta', arial, serif; line-height: 1.25; margin: 0 0 10px; font-size: 15px; font-weight: bold;"><?php echo $settings['messages']['submit_secret_subheader'] ?></label>
</div>
<div style="margin-top:10px; margin-bottom: 15px;">
<div style="margin-top:10px; margin-bottom: 15px;" id="content">
<textarea class="form-control" id="secret" name="secret" rows="8" maxlength="<?php echo $settings['max_secret_length'] ?>" style="resize: vertical;" placeholder="Secret text..." autofocus><?php echo $template_text ?></textarea>
</div>
</div>
<div class="form-group row float-end">
<div class="col">
<select id="select" name="select" class="form-select" onChange="window.location.href=this.value">
<select id="select" name="select" class="form-select" onChange="loadTemplate(this.value)">
<option value="" selected disabled hidden>-- Select Template</option>
<option value="./">No Template</option>
<option value="">No Template</option>
<?php
$templates = glob('templates/*.txt');
foreach ($templates as $t) {
$filename = basename($t, '.txt');
$url_filename = urlencode($filename);
echo "<option value=\"?t={$url_filename}\">{$filename}</option>";
echo "<option value=\"{$url_filename}\">{$filename}</option>";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ability to include the template as part of the URL is something I personally use quite often. I would imagine this is used by others as well. It's useful for sending a template URL to someone to have them fill out and send back

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is still available, but there was an weird behaviour when ?t= was used, also now when specifying the template the combo box is updated with the name of the template.

}
?>
</select>
</div>
</div>
<div class="form-group row float-start">
<div class="col">
<button name="submit" type="submit" class="btn btn-primary"><?php echo $settings['messages']['submit_secret_button'] ?></button>
<button id="submit" name="submit" type="submit" class="btn btn-primary"><?php echo $settings['messages']['submit_secret_button'] ?></button>
</div>
</div>
</fieldset>
Expand Down
15 changes: 15 additions & 0 deletions html/view_secret_html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php defined('_DIRECT_ACCESS_CHECK') or exit(); ?>
<div id="form-div">
<fieldset>
<div>
<label style="font-family: 'Enriqueta', arial, serif; line-height: 1.25; margin: 0 0 10px; font-size: 30px; font-weight: bold;"><?php echo $settings['messages']['view_secret_header'] ?></label>
<div style="font-style: italic">
<label style="font-family: 'Enriqueta', arial, serif; line-height: 1.25; margin: 0 0 10px; font-size: 15px; font-weight: bold;"><?php echo $settings['messages']['view_secret_subheader'] ?></label>
</div>
<?php echo $html ?>
<div class="col">
<button class="btn btn-primary" type="button" onclick="copyText()">Copy</button>
</div>
</div>
</fieldset>
</div>
21 changes: 21 additions & 0 deletions img/copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading