diff --git a/backend/db(needs_setup).php b/backend/db(needs_setup).php index 46f15b8..a361ab5 100644 --- a/backend/db(needs_setup).php +++ b/backend/db(needs_setup).php @@ -1,5 +1,14 @@ + + + '; echo 'console.log('. json_encode( $data ) .')'; echo ''; - } +} -function console_log_messages( ...$messages ){ + // using this method to log larger arrays of data to the console while debugging +function console_log_messages( ...$messages ) { $msgs = ''; + foreach ($messages as $msg) { $msgs .= json_encode($msg); } diff --git a/backend/forgotBackend.php b/backend/forgotBackend.php index dfa8c78..75ebe96 100644 --- a/backend/forgotBackend.php +++ b/backend/forgotBackend.php @@ -1,25 +1,35 @@ -if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) -{ + + +escape_string($_POST['email']); $result = $mysqli->query("SELECT * FROM users WHERE email='$email'"); - if ( $result->num_rows == 0 ) // User doesn't exist - { + if ( $result->num_rows == 0 ) {// result has no rows, hence user doesn't exist $_SESSION['message'] = "Użytkownik z takim adresem nie istnieje!"; echo ""; - } - else { // User exists (num_rows != 0) - $user = $result->fetch_assoc(); // $user becomes array with user data + } else { // User exists (num_rows != 0) + $user = $result->fetch_assoc(); // $user - array containing all user data $email = $user['email']; $hash = $user['hash']; $first_name = $user['first_name']; - // Session message to display on success.php + + //message informing user to check their inbox $_SESSION['message'] = "

Proszę sprawdzić mail $email" . " gdzie został wysłany link do ukończenia zerowania hasła!

"; - // Send registration confirmation link (reset.php) $to = $email; $subject = 'Zerowanie hasła ( StockExperience )'; $message_body = ' @@ -27,6 +37,7 @@ Prosiłeś o możliwość wyzerowania hasła, oto twój link: http://stockexperiencepl.000webhostapp.com/reset.php?email='.$email.'&hash='.$hash; mail($to, $subject, $message_body); + echo ""; } } diff --git a/backend/login.php b/backend/login.php index 6662f14..ab6a7ff 100644 --- a/backend/login.php +++ b/backend/login.php @@ -1,13 +1,22 @@ + + escape_string($_POST['email']); $result = $mysqli->query("SELECT * FROM users WHERE email='$email'"); -if ( $result->num_rows == 0 ){ // User doesn't exist +if ( $result->num_rows == 0 ) { // result has no rows, hence user doesn't exist $_SESSION['message'] = "Użytkownik z takim adresem nie istnieje!"; echo ""; -} -else { // User exists +} else { // User exists $user = $result->fetch_assoc(); if ( password_verify($_POST['password'], $user['password']) ) { $_SESSION['email'] = $user['email']; @@ -16,11 +25,10 @@ $_SESSION['active'] = $user['active']; $_SESSION['money'] = $user['money']; $_SESSION['action_qty_dict'] = $user['action_qty_dict']; - // This is how we'll know the user is logged in + // flag to check if user is logged in, for later use $_SESSION['logged_in'] = true; echo ""; - } - else { + } else { // wrong password $_SESSION['message'] = "Błędne hasło!"; echo ""; } diff --git a/backend/profileBackend.php b/backend/profileBackend.php index 307afe5..6cffb37 100644 --- a/backend/profileBackend.php +++ b/backend/profileBackend.php @@ -1,15 +1,25 @@ + + +"; -} -else { +} else { //correct check, parse data $email = $mysqli->escape_string($_SESSION['email']); $result = $mysqli->query("SELECT * FROM users WHERE email='$email'"); $user = $result->fetch_assoc(); @@ -41,8 +51,7 @@ $Header = $DOM->getElementsByTagName('tr'); //#Get header name of the table - foreach($Header as $NodeHeader) - { + foreach($Header as $NodeHeader) { $aDataTableHeaderHTML[] = trim($NodeHeader->textContent); } @@ -63,35 +72,15 @@ $actions_dict = implode(",", $actions_ar); $sql = "UPDATE users SET money='$money', action_qty_dict='$actions_dict' WHERE email='$email'"; if ( $mysqli->query($sql) ) { - echo "
-
- x -

Pomyslnie zakupiono akcje

-
-
"; + createModal("Pomyślnie zakupiono akcje"); } else { - echo "
-
- x -

Problem z serwerem, transakcja odrzucona

-
-
"; + createModal("Problem z serwerem, transakcja odrzucona"); } } else { - echo "
-
- x -

Za mało środków na koncie, transakcja odrzucona

-
-
"; + createModal("Za mało środków na koncie, transakcja odrzucona"); } } else { - echo "
-
- x -

Brak wartosci podanej w okienku

-
-
"; + createModal("Brak wartości podanej w okienku"); } //sell index } elseif ( isset( $_GET[$index[0].'s'] ) ) { @@ -104,38 +93,29 @@ $actions_dict = implode(",", $actions_ar); $sql = "UPDATE users SET money='$money', action_qty_dict='$actions_dict' WHERE email='$email'"; if ( $mysqli->query($sql) ) { - echo "
-
- x -

Pomyslnie sprzedano akcje

-
-
"; + createModal("Pomyślnie sprzedano posiadane akcje"); } else { - echo "
-
- x -

Problem z serwerem, transakcja odrzucona

-
-
"; + createModal("Problem z serwerem, transakcja odrzucona"); } } else { - echo "
-
- x -

Za mało akcji, transakcja odrzucona

-
-
"; + createModal("Za mało posiadanych akcji, transakcja odrzucona"); } } else { - echo "
-
- x -

Brak wartosci podanej w okienku

-
-
"; + createModal("Brak wartości podanej w okienku"); } } + //recalculate wallet $totalMoneyInStocks += floatval($price)*floatval($index[1]); } } + +function createModal( $message ) { + echo ''; +} + ?> \ No newline at end of file diff --git a/backend/register.php b/backend/register.php index 9a08c83..c883577 100644 --- a/backend/register.php +++ b/backend/register.php @@ -1,3 +1,13 @@ + + num_rows > 0 ) { $_SESSION['message'] = 'Uzytkownik z takim mailem już istnieje!'; echo ""; -} -else { +} else { // active is 0 by DEFAULT //Small forloop to make mainteneance easier in case of changes in stock indexes - $indexes = ["KGH","PKO","PKN","PZU","JSW","CCC","DNP","CDR","LTS","ALR","TPE","PEO","SAN","PGN","GNB","ENG","PGE","ENA","EUR","KRU","PKP","LPP","PLY","MIL","CPS","OPL","MBK","EAT","BMC","VST","GTC","BFT","MRB","11B","MAB","EURPLN","CHFPLN","USDPLN","GBPPLN"]; + $indexes = ["KGH","PKO","PKN","PZU","JSW","CCC","DNP","CDR","LTS","ALR","TPE","PEO","SAN","PGN","GNB","ENG","PGE","ENA","EUR","KRU","PKP","LPP","PLY","MIL","CPS","OPL","MBK","EAT","BMC","VST","GTC","BFT","MRB","11B","MAB","EURPLN","CHFPLN","USDPLN","GBPPLN"]; //indexes we want to use from GPW $listIndexValue = ""; $lastElement = end($indexes); foreach ($indexes as &$index) { @@ -32,15 +41,15 @@ $listIndexValue .= "-0,"; } } + //sql query to add user to app $sql = "INSERT INTO users (first_name, last_name, email, password, hash, money, action_qty_dict) " . "VALUES ('$first_name','$last_name','$email','$password','$hash','100000','$listIndexValue')"; - // Add user to the database - if ( $mysqli->query($sql) ){ + if ( $mysqli->query($sql) ) { $_SESSION['active'] = 0; //0 until user activates their account with verify.php $_SESSION['logged_in'] = true; // So we know the user has logged in $_SESSION['message'] = "Link weryfikacyjny wysłany na: $email, prosimy o weryfikacje przez kliknięcie w link!"; - // Send registration confirmation link (verify.php) + // Send registration confirmation link (verify.php) via email $to = $email; $subject = 'Weryfikacja konta ( StockExperience )'; $message_body = ' @@ -50,7 +59,7 @@ https://stockexperiencepl.000webhostapp.com/backend/verify.php?email='.$email.'&hash='.$hash; mail( $to, $subject, $message_body ); echo ""; - } else { + } else { //if anything has gone wrongs $_SESSION['message'] = 'Błąd rejestracji!'; echo ""; } diff --git a/backend/resetBackend.php b/backend/resetBackend.php index 077548e..c11ff4f 100644 --- a/backend/resetBackend.php +++ b/backend/resetBackend.php @@ -1,15 +1,26 @@ + + + +escape_string($_GET['email']); $hash = $mysqli->escape_string($_GET['hash']); - // Make sure user email with matching hash exist + // Make sure user email with matching hash exist in db $result = $mysqli->query("SELECT * FROM users WHERE email='$email' AND hash='$hash'"); - if ( $result->num_rows == 0 ) - { + if ( $result->num_rows == 0 ) { $_SESSION['message'] = "Zły adres do wyzerowania hasła!"; echo ""; } diff --git a/backend/reset_password.php b/backend/reset_password.php index d09efb1..7a1b1af 100644 --- a/backend/reset_password.php +++ b/backend/reset_password.php @@ -1,7 +1,19 @@ + + + + document.location = '../success.php'; "; } - } - else { + } else { $_SESSION['message'] = "Hasła się nie zgadzają!"; echo ""; } diff --git a/backend/verify.php b/backend/verify.php index 45f1059..3dee660 100644 --- a/backend/verify.php +++ b/backend/verify.php @@ -1,31 +1,37 @@ - + + + +escape_string($_GET['email']); $hash = $mysqli->escape_string($_GET['hash']); // Select user with matching email and hash, who hasn't verified their account yet (active = 0) $result = $mysqli->query("SELECT * FROM users WHERE email='$email' AND hash='$hash' AND active='0'"); - if ( $result->num_rows == 0 ) - { + if ( $result->num_rows == 0 ) { $_SESSION['message'] = "Konto już zostało aktywowane lub błędny link"; echo ""; - } - else { + } else { $_SESSION['message'] = "Konto aktywne!"; // Set the user status to active (active = 1) $mysqli->query("UPDATE users SET active='1' WHERE email='$email'") or die($mysqli->error); $_SESSION['active'] = 1; echo ""; } -} -else { - $_SESSION['message'] = "Nieprawidłowe wartości podane dla weryfikacji konta!"; +} else { // if user entered wrong data + $_SESSION['message'] = "Nieprawidłowe informacje podane do utworzenia konta"; echo ""; } ?> \ No newline at end of file diff --git a/css/css.html b/css/css.html index 27931b9..26eb79b 100644 --- a/css/css.html +++ b/css/css.html @@ -1,4 +1,13 @@ - + + diff --git a/error.php b/error.php index b6fbc48..c57eb85 100644 --- a/error.php +++ b/error.php @@ -2,6 +2,16 @@ session_start(); ?> + + @@ -14,7 +24,6 @@

