Hey everybody I want to let you know that I have undertaken the grueling task of getting the heck away from WordPress. I was so sick of the problems and updates I had to do all the time. I am now using my ezbloo system and I am integrating all my old posts into the new system. It sucks, but in the end, I will save bundles of time. I needed to keep things simple and that is why I created ezbloo. I'll have more on this later for you guys after I am done with the total integration of my old posts here. So if you are looking for a post and need it faster, shoot me an email and I will make it a priority. [email protected]

This self destruct letter script is fun, fast and mobile friendly. All you have to do is download it and upload it to your server. I created this script a while ago but I made some updates to it. You can see the self destruct letter script in action here. Feel free to use it. Ok, lets go over how it is programmed. 


Self Destruct Letter Script

Here are the files. You can copy and paste them into your server. If you do not want to copy and paste all these scripts you can download all the files on the last page.

Database File

Open up your PhpMyAdmin and create a database called selfdestructletters. Click on SQL and insert this code. This will create a table called letters.
-- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Aug 19, 2022 at 05:26 PM
-- Server version: 10.4.16-MariaDB
-- PHP Version: 7.4.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `selfdestructletters`
--

-- --------------------------------------------------------

--
-- Table structure for table `letters`
--

CREATE TABLE `letters` (
  `id` int(11) NOT NULL,
  `long` int(11) NOT NULL,
  `times` int(11) NOT NULL,
  `datee` varchar(22) NOT NULL,
  `letter` text NOT NULL,
  `ip` varchar(250) NOT NULL,
  `url` varchar(250) NOT NULL,
  `timestampp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `letters`
--
ALTER TABLE `letters`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `letters`
--
ALTER TABLE `letters`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Config.php File

Now you need to connect to your database. Use this file for that purpose. Make sure you change the database name, user and password to match your database.
<?php
define('DB_NAME', 'selfdestructletters');
define('DB_USER', 'DATABASEUSERNAME');
define('DB_PASSWORD', 'DATABASEPASSWORD');
define('DB_HOST', 'localhost');
$con = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);    
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }else{
  if(!empty ($_GET['user'])){
    $urlll =$_GET['user'];
    }else{
    echo '';
    }
  } ?>

Index.php File

This is the index file. Place it on your server. This is the first page everyone will see on your website.
<?php include_once('config.php');
include_once('functions.php'); 
head(); ?>
<body>
<div class="container-fluid sdll">
 <h1>Self Destruct Letters.com</h1>
<p id="tagline" class="large"></p>
 <div class="row">
<center><?php write(); ?></center>
<div class="a2a_kit a2a_kit_size_32 a2a_default_style social">
<a class="a2a_dd" href="https://www.addtoany.com/share"></a>
<a class="a2a_button_facebook"></a>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_google_plus"></a>
<a class="a2a_button_email"></a>
<a class="a2a_button_google_gmail"></a>
<a class="a2a_button_wordpress"></a>
<a class="a2a_button_aim"></a>
</div>
<script async src="https://static.addtoany.com/menu/page.js"></script>
</div>
</div>
<script>
var myString = 'Some things do not need to be repeated! Send a letter that destroys itself after its read.';
var myArray = myString.split("");
var loopTimer;
function frameLooper() {
  if(myArray.length > 0) {
document.getElementById("tagline").innerHTML += myArray.shift();
  } else {
    clearTimeout(loopTimer); 
                return false;
  }
  loopTimer = setTimeout('frameLooper()',70);
}
frameLooper();
</script>
<?php foot(); $con->close();?>

Letter.php File

This is the letter.php file. This is where people will read the letters.
<?php include_once('functions.php'); include_once('config.php'); 
head(); $time=timeout();?>
<body onload="setTimeout(myFunction, <?php echo $time; ?>);">
<div id="sdl"></div>
<div id="message">This Letter Has Self Destructed!If you would like to create one <a href="index.php">click here</a></div>
<?php $var=theletter(); 
$varr=str_replace("'", "\'", $var);

$varr = str_replace(array("\r\n", "\r"), "\n", $varr);
$lines = explode("\n", $varr);
$new_lines = array();

foreach ($lines as $i => $line) {
    if(!empty($line))
        $new_lines[] = trim($line);
}

?>
<script>
var myString = '<?php echo implode($new_lines); ?>';
var myArray = myString.split("");
var loopTimer;
function frameLooper() {
  if(myArray.length > 0) {
document.getElementById("sdl").innerHTML += myArray.shift();
  } else {
    clearTimeout(loopTimer); 
                return false;
  }
  loopTimer = setTimeout('frameLooper()',70);
}
frameLooper();
</script>
</body>
</html>

Processor.php File

This is the processor file which enters new letters into the database. It sanitizes the strings before entering into the database.
<?php
include_once('functions.php');
include_once('config.php');
head();
if(isset($_POST['rt'])){
$rt=mysqli_real_escape_string($con, $_POST['rt']);
$rtz = filter_var($rt, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$exp=mysqli_real_escape_string($con, $_POST['exp']);
$expz = filter_var($exp, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$dt=mysqli_real_escape_string($con, $_POST['dt']);
$dtz = filter_var($dt, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$lett=mysqli_real_escape_string($con, $_POST['lett']);
$lettz = filter_var($lett, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$urll=date('mdyi');
$ran=rand();
$url=$urll.$ran;
if($dtz==''){echo "Please pick an expiration date.";
exit();
}
$ct= strlen($lettz);
if($ct<7){echo "Please write a letter.";
exit();
}
$ipadd=$_SERVER['REMOTE_ADDR'];
$result = $con->query("SELECT ip, url FROM letters WHERE ip='$ipadd' ORDER BY id DESC") ;
 $num=$result->num_rows;
if($num > 33){
while ($row = $result->fetch_assoc()) {
echo '<p>Oh so you like to use this? I\'m glad that you do. You get to send 5 letters for free. However if you buy me a beer I\'ll lets you create 20 more for $5! email me [email protected] after you send me a paypal payment and Ill make it happen! </p>';
echo '<a href="letter.php?user='.$row['url'].'" target="_new">Visit your Last Letter If Still Available</a> ';
exit();
}
}
//test
$regex = "@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?).*$)@";
$theletter=preg_replace($regex, '', $lettz);
//end test
//echo $rtz.'<br/> '.$expz.'<br/> '.$dtz.'<br/> '.$lettz;
 mysqli_query($con,"INSERT INTO letters(`long`, `times`, `datee`, `letter`, `ip`, `url` )VALUES ('$rtz','$expz','$dtz','$theletter','$ipadd','$url')");
echo '<a href="letter.php?user='.$url.'" target="_new">Preview Letter Will Use 1 View</a>';
$dir=basename(getcwd());
$root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'.$dir;
echo '<br/><a href="mailto:?subject=You Have A Self Destruct Letter Waiting&body=You have been written a self destruct letter you can see your letter here. '.$root.'/letter.php?user='.$url.'">Email Letter</a>';

echo '<p>Share the link below with the person that the letter is intended for!</p>';
echo '<input type="test" value="'.$root.'/letter.php?user='.$url.'"/>';
}; 

foot()
?>

Functions.php File

Here is the functions file.
<?php include_once('config.php');
function head(){
  $dir=basename(getcwd());
$root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'.$dir;
echo '<html lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<meta name="description" content="Self destruct letters at your service.Letters self destruct after they are read. Say what you really want to!"/>
<meta property="og:title" content="Self Destruct Letters "/>
<meta property="og:url" content="'.$root.'"/>
<meta property="og:site_name" content="Self Destruct Letters "/>
<meta property="og:description" content="Self Destruct Letters At Your Service" />
<meta name="twitter:description" content="Self Destruct Letters At Your Service" />
<title>Self Destruct Letters</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Quintessential" rel="stylesheet">
<link rel="stylesheet" href="style.css">
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="js.js"></script>
</head>';
}

function foot(){
echo '</body></html>';
}

function write(){
echo '<button type="button" class="btn btn-danger btn-lg" data-toggle="modal" data-target="#letter">Try It Now</button>
<div id="letter" class="modal fade" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Write your letter.</h4>
      </div>
      <div class="modal-body">
<div class="form-group">
<label for="readtime"><a href="#" title="How Long" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="How long will you give a person to read this message?">How Long?</a>:</label>
  <select class="form-control" id="readtime">
    <option value="10000">10 Seconds</option>
    <option value="30000">30 Seconds</option>
    <option value="60000">1 Minute</option>
    <option value="90000">1 Minute 30 Seconds</option>
    <option value="120000">2 Minutes</option>
    <option value="180000">3 Minutes</option>
  </select>
</div>
<div class="form-group">
  <label for="expire"><a href="#" title="How Many Times" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="How many times can a person view this message? Make sure you select 2 if you plan on previewing the letter!!!">How Many Times?</a>:</label>
  <select class="form-control" id="expire">
    <option value="1">1 Time</option>
    <option value="2">2 Times Use this option if you want to preview letter.</option>
    <option value="3">3 Times</option>
  </select>
</div>
<div class="form-group">
  <label for="date"><a href="#" title="Expiration Date" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="Choose an Expiration date ">Expiration Date</a>:</label>
  <input type="date" class="form-control" id="date" />
</div>
<div class="form-group">
<label for="letter"><a href="#" title="How Long" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="Tell them how you really feel.">Write Letter</a>:</label>
  <textarea class="form-control" rows="10" id="letter">Dear </textarea>
</div>
<button onclick="ajax_post();">Submit</button>
<div id="status"></div>
<script>
function ajax_post(){
    var hr = new XMLHttpRequest();
    var url = "processor.php";
    var readtime1 = document.getElementById("readtime").value;
    var expire1 = document.getElementById("expire").value;
    var date1 = document.getElementById("date").value;
var letter1 = $("textarea#letter").val();
    var vars = "rt="+readtime1+"&exp="+expire1+"&dt="+date1+"&lett="+letter1;
    hr.open("POST", url, true);
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hr.onreadystatechange = function() {
      if(hr.readyState == 4 && hr.status == 200) {
        var return_data = hr.responseText;
      document.getElementById("status").innerHTML = return_data;
      }
    }
    hr.send(vars); // After Check Steps are done execute the request
    document.getElementById("status").innerHTML = "processing...";
}
</script>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>';
}
function timeout(){
global $con;
global $urlll;
$resultw = $con->query("SELECT * FROM letters WHERE url='$urlll'") ;
while ($roww = $resultw->fetch_assoc()) {
return $roww['long'];
}
}

function theletter(){
global $con;
global $urlll;
$result = $con->query("SELECT * FROM letters WHERE url='$urlll'") ;
while ($row = $result->fetch_assoc()) {
$date=date('Y-m-d');
$expdate=$row['datee'];
$times=$row['times'];
if($date>$expdate){
return 'The Letter you are trying to access has been destroyed!';
exit();
}
if($times>0){
$total=$times-1;
mysqli_query($con,"UPDATE letters SET times='$total'WHERE url='$urlll' ");
}
if($times<1){
return 'The Letter you are trying to access has been destroyed!';
exit();
}
return $row['letter'];
}

}


?>

js.js File

Here is your javascript file for the server.
function myFunction() {
document.getElementById('sdl').style.display="none";
document.getElementById('message').style.display="block";
}

$(document).ready(function(){
    $('[data-toggle="popover"]').popover(); 
});

document.addEventListener('contextmenu', event => event.preventDefault());

Style.css file

Here is the style.css file for your server.
#sdl{
  width:58%; 
  height:100%; 
  display:block; 
  margin:0 auto;
  background-image:url(images/parchment.png); 
  background-size:100% 100%;
  padding:88px;
  letter-spacing:3px; 
  font-size:large; 
  font-weight:bold;
  /*text-shadow:1px 1px 2px #000; */
  line-height:45px;
  font-family: 'Quintessential', cursive;
  -webkit-animation-name: animatecircle;
  animation-name:animatecircle;
  -webkit-animation-duration: 180s;
  animation-duration: 180s;
  z-index:50000;
}

@-webkit-keyframes animatecircle {

0% {height:100%;}

25% {height:150%;}

50% {height:200%;}

75% {height:250%; }

100% { height:300%;}

} 

@keyframes animatecircle {

0% {height:100%;}

25% {height:150%;}

50% {height:200%;}

75% {height:250%; }

100% { height:300%;}


}
.social{disply:block; width:380px; margin:0 auto; padding:45px;}

.large{font-size:3vw; line-height:4vw;}

.sdll{
  width:58%; 
  height:100%; 
  display:block; 
  margin:0 auto;
  background-image:url(images/parchment.png); 
  background-size:100% 100%;
  padding:25px 155px;
  letter-spacing:3px; 
  font-size:large; 
  font-weight:bold;
  text-shadow:1px 1px 2px #000; 
  line-height:45px;
  font-family: 'Quintessential', cursive;
}

.form-control{font-size:large;height:auto;}
h1{
  text-align:center;
  font-size:4vw;
  text-shadow:1px 2px 3px #000;
  letter-spacing:3px;
}

body{background-image:url(images/fire.gif);font-size:large;}

#message{
  display:none; 
  background-image:url(images/parchment.png); 
  background-size:100% 100%;
  padding:155px;
  letter-spacing:3px; 
  font-size:large; 
  font-weight:bold;
  text-shadow:1px 1px 2px #000; 
  line-height:45px; 
  width:58%; 
  height:100%; 
  margin:0 auto;
}
.container-fluid{
  width:75%;
  display:block;
  margin:0 auto;
  height:100%;
}

@media screen and (max-width: 480px) {
#sdl{
  width:95%; 
  height:100%; 
  display:block; 
  margin:0 auto;
  background-image:url(images/parchment.png); 
  background-size:100% 100%;
  padding:55px 5px;
  letter-spacing:3px; 
  font-size:large; 
  font-weight:bold;
  text-shadow:1px 1px 2px #000; 
  line-height:45px;
  font-family: 'Quintessential', cursive;
}

a{font-size:large;}

.large{font-size:7vw; line-height:8vw;}

.sdll{
  width:95%; 
  height:100%; 
  display:block; 
  margin:0 auto;
  background-image:url(images/parchment.png); 
  background-size:100% 100%;
  padding:55px 25px;
  letter-spacing:3px; 
  font-size:55px; 
  font-weight:bold;
  text-shadow:1px 1px 2px #000; 
  line-height:45px;
  font-family: 'Quintessential', cursive;
}

.form-control{font-size:large;height:auto;}
h1{
  text-align:center;
  font-size:4vw;
  text-shadow:1px 2px 3px #000;
  letter-spacing:3px;
}

body{background-image:url(images/fire.gif);font-size:large;}

#message{
  display:none; 
  background-image:url(images/parchment.png); 
  background-size:100% 100%;
  padding:55px 5px;
  letter-spacing:3px; 
  font-size:55px; 
  font-weight:bold;
  text-shadow:1px 1px 1px #000; 
  line-height:45px; 
  width:95%; 
  height:100%; 
  margin:0 auto;
}
.container-fluid{
  width:98%;
  display:block;
  margin:0 auto;
  height:100%;
}
}

Buy Self Destruct Letter Script For $5

If you do not want to copy and paste all the codes you can buy the script for $5. You can also have me install the script onto your server for $35 or we can customize the script for you for $70 which is 2 hours of my time.
Select An Option