-
Notifications
You must be signed in to change notification settings - Fork 6
/
do_fac_mail.php
182 lines (162 loc) · 6.74 KB
/
do_fac_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_fac_mail.php
* @author John Doe <[email protected]>
* @since 2009-08-17
* @version 2011-03-15
*/
/*
8/17/09 initial release - mail to facility
7/16/10 added check for no addressees
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
$evenodd = array ("even", "odd");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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
//dump($_POST);
if (empty($_POST)) {
?>
<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;
}
/**
*
* @param {type} lines
* @returns {undefined}
*/
function reSizeScr(lines) {
var the_width = 720;
var the_height = ((lines * 21)+400); // values derived via trial/error (more of the latter, mostly)
window.resizeTo(the_width,the_height);
}
/**
*
* @returns {Boolean}
*/
function validate() {
var addr_err = true;
for (i=0; i< document.mail_form.length; i++) {
if ((document.mail_form.elements[i].name.substring(0, 2) == 'cb') && (document.mail_form.elements[i].checked)) {
addr_err = false;
}
}
var errmsg="";
if (addr_err) {errmsg+="<?php print gettext('One or more addresses required');?>\n";}
if (document.mail_form.frm_subj.value.trim()=="") {errmsg+="<?php print gettext('Message subject is required');?>\n";}
if (document.mail_form.frm_text.value.trim()=="") {errmsg+="<?php print gettext('Message text is required');?>\n";}
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()
</SCRIPT>
</HEAD>
<?php
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]facilities` "; // (array_key_exists('first', $search_array))
$query .= (array_key_exists('fac_id', $_GET))? " WHERE `id` = " . quote_smart(trim($_GET['fac_id'])) . " LIMIT 1": "";
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename( __FILE__), __LINE__);
// dump($query);
?>
<BODY onLoad = "reSizeScr(<?php print mysql_affected_rows();?>);"><CENTER> <!-- 1/12/09 -->
<CENTER> <!-- 1/12/09 -->
<CENTER><H3>Facility Mail </H3>
<?PHP
if (mysql_affected_rows()>0) {
print "<FORM NAME='mail_form' METHOD='post' ACTION='" . basename(__FILE__) . "'>\n";
print "<TABLE BORDER = 0 ALIGN='center'>\n";
$i = 0;
while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
if (is_email($row['contact_email'])) {
print "<TR CLASS = '{$evenodd[($i%2)]}'><TD><INPUT TYPE='checkbox' NAME='cb{$i}' VALUE='{$row['contact_email']}' CHECKED/></TD>
<TD>{$row['name']}</TD><TD>{$row['contact_name']}</TD><TD>{$row['contact_email']}</TD><TD></TD></TR>\n";
$i++;
}
if (is_email($row['security_email'])) {
print "<TR CLASS = '{$evenodd[($i%2)]}'><TD><INPUT TYPE='checkbox' NAME='cb" .$i. "' VALUE='" . $row['security_email'] . "' CHECKED/></TD>
<TD>{$row['name']}</TD><TD>{$row['security_contact']}</TD><TD>{$row['security_email']}</TD><TD></TD></TR>\n";
$i++;
} // end if (is_email)
} // end while()
} // end if (mysql_affected_rows()>0)
if ($i > 0) { // 7/16/10
?>
<TR><TD COLSPAN=5> </TD></TR>
<TR CLASS='even'><TD ALIGN='right'><?php print gettext('Subject');?>: </TD><TD COLSPAN=4><INPUT TYPE = 'text' NAME = 'frm_subj' SIZE = 60/></TD></TR>
<TR CLASS='odd'><TD ALIGN='right'><?php print gettext('Message');?>:</TD><TD COLSPAN=4> <TEXTAREA NAME='frm_text' COLS=60 ROWS=4></TEXTAREA></TD></TR>
<TR CLASS='even'><TD></TD><TD ALIGN='left' COLSPAN=3><BR /><BR />
<INPUT TYPE='button' VALUE='<?php print gettext('Send');?>' onClick = "validate();" STYLE = 'margin-left: 100px'/>
<INPUT TYPE='reset' VALUE='<?php print gettext('Reset');?>' STYLE = 'margin-left: 20px'/>
<INPUT TYPE='button' VALUE='<?php print gettext('Cancel');?>' onClick = 'window.close();'STYLE = 'margin-left: 20px'/><BR /><BR />
</TD></TR>
</TABLE></FORM>
<?php
} // end if ($i > 0 )
else {
?>
<BR /><H3><?php print gettext('No facility addresses available');?></H3><BR /><BR />
<INPUT TYPE='button' VALUE = '<?php print gettext('Close');?>' onClick='window.close();' />
<?php
} // end if/else end if ($i > 0 )
} // end if (empty($_POST)) {
else {
$addr_str = $sep = "";
foreach ($_POST as $VarName=>$VarValue) {
if (substr($VarName, 0, 2) == 'cb') {
$addr_str .= $sep . $VarValue;
$sep = "|";
} // end if
} // end foreach
do_send ($addr_str, $_POST['frm_subj'], $_POST['frm_text'], 0, 0); // ($to_str, $subject_str, $text_str ) - | separator
?>
<BODY>
<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>