From f76f0d19fff5f5b0960f89e53b641d8a78cb2fb0 Mon Sep 17 00:00:00 2001 From: mael Date: Wed, 22 Mar 2023 00:13:04 -0700 Subject: [PATCH] wow --- td1_2/10.php | 27 +++++++++ td1_2/11.php | 39 ++++++++++++ td1_2/2.php | 21 +++++++ td1_2/3.php | 14 +++++ td1_2/4.php | 9 +++ td1_2/5.php | 10 +++ td1_2/6.php | 3 + td1_2/7.php | 11 ++++ td1_2/8.php | 13 ++++ td1_2/9.php | 24 ++++++++ td4/exo1.php | 48 +++++++++++++++ td4/exo1_traitement.php | 11 ++++ td4/exo3.php | 92 ++++++++++++++++++++++++++++ td4/exo4.php | 94 +++++++++++++++++++++++++++++ td4/td4b/data1.txt | 3 + td4/td4b/data1_old.txt | 3 + td4/td4b/data2.csv | 2 + td4/td4b/data2.json | 22 +++++++ td4/td4b/data2.txt | 1 + td4/td4b/exo1.php | 56 +++++++++++++++++ td4/td4b/exo2.php | 32 ++++++++++ td4/td4b/exo3.php | 22 +++++++ td4/td4b/exo4.php | 94 +++++++++++++++++++++++++++++ td4/td4b/menu.txt | 5 ++ td5/action/new.php | 24 ++++++++ td5/connexion.php | 91 ++++++++++++++++++++++++++++ td5/connexion_traitement.php | 21 +++++++ td5/deconnexion.php | 6 ++ td5/index.php | 57 ++++++++++++++++++ td5/personnages.json | 1 + td5/persos.php | 114 +++++++++++++++++++++++++++++++++++ td5/users.json | 14 +++++ td5/users.php | 42 +++++++++++++ tdajax/index.php | 39 ++++++++++++ tdajax/showDate.php | 8 +++ tdajax/texte.txt | 1 + tdajax/write.php | 3 + 37 files changed, 1077 insertions(+) create mode 100644 td1_2/10.php create mode 100644 td1_2/11.php create mode 100644 td1_2/2.php create mode 100644 td1_2/3.php create mode 100644 td1_2/4.php create mode 100644 td1_2/5.php create mode 100644 td1_2/6.php create mode 100644 td1_2/7.php create mode 100644 td1_2/8.php create mode 100644 td1_2/9.php create mode 100644 td4/exo1.php create mode 100644 td4/exo1_traitement.php create mode 100644 td4/exo3.php create mode 100644 td4/exo4.php create mode 100644 td4/td4b/data1.txt create mode 100755 td4/td4b/data1_old.txt create mode 100644 td4/td4b/data2.csv create mode 100755 td4/td4b/data2.json create mode 100644 td4/td4b/data2.txt create mode 100755 td4/td4b/exo1.php create mode 100755 td4/td4b/exo2.php create mode 100755 td4/td4b/exo3.php create mode 100755 td4/td4b/exo4.php create mode 100755 td4/td4b/menu.txt create mode 100644 td5/action/new.php create mode 100644 td5/connexion.php create mode 100644 td5/connexion_traitement.php create mode 100644 td5/deconnexion.php create mode 100644 td5/index.php create mode 100755 td5/personnages.json create mode 100644 td5/persos.php create mode 100644 td5/users.json create mode 100644 td5/users.php create mode 100644 tdajax/index.php create mode 100644 tdajax/showDate.php create mode 100755 tdajax/texte.txt create mode 100644 tdajax/write.php diff --git a/td1_2/10.php b/td1_2/10.php new file mode 100644 index 0000000..de7bd85 --- /dev/null +++ b/td1_2/10.php @@ -0,0 +1,27 @@ + "nunes", + "prenom" => "Jean-Claude", + "age" => 18, + "addresse" => "35400 Saint-Malo", + "profession" => "Java", +); + +echo "

FOR :

"; + +for ($i = 0; $i < count($tableau); $i++) { + print(array_keys($tableau)[$i] . ": "); + echo $tableau[array_keys($tableau)[$i]] . "
"; +} + +echo "

PRINT_R :

"; + +print_r($tableau); + + +echo "

FOREACH :

