Skip to content

This is the website of the KGB which lists the secret missions. The administrators can create update and delete the missions.

Notifications You must be signed in to change notification settings

Melissa-code/kgb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

137 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPY

SPY is a school project.

This is the website of a spy agency. It allows data management.

The front office is accessible to any user. It contains the list of the missions in alphabetical order. A pagination offers an easy navigation without refresh the page. A search bar is useful to search a mission by its first letters inside the title or the description. When the user clicks on the title of a mission, he is redirected on the page which displays the details of the mission.

The back office is accessible to the administrators of the website only. It allows to manage the database. The administrators have to log in via a secure form (front and back). They can log out. This back office allows to create, read, update and delete data using secure forms. The URLs are protected too because they are accessible to administrators only and the id of each data is encrypted.

How to use ?

See the website : Spy

Table of contents

  1. How to use ?
  2. Prerequisites
  3. Installation
  4. Run
  5. Log in as an administrator
  6. Built with
  7. Deploying
  8. Author
  9. License

Prerequisites

  • MySQL version 5.7

  • PHP version 7.4

  • MAMP (Macintosh, Apache, MySQL et PHP)

Installation

  1. Create a folder cours in the htdocs of MAMP.

  2. Download the zip or clone the project in local :

git clone https://github.com/Melissa-code/kgb.git

  1. Move into the directory :

cd /path/to/the/file/kgb

  1. Open the project with a code editor, for instance Visual Studio Code.

  2. Start MAMP, click on WebStart then Tools and go to phpMyAdmin.

  3. Create the database project_kgb by a SQL query in the tab SQL :

CREATE DATABASE project_kgb;

USE project_kgb;

  1. Add a new user for the database :

In phpMyAdmin, click on the tab User Account. Fill in the Username and the Password fields. Then, check the global privileges (here are all privileges) and link the user to the database.

  1. Connect the project to the database. Go to the file : models/Class/Model.php and change the values of the variables $username and $password.

  2. Create all the tables and insert data using the queries of the sql_queries file of the project.

  3. You can import the database project_kgb.sql in the tab Import of phpMyAdmin too. Upload the file.

Run

  1. Start MAMP if it's not already started.

  2. Open your browser and navigate to http://localhost:8888/cours/kgb/

Log in as an administrator

  1. In the login function of the AdminController, write : echo password_hash("passwordToHash", PASSWORD_DEFAULT);

  2. Copy (Ctrl + C) the encrypted password displayed on the login page and remove it.

  3. Edit the password saved in the database for an Administrator (id_admin = 1) with a SQL query : UPDATE Admins SET password_admin = 'hashedPassword' WHERE id_admin = 1;

It is possible to change the email too : UPDATE Admins SET email_admin = 'example@gmail.com' WHERE id_admin = 1;

  1. Or create a new user : INSERT INTO Admins (name_admin, firstname_admin, email_admin, password_admin, secret_admin) VALUES ('NameExample', 'FirstnameExample','email@example.com', hashedPassword, SHA1('password'));

Built with

Languages and Frameworks

Tools

IDE

Deploying

The production deployment of Spy is hosted on Heroku Heroku.

Prerequisite

  1. Install Git and Initialize a Git repository

  2. Create a Heroku account

  3. Install the Heroku CLI, for instance for MacOS use : $ brew tap heroku/brew && brew install heroku

(cf. Heroku Documentation Heroku Documentation).

Verify the installation using : heroku --version

Get started

  1. Log in to Heroku with the command :

heroku login

  1. Create a new app :

heroku create spyagentssecrets

  1. Remote the local project to the Heroku app :

git add .

git commit -m "Deploying the project."

git push heroku main

(cf. Deploying a PHP App on Heroku Heroku Documentation).

Create a database

  1. Create a new MySQL database with the Addon JawsDb :

heroku addons:create jawsdb:kitefin

(cf. Install JawsDB MySql JawsDB MySQL).

  1. Get the JAWSDB_URL :

heroku config:get JAWSDB_URL

  1. On the dashboard of Heroku's app, click on the JawsDB link to get the credentials of the database.

  2. Import the local database to the new database. Enter the credentials of JawsDB's database (replace hostname, username and password) :

mysql -h hostname -u username -ppassword database < quai_antique.sql

If necessary, check the file models/Class/Model.php :

(cf. Using JawsDb with PHP Using JawsDb with PHP).

  1. Deploy again :

git add .

git commit -m "Create the database"

git push heroku main

  1. Use DBeaver Community to work with the database and enter SQL queries to change the emails and the passwords of the admins table Log in as an Administrator.

Author

Melissa-code

License

MIT

About

This is the website of the KGB which lists the secret missions. The administrators can create update and delete the missions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published