Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Google Safe Browsing batch server, client
branch: master

This branch is 3 commits ahead, 1 commit behind client9:master

Failed to load latest commit information.
lib Fixup naming for use in autoloaders
schema Initial upload
COPYING Initial upload update readme pointing to blog post Update notes and thanks lists Merge with Etsy Mainline

This implements a toolkit for implementing the Google Safe Browsing API v2

Read more at Code As Craft

The lib directory contains the pieces you'll need to assemble to match your enivroment:

lib/GSB_Client.php The client to test if a URL is blacklisted
lib/GSB_Exception.php An empty class to namespace our exceptions
lib/GSB_Logger.php A really simple logger. Ideally you'd subclass to modify for your environment
lib/GSB_Request.php All network (http) calls are here
lib/GSB_Storage.php Every database query is here, wrapper up in a function
lib/GSB_Updater.php Updates the local GSB database
lib/GSB_URL.php URL cannonicalization

bin-sample shows how this might be done. You'll want to rewrite these for match your environment:

bin-sample/intro.php common code for both lookup and updater
bin-sample/lookup.php CLI to test a URL
bin-sample/update.php code to update the local GSB database
bin-sample/ shows how update might be run periodicially

The URL lookup and the local database update shares common code:

$gsblists = array('goog-malware-shavar', 'googpub-phish-shavar');

// make a PDO object, 2nd line is just good practice
$dbh = new PDO('mysql:host=;dbname=gsb', 'root');

// create the pieces.  Subclass, over-ride for your environment
$storage = new GSB_StoreDB($dbh);
$network = new GSB_Request($api);
$logger  = new GSB_Logger(5);

To make URL checker:

// make the client with the pieces, and test
$client  = new GSB_Client($storage, $network, $logger);
$client->lookup('http:// A URL /');

To make a database updater:

$x = new GSB_Updater($storage, $network, $logger);
$x->downloadData($gsblists, FALSE);
Something went wrong with that request. Please try again.