"; + +foreach ($tableau as $key => $value) { + echo "$key: $value
"; +} diff --git a/td1_2/11.php b/td1_2/11.php new file mode 100644 index 0000000..00ea723 --- /dev/null +++ b/td1_2/11.php @@ -0,0 +1,39 @@ + 14, + "claude" => 13, + "david" => 18, + "maxime" => 1, +); + +$moyenne = 0; + +foreach ($tableau as $prenom => $note) { + echo "$prenom: $note
"; + $moyenne += $note; +} + +$moyenne = $moyenne / count($tableau); + +echo "

Moyenne : $moyenne"; + +// Modification des notes +foreach ($tableau as $prenom => $note) { + if ($prenom == "jean") { + continue; + } + $tableau[$prenom] = $note - 2; +} + +echo "


Nouvelles notes

"; + +?> + +
+
+
+
+
\ No newline at end of file diff --git a/td1_2/2.php b/td1_2/2.php new file mode 100644 index 0000000..84989b1 --- /dev/null +++ b/td1_2/2.php @@ -0,0 +1,21 @@ + + + + Bonjour à tous"; + echo "

Salut lien

"; + ?> + + + + \ No newline at end of file diff --git a/td1_2/3.php b/td1_2/3.php new file mode 100644 index 0000000..f2b80ef --- /dev/null +++ b/td1_2/3.php @@ -0,0 +1,14 @@ + + + + "; + echo $var2; + + echo $var." : bonjour !"; + ?> + + diff --git a/td1_2/4.php b/td1_2/4.php new file mode 100644 index 0000000..6c26932 --- /dev/null +++ b/td1_2/4.php @@ -0,0 +1,9 @@ +"; + +echo $var_b + $var_a . "
"; \ No newline at end of file diff --git a/td1_2/5.php b/td1_2/5.php new file mode 100644 index 0000000..4b14006 --- /dev/null +++ b/td1_2/5.php @@ -0,0 +1,10 @@ +Prenom : $prenom - Nom : $nom - Addresse : $addr - Age : $age


"; + +echo ($age / 10) % 10; +?> \ No newline at end of file diff --git a/td1_2/6.php b/td1_2/6.php new file mode 100644 index 0000000..93eaaf8 --- /dev/null +++ b/td1_2/6.php @@ -0,0 +1,3 @@ + + + +
+");
+print_r($var2); ?> 
+    
+ + diff --git a/td1_2/8.php b/td1_2/8.php new file mode 100644 index 0000000..2ae6bb2 --- /dev/null +++ b/td1_2/8.php @@ -0,0 +1,13 @@ +Prénom : $prenom
Nom : $nom

"; + +if ($age < 18) { + echo "$prenom est mineur(e)."; +} else { + echo "$prenom est majeur(e)."; +} diff --git a/td1_2/9.php b/td1_2/9.php new file mode 100644 index 0000000..9a5e393 --- /dev/null +++ b/td1_2/9.php @@ -0,0 +1,24 @@ +"; +} + +echo "

"; + +$k = 2004; + +while ($k <= 2022) { + echo "$k
"; + $k++; +} + +$k = 2004; + +echo "

"; + + +do { + echo "$k
"; + $k++; +} while ($k <= 2022); diff --git a/td4/exo1.php b/td4/exo1.php new file mode 100644 index 0000000..cae046c --- /dev/null +++ b/td4/exo1.php @@ -0,0 +1,48 @@ + + + + + + + + Document + + + + +

Formulaire

+ +
+ +

+ + +

+ + +

+ +
+ +
+ +

+ +
+ +
+ +
+ +

