function recoverSendMail($db, $sEmail) { global $config; $row = getUserFromEmail($db, $sEmail); if (!$row) { echo json_encode(array("success" => false)); return; } $sRecoverCode = generateSalt(); $query = "UPDATE `user` SET `recoverCode` = ? WHERE `ID` = ?"; $stmt = $db->prepare($query); $stmt->execute(array($sRecoverCode, $row->ID)); if ($sEmail !== "") { $link = $config->teacherInterface->sCoordinatorFolder . "/recover.php?action=recover&email=" . urlencode($sEmail) . "&recoverCode=" . urlencode($sRecoverCode); $sBody = "Bonjour,\r\n\r\nPour définir un nouveau mot de passe, ouvrez le lien suivant dans votre navigateur : \r\n\r\n" . $link . "\r\n\r\nN'hésitez pas à nous contacter si vous rencontrez des difficultés.\r\n\r\nCordialement,\r\n--\r\nL'équipe du Castor Informatique"; $sTitle = "Réinitialisation de mot de passe Coordinateur Castor Informatique"; sendMail($sEmail, $sTitle, $sBody, $config->email->sEmailSender); //$params = array('recoverCode' => $recoverCode, 'email' => $email); //http_post("eval01.france-ioi.org", 80, "/castor/sendMail2.php", $params); } echo json_encode(array("success" => true)); }
/* Michael Gilbert getUserFromEmail Get the basics of a user from email Error Codes: 0 = user returned all good 1 = email doesnt exists Returns username userType complete */ $app->get('/api/getUserFromEmail/:email', function ($email) use($dbh) { $args[':email'] = $username; $result = getUserFromEmail($dbh, $args); echo json_encode($result); }); /* Andre Gras createBounty Creates a Bounty Error Codes: 0 = bounty created 1 = statement did not execute 2 = user was hunter Returns complete */ $app->post('/api/createBounty', function () use($dbh) {