Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cours php & Mysql - 5éme partie

2,792 views

Published on

Cours php et Mysql

Published in: Software
  • Verifique a fonte ⇒ www.boaaluna.club ⇐. Este site me ajudou escrever uma monografia.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Cours php & Mysql - 5éme partie

  1. 1. Cours PHP/MySQL 5éme partie
  2. 2. Séance précédente • Projet: Listing des produits • Projet: Listing de produits par catégorie • Projet: Ajout de produits au panier • Projet: Retirer des produits depuis le panier • Les concepts fondamentaux de la programmation orientée objet • La programmation orientée objet en PHP • Les exceptions • Les fichiers • Projet: Utilisation des concepts orientés objet
  3. 3. Séance d'aujourd'hui • Projet: Passer la commande • Sécuriser une application PHP/MySQL • Projet: Sécuriser notre site e-commerce • Architecture MVC • Projet: Adoption de l'architecture MVC • Simulation d’entretien technique PHP / MySQL
  4. 4. Projet: Passer la commande 4
  5. 5. Sécuriser une application PHP/MySQL 5
  6. 6. Quoi sécuriser ? • Dans un code php il faut sécuriser les données entrantes et sortantes: • Données entrantes: Depuis un formulaire (injection SQL) • Données sortantes: Affichages depuis la base de données (injection HTML, XSS) 6
  7. 7. Injection SQL 7 <?php $requete = "SELECT * FROM user WHERE email = ' " . $_GET['email'] . " ' AND password = ' " . $_GET['password'] . " ' "; ?> <?php $_GET['password'] = " ' OR 1 = '1 "; ?> <?php $requete = "SELECT * FROM user WHERE email = ' " . $_GET['email'] . " ' AND password = ' ' OR 1 = '1' "; ?>
  8. 8. Injection SQL: suppression 8 <?php $requete = "DELETE FROM user WHERE id = ' " . $_GET['id'] . " ' "; ?> <?php $_GET['id'] = "1 ' OR id > '0 "; ?> <?php $requete = "DELETE FROM user WHERE id = '1' OR id > '0' "; ?>
  9. 9. Injection SQL: Utilisation des caractères % et _ 9 <?php $requete = "SELECT * FROM user WHERE email LIKE ' " . $_GET['email'] . " ' "; ?> <?php $_GET['email'] = "a%"; ?> <?php $requete = "SELECT * FROM user WHERE email LIKE 'a%' "; ?>
  10. 10. Injection SQL: Solution ! 10 Une fonction très pratique pour empêcher les injections SQL est mysql_real_escape_string() Cette fonction échappe les caractères suivants: les guillemets simples ' les guillemets doubles " les slashes / les caractères NULL En gros, elle neutralise tous les caractères susceptibles d'être à l'origine d'une injection SQL
  11. 11. Injection SQL: Solution ! 11 Exemple d’utilisation de la fonction mysql_real_escape_string() <?php $email = mysql_real_escape_string($_POST['email']); $requete = "SELECT * FROM user WHERE email = '$email' "; ?>
  12. 12. Injection SQL: Solution ! 12 Exemple d’utilisation de la fonction addcslashes() <?php $chaine = "%salut_"; // Échappement des caractères % et _ $chaine = addcslashes($chaine, '%_'); echo $chaine; // Affiche %salut_ ?>
  13. 13. Injection SQL: Solution finale! 13 <?php function secureInput($string) { // On regarde si le type de string est un nombre entier (int) if (ctype_digit($string)) { $string = intval($string); } else { $string = mysql_real_escape_string($string); $string = addcslashes($string, '%_'); } return $string; } ?>
  14. 14. Injections HTML ou XSS 14 <html> <head> <title>Injection HTML</title> </head> <body> <?php echo "Salut, tu t'appelles ".$_GET['pseudo']; ?> </body> </html> http://mon_url/index.php?pseudo=<i>zaki</i> http://mon_url/index.php?pseudo=<i>zaki</i> <script src="http://sitepirate.com/injection.js" >
  15. 15. Injections HTML ou XSS: Solution ! 15 <html> <head> <title>Injection HTML</title> </head> <body> <?php echo "Salut, tu t'appelles ".htmlentities($_GET['pseudo']); ?> </body> </html> http://mon_url/index.php?pseudo=<i>zaki</i> http://mon_url/index.php?pseudo=<i>zaki</i> <script src="http://sitepirate.com/injection.js" >
  16. 16. Projet: Sécuriser notre site e- commerce 16
  17. 17. Architecture MVC 17
  18. 18. MVC c’est quoi ? 18 Le pattern MVC signifie Modèle - Vue - Contrôleur, il permet de bien organiser le code source, son but est de séparer la logique du code en trois parties que l'on retrouve dans des fichiers distincts. Cette fonction échappe les caractères suivants: Modèle : cette partie gère les données de votre site, son rôle est d'aller récupérer les informations « brutes » dans la base de données, de les organiser et de les assembler pour qu'elles puissent ensuite être traitées par le contrôleur, on y trouve donc les requêtes SQL. Vue : cette partie se concentre sur l'affichage, elle ne fait presque aucun calcul et se contente de récupérer des variables pour savoir ce qu'elle doit afficher, on y trouve essentiellement du code HTML mais aussi quelques boucles et conditions PHP très simples. Contrôleur : cette partie gère la logique du code qui prend des décisions, c'est en quelque sorte l'intermédiaire entre le modèle et la vue : le contrôleur va demander au modèle les données, les analyser, prendre des décisions et renvoyer le texte à afficher à la vue, le contrôleur contient exclusivement du PHP.
  19. 19. MVC: principe de fonctionnement 19
  20. 20. Projet: Adoption de l'architecture MVC 20
  21. 21. Simulation d’entretien technique PHP / MySQL 21
  22. 22. Questions entretiens PHP / MySQL 22 Quelle fonction retourne le nombre de secondes écoulées depuis le 1er janvier 1970 ? 1. time 2. timestamp 3. mktime 4. microtime
  23. 23. Questions entretiens PHP / MySQL 23 Quelle fonction retourne le nombre de secondes écoulées depuis le 1er janvier 1970 ? 1. time 2. timestamp 3. mktime 4. microtime
  24. 24. Questions entretiens PHP / MySQL 24 Dans quel tableau de données retrouve-t-on les cookies du visiteur ? 1. $SETCOOKIE 2. $COOKIES 3. $_COOKIE
  25. 25. Questions entretiens PHP / MySQL 25 Dans quel tableau de données retrouve-t-on les cookies du visiteur ? 1. $SETCOOKIE 2. $COOKIES 3. $_COOKIE
  26. 26. Questions entretiens PHP / MySQL 26 Quelle fonction permet de lire le résultat d'une ressources MySQL renvoyée par mysql_query() ? 1. mysql_fetch_row() 2. mysql_data_seek() 3. mysql_affected_rows()
  27. 27. Questions entretiens PHP / MySQL 27 Quelle fonction permet de lire le résultat d'une ressources MySQL renvoyée par mysql_query() ? 1. mysql_fetch_row() 2. mysql_data_seek() 3. mysql_affected_rows()
  28. 28. Questions entretiens PHP / MySQL 28 Comment peut-on trier un tableau en ordre inverse ? 1. $tableau = ksort($tableau); 2. rsort($tableau);
  29. 29. Questions entretiens PHP / MySQL 29 Comment peut-on trier un tableau en ordre inverse ? 1. $tableau = ksort($tableau); 2. rsort($tableau);
  30. 30. Questions entretiens PHP / MySQL 30 Comment définit-on une constante ? 1. set('inconnue' = 'parfaite'); 2. define("inconnue","parfaite"); 3. const $inconnue = parfaite;
  31. 31. Questions entretiens PHP / MySQL 31 Comment définit-on une constante ? 1. set('inconnue' = 'parfaite'); 2. define("inconnue","parfaite"); 3. const $inconnue = parfaite;
  32. 32. Questions entretiens PHP / MySQL 32 On évalue le code suivant: $kiwi = 'vert'; $fruit = &$kiwi; $fruit = array(); $fruit['kiwi'] = $kiwi; Que contient $fruit ? 1. Rien 2. wiki 3. vert 4. La variable n'est pas définie.
  33. 33. Questions entretiens PHP / MySQL 33 On évalue le code suivant: $kiwi = 'vert'; $fruit = &$kiwi; $fruit = array(); $fruit['kiwi'] = $kiwi; Que contient $fruit ? 1. Rien 2. wiki 3. vert 4. La variable n'est pas définie.
  34. 34. Questions entretiens PHP / MySQL 34 Ma page index.php contient le code suivant: $a = 'a'.file_exists(__FILE__); $a1 = 'wiki'; $a2 = 'kiwi'; echo ${$a}; Qu'est-ce qui s'affiche si on y accède ? 1. Une page blanche. 2. kiwi. 3. wiki 4. Une erreur PHP. 5. Aucune des solutions précédentes
  35. 35. Questions entretiens PHP / MySQL 35 Ma page index.php contient le code suivant: $a = 'a'.file_exists(__FILE__); $a1 = 'wiki'; $a2 = 'kiwi'; echo ${$a}; Qu'est-ce qui s'affiche si on y accède ? 1. Une page blanche. 2. kiwi. 3. wiki 4. Une erreur PHP. 5. Aucune des solutions précédentes
  36. 36. Questions entretiens PHP / MySQL 36 Comment forcer l'arrêt d'un script ? Comment inclure un script à l'intérieur d'un autre ? Comment faire une redirection ? Comment conserver des variables de page en page ? Peut-on modifier une constante ? Comment déclarer une classe en PHP 5 ? Comment faire de l'héritage en PHP 5 ? Est-il possible de faire de l'héritage multiple en PHP ? Comment initialiser les arguments d'une fonction par défaut ? Le code PHP est-il visible pour tous ? Comment concaténer des chaînes des caractères ? Quelle est la différence entre l’envoi de données en POST et en GET ? Quelle est la différence entre include et require ?

×