real_escape_string($_REQUEST['user']); $pubkey = $db->real_escape_string($_REQUEST['pubkey']); $pgp = gnupg_init(); if (!$pgp) error("pgp on server failed"); $verify = gnupg_import($pgp, $_REQUEST['pubkey']); if (!$verify) error("wrong identity"); $q = $db->query("select * from user where name='$user' and pubkey='$pubkey';"); if ($q->num_rows==1) { success("user $user found on server"); } elseif ($q->num_rows==0) { $q = $db->query("insert into user (name, pubkey) values ('$user', '$pubkey');"); if (!$q) error("creation of user failed"); success("user $user created on server"); } else { error("server database defect"); } } catch (Exception $e) { error("login failed"); } ?>