forked from mougnibas/archinsa
LESSGOOOO
This commit is contained in:
parent
043a047e50
commit
438943b0c4
6 changed files with 45 additions and 8 deletions
16
bdd.php
16
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 {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ $csrf = new CSRF();
|
|||
|
||||
<!-- Input to choose files -->
|
||||
|
||||
<form id="uploadForm">
|
||||
<form id="uploadForm" enctype="multipart/form-data">
|
||||
<input type="file" id="fileInput" multiple>
|
||||
<br>
|
||||
<input type="text" placeholder="titre" id="titre"></input>
|
||||
|
@ -38,7 +38,9 @@ $csrf = new CSRF();
|
|||
<label for="corrige_checkbox">Corrigé inclu</label>
|
||||
</div>
|
||||
|
||||
|
||||
<input type="date" id="date_conception_input">
|
||||
<label for="date_conception_input">Date de conception du/des documents (Mettez juste la bonne année si vous ne savez pas) </label>
|
||||
<br>
|
||||
<button type="button" onclick="uploadFiles()">Téléverser les fichiers</button>
|
||||
</form>
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -60,6 +60,10 @@ function displayDocuments() {
|
|||
echo "<embed src=\"{$row['upload_path']}\" type=\"application/pdf\" width=\"100%\" height=\"600px\" />";
|
||||
elseif (in_array(strtolower($extension), ['jpg', 'jpeg', 'png', 'gif'])):
|
||||
echo "<img src=\"{$row['upload_path']}\">";
|
||||
|
||||
elseif (strtolower($extension) == "html"):
|
||||
echo("<iframe src=\"{$row['upload_path']}\"></iframe>");
|
||||
|
||||
else:
|
||||
echo "<p>Unsupported file type</p>".$row['upload_path'];
|
||||
endif;
|
||||
|
|
Loading…
Reference in a new issue