-
Notifications
You must be signed in to change notification settings - Fork 6
/
do_direcs_mail.php
182 lines (168 loc) · 7.44 KB
/
do_direcs_mail.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
<?php
/**
* @package do_direcs_mail.php
* @author John Doe <[email protected]>
* @since 2009-09-17
* @version 2011-03-15
*/
/*
9/17/09 initial release - Email directions to Facilty to responding unit.
7/28/10 Added inclusion of startup.inc.php for checking of network status and setting of file name variables to support no-maps versions of scripts.
3/15/11 changed stylesheet.php to stylesheet.php
*/
error_reporting(E_ALL); //
@session_start();
require_once($_SESSION['fip']); //7/28/10
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE><?php print LessExtension(basename(__FILE__));?> </TITLE>
<META NAME="Description" CONTENT="Email to units" />
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" />
<META HTTP-EQUIV="Expires" CONTENT="0" />
<META HTTP-EQUIV="Cache-Control" CONTENT="NO-CACHE" />
<META HTTP-EQUIV="Pragma" CONTENT="NO-CACHE" />
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript" />
<META HTTP-EQUIV="Script-date" CONTENT="<?php print date("n/j/y G:i", filemtime(basename(__FILE__)));?>" />
<LINK REL="StyleSheet" HREF="stylesheet.php?version=<?php print time();?>" TYPE="text/css" /> <!-- 3/15/11 -->
<STYLE>
#.plain { background-color: #FFFFFF;}
</STYLE>
<?php
if (empty($_POST['frm_u_id'])) {
print "<CENTER>" . gettext('You must select a Unit first') . "</BR></BR>";
print "<A href='javascript: self.close();'>" . gettext('Close') . "</A></CENTER>";
exit();
}
$direcs = $_POST['frm_direcs'];
$tick_name = $_POST['frm_scope']; //10/29/09
$the_sms = ((isset($_POST['frm_smsgaddrs'])) && ($_POST['frm_smsgaddrs'] != "") && ($_POST['frm_use_smsg'] == 1)) ? $_POST['frm_smsgaddrs'] : "";
$the_tick = ((isset($_POST['frm_tick_id'])) && ($_POST['frm_tick_id'] != "")) ? $_POST['frm_tick_id'] : 0;
$unit_id = ((isset($_POST['frm_u_id'])) && ($_POST['frm_u_id'] != "")) ? $_POST['frm_u_id'] : 0;
$the_addrs = ((isset($_POST['frm_addr'])) && ($_POST['frm_addr'] != "")) ? $_POST['frm_addr'] : "";
$smsg_id = "";
$mail_subject = $_POST['frm_mail_subject'];
$direcs = str_replace(" ",' ',$direcs);
$direcs = strip_tags($direcs);
$direcs = stripslashes($direcs);
//$direcs = html_entity_decode($direcs);
unset($_POST['frm_direcs']);
unset($_POST['frm_u_id']);
unset($_POST['frm_tick_id']);
unset($_POST['frm_smsgaddrs']);
unset($_POST['frm_mail_subject']);
unset($_POST['frm_scope']); //10/29/09
if (empty($_POST)) {
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]responder` WHERE `id` = $unit_id";
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename( __FILE__), __LINE__);
while ($row = stripslashes_deep(mysql_fetch_array($result))) {
$contact_email = $row['contact_via'];
$contact_name = $row['contact_name'];
$smsg_id = $row['smsg_id'];
}
?>
<SCRIPT>
/**
*
* @returns {unresolved}
*/
String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
/**
*
* @returns {Array}
*/
function $() {
var elements = new Array();
for (var i = 0; i < arguments.length; i++) {
var element = arguments[i];
if (typeof element == 'string')
element = document.getElementById(element);
if (arguments.length == 1)
return element;
elements.push(element);
}
return elements;
}
/**
*
* @returns {Boolean}
*/
function validate() {
var errmsg="";
if (document.mail_form.frm_addr.value.trim()=="") {errmsg+="<?php print gettext('Message address is required');?>";}
if (document.mail_form.frm_subj.value.trim()=="") {errmsg+="<?php print gettext('Message subject is required');?>";}
if (document.mail_form.frm_text.value.trim()=="") {errmsg+="<?php print gettext('Message text is required');?>";}
if (!(errmsg=="")) {
alert ("<?php print gettext('Please correct the following and re-submit');?>:\n\n" + errmsg);
return false;
}
else {
document.mail_form.submit();
}
} // end function validate()
/**
*
* @returns {undefined}
*/
function back_to_routes() {
window.location.href("fac_routes.php");
}
</SCRIPT>
</HEAD>
<BODY><CENTER> <!-- 1/12/09 -->
<CENTER><H3><?php print gettext('Mail to Unit');?></H3>
<P>
<FORM NAME='mail_form' METHOD='post' ACTION='<?php print basename(__FILE__); ?>'>
<INPUT TYPE='hidden' NAME='frm_add_str' VALUE=''> <!-- for pipe-delim'd addr string -->
<TABLE BORDER = 0>
<TR CLASS= 'even'>
<TD ALIGN='right'><?php print gettext('To');?>:</TD><TD><INPUT NAME='frm_name' SIZE=32 VALUE = '<?php print $contact_name;?>'/></TD>
</TR>
<TR CLASS= 'odd'>
<TD ALIGN='right'><?php print gettext('Addr');?>:</TD><TD><INPUT NAME='frm_addr' SIZE=32 VALUE = '<?php print $contact_email;?>'/></TD>
</TR>
<?php
if ((get_variable('use_messaging') == 2) || (get_variable('use_messaging') == 3)) { // 10/23/12
?>
<TR CLASS='even'><TD ALIGN='right'><?php get_provider_name(get_msg_variable('smsg_provider'));?> <?php print gettext('Addrs');?>: </TD>
<TD><INPUT TYPE='text' NAME='frm_smsgaddrs' size='60' VALUE='<?php print $smsg_id;?>'></TD>
</TR>
<TR CLASS='even'><TD><?php print gettext('Use');?> <?php get_provider_name(get_msg_variable('smsg_provider'));?>?: </TD> <!-- 10/23/12 -->
<TD><INPUT TYPE='checkbox' NAME='frm_use_smsg' VALUE="0"/></TD> <!-- 10/23/12 -->
</TR>
<?php
} else {
?>
<INPUT TYPE="hidden" NAME = 'frm_smsgaddrs' VALUE=""/> <!-- 10/23/12 -->
<INPUT TYPE='hidden' NAME = 'frm_use_smsg' VALUE = "0"/> <!-- 10/23/12 -->
<?php
}
?>
<TR CLASS='even'><TD ALIGN='right'><?php print gettext('Subject');?>: </TD><TD COLSPAN=2><INPUT TYPE = 'text' NAME = 'frm_subj' SIZE = 60 VALUE = '<?php print $mail_subject;?> - <?php print $tick_name;?>'/></TD></TR> <!-- 10/29/09 -->
<TR CLASS='odd'><TD ALIGN='right'><?php print gettext('Message');?>:</TD><TD COLSPAN=2> <TEXTAREA NAME='frm_text' COLS=60 ROWS=4><?php print $direcs;?></TEXTAREA></TD></TR>
<TR CLASS='even'><TD ALIGN='center' COLSPAN=3><BR /><BR />
<INPUT TYPE="hidden" NAME="frm_direcs" VALUE=""/>
<INPUT TYPE="hidden" NAME="frm_u_id" VALUE='<?php print $unit_id;?>'/>
<INPUT TYPE="hidden" NAME="frm_tick_id" VALUE='<?php print $the_tick;?>'/>
<INPUT TYPE="hidden" NAME="frm_mail_subject" VALUE=""/>
<INPUT TYPE="hidden" NAME="frm_scope" VALUE=""/> <!-- 10/29/09 -->
<INPUT TYPE='button' VALUE='<?php print gettext('Send');?>' onClick = "validate();"/>
<INPUT TYPE='reset' VALUE='<?php print gettext('Reset');?>'/>
<INPUT TYPE='button' VALUE='<?php print gettext('Cancel');?>' onClick = 'window.close();'/><BR /><BR />
</TD></TR>
</TABLE></FORM>
<?php
} // end if (empty($_POST)) {
else {
do_send ($the_addrs, $the_sms, $_POST['frm_subj'], $_POST['frm_text'], $the_tick, $unit_id); // ($to_str, $subject_str, $text_str )
?>
<BODY><CENTER>
<CENTER><BR /><BR /><BR /><H3><?php print gettext('Mail sent');?></H3>
<BR /><BR /><BR /><INPUT TYPE='button' VALUE='<?php print gettext('Finished');?>' onClick = 'window.close();'/><BR /><BR />
<?php
} // end else
?> </BODY>
</HTML>