+ + + " type="hidden"> + + +
+ + + + + \ No newline at end of file diff --git a/td4/exo1_traitement.php b/td4/exo1_traitement.php new file mode 100644 index 0000000..c64dc12 --- /dev/null +++ b/td4/exo1_traitement.php @@ -0,0 +1,11 @@ + $valeur) { + if (is_string($valeur)) { + $valeur = strtolower($valeur); + } + if (is_array($valeur)) { + $valeur = implode(", ", $valeur); + } + echo "$cle : $valeur
"; +} diff --git a/td4/exo3.php b/td4/exo3.php new file mode 100644 index 0000000..00a8ec3 --- /dev/null +++ b/td4/exo3.php @@ -0,0 +1,92 @@ + + + + + + + + Document + + + + + +
+

Formulaire

+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + + + " type="hidden"> + + + +
+ + + Réponse "; + foreach ($_POST as $cle => $valeur) { + if (is_string($valeur)) { + $valeur = strtolower($valeur); + } + if (is_array($valeur)) { + $valeur = implode(", ", $valeur); + } + echo "$cle : $valeur
"; + } + } + ?> + +
+ + + + + + + \ No newline at end of file diff --git a/td4/exo4.php b/td4/exo4.php new file mode 100644 index 0000000..f4eae9d --- /dev/null +++ b/td4/exo4.php @@ -0,0 +1,94 @@ + + + + + + + + Document + + + + + +
+

Formulaire

+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + + + " type="hidden"> + + + +
+ + + Réponse "; + $mail = filter_var($_POST['email'], FILTER_SANITIZE_SPECIAL_CHARS); + $nom = filter_var($_POST['nom'], FILTER_SANITIZE_SPECIAL_CHARS); + $url = filter_var($_POST['url'], FILTER_SANITIZE_SPECIAL_CHARS); + echo "

Nom : $nom

"; + echo "

Email : $mail est " . (filter_var($address, FILTER_VALIDATE_EMAIL) ? 'OK' : 'NOK') . " valide

"; + echo "

URL : $url est " . (filter_var($url, FILTER_VALIDATE_URL) ? 'OK' : 'NOK') . " valide

"; + } + ?> + +
+ + + + + + + \ No newline at end of file diff --git a/td4/td4b/data1.txt b/td4/td4b/data1.txt new file mode 100644 index 0000000..8d73cbf --- /dev/null +++ b/td4/td4b/data1.txt @@ -0,0 +1,3 @@ +Jean Dupont jean.dupont@outlook.com +Pierre Martin p.mart1@gmail.com +Paul Durand durandpaul@caramail.fr diff --git a/td4/td4b/data1_old.txt b/td4/td4b/data1_old.txt new file mode 100755 index 0000000..02e7185 --- /dev/null +++ b/td4/td4b/data1_old.txt @@ -0,0 +1,3 @@ +Jean-Marc Pierrot jm.pierrot@univ-rennes.fr 019435812 +Frederic Sanchez fredsanch@gmail.fr 0968134529 +Stephanie Garcia setphanieg@outlook.com 0638913307 \ No newline at end of file diff --git a/td4/td4b/data2.csv b/td4/td4b/data2.csv new file mode 100644 index 0000000..118648c --- /dev/null +++ b/td4/td4b/data2.csv @@ -0,0 +1,2 @@ +David,Gatel,david@univ.fr,https://getbootstrap.com,192.168.64.1,"2023-03-16 01:29:20",csv, +fzani,fjia,jfai@euN.fr,http://a.fr,192.168.64.1,"2023-03-16 01:31:21",csv, diff --git a/td4/td4b/data2.json b/td4/td4b/data2.json new file mode 100755 index 0000000..897aafc --- /dev/null +++ b/td4/td4b/data2.json @@ -0,0 +1,22 @@ +[ + { + "prenom": "af", + "nom": "afzaf", + "email": "ae@e.fr", + "url": "http:\/\/fazfzafza.fr", + "userIP": "192.168.64.1", + "userDATE": "2023-03-16 01:32:23", + "sortie": "json", + "valide": "" + }, + { + "prenom": "af", + "nom": "afzaf", + "email": "ae@e.fr", + "url": "http:\/\/fazfzafza.fr", + "userIP": "192.168.64.1", + "userDATE": "2023-03-16 01:32:23", + "sortie": "json", + "valide": "" + } +] \ No newline at end of file diff --git a/td4/td4b/data2.txt b/td4/td4b/data2.txt new file mode 100644 index 0000000..75ecc08 --- /dev/null +++ b/td4/td4b/data2.txt @@ -0,0 +1 @@ +Jean Claude jean.claude@nunes.fr https://jean.fr 192.168.64.1 2023-03-16 00:50:15 diff --git a/td4/td4b/exo1.php b/td4/td4b/exo1.php new file mode 100755 index 0000000..4724fa0 --- /dev/null +++ b/td4/td4b/exo1.php @@ -0,0 +1,56 @@ + + + + + + + + Document + + + + + $title, "url" => $url); + } + } + + // Ferme le fichier + fclose($menu_file); + + // Affiche la barre de menu + echo ""; + ?> + + + \ No newline at end of file diff --git a/td4/td4b/exo2.php b/td4/td4b/exo2.php new file mode 100755 index 0000000..3ede091 --- /dev/null +++ b/td4/td4b/exo2.php @@ -0,0 +1,32 @@ + + + + + + + + Document + + + + +
+ $prenom $nom

Email : $email
Tél : $tel

"; + } + ?> +
+ + + + \ No newline at end of file diff --git a/td4/td4b/exo3.php b/td4/td4b/exo3.php new file mode 100755 index 0000000..7d698b1 --- /dev/null +++ b/td4/td4b/exo3.php @@ -0,0 +1,22 @@ + array( + "nom" => "Dupont", + "email" => "jean.dupont@outlook.com" + ), + "Pierre" => array( + "nom" => "Martin", + "email" => "p.mart1@gmail.com" + ), + "Paul" => array( + "nom" => "Durand", + "email" => "durandpaul@caramail.fr" + ), +); + +foreach ($donnees as $prenom => $info) { + $data = $prenom . " " . $info["nom"] . " " . $info["email"]; + file_put_contents("data1.txt", $data . PHP_EOL, FILE_APPEND); + echo "Ecriture de $prenom dans le fichier data1.txt
"; +} diff --git a/td4/td4b/exo4.php b/td4/td4b/exo4.php new file mode 100755 index 0000000..054e015 --- /dev/null +++ b/td4/td4b/exo4.php @@ -0,0 +1,94 @@ + + + + + + + + Document + + + + + +
+

Formulaire

+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ + +
+ + + " type="hidden"> + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + + Réponse "; + foreach ($_POST as $cle => $valeur) { + echo "$cle : $valeur
"; + } + if ($_POST["sortie"] == "txt") { + file_put_contents("data2.txt", $_POST['prenom'] . " " . $_POST['nom'] . " " . $_POST['email'] . " " . $_POST['url'] . " " . $_POST['userIP'] . " " . $_POST['userDATE'] . "\n", FILE_APPEND); + } else if ($_POST["sortie"] == "csv") { + $fp = fopen('data2.csv', 'a'); + fputcsv($fp, $_POST); + } else if ($_POST["sortie"] == "json") { + $actuel = file_get_contents('data2.json'); + $listeTemp = json_decode($actuel); + if (is_array($listeTemp)) { + array_push($listeTemp, $_POST); + } else { + $listeTemp = array($_POST); + } + $donneesJson = json_encode($listeTemp); + file_put_contents('data2.json', $donneesJson); + } + } + ?> + +
+ + + + + + + \ No newline at end of file diff --git a/td4/td4b/menu.txt b/td4/td4b/menu.txt new file mode 100755 index 0000000..9d9f75c --- /dev/null +++ b/td4/td4b/menu.txt @@ -0,0 +1,5 @@ +Exercice1 page01.php +Exercice2 page02.php +Exercice3 page03.php +Exercice4 page04.php +Exercice5 page05.php \ No newline at end of file diff --git a/td5/action/new.php b/td5/action/new.php new file mode 100644 index 0000000..38104b2 --- /dev/null +++ b/td5/action/new.php @@ -0,0 +1,24 @@ + $_POST["nom"], + "birthDate" => $_POST["bdate"], + "deathDate" => $_POST["ddate"], + "image" => $_POST["imgurl"], + "description" => $_POST["description"] + ); + + $actuel = file_get_contents('../personnages.json'); + $listeTemp = json_decode($actuel, true); + print_r($listeTemp["historicalFigures"]); + array_push($listeTemp["historicalFigures"], $newperso); + + $donneesJson = json_encode($listeTemp); + file_put_contents('../personnages.json', $donneesJson); + + header("Location: ../persos.php"); +} diff --git a/td5/connexion.php b/td5/connexion.php new file mode 100644 index 0000000..1c67383 --- /dev/null +++ b/td5/connexion.php @@ -0,0 +1,91 @@ + + + + + + + Mon Site - Connexion + + + + + + + + + + + + + +
+
+ +

