$_SESSION['user'] = getDefaultUserPrefs(); } // If logged in, repopulate the user prefs with their real values. if ($loggedin) { importUserPrefs($athena); } /** * This runs if the user has click "save road". It determines the login * status of the user and sets the hash to be either random characters * or something like username/20120504051511 */ if (isset($_POST['saveNewRoad'])) { requireCSRF(); requirePostDataFields('classes', 'majors'); $classes = CourseRoadDB::encrypt($_POST['classes']); $majors = CourseRoadDB::encrypt($_POST['majors']); $hash = substr(strtr(base64_encode(md5($classes . $majors)), '+/=', '-_,'), 0, 5); if (!CourseRoadDB::isHashSafe($hash, $classes, $majors)) { 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; }