From ce809b7466226cf2da9a4a513f7281446eed715e Mon Sep 17 00:00:00 2001
From: JunkJumper
Date: Mon, 28 Sep 2020 11:44:14 +0200
Subject: [PATCH] "TP2 finis"
---
2020-2021/TD2/index.php | 44 ++++++++++++++++++++++++++++++++++-------
1 file changed, 37 insertions(+), 7 deletions(-)
diff --git a/2020-2021/TD2/index.php b/2020-2021/TD2/index.php
index aec7106..4d44484 100755
--- a/2020-2021/TD2/index.php
+++ b/2020-2021/TD2/index.php
@@ -11,8 +11,6 @@
$aj = "Applejack is best pony !";
$cmc = "Applebloom is Applejack's little sister, Scootaloo is Rainbow Dash's little filly; Sweatie Belle is Rarity's little sister.";
$song = "We've traveled the road of generations… Joined by a common bond; We sing our song 'cross the pony nation; From Equestria and beyond… We're Apples forever, Apples together ! We're family, but so much more ! No matter what comes, we will face the weather ! We're Apples to the core…";
-$alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-$num = "0123456789";
$namesO = array (
"mots",
"phrases",
@@ -86,10 +84,23 @@ function keepOccurences(String $s) : array {
return $tabCount;
}
-function generatePassword(String $s) : String {
-
-
- return "";
+function generatePsw(String $s) : String {
+ $psw = "";
+ if(mb_strlen($s) >= 6) {
+ $i = 0;
+ while($i < 4) {
+ $alea = random_int(0,9);
+ $psw .=$alea;
+ $i++;
+ }
+ $i = 0;
+ while($i < 4) {
+ $alea = $s[random_int(0,mb_strlen($s))];
+ $psw .=$alea;
+ $i++;
+ }
+ }
+ return $psw;
}
?>
@@ -100,6 +111,7 @@ function generatePassword(String $s) : String {
M314 - TD1
M314 - TD2 : Manipulation des boucles, expressions conditionnelles et introduction aux tables globales
+
@@ -142,8 +154,26 @@ function generatePassword(String $s) : String {
for ($i=0; $i < 8 ; $i++) {
echo $tab[$i] . " " . $namesO[$i] . ", ";
}
- ?>
+ ?>
+
+ 5) Mot de passe aléatoire de "Applejack" :
+
+
+ Tables $GLOBALS, $_SERVER et $_ENV
+
+ Voici la valeur de SERVER_ADDR :
+ Voici la valeur de HTTP_HOST :
+ Voici la valeur de REMOTE_ADDR :
+ Voici la valeur de HTTP_USER_AGENT :
+ Voici la valeur de $_ENV :
+
+
+ Les fonctions date et mktime
+
+ Bonjour, nous sommes le , il est .
+ Le jour que nous sommes est le .
+ Ma date de naissance : à GMT-4.