Błąd

+ + diff --git a/index.php b/index.php index cff0f47..833e040 100644 --- a/index.php +++ b/index.php @@ -3,6 +3,16 @@ session_start(); ?> + + @@ -11,13 +21,10 @@ + @@ -37,6 +47,7 @@

Changelog

+

2(GM) (06.03) - Testowanie, zmiany w layoucie kodu, drobne poprawki, dokumentacja

2(B6) (10.12) - Zmiany w stronie informacyjnej i logowania, poprawki w stylach, testy pre-release, SEO

2(B5) (07.12) - Performance: 53x mniejszy plik, 7,3x szybsze ładowanie, dodane narzędzia deweloperskie

2(B4) (04.12) - Poprawa logo, oddzielenie backendu od frontendu, podsumowanie poczynań, refaktoryzacja, Regulamin

diff --git a/js/index.js b/js/index.js index cc8b245..b13330a 100644 --- a/js/index.js +++ b/js/index.js @@ -1,3 +1,13 @@ +/* + index.js + StockExperience + + Edited by BinarySoftware on 07/03/2019. + Copyright ©2019 BinarySoftware/Maciej Mikołajek. All rights reserved. + + Purpose: Functions for performing animations on appropriate elements +*/ + $('.form').find('input, textarea').on('keyup blur focus', function (e) { var $this = $(this), label = $this.prev('label'); diff --git a/logout.php b/logout.php index 2bd9cfd..7d614a1 100644 --- a/logout.php +++ b/logout.php @@ -5,6 +5,16 @@ session_destroy(); ?> + + @@ -14,7 +24,7 @@
-

Dziękujemy za korzystanie

+

Dziękujemy za skorzystanie z aplikacji i zapraszamy ponownie

diff --git a/profile.php b/profile.php index 88d1086..ee3650a 100644 --- a/profile.php +++ b/profile.php @@ -2,6 +2,16 @@ require 'backend/profileBackend.php'; ?> + + @@ -28,13 +38,13 @@ @@ -54,6 +64,7 @@ $name = explode(PHP_EOL, $aDataTableHeaderHTML[$key])[0]; $price = explode(PHP_EOL, $aDataTableHeaderHTML[$key])[1]; $change = explode(PHP_EOL, $aDataTableHeaderHTML[$key])[2]; + $color = "red"; if ($change >= 0) { $color = "lightgreen"; @@ -69,6 +80,8 @@ $quantityAndMoneyInIndex = 'Masz: '.$quantityOFIndexes; } + // Frontend part - prepare and display data as it should be displayed + echo ' '.$name.''; if ($key == 0) { @@ -104,7 +117,7 @@
-

Podsumowanie twojej gry od początku

+

Podsumowanie postępów od początku gry

Na początku miałeś 100 000 zł

'; $totalMoney = (floor($money * 100) / 100) + (floor($totalMoneyInStocks * 100) / 100); @@ -113,29 +126,22 @@

Graj tak dalej!

'; } else { echo '

Dotychczas straciłeś '.(floor(($totalMoney-100000) * -100) / 100).', co przekłada się na spadek o '.((floor(($totalMoney-100000) * 100) / 100)/1000).'%

-

Zmień taktykę!

'; +

Zmień taktykę, badaj rynek

'; } ?>
-
StockExperience Ⓒ2018 BinarySoftware Wszelkie prawa zastrzeżone.
+
StockExperience Ⓒ2019 BinarySoftware Wszelkie prawa zastrzeżone.
\ No newline at end of file diff --git a/reset.php b/reset.php index e96b4d1..50f1e0b 100644 --- a/reset.php +++ b/reset.php @@ -2,6 +2,16 @@ require 'backend/resetBackend.php'; ?> + + @@ -14,18 +24,14 @@

Podaj nowe hasło

- +
- +
- + diff --git a/success.php b/success.php index cf00886..9337f86 100644 --- a/success.php +++ b/success.php @@ -1,8 +1,18 @@ + + diff --git a/terms.php b/terms.php index e2aa45e..1bac9b6 100644 --- a/terms.php +++ b/terms.php @@ -1,3 +1,13 @@ + +