function leaveFeedback($Feedback, $Tags, $Anon) { $user = getUser(); if (!$user->isStudent()) { //TODO: log die("Cannot leave feedback as a non-student. :P"); //TODO: this doesn't seem to display to the screen... } //TODO: feedbacks per time sanitizeIn($Feedback); $conn = connectToDB(); //NB: Anonymous value (0/1) MUST NOT BE QUOTED $id = CheckedQueryAndGetID("INSERT INTO `Feedbacks` (`UserID`, `Text`, `Anonymous`, `Edited`) VALUES ('" . $user->userID . "', '" . $Feedback . "', " . $Anon . ", NOW())", $conn); //Now apply any tags to the feedback if (isset($id) && count($Tags) != 0) { SetTags($id, $Tags, "Feedback", $conn); } $conn->close(); }
function createUser($data) { $user = getUser(); $perms = $user->getPermissions(); if ($perms['CreateUser'] != 1) { logToFile("Log Suspicious Activity.txt", "UserID: " . $user->userID . " attempted account creation without permission."); die("Cannot create account without User Creation permission. :P"); //TODO: this doesn't seem to display to the screen... } else { if ($perms['SuperAdmin'] != 1) { //But if not Super Admin, delete any permissions that the current user does not have $data->Permissions = array_intersect_assoc($data->Permissions, $perms); //TODO: log any change? } } $conn = connectToDB(); //make a user, and grab the auto-increment key $id = CheckedQueryAndGetID($data->makeSQL(), $conn); //TODO: nicer message for Duplicate-Email if (isset($id)) { logToFile("Log Account Creation.txt", "UserID: " . $user->userID . " created account " . $id . "."); //log all permissions in one line if (count($data->Permissions) > 0) { $permsText = ''; foreach ($data->Permissions as $perm) { $permsText = $permsText . $perm . ', '; } $permsText = substr($permsText, 0, -2); logToFile("Log Account Permissions.txt", "UserID: " . $user->userID . " created account " . $id . " with permission(s) " . $permsText . "."); } CheckedQuery($data->makePermissionsSQL($id), $conn); CheckedQuery($data->makeDegreesSQL($id), $conn); //Debug logging for thoroughness' sake and to avoid forgetting passwords //TODO: Remove before final release logToFile("Log Debug Password.txt", $data->Email . " Password: "******" Salt: " . $data->Salt . " SaltedHash: " . $data->SaltedHash); //Send the user an email, so they can use their account (and to save the password...) sendEmailOnAccountCreated($data); } else { logToFile("Log Account Creation.txt", "UserID: " . $user->userID . " failed to create account."); } $conn->close(); }