-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
110 lines (85 loc) · 3.38 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
require_once("Config/ftpConnect.php");
session_start();
//When a user loads this page, they will automatically first logged out by them selves for browser
if(isset($_SESSION['ftp_User']) && isset($_SESSION['login_details'])){
unset($_SESSION['login_details']);
unset($_SESSION['ftp_User']);
unset($_SESSION['data']);
}
include("Classes/classes.php");
$error = "-";
if(isset($_POST['username']) && isset($_POST['password'])){
$ftpUser = new ftpUser($_POST['username']);
$ftpUser->login($ftp_conn, $_POST['username'], $_POST['password']);
if($ftpUser->checkLogin()){
//code if the login is successfull
echo "successfull login";
$_SESSION['ftp_User'] = $ftpUser;
$_SESSION['login_details'] = $_POST['username'];
$_SESSION['directory'] = "/";
$_SESSION['data'] = base64_encode($_POST['username']."#".$_POST['password']);
}
else{
//code if the login is fail
$error = "Incorrect password or username";
}
if(isset($_SESSION['ftp_User']) && isset($_SESSION['login_details'])){
header("Location:fileManager.php");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>FTP-Browser | Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link href="https://fonts.googleapis.com/css2?family=Balsamiq+Sans:wght@700&display=swap" rel="stylesheet"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="CSS/kel.css">
<style>
.loader{
border: 5px solid #f3f3f3;
border-radius: 50%;
border-top: 5px solid #3498db;
width: 30px;
height: 30px;
-webkit-animation: spin 1s linear infinite; /* Safari */
animation: spin 1s linear infinite;
}
</style>
</head>
<body>
<div id="load" class="w3-modal">
<span class="w3-modal-content">
<center><div class="loader" id="loader"></div></center>
</span>
</div>
<div class="w3-padding w3-black w3-center">FTP-Browser created in XAMPP server by the contributers of <a href="https://github.com/Kelta-King/FTP-browser">FTP-Browser</a></div>
<div class="w3-light-gray w3-container w3-center w3-padding-32" style="z-index:2;">
<div class="w3-padding-16">
<div class="w3-margin-bottom w3-text-red" >
<!-- <center><div class="loader" id="loader" style="display:none;"></div></center> -->
<div id="error"><?php echo $error ?></div>
</div>
<div class="w3-xxlarge w3-bold w3-margin-top"><b>FTP-Browser</b></div>
<form class="w3-container w3-center w3-margin" id="login">
<div class="w3-section">
<input type="text" class="w3-padding w3-round w3-border w3-hover-border-black" name="username" placeholder="Username" style="margin:0;width:20%;" <?php if(isset($_GET['u_name'])){echo "value=".$_GET['u_name'];} ?> required><br>
</div>
<div class="w3-section">
<input type="password" class="w3-padding w3-round w3-border w3-hover-border-black" name="password" placeholder="Password" style="margin:0;width:20%;" required><br>
</div>
<div class="w3-section">
<button type="button" class="w3-black w3-round w3-padding w3-border-0 w3-black" onclick="login()" style="margin:0;width:20%;cursor:pointer">Log In</button>
</div>
</form>
</div>
</div>
<script src="JS/login.js"></script>
</body>
</html>
<?php
require_once("Config/ftpClose.php");
?>