From 4ab9578b6522081dc07bfbed3ec3d1c3b34f166e Mon Sep 17 00:00:00 2001 From: name Date: Sun, 14 Dec 2014 20:53:18 -0800 Subject: [PATCH 1/3] added a simple lookup.fastcgi.php --- lookup.fastcgi.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lookup.fastcgi.php 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(); +?> From 6d42af5a7717fda0c7dd3a4b05349dc079bf1593 Mon Sep 17 00:00:00 2001 From: name Date: Sun, 14 Dec 2014 20:58:29 -0800 Subject: [PATCH 2/3] added a simple lookup.fastcgi.php --- Readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Readme.md b/Readme.md index a18ad8b..92ff611 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 + ## FAQ * **When I do a lookup, phpGSB says the URL is safe but I know it's not.** From 91b385dc616bb13736cea3933cc76f1c8c3cf402 Mon Sep 17 00:00:00 2001 From: name Date: Sun, 14 Dec 2014 20:59:12 -0800 Subject: [PATCH 3/3] added a simple lookup.fastcgi.php --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 92ff611..ee33af5 100644 --- a/Readme.md +++ b/Readme.md @@ -28,7 +28,7 @@ $ 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 +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