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
"vscode:/vscode.git/clone" did not exist on "df0e9928facf69ab31c846bf499ebfe30833cbd1"
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
...
@@ -16,11 +16,6 @@ class GrupoPesquisaValidation
$url
=
filter_var
(
$url
,
FILTER_SANITIZE_URL
);
$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 url doesn't have a protocol
if
(
substr
(
$url
,
0
,
4
)
!=
'http'
){
if
(
substr
(
$url
,
0
,
4
)
!=
'http'
){
$url
=
'http://'
.
$url
;
$url
=
'http://'
.
$url
;
...
@@ -30,31 +25,7 @@ class GrupoPesquisaValidation
...
@@ -30,31 +25,7 @@ class GrupoPesquisaValidation
return
false
;
return
false
;
}
}
if
(
$this
->
getHttpResponseCode_using_getheaders
(
$url
)
!=
200
){
return
false
;
}
return
true
;
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
...
@@ -4,6 +4,7 @@ class LattesValidation
{
{
public
function
validate
(
$attribute
,
$value
,
$parameters
,
$validator
)
public
function
validate
(
$attribute
,
$value
,
$parameters
,
$validator
)
{
{
// dd($this->isValidUrl($value));
return
$this
->
isValidUrl
(
$value
);
return
$this
->
isValidUrl
(
$value
);
}
}
...
@@ -16,12 +17,6 @@ class LattesValidation
...
@@ -16,12 +17,6 @@ class LattesValidation
}
}
$url
=
filter_var
(
$url
,
FILTER_SANITIZE_URL
);
$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 url doesn't have a protocol
if
(
substr
(
$url
,
0
,
4
)
!=
'http'
){
if
(
substr
(
$url
,
0
,
4
)
!=
'http'
){
...
@@ -31,33 +26,9 @@ class LattesValidation
...
@@ -31,33 +26,9 @@ class LattesValidation
//dd(parse_url($url)['host'] != 'lattes.cnpq.br');
//dd(parse_url($url)['host'] != 'lattes.cnpq.br');
if
(
parse_url
(
$url
)[
'host'
]
!=
'buscatextual.cnpq.br'
&&
parse_url
(
$url
)[
'host'
]
!=
'lattes.cnpq.br'
){
if
(
parse_url
(
$url
)[
'host'
]
!=
'buscatextual.cnpq.br'
&&
parse_url
(
$url
)[
'host'
]
!=
'lattes.cnpq.br'
){
return
false
;
return
false
;
}
}
if
(
$this
->
getHttpResponseCode_using_getheaders
(
$url
)
!=
200
){
return
false
;
}
return
true
;
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