Skip to content

Sven-I-Am/challenge-php-guestbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Consolidation challenge - create a guestbook!

exercise in week 7 (01/11/2021 - 05/11/2021) of my BeCode training

Challenge

Using all we have learned so far in PHP we're going to create a classic 90's guestbook.
We're storing the messages on our local machine. And we're doing it all in 1 day!

The objective of this exercise

  • Consolidate what we've learned so far
  • Store data in files
  • Convert arrays/objects to string representation
  • Stick to a strict deadline!

Tools and languages used

Description
ubuntu Running Ubuntu 20.04
php-storm Working with PHPStorm as IDE
php Main language used is PHP
git Using git for version control
github Hosting my files on github

No code provided by BeCode

Timeline

  • Day 1 (:date:03/11/2021)
    • assignment was given at 9AM with short briefing and Q&A by coach Tim
    • created the challenge-php-guestbook repository on gitHub and git clone to local device
    • read through the readme to understand the mission objective
    • created this readme for an overview of the exercise and to keep track of progress
    • what got done so far:
      • created file structure ✔️
      • created .gitignore to ignore .idea folder ✔️
      • created index.php file ✔️
      • first commit and push of the project at 🕘 09:30AM ✔️
      • created form with title, message and name fields ✔️
      • create new Post with title, message, name, date and timestamp ✔️
      • seperated view from php ✔️
      • seperated header, footer and body ✔️
      • having trouble saving the messages to a file and then getting the file contents in a readable format
      • after Lunch, I asked for help from our coach Tim to understand the way json_encode structured the data in the messages.json file
      • I can now put and get data from message.json ✔️
      • I'm showing the messages with the latest message at the top ✔️
      • Finally, got the messages to show where I want them, had to move the require "body.html"; ✔️
      • had trouble showing the messages up to date after new post submission, something strange was happening when checking the 'isset($_POST)' it now works!!:heavy_check_mark:
      • added a layer of protection by putting all the user input through a protect() method which uses the htmlspecialchars() ✔️
      • I should now have the core functionalities in there ✔️
        • although there is still something strange with the first message to be posted after emptying out the json file.
      • 🎉 Done with the must-haves
      • 🕔 5PM end of the day, ran out of time for extras
  • Day 2 (:date:04/11/2021)
    • We got the happy news that our deadline was extended by a day!
    • Those of us that got the must-haves done yesterday are now helping our fellow learners in small teams of 4
    • In between helping I'm working on the nice to haves
      • Done today:
        • profanity filter should now work without case sensitivity ✔️
        • I had to combine the profanity filter and the defacement protection into one method and filter out profanities before filtering out bad intent code ✔️
          • the defacement check still shows the written code as is, just in case someone wants to share a code snippet this will still allow it without running the actual code
        • Now featuring smileys! ✔️
        • The user can now select the number of posts they want to have displayed ✔️
        • I also added error messages when either input field is left empty ✔️
    • 🎉 **done with the extras now! 🎉
    • final push of the project at 🕒 14:45

To Do

This to do list is for my personal use, the full to do list is added at the start of the challenge and as I complete objectives they will be moved up into the timeline section and ticked off using either emotes such as ✔️ or the checkbox syntax [ ] [x] provided by markdown.

must-haves ✔️

❗ Keep your view (html code) seperated from your PHP as much as possible ✔️

❗ Separate the footer and header HTML code and require() them in your template files to avoid code repetition ✔️

  1. Posts must contain at least a Title, Date, Content, Author name ✔️
  2. At least 2 classes: PostLoader & Post ✔️
  3. Sort messages from new to old (most recent on top) ✔️
  4. Handle possible site defacement attacks using htmlspecialchars() ✔️
  5. Only show the 20 latest posts ✔️

Nice to have

  1. Add a profanity filter (array with "bad" words) ✔️
  2. Replace typed smileys with their image counterpart ✔️
  3. Allow the user to pick how many messages he wants to see displayed ✔️