NoHomey / PFCCcalcolator

Course project for the Programming technologies practise course in ELSYS (TUES)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PFCCcalcolator

Course project for the Programming technologies practise course in ELSYS (TUES) - Technological shcool "Electronic systems".

This project has so many bugs that there is one even in it's name (C++ who's laughing now -> everyone laughs at PHP ofcourse ?). This project should stand as demonstration of worst JavaScript OOP (Object Oriented Programming) practices, as well this was the project with which I learned JavaScript and developed ilness for PHP :)

Ivo Stratev, Borislav Stratev.

Project is named PFCCcalcolator.

PFCCcalcalcolator stands for Protein, Fat & Carbs. Calorie calculator.

The Purpose of this project is to make calculations based on:

Protein, Fat & Carbs. Calories for multiple foods.

Project start date: 18.02.2015-10:36:01.

Project finish date: 20.05.2015-23:59:59.

Project is developed by Team Project.

The rights for the code in this repository and for final & staged product are held by:

Ivo Stratev:

The creator of the idea for this project and this repository.

Known Bugs:

The folder calcolations need to have permision for Create adn Delete Files else you can't save files in it!

How to setup locally:

If you have LAMP (Linux, Apache, MySQL and PhpMyAdmin) and seted Virtual Host on your machine go to How to run locally part :

Else :

Run the following set of commands in order to install LAMP (Linux, Apache, MySQL and PhpMyAdmin) on your machine :

Press Y everytime you are asked to install extra pakages*

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install apache2

sudo apt-get install mysql-server mysql-client

Eneter new password for MySQL

Repeat it

sudo apt-get install phpmyadmin

Press Enter when asked: Configure database for phpmyadmin with dbconfig-common?

Enter the same password you used for MySQL

Renter the same password

Reneter it one more time

Press Enter when asked: Configure database for phpmyadmin with dbconfig-common?

sudo apt-get install php5 libapache2-mod-php5

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

Run the following set of commands in order to Create new Virtual Host on your machine :

sudo mkdir -p /var/www/pfcccalcolator.com/public_htmл

sudo chown -R $USER:$USER /var/www/pfcccalcolator.com/public_html

sudo chmod -R 755 /var/www

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/server_name.conf

sudo nano /etc/apache2/sites-available/pfcccalcolator.com.conf

Write the following lines to the file:

ServerAdmin admin@pfcccalcolator.com

ServerName pfcccalcolator.com

ServerAlias www.pfcccalcolator.com

DocumentRoot /var/www/pfcccalcolator.com/public_html

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

Press Ctrl+o to acces saving

Press Enter to save it*

Press Ctrl+x to exit

Run the following set of commands in order to allow the Virtual Host on your machine :

sudo a2ensite pfcccalcolator.com.conf

sudo cp /etc/apache2/sites-available/pfcccalcolator.com.conf /etc/apache2/sites-available/000-default.conf

sudo nano /etc/hosts

Add the following line :

your_ip_adress pfcccalcolator.com

If you dont know your ip adress Run the following command :

ifconfig

If you are on ethernet conection look for :

eth0

inet addr:...**

Else look for :

wlan0

inet addr:...**

Everytime you eccounter your_ip_adress write those: ... !!!**

Press Ctrl+o to acces saving

Press Enter to save it*

Press Ctrl+x to exit

Run the following command in order to configure as global your Virtual Host on your Apache2 server :

sudo nano /etc/apache2/apache2.conf

Add following lines on top of the file :

ServerName pfcccalcolator.com

DocumentRoot "/var/www/pfcccalcolator.com/public_html"

Include /etc/phpmyadmin/apache.conf

Press Ctrl+o to acces saving

Press Enter to save it*

Press Ctrl+x to exit

Run the following set of commands in order to secure, configure, create new priveleged user & test if everything is OK with MySQL on your machine :

mysql -u root -p

Enter password

*From here enter the following lines in your mssql console :

CREATE USER 'user'@'pfcccalcolator.com' IDENTIFIED BY 'HERE ENTER THE PASSWORD YOU WANT TO BE USED FOR THAT USER!!!';

GRANT ALL PRIVILEGES ON . TO 'user'@'pfcccalcolator.com'

WITH GRANT OPTION;

CREATE USER 'user'@'%' IDENTIFIED BY 'HERE ENTER THE PASSWORD YOU WANT TO BE USED FOR THAT USER!!!';

GRANT ALL PRIVILEGES ON . TO 'user'@'%'

WITH GRANT OPTION;

The Console log should look like this :

