for ($i = 0; !CourseRoadDB::isHashSafe($hash . $i, $classes, $majors); $i++) { } } $hash .= $i; $_SESSION['crhash'] = $hash; $_SESSION['trycert'] = false; if ($_POST['trycert']) { if ($loggedin) { $hash = defaultOwnedHashName($athena); } else { if (!$_SESSION['triedcert']) { $_SESSION['trycert'] = true; } } } CourseRoadDB::saveNewRoad($hash, $athena, $classes, $majors); dieJSON(array('redirectToAuth' => $_SESSION['trycert'], 'hash' => $hash)); } // Returns the desired table of saved roads when the user is logged in if (isset($_POST['viewSavedRoads'])) { requireCSRF(); if (!$loggedin) { dieJSON(array('error' => true, 'errorDesc' => 'Not logged in', 'html' => 'Sorry, you need to log in again.')); } $saved_roads = CourseRoadDB::getSavedRoads($athena); $html = '<table>'; $html .= '<tr>'; $html .= '<th style="min-width:50px" title="Select if you\'d like one of ' . 'your saved roads to be available more easily at ' . 'courseroad.mit.edu/index.php#' . $athena . '">Public</th>'; $html .= '<th style="min-width:118px">Hash</th>'; $html .= '<th style="min-width:118px">Added</th>'; $html .= '<th style="min-width:95px">Major(s)</th>';