Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eterfund-api-email
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
eterfund-api-email
Commits
5a3fffe4
You need to sign in or sign up before continuing.
Commit
5a3fffe4
authored
Nov 28, 2018
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add validate_email function and move to return error firstly
parent
f20cf44b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
19 deletions
+27
-19
svcCheckEmail.php
svcCheckEmail.php
+27
-19
No files found.
svcCheckEmail.php
View file @
5a3fffe4
...
@@ -69,16 +69,37 @@ function calc_hash($domain, $ip, $email)
...
@@ -69,16 +69,37 @@ function calc_hash($domain, $ip, $email)
return
md5
(
$domain
.
$net
.
$email
);
return
md5
(
$domain
.
$net
.
$email
);
}
}
// TODO: improve domain list? drop it?
function
validate_email
(
$email
,
&
$matches
)
{
if
(
mb_strlen
(
$email
,
'utf8'
)
<=
5
)
return
false
;
//return preg_match('/^([^@\s]+)@(([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2}|aero|arpa|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|post|pro|tel|travel|events|space))$/', $email, $matches);
return
preg_match
(
'/^([^@\s]+)@(([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2,10}))$/'
,
$email
,
$matches
);
}
$email
=
isset
(
$argv
[
1
])
?
$argv
[
1
]
:
$_GET
[
'email'
];
$email
=
isset
(
$argv
[
1
])
?
$argv
[
1
]
:
$_GET
[
'email'
];
$http_referer
=
$_SERVER
[
'HTTP_REFERER'
];
$http_referer
=
$_SERVER
[
'HTTP_REFERER'
];
$site_domain
=
parse_url
(
$http_referer
,
PHP_URL_HOST
);
$site_domain
=
parse_url
(
$http_referer
,
PHP_URL_HOST
);
$ip_from
=
get_client_ip
();
$ip_from
=
get_client_ip
();
// TODO: improve domain list? drop it?
if
(
mb_strlen
(
$email
,
'utf8'
)
>
5
&&
if
(
!
validate_email
(
$email
,
$matches
)
)
{
preg_match
(
'/^([^@\s]+)@(([a-zA-Z0-9\_\-]+\.)+([a-zA-Z]{2}|aero|arpa|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|post|pro|tel|travel|events))$/'
,
$email
,
$matches
)
$response
=
array
(
)
{
'email'
=>
$email
,
'username'
=>
null
,
'domain'
=>
null
,
'ip_from'
=>
$ip_from
,
'hash'
=>
null
,
'status'
=>
false
,
'error'
=>
'wrong_email_format'
);
echo
json_encode
(
$response
);
// Failed to load resource: the server responded with a status of 406 (Not Acceptable)
// http_response_code(406); // 406 Not Acceptable («неприемлемо»
exit
(
1
);
}
$response
=
array
(
$response
=
array
(
'email'
=>
$matches
[
0
],
'email'
=>
$matches
[
0
],
...
@@ -122,18 +143,6 @@ if(
...
@@ -122,18 +143,6 @@ if(
PHP_EOL
;
PHP_EOL
;
file_put_contents
(
dirname
(
__FILE__
)
.
'/logs/'
.
$referer_host
.
'.'
.
(
$response
[
'status'
]
?
'ok'
:
'error'
)
.
'.log'
,
$data
,
FILE_APPEND
);
file_put_contents
(
dirname
(
__FILE__
)
.
'/logs/'
.
$referer_host
.
'.'
.
(
$response
[
'status'
]
?
'ok'
:
'error'
)
.
'.log'
,
$data
,
FILE_APPEND
);
}
else
{
$response
=
array
(
'email'
=>
$email
,
'username'
=>
null
,
'domain'
=>
null
,
'ip_from'
=>
$ip_from
,
'hash'
=>
null
,
'status'
=>
false
,
'error'
=>
'wrong_email_format'
);
}
echo
json_encode
(
$response
);
echo
json_encode
(
$response
);
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment