-
Notifications
You must be signed in to change notification settings - Fork 0
/
step1-code.php
124 lines (97 loc) · 3.34 KB
/
step1-code.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
<?php
namespace XF\Service\User;
use function intval;
class Registration extends \XF\Service\AbstractService
{
use \XF\Service\ValidateAndSavableTrait;
/**
* @var \XF\Entity\User
*/
protected $user;
protected $fieldMap = [
'username' => 'username',
'email' => 'email',
'timezone' => 'timezone',
'location' => 'Profile.location',
];
protected $logIp = true;
protected $avatarUrl = null;
protected $preRegActionKey = null;
protected $preRegContent = null;
protected $skipEmailConfirm = false;
protected function setup()
{
$this->user = $this->app->repository('XF:User')->setupBaseUser();
}
public function getUser()
{
return $this->user;
}
public function setMapped(array $input)
{
foreach ($this->fieldMap AS $inputKey => $entityKey)
{
if (!isset($input[$inputKey]))
{
continue;
}
$value = $input[$inputKey];
if (strpos($entityKey, '.'))
{
list($relation, $relationKey) = explode('.', $entityKey, 2);
$this->user->{$relation}->{$relationKey} = $value;
}
else
{
$this->user->{$entityKey} = $value;
}
}
}
public function setPassword($password, $passwordConfirm = '', $doPasswordConfirmation = true)
{
// Existing setPassword method...
}
// paste right under here
////////////////////////////////////////////////
public function setEmail($email)
{
$this->user->email = $email;
}
public function checkDisposableEmail()
{
$email = $this->user->email;
// Make API call to check if email is disposable
$apiUrl = 'https://api.api-aries.online/v1/checkers/proxy/email/?email=' . urlencode($email);
$headers = [
'Type: TOKEN TYPE', // learn more: https://support.api-aries.online/hc/articles/1/3/3/email-checker
'APITOKEN: API KEY', // learn more: https://support.api-aries.online/hc/articles/1/3/3/email-checker
];
$curl = curl_init($apiUrl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpCode === 200) {
$responseData = json_decode($response, true);
// Check if the email is disposable according to the API response
if (isset($responseData['disposable']) && strtolower($responseData['disposable']) === 'yes') {
// Email is disposable, handle accordingly
$this->user->error(\XF::phrase('disposable_email_address'));
return false;
} else {
return true; // Email is not disposable
}
} else {
// Failed to check disposable email via API
$this->user->error(\XF::phrase('disposable_email_check_failed'));
return false;
}
}
//////////////////////////////////////////////////////////////////
// Existing code ...
public function setDob($day, $month, $year)
{
return $this->user->Profile->setDob($day, $month, $year);
}
// etc etc code ...