} else { dump("HOBA: Initiating HOBA+YeOlde Login"); printHOBAYeOldePrompt(); } } else { if (isset($_POST['uName'])) { $err = dbSetUserName($dev['uid'], $_POST['uName']); } elseif (isset($_POST['uPass'])) { $err = dbSetUserPass($dev['uid'], $_POST['uPass']); } elseif (isset($_POST['msg'])) { $err = dbAddMsg($dev['uid'], $_POST['msg']); } elseif (isset($_POST['bondAttempt'])) { $err = dbRequestBond($dev['did'], $_POST['bondAttemptTarget']); } elseif (isset($_POST['bondConfirm'])) { if ($_POST['bondMe'] === "false") { $err = dbDeleteBond($_POST['bondConfirmSource'], $dev['uid']); } elseif ($_POST['bondMe'] === "true") { $err = dbConfirmBond($_POST['bondConfirmSource'], $dev['uid']); } } printHeader(); if ($err !== true) { dump($err); printMeat(false, $dev['did'], $err); } else { printMeat(false, $dev['did'], ""); } printFooter(); } } else { dump("HOBA: No HOBA session found");
function dbConfirmBond($srcDid, $trgUid) { $q = $GLOBALS['db']->query("SELECT srcDid,trgUid from bondMap where srcDid=" . $srcDid . " AND trgUid=" . $trgUid); if ($q === false) { dump("Bond attempt does not exist" . $srcDid . " " . $trgUid); // This should never happen return "Bond attempt does not exist"; } // Get the old uid $q = $GLOBALS['db']->query("SELECT uid from devices WHERE did=" . $srcDid); $old = $q->fetch_assoc(); $q->close(); $oldUid = $old['uid']; $GLOBALS['db']->query("UPDATE devices set uid=" . $trgUid . " WHERE uid=" . $oldUid); $GLOBALS['db']->query("UPDATE messages set uid=" . $trgUid . " WHERE uid=" . $oldUid); $GLOBALS['db']->query("delete from users where uid=" . $oldUid); return dbDeleteBond($srcDid, $trgUid); }