Connectez-Vous

+ + + Identifiant ou mot de passe incorrect + "; + } + ?> + +
+ + +
+
+ + +
+ + +

© 2023

+
+
+ + + + + + \ No newline at end of file diff --git a/td5/connexion_traitement.php b/td5/connexion_traitement.php new file mode 100644 index 0000000..f4878ff --- /dev/null +++ b/td5/connexion_traitement.php @@ -0,0 +1,21 @@ + + + + + + + Monsite + + + + + + + +
+ Vous êtes déconnecté.
"; + } + ?> +
+ +

Bonjour

+

Vous êtes

+ Deconnexion » + +

Vous n'êtes pas connecté.

+ Connectez vous » + +
+ + + + + + + + + \ No newline at end of file diff --git a/td5/personnages.json b/td5/personnages.json new file mode 100755 index 0000000..1917f5c --- /dev/null +++ b/td5/personnages.json @@ -0,0 +1 @@ +{"historicalFigures":[{"name":"Leonardo da Vinci","birthDate":"April 15, 1452","deathDate":"May 2, 1519","description":"Leonardo da Vinci was a Renaissance artist and inventor, best known for works like the Mona Lisa and The Last Supper. He was also a scientist and engineer, and made significant contributions to fields like anatomy and architecture.","image":"https:\/\/uploads0.wikiart.org\/images\/leonardo-da-vinci.jpg!Portrait.jpg"},{"name":"Cleopatra","birthDate":"69 BC","deathDate":"August 10, 30 BC","description":"Cleopatra was the last active pharaoh of ancient Egypt, and is famous for her relationships with Julius Caesar and Mark Antony. She was also a powerful political figure in her own right, and played a significant role in the power struggles of the Roman Republic.","image":"https:\/\/media.vogue.fr\/photos\/5c769fa2488cdc91cadf65f6\/2:3\/w_2560%2Cc_limit\/GettyImages-139633685.jpg"},{"name":"Nelson Mandela","birthDate":"July 18, 1918","deathDate":"December 5, 2013","description":"Nelson Mandela was a South African anti-apartheid revolutionary and politician, who served as the President of South Africa from 1994 to 1999. He was a prominent leader in the struggle against apartheid, and was imprisoned for 27 years before being released in 1990.","image":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/0\/02\/Nelson_Mandela_1994.jpg\/640px-Nelson_Mandela_1994.jpg"},{"name":"Marie Curie","birthDate":"November 7, 1867","deathDate":"July 4, 1934","description":"Marie Curie was a Polish-born physicist and chemist, who conducted pioneering research on radioactivity. She was the first woman to win a Nobel Prize, and the first person to win two Nobel Prizes in different fields (physics and chemistry).","image":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/7\/7e\/Marie_Curie_c1920.jpg\/1200px-Marie_Curie_c1920.jpg"},{"name":"William Shakespeare","birthDate":"April 26, 1564","deathDate":"April 23, 1616","description":"William Shakespeare was an English playwright and poet, widely regarded as one of the greatest writers in the English language. He wrote over 30 plays, including classics like Romeo and Juliet, Hamlet, and Macbeth.","image":"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/a\/a2\/Shakespeare.jpg\/800px-Shakespeare.jpg"},{"name":"ZBAD","birthDate":"13","deathDate":"1555","image":"https:\/\/google.com","description":"zffaaza"}]} \ No newline at end of file diff --git a/td5/persos.php b/td5/persos.php new file mode 100644 index 0000000..432af63 --- /dev/null +++ b/td5/persos.php @@ -0,0 +1,114 @@ + + + + + + + Monsite + + + + + + + +
+
+ + + +
+
+ " class="card-img-top" alt="Photo de "> +
+
+

