static function create($host = null, $port = null, $scrapername = null, $runid = null, $attachables = null, $verification_key = null)
 {
     if (is_null(self::$m_ds)) {
         self::$m_ds = new SW_DataStoreClass($host, $port, $scrapername, $runid, $attachables, $verification_key);
     }
     return self::$m_ds;
 }
 static function gb_postcode_to_latlng($postcode)
 {
     if (is_null($postcode)) {
         return null;
     }
     $ds = SW_DataStoreClass::create();
     $result = $ds->postcodeToLatLng($postcode);
     if (!$result[0]) {
         scraperwiki::sw_dumpMessage(array('message_type' => 'console', 'content' => 'Warning: ' + sprintf('%s: %s', $result[1], $postcode)));
         return null;
     }
     return $result[1];
 }
 static function get_var($name, $default = null)
 {
     $ds = SW_DataStoreClass::create();
     try {
         $result = scraperwiki::sqliteexecute("select value_blob, type from swvariables where name=?", array($name));
     } catch (Exception $e) {
         if (substr($e->getMessage(), 0, 29) == 'sqlite3.Error: no such table:') {
             return $default;
         }
         if (substr($e->getMessage(), 0, 43) == 'DB Error: (OperationalError) no such table:') {
             return $default;
         }
         throw $e;
     }
     $data = $result->data;
     if (count($data) == 0) {
         return $default;
     }
     $svalue = $data[0][0];
     $vtype = $data[0][1];
     if ($vtype == "integer") {
         return intval($svalue);
     }
     if ($vtype == "double") {
         return floatval($svalue);
     }
     if ($vtype == "NULL") {
         return null;
     }
     return $svalue;
 }
        scraperwiki::sw_dumpMessage($etb);
    }
}
register_shutdown_function('shutdown');
// make the $_GET array
$QUERY_STRING = getenv("QUERY_STRING");
$QUERY_STRING_a = explode('&', $QUERY_STRING);
$_GET = array();
for ($i = 0; $i < count($QUERY_STRING_a); $i++) {
    $QUERY_STRING_b = split('=', $QUERY_STRING_a[$i]);
    if (count($QUERY_STRING_b) > 1) {
        $_GET[urldecode($QUERY_STRING_b[0])] = urldecode($QUERY_STRING_b[1]);
    }
}
$dsinfo = split(':', $datastore);
SW_DataStoreClass::create($dsinfo[0], $dsinfo[1], $scrapername, $runid, $attachables, $verification_key);
// the following might be the only way to intercept syntax errors
//$errors = array();
//parsekit_compile_file($script, $errors);
// intercept errors for stack dump
// refer to http://php.net/manual/en/function.set-error-handler.php
function errorHandler($errno, $errstr, $errfile, $errline)
{
    // if error has been surpressed with an @
    // see: http://php.net/manual/en/function.set-error-handler.php
    if (error_reporting() == 0) {
        return;
    }
    global $script;
    $etb = errorParserStack($errno, $errstr, $script);
    scraperwiki::sw_dumpMessage($etb);