コード例 #1
0
ファイル: profile.php プロジェクト: vdabteam/whisky_scrum
     } else {
         $_SESSION['dialogBlock'] = "Only .png, .jpg, .jpeg and .gif files are allowed.";
     }
 }
 /**
  * Remove image path (images itself remain in userimages folder)  unlink('test.html');
  */
 if (isset($_POST['removeProfileImageBtn'])) {
     /**
      * if user removes his picture, a default.jpg will be added to his profile
      */
     $newImagePath = "default.jpg";
     /**
      * Change image name in DB
      */
     if (updateImagePathInDB($userId, $newImagePath, $profile)) {
         $toRemoveImage = "src/ProjectWhisky/presentation/userimages/" . $userData['image_path'];
         unlink($toRemoveImage);
         $_SESSION['dialogBlock'] = "Your profile image has been removed";
     } else {
         $_SESSION['dialogBlock'] = "Something went wrong";
     }
     header('Location: profile.php?updated=1');
 }
 /**
  * Perform password change only if user presses "Change password" button on profile page
  */
 if (isset($_POST['userOldPassword'])) {
     $oldPassword = $_POST['userOldPassword'];
     $newPassword = $_POST['userNewPassword'];
     $newPasswordRepeat = $_POST['userNewPasswordRepeat'];
コード例 #2
0
 //if error in inserting recipe into db
 if ($recipeId < 0) {
     exit("Sorry, could not access database when adding recipe. Please try again.");
 }
 $photoPath = NULL;
 //check if image uploaded
 if (checkImageUploaded()) {
     $photo = getImageTmpName();
     $photoPath = getImagePath($recipeId);
     if (!mkdir("images/" . $recipeId, 0777, true)) {
         exit('Could not upload image to server.');
     }
     if (!move_uploaded_file($photo, "images/" . $photoPath)) {
         exit('Could not create space on server for image.');
     }
     if (!updateImagePathInDB($conn, "images/" . $photoPath, $recipeId)) {
         exit('Could not connect image to account.');
     }
 }
 $numFriends = countFriends();
 $success = addFriendsToDB($conn, $numFriends, $recipeId);
 //if error in inserting friends into db
 if (!$success) {
     exit("Sorry, could not access database when adding friends. Please try again.");
 }
 if ($privacy == 'friendly') {
     $sql = "SELECT email\n                FROM Account\n                WHERE user_id = '{$userId}' ";
     $result = mysqli_query($conn, $sql);
     $row = mysqli_fetch_assoc($result);
     $emailAddr = $row["email"];
     $sql = "INSERT INTO Friends (email, type, type_id) \n                    VALUES ('{$emailAddr}', 'RECIPE','{$recipeId}');";