-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.php
executable file
·180 lines (172 loc) · 5.31 KB
/
validate.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
<?php
/*
Copyright © 2009,2015,2022 Siggi Bjarnason.
Licensed under GNU GPL v3 and later. Check out LICENSE.TXT for details
or see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>
*/
$PostVarCount = count($_POST);
if($PostVarCount == 0 )
{
header("Location: index.php" );
}
require_once("DBCon.php");
$strReferer = $_SERVER["HTTP_REFERER"];
$strPageNameParts = explode("/",$strReferer);
$strRefServer = "$strPageNameParts[2]";
$bUpdate = "n/a";
$strName = substr(trim($_POST["txtName"]),0,49);
$strNameParts = explode(" ",$strName);
$strEmail = substr(trim($_POST["txtEmail"]),0,49);
$strAddr1 = substr(trim($_POST["txtAddr1"]),0,49);
$strAddr2 = substr(trim($_POST["txtAddr2"]),0,49);
$strCity = substr(trim($_POST["txtCity"]),0,49);
$strState = substr(trim($_POST["cmbState"]),0,49);
$strZip = substr(trim($_POST["txtZip"]),0,10);
$strPhone = substr(trim($_POST["txtPhone"]),0,19);
$strCountry = substr(trim($_POST["cmbCountry"]),0,99);
$strReason = "";
$strURLRegx = "#(http://)|(a href)#i";
if($strHost != $strRefServer)
{
$bSpam = "Yes";
$strReason .= "\n<br>Bad reference";
$arrReason["Ref"]["Spam"]="Bad reference. Posting server isn't this server, denied!";
$strContent = "";
}
if(preg_match($strURLRegx,$strName))
{
$bSpam = "Yes";
$strReason .= "\n<br>URL in Name";
$strContent = $strName;
$arrReason["Name"]["Spam"]="URL in Name";
$arrReason["Name"]["Cont"]=$strName;
error_log("URL in Name: $strName");
}
if(preg_match($strURLRegx,$strEmail))
{
$bSpam = "Yes";
$strReason .= "\n<br>URL in email";
$strContent = $strEmail;
$arrReason["email"]["Spam"]="URL in email";
$arrReason["email"]["Cont"]=$strEmail;
}
if(preg_match($strURLRegx,$strPhone))
{
$bSpam = "Yes";
$strReason .= "\n<br>URL in phone";
$strContent = $strPhone;
$arrReason["phone"]["phone"]="URL in phone";
$arrReason["phone"]["Cont"]=$strPhone;
}
if(preg_match($strURLRegx,$strAddr1))
{
$bSpam = "Yes";
$strReason .= "\n<br>URL in Street 1";
$strContent = $strAddr1;
$arrReason["Street1"]["Spam"]="URL in Street 1";
$arrReason["Street1"]["Cont"]=$strAddr1;
}
if(preg_match($strURLRegx,$strAddr2))
{
$bSpam = "Yes";
$strReason .= "\n<br>URL in Street 2";
$strContent = $strAddr2;
$arrReason["Street2"]["Spam"]="URL in Street 2";
$arrReason["Street2"]["Cont"]=$strAddr2;
}
if(preg_match($strURLRegx,$strCity))
{
$bSpam = "Yes";
$strReason .= "\n<br>URL in Cisty";
$strContent = $strCity;
$arrReason["city"]["Spam"]="URL in City";
$arrReason["city"]["Cont"]=$strCity;
}
if(preg_match($strURLRegx,$strZip))
{
$bSpam = "Yes";
$strReason .= "\n<br>URL in Zip";
$strContent = $strZip;
$arrReason["zip"]["Spam"]="URL in Zip";
$arrReason["zip"]["Cont"]=$strZip;
}
if(preg_match($strURLRegx,$strPhone))
{
$bSpam = "Yes";
$strReason .= "\n<br>URL in Phone";
$strContent = $strPhone;
$arrReason["zip"]["Spam"]="URL in Zip";
$arrReason["zip"]["Cont"]=$strZip;
}
if($strState == "Please Select State")
{
$bValid = "no";
$strReason = "You failed to select proper value for State.";
$arrReason["State"]["invalid"]="You failed to select proper value for State.";
$arrReason["State"]["Cont"]=$strState;
}
if(!$strName)
{
$bValid = "no";
$strReason .= "\n<br>You failed to provide name.";
$arrReason["Name"]["invalid"]="Name is required";
$arrReason["Name"]["Cont"]=$strName;
}
if(!$strEmail)
{
$bValid = "no";
$strReason .= "\n<br>You failed to provide email address.";
$arrReason["email"]["invalid"]="Email is required";
$arrReason["email"]["Cont"]=$strEmail;
}
if(!$strAddr1)
{
$bValid = "no";
$strReason .= "\n<br>You failed to provide Street.";
$arrReason["Street1"]["invalid"]="Address is required";
$arrReason["Street1"]["Cont"]=$strAddr1;
}
if(!$strCity)
{
$bValid = "no";
$strReason .= "\n<br>You failed to provide city.";
$arrReason["city"]["invalid"]="City is required";
$arrReason["city"]["Cont"]=$strCity;
}
if(!$strZip)
{
$bValid = "no";
$strReason .= "\n<br>You failed to provide Zip.";
$arrReason["zip"]["invalid"]="Zip is required";
$arrReason["zip"]["Cont"]=$strZip;
}
$strName = str_replace("\\","",$strName);
$strName = strip_tags($strName);
$strName = str_replace("'","\'",$strName);
$strName = str_replace('"',""",$strName);
$strAddr1 = str_replace("\\","",$strAddr1);
$strAddr1 = strip_tags($strAddr1);
$strAddr1 = str_replace("'","\'",$strAddr1);
$strAddr1 = str_replace('"',""",$strAddr1);
$strAddr2 = str_replace("\\","",$strAddr2);
$strAddr2 = strip_tags($strAddr2);
$strAddr2 = str_replace("'","\'",$strAddr2);
$strAddr2 = str_replace('"',""",$strAddr2);
$strCity = str_replace("\\","",$strCity);
$strCity = strip_tags($strCity);
$strCity = str_replace("'","\'",$strCity);
$strCity = str_replace('"',""",$strCity);
$strZip = str_replace("\\","",$strZip);
$strZip = strip_tags($strZip);
$strZip = str_replace("'","\'",$strZip);
$strZip = str_replace('"',""",$strZip);
$strPhone = str_replace("\\","",$strPhone);
$strPhone = strip_tags($strPhone);
$strPhone = str_replace("'","\'",$strPhone);
$strPhone = str_replace('"',""",$strPhone);
$strEmail = str_replace("'","",$strEmail);
$strEmail = strip_tags($strEmail);
$strEmail = str_replace("\\","",$strEmail);
$strEmail = str_replace('"',""",$strEmail);
$_SESSION["POSTArray"] = $_POST;
?>