Best Mockery code snippet using Contains
index.php
Source:index.php
1<?php session_start() ?>2<?php3use PHPMailer\PHPMailer\PHPMailer;4use PHPMailer\PHPMailer\Exception;5if (isset($_POST['register'])) {6 $showAlert = false; 7 $showError = false; 8 $exists=false;9 10 if($_SERVER["REQUEST_METHOD"] == "POST") {11 12 $server = 'localhost';13 $user = 'root';14 $password = '';15 $bdd = 'nfe114';16 $conn = new mysqli($server, $user, $password, $bdd);17 if (!$conn) {18 echo "<script>alert('Une erreur a eu lieu');</script>";19 }20 21 22 if (isset($_POST["username"])) {23 $user_mail = $_POST["username"];24 }25 else {26 $user_mail = "";27 }28 if (isset($_POST["nom"])) {29 $nom = $_POST["nom"];30 }31 else {32 $nom = "";33 }34 if (isset($_POST["prenom"])) {35 $prenom = $_POST["prenom"];36 }37 else {38 $prenom = "";39 }40 if (isset($_POST["password"])) {41 $password = $_POST["password"];42 }43 else {44 $password = "";45 }46 if (isset($_POST["cpassword"])) {47 $cpassword = $_POST["cpassword"];48 }49 else {50 $cpassword = "";51 }52 $token = md5(crypt($user_mail, $nom));53 $sql = "Select * from `users` where `email`='$user_mail'";54 $result = mysqli_query($conn, $sql);55 $num = mysqli_num_rows($result); 56 $valid = 0;57 $_SESSION['token'] = $token;58 $fullname = $prenom." ".$nom;59 if($num == 0) {60 if ((str_contains($nom, "&") || str_contains($nom, "\"") || str_contains($nom, "'") || str_contains($nom, "(") || str_contains($nom, "-") || str_contains($nom, "_") || str_contains($nom, ")") || str_contains($nom, "=") || str_contains($nom, "$") || str_contains($nom, "*") || str_contains($nom, "ù") || str_contains($nom, "!") || str_contains($nom, ":") || str_contains($nom, ";") || str_contains($nom, ",") || str_contains($nom, "~") || str_contains($nom, "#") || str_contains($nom, "{") || str_contains($nom, "[") || str_contains($nom, "|") || str_contains($nom, "`") || str_contains($nom, "\\") || str_contains($nom, "^") || str_contains($nom, "@") || str_contains($nom, "]") || str_contains($nom, "}") || str_contains($nom, "°") || str_contains($nom, "+") || str_contains($nom, "0") || str_contains($nom, "1") || str_contains($nom, "2") || str_contains($nom, "3") || str_contains($nom, "4") || str_contains($nom, "5") || str_contains($nom, "6") || str_contains($nom, "7") || str_contains($nom, "8") || str_contains($nom, "9") || str_contains($nom, "¨") || str_contains($nom, "£") || str_contains($nom, "¤") || str_contains($nom, "µ") || str_contains($nom, "%") || str_contains($nom, "§") || str_contains($nom, "/") || str_contains($nom, ".") || str_contains($nom, "?") || str_contains($nom, "<") || str_contains($nom, ">") || str_contains($nom, "²")) || (str_contains($prenom, "&") || str_contains($prenom, "\"") || str_contains($prenom, "'") || str_contains($prenom, "(") || str_contains($prenom, "-") || str_contains($prenom, "_") || str_contains($prenom, ")") || str_contains($prenom, "=") || str_contains($prenom, "$") || str_contains($prenom, "*") || str_contains($prenom, "ù") || str_contains($prenom, "!") || str_contains($prenom, ":") || str_contains($prenom, ";") || str_contains($prenom, ",") || str_contains($prenom, "~") || str_contains($prenom, "#") || str_contains($prenom, "{") || str_contains($prenom, "[") || str_contains($prenom, "|") || str_contains($prenom, "`") || str_contains($prenom, "\\") || str_contains($prenom, "^") || str_contains($prenom, "@") || str_contains($prenom, "]") || str_contains($prenom, "}") || str_contains($prenom, "°") || str_contains($prenom, "+") || str_contains($prenom, "0") || str_contains($prenom, "1") || str_contains($prenom, "2") || str_contains($prenom, "3") || str_contains($prenom, "4") || str_contains($prenom, "5") || str_contains($prenom, "6") || str_contains($prenom, "7") || str_contains($prenom, "8") || str_contains($prenom, "9") || str_contains($prenom, "¨") || str_contains($prenom, "£") || str_contains($prenom, "¤") || str_contains($prenom, "µ") || str_contains($prenom, "%") || str_contains($prenom, "§") || str_contains($prenom, "/") || str_contains($prenom, ".") || str_contains($prenom, "?") || str_contains($prenom, "<") || str_contains($prenom, ">") || str_contains($prenom, "²")) || (str_contains($user_mail, "&") || str_contains($user_mail, "\"") || str_contains($user_mail, "'") || str_contains($user_mail, "(") || str_contains($user_mail, ")") || str_contains($user_mail, "=") || str_contains($user_mail, "$") || str_contains($user_mail, "*") || str_contains($user_mail, "!") || str_contains($user_mail, ":") || str_contains($user_mail, ";") || str_contains($user_mail, "~") || str_contains($user_mail, "#") || str_contains($user_mail, "{") || str_contains($user_mail, "[") || str_contains($user_mail, "|") || str_contains($user_mail, "`") || str_contains($user_mail, "\\") || str_contains($user_mail, "^") || str_contains($user_mail, "]") || str_contains($user_mail, "}") || str_contains($user_mail, "°") || str_contains($user_mail, "+") || str_contains($user_mail, "¨") || str_contains($user_mail, "£") || str_contains($user_mail, "¤") || str_contains($user_mail, "µ") || str_contains($user_mail, "%") || str_contains($user_mail, "§") || str_contains($user_mail, "/") || str_contains($user_mail, "?") || str_contains($user_mail, "<") || str_contains($user_mail, ">") || str_contains($user_mail, "²")) || (str_contains($password, "&") || str_contains($password, "\"") || str_contains($password, "'") || str_contains($password, "(") || str_contains($password, "-") || str_contains($password, "_") || str_contains($password, ")") || str_contains($password, "=") || str_contains($password, "$") || str_contains($password, "*") || str_contains($password, "ù") || str_contains($password, "!") || str_contains($password, ":") || str_contains($password, ";") || str_contains($password, ",") || str_contains($password, "~") || str_contains($password, "#") || str_contains($password, "{") || str_contains($password, "[") || str_contains($password, "|") || str_contains($password, "`") || str_contains($password, "\\") || str_contains($password, "^") || str_contains($password, "@") || str_contains($password, "]") || str_contains($password, "}") || str_contains($password, "°") || str_contains($password, "+")|| str_contains($password, "¨") || str_contains($password, "£") || str_contains($password, "¤") || str_contains($password, "µ") || str_contains($password, "%") || str_contains($password, "§") || str_contains($password, "/") || str_contains($password, ".") || str_contains($password, "?") || str_contains($password, "<") || str_contains($password, ">") || str_contains($password, "²")) || (str_contains($cpassword, "&") || str_contains($cpassword, "\"") || str_contains($cpassword, "'") || str_contains($cpassword, "(") || str_contains($cpassword, "-") || str_contains($cpassword, "_") || str_contains($cpassword, ")") || str_contains($cpassword, "=") || str_contains($cpassword, "$") || str_contains($cpassword, "*") || str_contains($cpassword, "ù") || str_contains($cpassword, "!") || str_contains($cpassword, ":") || str_contains($cpassword, ";") || str_contains($cpassword, ",") || str_contains($cpassword, "~") || str_contains($cpassword, "#") || str_contains($cpassword, "{") || str_contains($cpassword, "[") || str_contains($cpassword, "|") || str_contains($cpassword, "`") || str_contains($cpassword, "\\") || str_contains($cpassword, "^") || str_contains($cpassword, "@") || str_contains($cpassword, "]") || str_contains($cpassword, "}") || str_contains($cpassword, "°") || str_contains($cpassword, "+")|| str_contains($cpassword, "¨") || str_contains($cpassword, "£") || str_contains($cpassword, "¤") || str_contains($cpassword, "µ") || str_contains($cpassword, "%") || str_contains($cpassword, "§") || str_contains($cpassword, "/") || str_contains($cpassword, ".") || str_contains($cpassword, "?") || str_contains($cpassword, "<") || str_contains($cpassword, ">") || str_contains($cpassword, "²"))) {61 echo "<script>alert('Des champs contiennent des caractères interdits. Pour rappel, on ne peut utiliser que des lettres, ou également des chiffres dans le cas du mail et du mot de passe.')</script>";62 }63 else if ($user_mail == "") {64 echo "<script>alert('Veuillez indiquer une adresse e-mail')</script>";65 }66 else if ($nom == "") {67 echo "<script>alert('Veuillez indiquer votre nom')</script>";68 }69 else if ($prenom == "") {70 echo "<script>alert('Veuillez indiquer votre prénom')</script>";71 }72 else if ($password == "") {73 echo "<script>alert('Veuillez choisir un mot de passe')</script>";74 }75 else if(($password == $cpassword) && $exists==false) {76 77 $hash = md5($password);78 79 $sql = "INSERT INTO `users` ( `nom`, 80 `prenom`, `email`, `password`, `token`, `valid`) VALUES ('$nom', 81 '$prenom', '$user_mail', '$hash', '$token', $valid)";82 83 $result = mysqli_query($conn, $sql);84 85 if ($result) {86 $showAlert = true; 87 }88 require '.\vendor\phpmailer\phpmailer\src\Exception.php';89 require '.\vendor\phpmailer\phpmailer\src\PHPMailer.php';90 require '.\vendor\phpmailer\phpmailer\src\SMTP.php';91 $mail = new PHPMailer();92 $mail->IsSMTP();93 $mail->Host = 'smtp.gmail.com';94 $mail->Port = 465;95 $mail->SMTPAuth = 1;96 if($mail->SMTPAuth){97 $mail->SMTPSecure = 'ssl';98 $mail->Username = 'connexionprogramme@gmail.com'; 99 $mail->Password = '@MotDePasse50$';100 }101 $mail->CharSet = 'UTF-8';102 $mail->smtpConnect();103 $mail->setFrom('connexionprogramme@gmail.com', 'Prgramme de connexion');104 $mail->FromName = 'Programme de connexion';105 $mail->Subject = 'Validation du compte';106 // $mail->MsgHTML("Bonjour,<br>Vous venez de vous inscrire sur notre site. Pour pouvoir y accéder, veuillez cliquer sur le lien ci-dessous pour valider votre adresse e-mail :<br><a href='https://747f-185-189-23-50.ngrok.io/verif.php?$token'>Vérifier votre adresse e-mail</a><br><br>Toute l'équipe espère que vous vous plairez sur notre site.<br><br><small>En cas de problème de connexion, n'hésitez pas à contacter l'équipe en répondant à ce mail.</small>");107 $mail->MsgHTML("Bonjour,<br>Vous venez de vous inscrire sur notre site. Pour pouvoir y accéder, veuillez cliquer sur le lien ci-dessous pour valider votre adresse e-mail :<br><a href='http://localhost/verif.php?$token'>Vérifier votre adresse e-mail</a><br><br>Toute l'équipe espère que vous vous plairez sur notre site.<br><br><small>En cas de problème de connexion, n'hésitez pas à contacter l'équipe en répondant à ce mail.</small>");108 $mail->IsHTML(true);109 $fullname = "$prenom"." "."$nom";110 $mail->AddAddress("$user_mail","$fullname");111 if (!$mail->send()) {112 echo "<script>alert('Une erreur a eu lieu')</script>";113 }114 } 115 else { 116 $showError = "Les mots de passe ne correspondent pas"; 117 } 118 }119 120 if($num>0)121 {122 $exists="Cet email est déjà utilisé"; 123 } 124 125 }126 echo "<script>if(window.history.replaceState){window.history.replaceState(null,null,window.location.href);}</script>";127}128?>129<!DOCTYPE html>130<html lang="fr">131<head>132 <meta charset="UTF-8">133 <meta http-equiv="X-UA-Compatible" content="IE=edge">134 <meta name="viewport" content="width=device-width, initial-scale=1.0">135 <title>Accueil</title>136 <link rel="stylesheet" href="style.css">137 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"138 integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">139 <link rel="shortcut icon" href="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fapplication-blondel.com%2Fimages%2Ficon-512x512.png" type="image/x-icon">140 <script>141 document.onkeydown = function(e) {142 if(event.keyCode == 123) {143 return false;144 }145 if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) {146 return false;147 }148 if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) {149 return false;150 }151 if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) {152 return false;153 }154 if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) {155 return false;156 }157}158 </script>159</head>160<body oncontextmenu="return false;">161 <h1>Accueil</h1>162 <hr>163 <div class="container">164 <div class="login">165 <h2>Connexion</h2>166 <form action="" method="post">167 <div class="mb-3">168 <input type="email" class="form-control" id="login_email" name="login_email"169 placeholder="Adresse E-Mail" required>170 </div>171 <div class="mb-3">172 <input type="password" pattern="[a-zA-Z0-9]+" class="form-control" id="login_password" name="login_password"173 placeholder="Mot de passe" required>174 </div>175 <button type="submit" name="login" class="btn btn-primary">Connexion</button>176 </form>177 <a href="forgot.php">Mot de passe oublié</a>178 </div>179 <div class="trait"></div>180 <div class="signin">181 <h2>Inscription</h2>182 <?php183 if (isset($_POST['register'])) {184 if($showAlert) {185 186 echo "<script>alert('Votre compte a bien été créé')</script>";187 }188 189 if($showError) {190 191 echo "<script>alert('".$showError."')</script>";192 }193 194 if($exists) {195 echo "<script>alert('".$exists."')</script>";196 }197 }198?>199 200<div>201 202 <form action="" method="post">203 204 <div class="form-group mb-3"> 205 <input type="email" class="form-control" id="username" name="username" placeholder="E-Mail" required>206 </div>207 <div class="form-group mb-3"> 208 <input type="text" pattern="[a-zA-Z]+" title="Les chiffres et caractères spéciaux ne sont pas acceptés" class="form-control" id="nom"209 name="nom" placeholder="Nom" required> 210 </div>211 <div class="form-group mb-3"> 212 <input type="text" pattern="[a-zA-Z]+" title="Les chiffres et caractères spéciaux ne sont pas acceptés" class="form-control" id="prenom"213 name="prenom" placeholder="Prénom" required> 214 </div>215 216 <div class="form-group mb-3"> 217 <input type="password" pattern="[a-zA-Z0-9]+" title="Les caractères spéciaux ne sont pas acceptés" class="form-control"218 id="password" name="password" placeholder="Mot de passe" required> 219 </div>220 221 <div class="form-group mb-3"> 222 <input type="password" pattern="[a-zA-Z0-9]+" title="Les caractères spéciaux ne sont pas acceptés" class="form-control"223 id="cpassword" name="cpassword" placeholder="Confirmer le mot de passe" required>224 </div> 225 226 <button type="submit" name="register" class="btn btn-primary">227 S'enregistrer228 </button> 229 </form> 230</div>231 </div>232 </div>233</body>234</html>235<?php236 if (isset($_POST['login'])){237 $server = 'localhost';238 $user = 'root';239 $password = '';240 $bdd = 'nfe114';241 $connection = new mysqli('localhost', $user, $password, $bdd);242 if (!$connection) {243 echo "<script>alert('Une erreur a eu lieu');</script>";244 }245 if (isset($_POST["login_email"])) {246 $le = $_POST["login_email"];247 }248 else{249 $le = "";250 }251 if (isset($_POST["login_password"])) {252 $lp = md5($_POST["login_password"]);253 }254 else{255 $lp = "";256 }257 if ((str_contains($le, "&") || str_contains($le, "\"") || str_contains($le, "'") || str_contains($le, "(") || str_contains($le, ")") || str_contains($le, "=") || str_contains($le, "$") || str_contains($le, "*") || str_contains($le, "!") || str_contains($le, ":") || str_contains($le, ";") || str_contains($le, "~") || str_contains($le, "#") || str_contains($le, "{") || str_contains($le, "[") || str_contains($le, "|") || str_contains($le, "`") || str_contains($le, "\\") || str_contains($le, "^") || str_contains($le, "]") || str_contains($le, "}") || str_contains($le, "°") || str_contains($le, "+") || str_contains($le, "¨") || str_contains($le, "£") || str_contains($le, "¤") || str_contains($le, "µ") || str_contains($le, "%") || str_contains($le, "§") || str_contains($le, "/") || str_contains($le, "?") || str_contains($le, "<") || str_contains($le, ">") || str_contains($le, "²")) || (str_contains($lp, "&") || str_contains($lp, "\"") || str_contains($lp, "'") || str_contains($lp, "(") || str_contains($lp, "-") || str_contains($lp, "_") || str_contains($lp, ")") || str_contains($lp, "=") || str_contains($lp, "$") || str_contains($lp, "*") || str_contains($lp, "ù") || str_contains($lp, "!") || str_contains($lp, ":") || str_contains($lp, ";") || str_contains($lp, ",") || str_contains($lp, "~") || str_contains($lp, "#") || str_contains($lp, "{") || str_contains($lp, "[") || str_contains($lp, "|") || str_contains($lp, "`") || str_contains($lp, "\\") || str_contains($lp, "^") || str_contains($lp, "@") || str_contains($lp, "]") || str_contains($lp, "}") || str_contains($lp, "°") || str_contains($lp, "+")|| str_contains($lp, "¨") || str_contains($lp, "£") || str_contains($lp, "¤") || str_contains($lp, "µ") || str_contains($lp, "%") || str_contains($lp, "§") || str_contains($lp, "/") || str_contains($lp, ".") || str_contains($lp, "?") || str_contains($lp, "<") || str_contains($lp, ">") || str_contains($lp, "²"))) {258 echo "<script>alert('Des champs contiennent des caractères interdits. Pour rappel, on ne peut utiliser que des lettres, ou également des chiffres dans le cas du mail et du mot de passe.')</script>";259 }260 else if ($le == "") {261 echo "<script>alert('Veuillez indiquer votre adresse e-mail')</script>";262 }263 else if ($lp == "") {264 echo "<script>alert('Veuillez indiquer votre')</script>";265 }266 else {267 $_SESSION['mail'] = $le;268 $req = $connection->query("SELECT `valid` FROM `users` WHERE `email` = '$le'");269 $row = $req->fetch_assoc();270 if ($row['valid']) {271 $query = mysqli_query($connection, "SELECT * FROM `users` WHERE `password`='$lp' and `email`='$le'");272 $row = mysqli_fetch_array($query);273 $num_row = mysqli_num_rows($query);274 275 if ($num_row > 0) 276 { 277 $_SESSION['user'] = $le;278 header('location:space.php');279 280 }281 else282 {283 echo "<script>alert('Identifiants invalides')</script>";284 echo "<script>if(window.history.replaceState){window.history.replaceState(null,null,window.location.href);}</script>";285 }286 }287 else {288 echo "<script>alert('Vous n\'avez pas validé votre adresse e-mail ou créé votre compte')</script>";289 echo "<script>if(window.history.replaceState){window.history.replaceState(null,null,window.location.href);}; location.reload()</script>";290 }291 }292 echo "<script>if(window.history.replaceState){window.history.replaceState(null,null,window.location.href);}</script>";293 }294 ?>...
change.php
Source:change.php
1<?php 2session_start();3$server = 'localhost';4$user = 'root';5$password = '';6$bdd = 'nfe114';7$le = $_SESSION['user'];8$connection = new mysqli($server, $user, $password, $bdd);9if (!$connection) {10 echo "<script>alert('Une erreur a eu lieu');</script>";11}12$query = mysqli_query($connection, "SELECT * FROM `users` WHERE `email`='$le'");13$num_row = mysqli_num_rows($query);14if ($num_row == 0) {15 header('Location: ./');16 exit;17}18?>19<!DOCTYPE html>20<html lang="fr">21<head>22 <meta charset="UTF-8">23 <meta http-equiv="X-UA-Compatible" content="IE=edge">24 <meta name="viewport" content="width=device-width, initial-scale=1.0">25 <title>Changement de mot de passe</title>26 <link rel="stylesheet" href="style.css">27 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"28 integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">29 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">30 <link rel="shortcut icon" href="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fapplication-blondel.com%2Fimages%2Ficon-512x512.png" type="image/x-icon">31 <script>32 document.onkeydown = function(e) {33 if(event.keyCode == 123) {34 return false;35 }36 if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) {37 return false;38 }39 if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) {40 return false;41 }42 if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) {43 return false;44 }45 if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) {46 return false;47 }48}49 </script>50</head>51<body oncontextmenu="return false;">52 <div class="header">53 <div style="padding: 25px;"><a href="space.php" style="color: black;"><i class="fa fa-backward" aria-hidden="true">   Retour</i></a></div>54 <h1>Changement de mot de passe</h1>55 <div></div>56 </div>57 <hr>58 <div class="change">59 <form action="" method="post">60 <div class="mb-3">61 <input type="password" pattern="[a-zA-Z0-9]+" title="Les caractères spéciaux ne sont pas acceptés" class="form-control" id="change_password_old" name="change_password_old"62 placeholder="Ancien mot de passe" required>63 </div>64 <div class="mb-3">65 <input type="password" pattern="[a-zA-Z0-9]+" title="Les caractères spéciaux ne sont pas acceptés" class="form-control" id="change_password" name="change_password"66 placeholder="Nouveau mot de passe" required>67 </div>68 <div class="mb-3">69 <input type="password" pattern="[a-zA-Z0-9]+" title="Les caractères spéciaux ne sont pas acceptés" class="form-control" id="confirm_change_password" name="confirm_change_password"70 placeholder="Confirmez le nouveau mot de passe" required>71 </div>72 <button type="submit" name="change" class="btn btn-primary">Changer le mot de passe</button>73 </form>74 </div>75</body>76</html>77<?php78if (isset($_POST['change'])) {79 $server = 'localhost';80 $user = 'root';81 $password = '';82 $bdd = 'nfe114';83 $le = $_SESSION['mail'];84 $conn = new mysqli($server, $user, $password, $bdd);85 if (!$conn) {86 echo "<script>alert('Une erreur a eu lieu');</script>";87 }88 $mail = $le;89 if (isset($_POST['change_password_old'])) {90 $old = md5($_POST['change_password_old']);91 }92 else {93 $old = "";94 }95 if (isset($_POST['change_password'])) {96 $new = md5($_POST['change_password']);97 }98 else {99 $new = "";100 }101 if (isset($_POST['confirm_change_password'])) {102 $cnew = md5($_POST['confirm_change_password']);103 }104 else {105 $cnew = "";106 }107 if ((str_contains($old, "&") || str_contains($old, "\"") || str_contains($old, "'") || str_contains($old, "(") || str_contains($old, "-") || str_contains($old, "_") || str_contains($old, ")") || str_contains($old, "=") || str_contains($old, "$") || str_contains($old, "*") || str_contains($old, "ù") || str_contains($old, "!") || str_contains($old, ":") || str_contains($old, ";") || str_contains($old, ",") || str_contains($old, "~") || str_contains($old, "#") || str_contains($old, "{") || str_contains($old, "[") || str_contains($old, "|") || str_contains($old, "`") || str_contains($old, "\\") || str_contains($old, "^") || str_contains($old, "@") || str_contains($old, "]") || str_contains($old, "}") || str_contains($old, "°") || str_contains($old, "+")|| str_contains($old, "¨") || str_contains($old, "£") || str_contains($old, "¤") || str_contains($old, "µ") || str_contains($old, "%") || str_contains($old, "§") || str_contains($old, "/") || str_contains($old, ".") || str_contains($old, "?") || str_contains($old, "<") || str_contains($old, ">") || str_contains($old, "²")) || (str_contains($new, "&") || str_contains($new, "\"") || str_contains($new, "'") || str_contains($new, "(") || str_contains($new, "-") || str_contains($new, "_") || str_contains($new, ")") || str_contains($new, "=") || str_contains($new, "$") || str_contains($new, "*") || str_contains($new, "ù") || str_contains($new, "!") || str_contains($new, ":") || str_contains($new, ";") || str_contains($new, ",") || str_contains($new, "~") || str_contains($new, "#") || str_contains($new, "{") || str_contains($new, "[") || str_contains($new, "|") || str_contains($new, "`") || str_contains($new, "\\") || str_contains($new, "^") || str_contains($new, "@") || str_contains($new, "]") || str_contains($new, "}") || str_contains($new, "°") || str_contains($new, "+")|| str_contains($new, "¨") || str_contains($new, "£") || str_contains($new, "¤") || str_contains($new, "µ") || str_contains($new, "%") || str_contains($new, "§") || str_contains($new, "/") || str_contains($new, ".") || str_contains($new, "?") || str_contains($new, "<") || str_contains($new, ">") || str_contains($new, "²")) || (str_contains($cnew, "&") || str_contains($cnew, "\"") || str_contains($cnew, "'") || str_contains($cnew, "(") || str_contains($cnew, "-") || str_contains($cnew, "_") || str_contains($cnew, ")") || str_contains($cnew, "=") || str_contains($cnew, "$") || str_contains($cnew, "*") || str_contains($cnew, "ù") || str_contains($cnew, "!") || str_contains($cnew, ":") || str_contains($cnew, ";") || str_contains($cnew, ",") || str_contains($cnew, "~") || str_contains($cnew, "#") || str_contains($cnew, "{") || str_contains($cnew, "[") || str_contains($cnew, "|") || str_contains($cnew, "`") || str_contains($cnew, "\\") || str_contains($cnew, "^") || str_contains($cnew, "@") || str_contains($cnew, "]") || str_contains($cnew, "}") || str_contains($cnew, "°") || str_contains($cnew, "+")|| str_contains($cnew, "¨") || str_contains($cnew, "£") || str_contains($cnew, "¤") || str_contains($cnew, "µ") || str_contains($cnew, "%") || str_contains($cnew, "§") || str_contains($cnew, "/") || str_contains($cnew, ".") || str_contains($cnew, "?") || str_contains($cnew, "<") || str_contains($cnew, ">") || str_contains($cnew, "²"))) {108 echo "<script>alert('Des champs contiennent des caractères interdits. Pour rappel, on ne peut utiliser que des lettres, ou des chiffres dans le cas du mail et du mot de passe.')</script>";109 }110 else if ($old == "") {111 echo "<script>alert('Veuillez indiquer votre ancien mot de passe')</script>";112 }113 else if ($new == "") {114 echo "<script>alert('Veuillez indiquer votre nouveau mot de passe')</script>";115 }116 else if ($cnew == "") {117 echo "<script>alert('Veuillez confirmer votre nouveau mot de passe')</script>";118 }119 else {120 $req = $conn->query("SELECT `password` FROM `users` WHERE `email` = '$mail'");121 $row = $req->fetch_assoc();122 if ($row['password'] == $new) {123 echo "<script>alert('Vous ne pouvez pas utiliser votre mot de passe actuel comme nouveau mot de passe.')</script>";124 }125 elseif ($new == $cnew && $row['password'] != $new) {126 $upd = $conn->query("UPDATE `users` SET `password` = '$new' WHERE `email` = '$mail'");127 echo "<script>alert('Votre mot de passe a bien été mis à jour');window.location.href = 'space.php';</script>";128 }129 else {130 echo "<script>alert('Une erreur a eu lieu.')</script>";131 }132 }133}134?>...
change_forgot.php
Source:change_forgot.php
1<?php2session_start();3?>4<!DOCTYPE html>5<html lang="en">6<head>7 <meta charset="UTF-8">8 <meta http-equiv="X-UA-Compatible" content="IE=edge">9 <meta name="viewport" content="width=device-width, initial-scale=1.0">10 <title>Mot de passe oublié</title>11 <link rel="stylesheet" href="style.css">12 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"13 integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">14 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">15 <link rel="shortcut icon" href="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fapplication-blondel.com%2Fimages%2Ficon-512x512.png" type="image/x-icon">16 <script>17 document.onkeydown = function(e) {18 if(event.keyCode == 123) {19 return false;20 }21 if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) {22 return false;23 }24 if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) {25 return false;26 }27 if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) {28 return false;29 }30 if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) {31 return false;32 }33}34 </script>35</head>36<body oncontextmenu="return false;">37 <div class="header">38 <div style="padding: 25px;"><a href="./" style="color: black;"><i class="fa fa-home" aria-hidden="true">   Accueil</i></a></div>39 <h1>Mot de passe oublié</h1>40 <div></div>41 </div>42 <hr>43 <form action="" method="post" class="cf">44 <div class="mb-3">45 <input type="password" pattern="[a-zA-Z0-9]+" title="Les caractères spéciaux ne sont pas acceptés" class="form-control" name="new_pass" placeholder="Entrez votre nouveau mot de passe" required>46 </div>47 <div class="mb-3">48 <input type="password" pattern="[a-zA-Z0-9]+" title="Les caractères spéciaux ne sont pas acceptés" class="form-control" name="cnew_pass" placeholder="Confirmez votre nouveau mot de passe" required>49 </div>50 <div class="mb-3">51 <input type="submit" class="btn btn-primary cf_btn" value="Changer le mot de passe" name="change_forgot">52 </div>53 </form>54</body>55</html>56<?php57$url = $_SERVER['REQUEST_URI'];58$pos = strrpos($url, '/');59$id = $pos === false ? $url : substr($url, $pos + 19);60$token = $id;61$server = 'localhost';62$user = 'root';63$password = '';64$bdd = 'nfe114';65$conn = new mysqli($server, $user, $password, $bdd);66if (!$conn) {67 echo "<script>alert('Une erreur a eu lieu');</script>";68}69if (isset($_POST['new_pass'])) {70 $new_pass = md5($_POST['new_pass']);71}72else {73 $new_pass = "";74}75if (isset($_POST['cnew_pass'])) {76 $cnew_pass = md5($_POST['cnew_pass']);77}78else {79 $cnew_pass = "";80}81if (isset($_POST['change_forgot'])) {82 if ((str_contains($new_pass, "&") || str_contains($new_pass, "\"") || str_contains($new_pass, "'") || str_contains($new_pass, "(") || str_contains($new_pass, "-") || str_contains($new_pass, "_") || str_contains($new_pass, ")") || str_contains($new_pass, "=") || str_contains($new_pass, "$") || str_contains($new_pass, "*") || str_contains($new_pass, "ù") || str_contains($new_pass, "!") || str_contains($new_pass, ":") || str_contains($new_pass, ";") || str_contains($new_pass, ",") || str_contains($new_pass, "~") || str_contains($new_pass, "#") || str_contains($new_pass, "{") || str_contains($new_pass, "[") || str_contains($new_pass, "|") || str_contains($new_pass, "`") || str_contains($new_pass, "\\") || str_contains($new_pass, "^") || str_contains($new_pass, "@") || str_contains($new_pass, "]") || str_contains($new_pass, "}") || str_contains($new_pass, "°") || str_contains($new_pass, "+")|| str_contains($new_pass, "¨") || str_contains($new_pass, "£") || str_contains($new_pass, "¤") || str_contains($new_pass, "µ") || str_contains($new_pass, "%") || str_contains($new_pass, "§") || str_contains($new_pass, "/") || str_contains($new_pass, ".") || str_contains($new_pass, "?") || str_contains($new_pass, "<") || str_contains($new_pass, ">") || str_contains($new_pass, "²")) || (str_contains($cnew_pass, "&") || str_contains($cnew_pass, "\"") || str_contains($cnew_pass, "'") || str_contains($cnew_pass, "(") || str_contains($cnew_pass, "-") || str_contains($cnew_pass, "_") || str_contains($cnew_pass, ")") || str_contains($cnew_pass, "=") || str_contains($cnew_pass, "$") || str_contains($cnew_pass, "*") || str_contains($cnew_pass, "ù") || str_contains($cnew_pass, "!") || str_contains($cnew_pass, ":") || str_contains($cnew_pass, ";") || str_contains($cnew_pass, ",") || str_contains($cnew_pass, "~") || str_contains($cnew_pass, "#") || str_contains($cnew_pass, "{") || str_contains($cnew_pass, "[") || str_contains($cnew_pass, "|") || str_contains($cnew_pass, "`") || str_contains($cnew_pass, "\\") || str_contains($cnew_pass, "^") || str_contains($cnew_pass, "@") || str_contains($cnew_pass, "]") || str_contains($cnew_pass, "}") || str_contains($cnew_pass, "°") || str_contains($cnew_pass, "+")|| str_contains($cnew_pass, "¨") || str_contains($cnew_pass, "£") || str_contains($cnew_pass, "¤") || str_contains($cnew_pass, "µ") || str_contains($cnew_pass, "%") || str_contains($cnew_pass, "§") || str_contains($cnew_pass, "/") || str_contains($cnew_pass, ".") || str_contains($cnew_pass, "?") || str_contains($cnew_pass, "<") || str_contains($cnew_pass, ">") || str_contains($cnew_pass, "²"))) {83 echo "<script>alert('Des champs contiennent des caractères interdits. Pour rappel, on ne peut utiliser que des lettres, ou également des chiffres dans le cas du mail et du mot de passe.')</script>";84 }85 else if ($new_pass == "") {86 echo "<script>alert('Veuillez indiquer votre mot de passe')</script>";87 }88 else if ($new_pass != $cnew_pass) {89 echo "<script>alert('Les mots de passe ne correspondent pas')</script>";90 }91 else {92 $req = $conn->query("UPDATE `users` SET `password` = '$new_pass' WHERE `token` = '$token'");93 echo "<script>alert('Votre mot de passe a bien été changé');window.location.href = './';</script>";94 }95}96?>...
Contains
Using AI Code Generation
1use Mockery as m;2use PHPUnit\Framework\TestCase;3{4 public function tearDown()5 {6 m::close();7 }8 public function testContains()9 {10 $mock = m::mock('overload:Contains');11 $mock->shouldReceive('contains')->with(m::on(function ($arg) {12 return $arg == 'foo';13 }))->andReturn(true);14 $this->assertTrue($mock->contains('foo'));15 }16}17{18 public function contains($str)19 {20 return strpos($str, 'foo') !== false;21 }22}
Contains
Using AI Code Generation
1use Mockery as m;2use PHPUnit\Framework\TestCase;3{4 public function tearDown() : void5 {6 m::close();7 }8 public function testContains()9 {10 $mock = m::mock('overload:SomeClass');11 $mock->shouldReceive('someMethod')12 ->with(m::on(function($arg) {13 return $arg->contains('foo');14 }))15 ->once();16 $mock->someMethod('barfoo');17 }18}
Contains
Using AI Code Generation
1use Mockery as m;2{3 public function tearDown()4 {5 m::close();6 }7 public function testContains()8 {9 $mock = m::mock('ArrayObject');10 $mock->shouldReceive('offsetExists')->with(m::contains('foo'))->once()->andReturn(true);11 $this->assertTrue($mock->offsetExists('foobar'));12 }13}14use PHPUnit_Framework_Assert as PHPUnit;15{16 public function testContains()17 {18 $mock = $this->getMock('ArrayObject', array('offsetExists'));19 $mock->expects($this->once())20 ->method('offsetExists')21 ->with($this->logicalOr($this->equalTo('foo'), $this->equalTo('bar')));22 $this->assertTrue($mock->offsetExists('foobar'));23 }24}
Contains
Using AI Code Generation
1use Mockery as m;2{3 public function tearDown()4 {5 m::close();6 }7 public function testContains()8 {9 $mock = m::mock('ClassToMock');10 $mock->shouldReceive('foo')->with(m::contains('bar'))->once()->andReturn('foo');11 $this->assertEquals('foo', $mock->foo('bar'));12 }13}14{15 public function foo($bar)16 {17 return $bar;18 }19}
Contains
Using AI Code Generation
1use Mockery as m;2{3 public function tearDown()4 {5 m::close();6 }7 public function testContains()8 {9 $mock = m::mock('overload:Contains');10 $mock->shouldReceive('contains')11 ->with('foo', 'bar')12 ->andReturn(true);13 $this->assertTrue($mock->contains('foo', 'bar'));14 }15}16OK (1 test, 1 assertion)17In this article, we will learn how to use Mockery to mock a class. Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Mockery is a mocking framework for PHP which allows you to mock objects, stub methods and spy on method calls. Mockery is a library for mocking objects in PHP. It provides a simple API for creating mock objects, stubbing methods and verifying method calls. Mockery is a PHP library that provides a simple API for creating mock objects using a human-readable Domain Specific Language (DSL). Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Mockery is a mocking framework for PHP which allows you to mock objects, stub methods and spy on method calls. Mockery is a library for mocking objects in PHP. It provides a simple API for creating mock objects, stubbing methods and verifying method calls. Mockery is a PHP library that provides a simple API for creating mock objects using a human-readable Domain Specific Language (DSL). Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Mockery is a mocking framework for PHP which allows you to mock objects, stub methods and spy on method calls. Mockery is a library for mocking objects in PHP. It provides a simple API for creating mock objects, stubbing methods and verifying method calls. Mockery is a PHP library that
Contains
Using AI Code Generation
1$mock = Mockery::mock('Contains');2$mock->shouldReceive('contains')->with('foo', 'bar')->once()->andReturn(true);3$mock->shouldReceive('contains')->with('foo', 'baz')->once()->andReturn(false);4$mock->shouldReceive('contains')->with('foo', 'qux')->once()->andReturn(true);5$mock = Mockery::mock('Contains');6$mock->shouldReceive('contains')->with('foo', 'bar')->once()->andReturn(true);7$mock->shouldReceive('contains')->with('foo', 'baz')->once()->andReturn(false);8$mock->shouldReceive('contains')->with('foo', 'qux')->once()->andReturn(true);9$mock = Mockery::mock('Contains');10$mock->shouldReceive('contains')->with('foo', 'bar')->once()->andReturn(true);11$mock->shouldReceive('contains')->with('foo', 'baz')->once()->andReturn(false);12$mock->shouldReceive('contains')->with('foo', 'qux')->once()->andReturn(true);13I'm using Mockery with PHPUnit. I have a class, Contains , which contains a method, contains() . I have two tests, 1.php and 2.php , which use the Contains class. I want to mock the Contains class in both the tests. I tried doing this:But when I run the tests, the second test fails. I think the problem is that the mock is not reset between the two tests. How can I reset the mock between the two tests?
Contains
Using AI Code Generation
1$mockery = new Mockery();2$mockery->shouldReceive('contains')->andReturn(true);3$mockery->shouldReceive('contains')->andReturn(false);4$mockery = new Mockery();5$mockery->shouldReceive('contains')->andReturn(true);6$mockery->shouldReceive('contains')->andReturn(false);7{8 public function setUp()9 {10 $this->mockery = new Mockery();11 }12}13{14 public function setUp()15 {16 $this->mockery = new Mockery();17 }18 public function tearDown()19 {20 $this->mockery->verify();21 }22}
Contains
Using AI Code Generation
1use Mockery as m;2use PHPUnit\Framework\TestCase;3use PHPUnit_Framework_TestCase;4use Mockery as m;5use PHPUnit\Framework\TestCase;6use PHPUnit_Framework_TestCase;7use Mockery as m;8use PHPUnit\Framework\TestCase;9use PHPUnit_Framework_TestCase;10use Mockery as m;11use PHPUnit\Framework\TestCase;12use PHPUnit_Framework_TestCase;13use Mockery as m;14use PHPUnit\Framework\TestCase;15use PHPUnit_Framework_TestCase;16use Mockery as m;17use PHPUnit\Framework\TestCase;18use PHPUnit_Framework_TestCase;19use Mockery as m;20use PHPUnit\Framework\TestCase;21use PHPUnit_Framework_TestCase;22use Mockery as m;23use PHPUnit\Framework\TestCase;24use PHPUnit_Framework_TestCase;25use Mockery as m;26use PHPUnit\Framework\TestCase;27use PHPUnit_Framework_TestCase;28use Mockery as m;29use PHPUnit\Framework\TestCase;30use PHPUnit_Framework_TestCase;
Contains
Using AI Code Generation
1$mock = Mockery::mock('Contains');2$mock->shouldReceive('contains')->with('foo')->andReturn(true);3$mock->shouldReceive('contains')->with('bar')->andReturn(false);4$mock = Mockery::mock('Contains');5$mock->shouldReceive('contains')->with('foo')->andReturn(true);6$mock->shouldReceive('contains')->with('bar')->andReturn(false);7$mock = Mockery::mock('Contains');8$mock->shouldReceive('contains')->with('foo')->andReturn(true);9$mock->shouldReceive('contains')->with('bar')->andReturn(false);10$mock = Mockery::mock('Contains');11$mock->shouldReceive('contains')->with('foo')->andReturn(true);12$mock->shouldReceive('contains')->with('bar')->andReturn(false);13$mock = Mockery::mock('Contains');14$mock->shouldReceive('contains')->with('foo')->andReturn(true);15$mock->shouldReceive('contains')->with('bar')->andReturn(false);16$mock = Mockery::mock('Contains');17$mock->shouldReceive('contains')->with('foo')->andReturn(true);18$mock->shouldReceive('contains')->with('bar')->andReturn(false);19$mock = Mockery::mock('Contains');20$mock->shouldReceive('contains')->with('foo')->andReturn(true);21$mock->shouldReceive('contains')->with('bar')->andReturn(false);22$mock = Mockery::mock('Contains');23$mock->shouldReceive('contains')->with('foo')->andReturn(true);24$mock->shouldReceive('contains')->with('bar')->andReturn(false);25$mock = Mockery::mock('Contains');26$mock->shouldReceive('contains')->with('foo')->andReturn(true);27$mock->shouldReceive('contains')->with('bar')->andReturn(false);28$mock = Mockery::mock('Contains');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.
Test now for FreeGet 100 minutes of automation test minutes FREE!!