diff --git a/bdd.php b/bdd.php index 765f9d8..d59b106 100644 --- a/bdd.php +++ b/bdd.php @@ -53,13 +53,14 @@ function ajouter_doc($request){ die("Connection failed: " . $conn->connect_error); } - $sql = "INSERT INTO ensembles (commentaire_auteur,corrige_inclu) VALUES(?,?)"; + $sql = "INSERT INTO ensembles (commentaire_auteur,corrige_inclu,date_conception) VALUES(?,?,?)"; try{ $stm = $conn->prepare($sql); echo "test1"; - $request['commentaire_auteur'] = htmlspecialchars($request['commentaire_auteur']); + $request['commentaire_auteur'] = htmlspecialchars($request["commentaire_auteur"]); $request["corrige_inclu"] = boolval($request["corrige_inclu"]); + $request["date_conception"] = htmlspecialchars($request["date_conception"]); $stm->bind_param("si",$request['commentaire_auteur'],$request["corrige_inclu"]); echo "test2"; $stm->execute(); @@ -91,6 +92,9 @@ function saveFilesFromPost($postData,$id_ensemble) { $i = 0; + var_dump($_FILES); + + foreach ($_FILES as $file) { // Extract file information if (isset($file['name'])){ @@ -112,9 +116,15 @@ function saveFilesFromPost($postData,$id_ensemble) { $filePath = $GLOBALS['uploadDir'] . $uniqueFileName; //echo($filePath."\n"); - + + // Save the file + $f = fopen($file['tmp_name'],"r"); + echo fread($f,filesize($file['tmp_name'])); + fclose($f); + + if (move_uploaded_file($file['tmp_name'], $filePath)) { echo(json_encode(["status"=>"1","msg" =>"File '$uniqueFileName' has been saved successfully."])); } else { diff --git a/index.php b/index.php index b4c03fa..aee05bf 100644 --- a/index.php +++ b/index.php @@ -163,7 +163,7 @@ break; case "html": ele = document.createElement("iframe"); - ele.setAttribute("sandbox","allow-forms allow-modals allow-scripts") + ele.setAttribute("sandbox","allow-forms allow-modals allow-scripts"); break; default: ele = document.createElement("img"); diff --git a/init_db.php b/init_db.php index 25e053f..de12de0 100644 --- a/init_db.php +++ b/init_db.php @@ -22,7 +22,8 @@ $sql = " commentaire_auteur TEXT, valide BOOLEAN NOT NULL DEFAULT FALSE, corrige_inclu BOOLEAN NOT NULL DEFAULT FALSE, - date_televersement DATETIME DEFAULT CURRENT_TIMESTAMP + date_televersement DATETIME DEFAULT CURRENT_TIMESTAMP, + date_conception VARCHAR(9) ); CREATE TABLE IF NOT EXISTS documents ( diff --git a/readme.md b/readme.md index e1f0e05..c879ec5 100644 --- a/readme.md +++ b/readme.md @@ -56,6 +56,8 @@ D'autres fonctionnalités seront ajoutées petit à petit. (si vous avez des sug ## TOUDOU : +- dates de conception de l'annale pour chaque ensemble dans la bdd +- support html dans la page de verif mais sans le js dans les iframes @@ -78,4 +80,3 @@ let ex = [{duree:"10",themes:["algèbre","analyse"],commentaire_exo:"cci est un - diff --git a/televerser.php b/televerser.php index 9142512..ed07861 100644 --- a/televerser.php +++ b/televerser.php @@ -17,7 +17,7 @@ $csrf = new CSRF(); -
@@ -63,6 +65,8 @@ function uploadFiles() { formData.append("corrige_inclu",document.getElementById("corrige_checkbox").value); + formData.append("date_conception",document.getElementById("date_conception_input").value); + //let ex = [{duree:"10",themes:["algèbre","analyse"],commentaire_exo:"ceci est un commenataire"},{duree:"15",themes:["elec analogique"],commentaire_exo:""}]; var ex = []; @@ -255,6 +259,23 @@ function changer_mode(){ } +function init_date(){ + var today = new Date(); + var dd = today.getDate(); + var mm = today.getMonth()+1; + var yyyy = today.getFullYear()-1; // pourquoi 2025 ????? + yyyy = parseInt(yyyy) + 1; + today = yyyy+"-"+mm+"-"+dd; + console.log(today); + document.getElementById("date_conception_input").setAttribute("value",today); +} + +document.addEventListener("DOMContentLoaded", (event) => { + init_date(); +}); + + +