diff --git a/Readme.md b/Readme.md index a18ad8b..ee33af5 100644 --- a/Readme.md +++ b/Readme.md @@ -28,6 +28,8 @@ $ composer require samcleaver/phpgsb 3. Look at listupdater.php and lookup.php example files for basic methods on using the system. 4. If you choose to use listupdater.php as-is then set it as a cron job/scheduled task to run every minute. *(It won't actually update every minute but is required incase of backoff procedures and timeouts)* +5. Optional: set up a simple REST service based on lookup.fastcgi.php, FastCGI and a web server. E.g., configure an Nginx/FastCGI combo to point at the phpGSB directory, and see usage URL examples inside lookup.fastcgi.php. Works relatively well, tested on 100s of lookups/second. + ## FAQ * **When I do a lookup, phpGSB says the URL is safe but I know it's not.** diff --git a/lookup.fastcgi.php b/lookup.fastcgi.php new file mode 100644 index 0000000..f90e3a8 --- /dev/null +++ b/lookup.fastcgi.php @@ -0,0 +1,53 @@ +apikey = "API_KEY_HERE"; +$phpgsb->usinglists = array('googpub-phish-shavar','goog-malware-shavar'); +$url = $_GET["domain"]; + +if ( $parts = parse_url($url) ) { + if ( !isset($parts["scheme"]) ) + { + $url = "http://$url"; + } +} + +$result['status'] = "fail"; +$result['data'] = (object) null; +if ($url === null || $url === "" || !filter_var($url, FILTER_VALIDATE_URL)) { + http_response_code(400); + print json_encode($result); + return; +} + +$checkres = $phpgsb->doLookup($url); +if ($checkres === true) { + $result['status'] ="success"; + $list["list_name"] = "gsb"; + $result['data'] = $list; +} else if ($checkres === false) { + $result['status'] ="success"; + $result['data'] = (object) null; +} +print json_encode($result); +$phpgsb->close(); +?>