Google Safe Browsing
<?php
/**
* Defining constants for the CGI parameters of the HTTP GET Request
* */
define ( 'API_KEY', "YOUR_API_KEY" ); //발급받은 API KEY 입력
define ( 'PROTOCOL_VER', '3.0' );
define ( 'CLIENT', 'checkURLapp' );
define ( 'APP_VER', '1.0' );
/**
* Function for sending a HTTP GET Request
* to the Google Safe Browsing Lookup API
*/
function get_data($url) {
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
$data = curl_exec ( $ch );
$httpStatus = curl_getinfo ( $ch, CURLINFO_HTTP_CODE );
curl_close ( $ch );
return array (
'status' => $httpStatus,
'data' => $data
);
}
/**
* Function for analyzing and paring the
* data received from the Google Safe Browsing Lookup API
*/
function send_response($input) {
if (! empty ( $input )) {
$urlToCheck = urlencode ( $input );
$url = 'https://sb-ssl.google.com/safebrowsing/api/lookup?client=' . CLIENT . '&apikey=' . API_KEY . '&appver=' . APP_VER . '&pver=' . PROTOCOL_VER . '&url=' . $urlToCheck;
$response = get_data ( $url );
if ($response ['status'] == 204) {
return json_encode ( array (
'status' => 204,
'checkedUrl' => $urlToCheck,
'message' => 'The website is not blacklisted and looks safe to use.'
) );
} elseif ($response ['status'] == 200) {
return json_encode ( array (
'status' => 200,
'checkedUrl' => $urlToCheck,
'message' => 'The website is blacklisted as ' . $response ['data'] . '.'
) );
} else {
return json_encode ( array (
'status' => 501,
'checkedUrl' => $urlToCheck,
'message' => 'Something went wrong on the server. Please try again.'
) );
}
} else {
return json_encode ( array (
'status' => 401,
'checkedUrl' => '',
'message' => 'Please enter URL.'
) );
}
;
}
$checkMalware = send_response ('URL'); //검사할 URL 입력
$checkMalware = json_decode($checkMalware, true);
$malwareStatus = $checkMalware['status'];
echo $malwareStatus;
?>
/**
* Defining constants for the CGI parameters of the HTTP GET Request
* */
define ( 'API_KEY', "YOUR_API_KEY" ); //발급받은 API KEY 입력
define ( 'PROTOCOL_VER', '3.0' );
define ( 'CLIENT', 'checkURLapp' );
define ( 'APP_VER', '1.0' );
/**
* Function for sending a HTTP GET Request
* to the Google Safe Browsing Lookup API
*/
function get_data($url) {
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
$data = curl_exec ( $ch );
$httpStatus = curl_getinfo ( $ch, CURLINFO_HTTP_CODE );
curl_close ( $ch );
return array (
'status' => $httpStatus,
'data' => $data
);
}
/**
* Function for analyzing and paring the
* data received from the Google Safe Browsing Lookup API
*/
function send_response($input) {
if (! empty ( $input )) {
$urlToCheck = urlencode ( $input );
$url = 'https://sb-ssl.google.com/safebrowsing/api/lookup?client=' . CLIENT . '&apikey=' . API_KEY . '&appver=' . APP_VER . '&pver=' . PROTOCOL_VER . '&url=' . $urlToCheck;
$response = get_data ( $url );
if ($response ['status'] == 204) {
return json_encode ( array (
'status' => 204,
'checkedUrl' => $urlToCheck,
'message' => 'The website is not blacklisted and looks safe to use.'
) );
} elseif ($response ['status'] == 200) {
return json_encode ( array (
'status' => 200,
'checkedUrl' => $urlToCheck,
'message' => 'The website is blacklisted as ' . $response ['data'] . '.'
) );
} else {
return json_encode ( array (
'status' => 501,
'checkedUrl' => $urlToCheck,
'message' => 'Something went wrong on the server. Please try again.'
) );
}
} else {
return json_encode ( array (
'status' => 401,
'checkedUrl' => '',
'message' => 'Please enter URL.'
) );
}
;
}
$checkMalware = send_response ('URL'); //검사할 URL 입력
$checkMalware = json_decode($checkMalware, true);
$malwareStatus = $checkMalware['status'];
echo $malwareStatus;
?>
댓글 1개
8년 전
계속 프로그램 공부를 하시네요?
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4427 | ||
| 714 | 8년 전 | 7115 | ||
| 713 | 8년 전 | 5062 | ||
| 712 | 8년 전 | 6493 | ||
| 711 | 8년 전 | 6727 | ||
| 710 |
saesini
|
8년 전 | 4140 | |
| 709 | 8년 전 | 4947 | ||
| 708 | 8년 전 | 5183 | ||
| 707 | 8년 전 | 5946 | ||
| 706 | 8년 전 | 9346 | ||
| 705 | 8년 전 | 7030 | ||
| 704 | 8년 전 | 5191 | ||
| 703 | 8년 전 | 5523 | ||
| 702 | 8년 전 | 5591 | ||
| 701 | 8년 전 | 4451 | ||
| 700 | 8년 전 | 5601 | ||
| 699 | 8년 전 | 4780 | ||
| 698 | 8년 전 | 5309 | ||
| 697 | 8년 전 | 4345 | ||
| 696 | 8년 전 | 7947 | ||
| 695 | 8년 전 | 6697 | ||
| 694 | 8년 전 | 3945 | ||
| 693 |
Mentor
|
8년 전 | 8483 | |
| 692 | 8년 전 | 7023 | ||
| 691 | 8년 전 | 6729 | ||
| 690 | 8년 전 | 12423 | ||
| 689 | 8년 전 | 4381 | ||
| 688 | 8년 전 | 4846 | ||
| 687 | 8년 전 | 6620 | ||
| 686 | 8년 전 | 6909 | ||
| 685 |
|
8년 전 | 5811 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기