-
Notifications
You must be signed in to change notification settings - Fork 3
/
textprocessor.php
115 lines (93 loc) · 3 KB
/
textprocessor.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
<?php
//20180403 KM4ACK
//edited 20180520
//capture data from mytext.php and convert to email format
//for sending via Pat Winlink
//session_start();
//include variables from config.php
include('/var/www/html/config.php');
//generate random file name
function generateRandomString($length = 10) {
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
//set length of random generated numbers
//for the MID number
$mid = generateRandomString(12);
//determines is replies are allowed or not
//see config.php to make changes
if ($replies > 0) {
$callsign1 = $callsign;
} else {
$callsign1 = "NOREPLY";
}
//data from mytext.php
$name = $_POST["name"];
$email = $_POST["email"];
$body = $_POST["body"];
$body = "From ".$name."\r\n\r\n" .$body;
$provider = $_POST["provider"];
$newnumber = $email.$provider;
//add footer to body
$newbody = $body;
//set time variables
$date = gmdate('Y/m/d h:i',time());
//$time = date('Ymd-h:i:s',time()); //commented out 20180407
//set file name with .b2f extension
$filename = $mid.'.b2f';
//get character count of body
//and add 2 for escape commands
$count = strlen($newbody);
$count = $count+2;
//write text to the
//temp emails directory
//change directory
chdir("emails");
//open & write file
$file = fopen($filename,"w"); //create the file
fwrite($file,"Mid: ".$mid."\r\n"); //write the MID
fwrite($file,"Body: ".$count."\r\n"); //write the body count
fwrite($file,"Content-Transfer-Encoding: 8bit\r\n"); //write this text (required by wl2k)
fwrite($file,"Content-Type: text/plain; charset=ISO-8859-1\r\n"); //write this text (required by wl2k)
fwrite($file,"Date: ".$date."\r\n"); //write the date
fwrite($file,"From: ".$callsign1."\r\n"); //write callsign
fwrite($file,"Mbo: ".$callsign."\r\n"); //write callsign
fwrite($file,"Subject: ".$textsubject."\r\n"); //write subject of email
fwrite($file,"To: SMTP:".$newnumber."\r\n"); //write the email address for delivery
fwrite($file,"Type: Private\r\n"); //set message type to private
fwrite($file,"\r\n"); //returns a blank line
fwrite($file,$newbody."\r\n"); //write the body of the message
fclose($file); //close the file
//echo any errors
print_r(error_get_last());
?>
<!DOCTYPE html>
<html>
<head>
<title>Thanks for your text</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div>
<h1><?php echo $callsign ?> Emergency Email Server<br>
<div id="pagelabel">Message Queued</h1>
<hr><br>
<?php echo "<h3><strong>$time Current Time</strong></h3>" ?>
</div>
<div>
<?php
//echo "<br>";
echo "<h3>Thank you ".$name."<br></h3>";
echo "<h3>You text to ".$email." has been queued for sending.</h3>";
echo "<h3><Strong>".$visitmsg."</h3></strong>";
echo $newnumber;
?>
</div>
<form action="mytext.php">
<input type="submit" value="Send Another" />
</body>