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년 전 | 4404 | ||
| 2694 | 2개월 전 | 191 | ||
| 2693 | 2개월 전 | 150 | ||
| 2692 | 2개월 전 | 159 | ||
| 2691 | 2개월 전 | 176 | ||
| 2690 | 2개월 전 | 326 | ||
| 2689 | 2개월 전 | 237 | ||
| 2688 |
|
2개월 전 | 441 | |
| 2687 | 2개월 전 | 294 | ||
| 2686 |
선택과집중
|
2개월 전 | 331 | |
| 2685 | 2개월 전 | 292 | ||
| 2684 | 2개월 전 | 350 | ||
| 2683 | 2개월 전 | 482 | ||
| 2682 | 2개월 전 | 279 | ||
| 2681 | 3개월 전 | 304 | ||
| 2680 |
선택과집중
|
3개월 전 | 278 | |
| 2679 | 3개월 전 | 332 | ||
| 2678 |
|
3개월 전 | 430 | |
| 2677 |
|
3개월 전 | 502 | |
| 2676 | 3개월 전 | 326 | ||
| 2675 | 3개월 전 | 305 | ||
| 2674 |
선택과집중
|
3개월 전 | 481 | |
| 2673 |
|
3개월 전 | 323 | |
| 2672 | 3개월 전 | 335 | ||
| 2671 | 3개월 전 | 284 | ||
| 2670 | 3개월 전 | 261 | ||
| 2669 | 3개월 전 | 374 | ||
| 2668 | 3개월 전 | 290 | ||
| 2667 |
선택과집중
|
3개월 전 | 486 | |
| 2666 |
선택과집중
|
3개월 전 | 472 | |
| 2665 |
선택과집중
|
3개월 전 | 409 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기