mysql> CREATE USER 'user'@'pfcccalcolator.com' IDENTIFIED BY 'some_pass';

mysql> GRANT ALL PRIVILEGES ON . TO 'monty'@'pfcccalcolator.com'

  ->     WITH GRANT OPTION;

mysql> CREATE USER 'user'@'%' IDENTIFIED BY 'some_pass';

mysql> GRANT ALL PRIVILEGES ON . TO 'user'@'%'

  ->     WITH GRANT OPTION;

Press Ctrl+c to exit

sudo nano /etc/mysql/my.cnf

Change the line bind-adress = 127.0.0.1 :

Before: After:
bind-adress = 127.0.0.1 bind-adress = your_ip_adress

Press Ctrl+o to save it

Press Ctrl+x to exit

Run the following set of commands in order to secure & configure PhpMyAdmin on your machine :

sudo php5enmod mcrypt

sudo nano /etc/phpmyadmin/config.inc.php

Change the line $dbserver = 'localhost'; :

Before: After:
$dbserver = 'localhost'; $dbserver = 'pfcccalcolator.com';

Press Ctrl+o to save it

Press Ctrl+x to exit

sudo nano /etc/phpmyadmin/config-db.php

Change the line $dbuser = 'phpmyadmin'; or $dbuser = 'root'; :*

Before: After:
$dbuser = 'phpmyadmin'; or $dbuser = 'root' $dbuser = 'user';

Press Ctrl+o to save it

Press Ctrl+x to exit

Run the following set of commands to restart MySQL and Apach2 servers :

sudo service apache2 restart

sudo service mysql restart

mysql -u user -h 'pfcccalcolator.com' -p

Enter password

Pres Ctrl + c to exit*

I my self Ivo Stratev reinstalled and reconfigured all following previus steps twice and i had no problem under Ubuntu 14.04.02 LTS OS

If any error ocure during the installaion or setup please search them and try to fix them if you can!

How to run locally :

Navigate to /var/www/ppfcccalcolator.com/public_html folder

Copy all the files from the repository folder Project in /var/www/ppfcccalcolator.com/public_html folder

Open Borser and Type pfcccalcolator.com in adress field

Do the same with pfcccalcolator.com/phpmyadmin

Login with :

Username:

user

Password:

The password you set when you created the user 'user'

Click

Go

Both should work!

If they dont work search the errors you get!!!

Now import database using the phpmyadmin from browser by executing the file content loacated at path_to_repo/_instalation/, one by one: files to be executed are (01-create-database.sql, 02-create-and-fill-users-table.sql & o3-create-and-fill-files-table.sql)

Now return to pfcccalcolator.com and you are ready to go

How to reinstall locall setup of LAMP :

Run the following two commands :

sudo apt-get purge apache2 php5-cli apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libnet-daemon-perl libplrpc-perl libpq5 mysql-client mysql-common mysql-server php5-common php5-mysql phpmyadmin

sudo apt-get autoremove

And now follow the How to setup locally section

How to reconfig if the ip of he machine has been change :

** You need to change 3 files (/etc/hosts, project_foldere*/config/db.php* & /etc/mysql/my.cnf)

sudo nano /etc/hosts

Add the following line :

your_ip_adress pfcccalcolator.com

If you dont know your ip adress Run the following command :

ifconfig

If you are on ethernet conection look for :

eth0

inet addr:...**

Else look for :

wlan0

inet addr:...**

Everytime you eccounter your_ip_adress write those: ... !!!**

Press Ctrl+o to acces saving

Press Enter to save it*

Press Ctrl+x to exit

sudo nano path to /config/db.php

Change the line define("DB_HOST", "XXX.XXX.X.XXX"); to : define("DB_HOST", "your_ip_adress")

Press Ctrl+o to acces saving

Press Enter to save it*

Press Ctrl+x to exit

sudo nano /etc/mysql/my.cnf

*Change the line bind-adress = XXX.XXX.XX.XXX :

Before: After:
bind-adress = XXX.XXX.XX.XXX bind-adress = your_ip_adress

Press Ctrl+o to save it

Press Ctrl+x to exit

***Restart both apche2 and mysql: ***

sudo service apache2 restart
sudo service mysql restart

Login:

The login is a copy of https://github.com/panique/php-login-minimal distibuted under MIT LICENSE

About

Course project for the Programming technologies practise course in ELSYS (TUES)

License:GNU General Public License v3.0


Languages

Language:JavaScript 67.3%Language:PHP 22.5%Language:CSS 7.9%Language:Hack 2.4%