connect_errno) { // the connection may fail ?>{"err":"db conn failed"}query("SELECT `revoke_id` FROM `$dbname`.`$dbtable` WHERE `public_key` = '$public_key' LIMIT 1"); // has the certificate been revoked? $revoked = $req->num_rows > 0; // close the connection $mysqli->close(); return $revoked; } else { $link = mysql_connect($dbhost, $dbuser, $dbpw, $dbname); if (!$link) { // the connection may fail ?>{"err":"db conn failed"}{"err":"query failed"} 0; // close the connection mysql_close($link); return $revoked; } } // this script expects a public key as a GET parameter. if(!empty($_GET["pub"])) { // we filter everything except for hexadecimal characters $public_key = preg_replace("/[^a-fA-F0-9]+/", "", $_GET["pub"]); // a public key in this representation has the length 32 * 2 // (32 bytes with each 2 characters) if(strlen($public_key) == 32 * 2) { $revoked = is_revoked($public_key); ?>{"pub":"","revoked":}{"err":"wrong len"}{"err":"no pub given"}