-

+

+
+
+
+ +
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/td5/users.json b/td5/users.json new file mode 100644 index 0000000..8409ac9 --- /dev/null +++ b/td5/users.json @@ -0,0 +1,14 @@ +[ + { + "username": "mgramain", + "password": "bonjour", + "email": "maelgramain@etudiant.univ-rennes1.fr", + "role": "admin" + }, + { + "username": "john35", + "password": "R139OO", + "email": "john35@gmail.com", + "role": "user" + } +] \ No newline at end of file diff --git a/td5/users.php b/td5/users.php new file mode 100644 index 0000000..6a7689f --- /dev/null +++ b/td5/users.php @@ -0,0 +1,42 @@ + + + + + + + + + Utilisateurs + + + + +

Liste d'utilisateurs

+ + + + + + + + + + + "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> + +
UsernamePasswordE-MailRole
" . $user['username'] . "" . $user['password'] . "" . $user['email'] . "" . $user['role'] . "
+ + + + \ No newline at end of file diff --git a/tdajax/index.php b/tdajax/index.php new file mode 100644 index 0000000..d26f35f --- /dev/null +++ b/tdajax/index.php @@ -0,0 +1,39 @@ + + + + + JSON Content + + + + + +
+ + + + + \ No newline at end of file diff --git a/tdajax/showDate.php b/tdajax/showDate.php new file mode 100644 index 0000000..bad5451 --- /dev/null +++ b/tdajax/showDate.php @@ -0,0 +1,8 @@ + date('d-m-y h:i:s') +); +header("Content-Type: application/json"); + +echo (json_encode($res)); diff --git a/tdajax/texte.txt b/tdajax/texte.txt new file mode 100755 index 0000000..0ae6d99 --- /dev/null +++ b/tdajax/texte.txt @@ -0,0 +1 @@ +zaddzadza \ No newline at end of file diff --git a/tdajax/write.php b/tdajax/write.php new file mode 100644 index 0000000..94edaa2 --- /dev/null +++ b/tdajax/write.php @@ -0,0 +1,3 @@ +