Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.47 KB | None | 0 0
  1. <?php
  2.  
  3.   require_once 'src/auth/function.php';
  4.   access_page();
  5.   require_once 'src/auth/bdd.php';
  6.  
  7.   if(isset($_FILES['banner']) AND !empty($_FILES['banner']['name'])) {
  8.     $tailleMax = 2097152;
  9.     $extensionsValides = array('jpg', 'jpeg', 'png');
  10.     if($_FILES['banner']['size'] <= $tailleMax) {
  11.         $extensionUpload = strtolower(substr(strrchr($_FILES['banner']['name'], '.'), 1));
  12.         if(in_array($extensionUpload, $extensionsValides)) {
  13.           $chemin = "src/assets/members/banner/".$_SESSION['id'].".".$extensionUpload;
  14.           $resultat = move_uploaded_file($_FILES['banner']['tmp_name'], $chemin);
  15.           if($resultat) {
  16.               $updatebanner = $pdo->prepare('UPDATE users SET banner = :banner WHERE id = :id');
  17.               $updatebanner->execute(array(
  18.                 'banner' => $_SESSION['id'].".".$extensionUpload,
  19.                 'id' => $_SESSION['id']
  20.                 ));
  21.               header('Location: account.php');
  22.           } else {
  23.               $msg = "Erreur durant l'importation de votre photo de profil";
  24.           }
  25.         } else {
  26.           $msg = "Votre photo de profil doit être au format jpg, jpeg, gif ou png";
  27.         }
  28.     } else {
  29.         $msg = "Votre photo de profil ne doit pas dépasser 2Mo";
  30.     }
  31.   }
  32.  
  33. ?>
  34.  
  35. <!DOCTYPE>
  36. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  37.     <head>
  38.         <title>FlightTips - Account</title>
  39.         <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet"/>
  40.     <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  41.         <!-- Css -->
  42.         <link rel="stylesheet" href="src/app.css?refresh=0"/>
  43.     </head>
  44.     </head>
  45.     <body>
  46.  
  47.     <?php require 'src/header/header.php'; ?>
  48.  
  49.     <?php if(isset($msg)) {echo $msg;} ?>
  50.  
  51.     <section class="account_container">
  52.       <div class="account_banner"></div>
  53.       <div class="l-container">
  54.         <div class="account_img"></div> <!-- PHP remplacer -->
  55.         <h1 class="account_user"><?= $_SESSION['auth']->fullname; ?></h1> <!-- PHP remplacer -->
  56.         <button id="edit_button" class="account_img_upload"></button>
  57.         <div id="upload_modal" class="upload_modal">
  58.           <span class="upload_close"></span>
  59.           <div class="upload_modal_content">
  60.             <h1>Simply drop your file here jpg, png.</h1>
  61.             <h3>Recommend size 1920×630</h3>
  62.             <form method="POST" action="" enctype="multipart/form-data">
  63.               <input type="file" name="banner"></input>
  64.               <button type="submit">Upload</button>
  65.             </form>
  66.           </div>
  67.         </div>
  68.         <div class="account_alert"> <!-- PHP remplacer -->
  69.           <?php if(isset($_SESSION['account_alert'])): ?>
  70.             <?php foreach($_SESSION['account_alert'] as $type => $message): ?>
  71.               <div class="account_alert_img_<?= $type; ?>"></div>
  72.               <div class="account_alert_<?= $type; ?>">
  73.                 <?= $message; ?>
  74.               </div>
  75.             <?php endforeach; ?>
  76.             <?php unset($_SESSION['account_alert']); ?>
  77.           <?php endif; ?>
  78.         </div>
  79.       </div>
  80.     </section>
  81.  
  82.         <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
  83.         <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  84.         <script src="src/js/auth.js"></script>
  85.     <script src="src/js/header.js"></script>
  86.     <script src="src/js/upload_account.js"></script>
  87.  
  88.     </body>
  89. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement