-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgc_formmail.php
More file actions
206 lines (163 loc) · 5.06 KB
/
gc_formmail.php
File metadata and controls
206 lines (163 loc) · 5.06 KB
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?
/**
* GC_Formmail 1.2
* Data creazione: 17/2/2005
* Data ultima modifica: 21/2/2005
* Author: Giuseppe Calbi <peppiniel@peppiniel.com>
* Website: http://www.giuseppecalbi.com
*
* Licenza: l'utilizzo di questo script Ë gratuito. Sarei grato se inseriste un link a http://www.giuseppecalbi.com
* o http://www.giuseppecalbi.com/scripts in fondo alle pagine che utlizzano questo script, o in un'area credits o links del vostro sito
*
* Vi suggerisco di inserire nei form, per i quali userete questo script, in fondo alla pagina la riga:
* <? $act=1; include "gc_formmail.php"; ?>
* ricordandovi di dare alla pagina un'estensione .php e di inserire eventualmente l'url completo dello script nel caso in cui
* il form non si trovasse nella stessa cartella.
* In questo modo sarý possibile essere avvisati automaticamente di nuovi aggiornamenti rispetto alla versione corrente
**/
// Non toccare NULLA in questo file
include "config.php";
$version = "1.2";
if ($act == 1)
{
echo getCredits();
return;
}
$key = array ();
$val = array ();
$output = "";
$senderNames = array ($senderNames);
foreach($_POST as $chiave=>$valore)
{
// <Input type=qualunque name=chiave value=valore>
array_push ($key, $chiave);
array_push ($val, eregi_replace("\\\\'", "'", $valore));
if (!empty($emailField))
{
if ($chiave == $emailField)
{
$emailMittente = $valore;
}
}
if (!empty($subjectField))
{
if ($chiave == $subjectField)
{
$subject = $valore;
}
}
if (!empty($senderNames))
{
for ($i = 0; $i < count ($senderNames); $i++)
{
if ($chiave == $senderNames[$i])
{
$nome .= $valore." ";
}
}
}
}
if (!empty($subject))
{
$oggetto .= " - ".$subject;
}
if ($html)
{
$output = getHtmlOutput ($key, $val);
$intestazioni = "MIME-Version: 1.0\r\n";
$intestazioni .= "Content-type: text/html; charset=iso-8859-1\r\n";
}
else
{
for ($i = 0; $i < count ($key); $i++)
{
$output .= $key[$i].": ".$val[$i]."\n";
}
$intestazioni = "";
}
if ( (!empty($emailMittente)) || (!empty($nome)) )
{
$intestazioni .= "From: ".$nome."<".$emailMittente."> \r\n";
}
else
{
$intestazioni .= "From: ".$mittente."\r\n";
}
if (!mail($destinatari, $oggetto, $output, $intestazioni))
{
echo "<br>".$messaggioErrore."<br><br><br>".getHtmlOutput($key, $val)."<br><br><br>".getCredits();
if (strlen($paginaErrore) < 5)
{
exit ();
}
else
{
echo "<META HTTP-EQUIV=Refresh CONTENT=\"10; URL=".$paginaErrore."\">";
}
}
echo "<br>".$messaggioConferma."<br><br><br>".getHtmlOutput($key, $val)."<br><br><br>".getCredits();
if (strlen($paginaConferma) < 5)
{
exit ();
}
else
{
echo "<META HTTP-EQUIV=Refresh CONTENT=\"10; URL=".$paginaConferma."\">";
}
function getHtmlOutput ($k, $v)
{
global $stripsHtml;
global $tagAllowed;
$return = "<center><div style=\"width: 322; height: 147; text-align: center\">";
$return .= "<fieldset style=\"font-family: Verdana; font-size: 10pt; color: #008080; font-weight: bold; border: 3px double #F3C65C; background-color: #F4F5FF\">";
$return .= "<legend align=center>Dati inseriti</legend>";
$return .= "<table border=0 cellpadding=3 style=\"border-collapse: collapse; font-family:Verdana; font-size:10pt; color:#4062EA\" bordercolor=#111111 cellspacing=5 width=300>";
$return .= "<colgroup span=1 style=\"text-align:right; font-weight: bold; background-color: #DDE8FF\"></colgroup>";
for ($i = 0; $i < count ($k); $i++)
{
$v[$i] = eregi_replace ("\n", "<br>", $v[$i]);
if ($stripsHtml)
{
$v[$i] = strip_tags ($v[$i], $tagAllowed);
}
$return .= "<tr><td width=\"30%\">".$k[$i].": </td><td>".$v[$i]."</td></tr>";
}
$return .= "</table></fieldset></div></center>";
return $return;
}
function getCredits ()
{
global $version;
$return = "<br><br>
<center> <p><a href=\"http://www.giuseppecalbi.com/scripts/GC_Formmail\" style=\"text-decoration: none\">
<font face=Verdana size=1 color=#000000><b>GC_Formmail ".$version."</b></a><br>
Written by <a href=\"http://www.giuseppecalbi.com\">Giuseppe Calbi</a><br>
Check for script updates: <img alt=\"New updates available at GiuseppeCalbi.com if image is green. The current is the newest version if image is red\" src=http://www.giuseppecalbi.com/scripts/gc_formmail/getUpdatesSemaph.php?current=".$version."></p>
</center></font>";
return $return;
}
/*
* To Do:
* - Limite inserimento ogni n secondi o n richieste al minuto
* - Messaggio di conferma al mittente. Pi˜ complicato, potrebbe essere hackerato e diventerebbe minaccia seria.
*/
/*
*
* Changelog:
* 1.2 (21/2/05)
* - Configuration file
* - Documentation
* - Other few changes
*
* 1.12 (19/2/05)
* - Removed backslash before char "'".
* - In html output and mail, \n becomes <br>
* - Possibility to strips (all or some) html tags from html ouput
* - Possibility to set some field names as Name and Email Address of mail received
* - Possibility to set a field as subject after that set in "$oggetto"
* - Button green/red to see updates
*
* 1.11 (18/2/05)
* - Added Html Email Format
*/
?>