_emailClass.php
5.21 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
<?php
date_default_timezone_set('Asia/Kolkata');
require 'PHPMailerAutoload.php';
include_once 'helperClass.php' ;
/**
* Description of emailClass
*
* @author admin
*/
class EmailClass {
var $fromname = 'Concorde Tech Turf';
var $defaultUrl = 'mohanritteka.indiahomes.com';
public function callback() {
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$mobile = $_REQUEST['mobile'];
$source = $_REQUEST['source'];
$coutrycode = $_REQUEST['CountryCode'];
$validMobile = EmailClass::validationCheckMobile($mobile);
if ($source === 'Speak to an Expert' || $source === 'Popup Form' || $source === 'Price Popup' || $source === 'Fixed Callback') {
setcookie('popout', 'it works');
if ($validMobile === true) {
$this->_callbackin5minutes($name, $email, $mobile, $countryCode, $_REQUEST['Comment'], '' . $this->defaultUrl. ' - ' . $source, $_REQUEST['projectid']);
}
return $validMobile;
} elseif ($source === 'Footer Form' || $source === 'Instant Callback') {
setcookie('popout', 'it works');
$validEmail = EmailClass::validationCheckEmail($email);
if (($validMobile === true) && ($validEmail === true)) {
if($source === 'Footer Form'){unset($_SESSION['captcha']);}
$this->_callbackin5minutes($name, $email, $mobile, $countryCode, $_REQUEST['Comment'], '' . $this->defaultUrl. ' - ' . $source, $_REQUEST['projectid']);
return $validMobile;
} else{
$errorMsg = 'Enter a valid mobile number and/or email address.';
return $errorMsg;
}
}
}
public static function validationCheckMobile($mobile) {
$msg = true;
if (empty($mobile) || strlen($mobile) >= 18 || strlen($mobile) <= 3 || $mobile === 'Mobile:' || !(EmailClass::is_mobileNumber($mobile))) {
$msg = 'Enter a valid mobile number.';
return $msg;
}
return $msg;
}
public static function validationCheckEmail($email) {
$msg = true;
if (empty($email) || !(EmailClass::isValidEmail($email)) || $email === 'Email:') {
$msg = 'Enter a valid email address.';
return $msg;
}
return $msg;
}
public static function isValidEmail($email) {
//return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
return filter_var($email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email);
}
public static function is_mobileNumber($mobile) {
$regex1 = '123456789';
$regex2 = '1234567890';
$regex3 = '0123456789';
if (preg_match('/^([0-9])\1*$/', $mobile)) {
return false;
} elseif ($mobile == $regex1) {
return false;
} elseif ($mobile == $regex2) {
return false;
} elseif ($mobile == $regex3) {
return false;
} elseif (preg_match("/[^0-9]/", $mobile)) {
return false;
} else {
return true;
}
}
public function _callbackin5minutes($name, $email, $mobile, $countryCode, $comments, $screenName, $projectID) {
$key = 'SEM';
$campaignName = $_COOKIE['vaLead_Campaign'];
$channelName = $_COOKIE['vaLead_Channel'];
$keyword = $_COOKIE['vaLead_Keyword'];
$placement = $_COOKIE['vaLead_Placement'];
$device = $_COOKIE['vaLead_Device'];
$utmSource = $_COOKIE['vaLead_UtmSourceName'];
$utmMedium = $_COOKIE['vaLead_UtmMediumName'];
$utmCampaign = $_COOKIE['vaLead_UtmCampaignName'];
$ip_add = helperClass::getIpAddr();
//$ChannelDetails = "Source of traffic: VT, Project Name: ". $this->fromname .", Client Name:". $name .", Campaign Name:". $campaignName .", Channel Name:". $channelName .", Keyword:". $keyword .", Placement:". $placement .", Device:". $device;
$ChannelDetails = "Source of traffic: VT, Project Name: .". $this->fromname ." , Client Name:". $name .", Campaign Name:". $campaignName .", Channel Name:". $channelName .", Keyword:". $keyword .", Placement:". $placement .", Device:". $device .", UTM Source Name:". $utmSource .", UTM Medium Name:". $utmMedium .", UTM Campaign Name:". $utmCampaign;
if ($countryCode!="") {
$mobile = $countryCode.$mobile;
}
$url = "http://www.indiahomes.com/util.html?";
$url .= "action=genericFormFill";
$url .= "&name=". urlencode($name) ."";
$url .= "&mobileNumber=". urlencode($mobile) ."";
$url .= "&emailId=". urlencode( $email ) . "";
$url .= "&via=". urlencode($key) ."";
$url .= "&viaDetails=". urlencode($ChannelDetails). "";
$url .= "&projectId=". urlencode($projectID) ."";
$url .= "&ip=". urlencode($ip_add) ."";
$url .= "&screenName=". urlencode($screenName);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
curl_close($ch);
}
}
?>