Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Walter Felipe
submeta
Commits
8f842ea4
Commit
8f842ea4
authored
Jun 25, 2020
by
alinetenorio
Browse files
atualizando validação
parent
02d5a421
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/Utils/GrupoPesquisaValidation.php
View file @
8f842ea4
...
...
@@ -16,11 +16,6 @@ class GrupoPesquisaValidation
$url
=
filter_var
(
$url
,
FILTER_SANITIZE_URL
);
// // Validate url
// if (!filter_var($url, FILTER_VALIDATE_URL)) {
// return false;
// }
//If url doesn't have a protocol
if
(
substr
(
$url
,
0
,
4
)
!=
'http'
){
$url
=
'http://'
.
$url
;
...
...
@@ -30,31 +25,7 @@ class GrupoPesquisaValidation
return
false
;
}
if
(
$this
->
getHttpResponseCode_using_getheaders
(
$url
)
!=
200
){
return
false
;
}
return
true
;
}
function
getHttpResponseCode_using_getheaders
(
$url
,
$followredirects
=
true
)
{
if
(
!
$url
||
!
is_string
(
$url
))
{
return
false
;
}
$headers
=
@
get_headers
(
$url
);
if
(
$headers
&&
is_array
(
$headers
))
{
if
(
$followredirects
)
{
$headers
=
array_reverse
(
$headers
);
}
foreach
(
$headers
as
$hline
)
{
if
(
preg_match
(
'/^HTTP\/\S+\s+([1-9][0-9][0-9])\s+.*/'
,
$hline
,
$matches
))
{
$code
=
$matches
[
1
];
return
$code
;
}
}
return
false
;
}
return
false
;
}
}
\ No newline at end of file
app/Utils/LattesValidation.php
View file @
8f842ea4
...
...
@@ -4,6 +4,7 @@ class LattesValidation
{
public
function
validate
(
$attribute
,
$value
,
$parameters
,
$validator
)
{
// dd($this->isValidUrl($value));
return
$this
->
isValidUrl
(
$value
);
}
...
...
@@ -16,12 +17,6 @@ class LattesValidation
}
$url
=
filter_var
(
$url
,
FILTER_SANITIZE_URL
);
// Validate url
// if (!filter_var($url, FILTER_VALIDATE_URL)) {
// dd('1');
// return false;
// }
//If url doesn't have a protocol
if
(
substr
(
$url
,
0
,
4
)
!=
'http'
){
...
...
@@ -31,33 +26,9 @@ class LattesValidation
//dd(parse_url($url)['host'] != 'lattes.cnpq.br');
if
(
parse_url
(
$url
)[
'host'
]
!=
'buscatextual.cnpq.br'
&&
parse_url
(
$url
)[
'host'
]
!=
'lattes.cnpq.br'
){
return
false
;
}
if
(
$this
->
getHttpResponseCode_using_getheaders
(
$url
)
!=
200
){
return
false
;
}
}
return
true
;
}
function
getHttpResponseCode_using_getheaders
(
$url
,
$followredirects
=
true
)
{
if
(
!
$url
||
!
is_string
(
$url
))
{
return
false
;
}
$headers
=
@
get_headers
(
$url
);
if
(
$headers
&&
is_array
(
$headers
))
{
if
(
$followredirects
)
{
$headers
=
array_reverse
(
$headers
);
}
foreach
(
$headers
as
$hline
)
{
if
(
preg_match
(
'/^HTTP\/\S+\s+([1-9][0-9][0-9])\s+.*/'
,
$hline
,
$matches
))
{
$code
=
$matches
[
1
];
return
$code
;
}
}
return
false
;
}
return
false
;
}
}
\ 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