Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/netKnow/DatabaseConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
public class DatabaseConnection {
private final static String DBURL = "jdbc:mysql://sql.slowiak.nazwa.pl:3306/slowiak";
private final static String DBURL2 = "jdbc:mysql://127.0.0.1:3306/slowiak?serverTimezone=UTC";
private final static String DBUSER = "slowiak";
private final static String DBUSER2 = "root";
private final static String DBUSER = "slowiak";
private final static String DBUSER2 = "root";
private final static String DBPASS = "ZaQ1XsW2";
private static Connection connection = null;

public static Connection getConenction(){
try {
//connection = DriverManager.getConnection(DBURL, DBUSER, DBPASS);
connection = DriverManager.getConnection(DBURL2, DBUSER2, DBPASS);
connection = DriverManager.getConnection(DBURL, DBUSER, DBPASS);
//connection = DriverManager.getConnection(DBURL2, DBUSER2, DBPASS);
if(connection != null){
System.out.println("Connected to the datebase :D");
return connection;
Expand Down
14 changes: 12 additions & 2 deletions src/netKnow/controller/CalculatorIPController.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package netKnow.controller;

import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import netKnow.Class.IP;
import netKnow.scene.MainOptionsScene;

public class CalculatorIPController {

Expand All @@ -32,9 +34,11 @@ public class CalculatorIPController {
private TextArea minHostField;
@FXML
private TextArea maxHostField;
@FXML
private Button goBackButton;


IP myIP;
private Scene scene;
private IP myIP;

@FXML
void initialize(){
Expand All @@ -55,6 +59,12 @@ void initialize(){
countButton.fire();
}
});
goBackButton.setOnAction(e -> {
new MainOptionsScene(scene);
});
}

public void setScene(Scene scene){
this.scene = scene;
}
}
2 changes: 1 addition & 1 deletion src/netKnow/controller/HeaderController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private void setDates(){
String query = "SELECT login, registrationDate, lastVisitDate FROM Users" + " WHERE login='"+login+"'";
ResultSet rs = statement.executeQuery(query);
rs.next();
userLoginLabel.setText(login);
userLoginLabel.setText(login + "!");
registrationDateLabel.setText(rs.getString("registrationDate"));
lastVisitDateLabel.setText(rs.getString("lastVisitDate"));
rs.close();
Expand Down
11 changes: 2 additions & 9 deletions src/netKnow/controller/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ void initialize(){
}
});

registerButton.setOnAction(e ->{
new RegistrationScene(scene);
});
registerButton.setOnAction(e -> new RegistrationScene(scene));

passwordField.setOnKeyPressed(e -> {
if(e.getCode() == KeyCode.ENTER){
Expand All @@ -86,7 +84,6 @@ private int loginUser(String login, String password){
while(rs.next()){
dbLogin = rs.getString("login");
dbPassword = rs.getString("password");
System.out.println("xd: " + dbLogin + " " + dbPassword);
}
}
rs.close();
Expand All @@ -97,7 +94,6 @@ private int loginUser(String login, String password){
}

if(login == null || login.isEmpty()){
System.out.println("puste");
return 4;
}else{
if(login.equals(dbLogin)){
Expand Down Expand Up @@ -128,10 +124,7 @@ private boolean validateLicenseKey(String userLogin){
DatabaseConnection.closeConnection();
}

if(dbKey){
return true;
}
return false;
return dbKey;
}

private void activateLicense(String userLogin){
Expand Down
21 changes: 4 additions & 17 deletions src/netKnow/controller/RegistrationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ public class RegistrationController {

@FXML
void initialize(){
goBackButton.setOnAction(e ->{
new LoginScene(scene);
});
goBackButton.setOnAction(e -> new LoginScene(scene));

registerButton.setOnAction(e ->{

Expand All @@ -79,9 +77,7 @@ void initialize(){
if(!checkIfLoginExists()){
if(!checkIfEmailExists()){
if(checkIfPasswordMatch()){
System.out.println("Przed kodowaniem: " + password);
encryptedPassword = PasswordEncrypter.encryptPassword(password);
System.out.println("Po zakodowaniu: " + encryptedPassword);
registerUser(login, encryptedPassword, firstName, lastName, email);
MailSender mailSender = new MailSender(email, getMessageContent());
try {
Expand Down Expand Up @@ -115,7 +111,6 @@ private static void registerUser(String login, String password, String firstName
String date = dtf.format(now);

String query = "INSERT INTO `Users` (login, password, registrationDate, lastVisitDate, firstname, lastname, email, licenseKey) VALUES ('"+login+"', '"+password+"', '"+date+"', '"+date+"', '"+firstName+"', '"+lastName+"', '"+email+"', '"+licenseKey+"');";
System.out.println(query);
statement.executeUpdate(query);
} catch (SQLException e) {
e.printStackTrace();
Expand Down Expand Up @@ -149,7 +144,7 @@ private String getMessageContent(){
return "Witaj " + firstName + " " + lastName + "!\n\n" +
"Dziękujemy za założenie konta.\nCieszymy się, że chcesz używać naszej aplikacji!\n\n" +
"Oto Twoje dane podane podczas rejestracji: \n\n"+
"\nLoginScene: " + login +
"\nLogin: " + login +
"\nHasło: " + password +
"\nAdres email: " + email;
}
Expand All @@ -170,11 +165,7 @@ private boolean checkIfLoginExists(){
e1.printStackTrace();
}

if(login.equals(dbLogin)){
return true;
}else{
return false;
}
return login.equals(dbLogin);
}

private boolean checkIfEmailExists(){
Expand All @@ -192,11 +183,7 @@ private boolean checkIfEmailExists(){
e1.printStackTrace();
}

if(email.equals(dbEmail)){
return true;
}else{
return false;
}
return email.equals(dbEmail);
}

private boolean checkIfPasswordMatch(){
Expand Down
30 changes: 25 additions & 5 deletions src/netKnow/fxml/calculator_ip.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
<children>
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
<children>
<Label text="Kalkulator IP">
<VBox.margin>
<Insets bottom="20.0" top="20.0" />
</VBox.margin>
<font>
<Font name="System Bold" size="24.0" />
</font>
</Label>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children>
<Label prefHeight="45.0" prefWidth="26.0" text="IP: ">
Expand Down Expand Up @@ -68,18 +76,21 @@
<Insets />
</opaqueInsets></Button>
</children>
<VBox.margin>
<Insets />
</VBox.margin>
</HBox>
<GridPane alignment="CENTER" hgap="10.0" prefHeight="259.0" prefWidth="580.0" vgap="10.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="150.0" minWidth="10.0" prefWidth="150.0" />
<ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" maxWidth="200.0" minWidth="10.0" prefWidth="200.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="150.0" minHeight="7.5" prefHeight="50.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="0.0" prefHeight="50.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="10.0" prefHeight="50.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="10.0" prefHeight="50.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="10.0" prefHeight="50.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="150.0" minHeight="7.5" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="0.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="200.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="33.0" prefWidth="127.0" text="adres sieci">
Expand Down Expand Up @@ -121,6 +132,15 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</VBox.margin>
</GridPane>
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
<children>
<Button fx:id="goBackButton" mnemonicParsing="false" prefHeight="39.0" prefWidth="107.0" text="Wstecz">
<HBox.margin>
<Insets bottom="30.0" left="50.0" right="50.0" />
</HBox.margin>
</Button>
</children>
</HBox>
</children>
</VBox>
</children>
Expand Down
7 changes: 5 additions & 2 deletions src/netKnow/fxml/login_scene.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Login:" />
<Label text="Password: " GridPane.rowIndex="1" />
<TextField fx:id="loginField" promptText="login" GridPane.columnIndex="1" />
<PasswordField fx:id="passwordField" promptText="password" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Button fx:id="loginButton" mnemonicParsing="false" text="Zaloguj się" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
</children>
<VBox.margin>
<Insets left="150.0" right="150.0" />
</VBox.margin>
</GridPane>
<Button fx:id="loginButton" mnemonicParsing="false" prefHeight="25.0" prefWidth="210.0" text="Zaloguj się">
<VBox.margin>
<Insets top="20.0" />
</VBox.margin>
</Button>
<Label fx:id="logErrorLabel" textFill="#fc0000">
<VBox.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/netKnow/fxml/user_header.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Label>
<Label fx:id="userLoginLabel">
<font>
<Font size="36.0" />
<Font name="System Bold" size="36.0" />
</font>
</Label>
</children>
Expand All @@ -29,7 +29,7 @@
<children>
<Label text="Jesteś z nami od: ">
<font>
<Font size="14.0" />
<Font name="System Bold" size="14.0" />
</font>
</Label>
<Label fx:id="registrationDateLabel">
Expand All @@ -46,7 +46,7 @@
<children>
<Label text="Ostatnie logowanie:">
<font>
<Font size="14.0" />
<Font name="System Bold" size="14.0" />
</font>
</Label>
<Label fx:id="lastVisitDateLabel">
Expand Down
2 changes: 1 addition & 1 deletion src/netKnow/scene/IPCalculatorScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private void setScene(){
}

private void setController(){
//System.out.println("setController");
calculatorIPController = loader.getController();
calculatorIPController.setScene(scene);
}
}
65 changes: 0 additions & 65 deletions src/netKnow/scene/LoggedInScene.java

This file was deleted.