forked from zeus911/SSLChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addserver.php
99 lines (79 loc) · 3.01 KB
/
addserver.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
<?php
session_start();
include_once("config.php");
$error = "";
if (!isset($_SESSION['admin']) && $_SESSION['admin'] != 1) {
header('Location: index.php');
return;
}
if(!isset($_SESSION['username'])) {
header("Location: login.php");
return;
}
if(isset($_POST['update'])) {
$name = $_POST["name"];
$port = $_POST["port"];
if ($port == "") {
$port = "443";
}
$sql = "INSERT INTO servers (name, port, authority,valid_from,valid_to,state) VALUES ('$name','$port','First update can take up to 24 hours.','0000-00-00','0000-00-00','4')";
$sql1 = "SELECT * FROM servers WHERE name='$name'";
$result = mysqli_query($db , $sql1);
if($result->num_rows > 0){
$error = "
<div class='alert alert-Danger alert-dismissible fade show' role='alert'>
<button type='button' class='close' data-dismiss='alert'><span>×</span></button>
<strong>Error!</strong><br> Domain already exists.
</div>
";
} else {
if($name == "") {
$error = "
<div class='alert alert-Danger alert-dismissible fade show' role='alert'>
<button type='button' class='close' data-dismiss='alert'><span>×</span></button>
<strong>Error!</strong><br> Please complete the fields.
</div>
";
} else {
if (! mysqli_query($db, $sql) ){
printf("Erreur : %s\n", mysqli_error($db) );
}
$error = "
<div class='alert alert-success alert-dismissible fade show' role='alert'>
<button type='button' class='close' data-dismiss='alert'><span>×</span></button>
<strong>Congratulations!</strong><br> You successfully submitted your request. We'll process it soon.
</div>
";
}
}
}
?>
<?php
include("header.php");
?>
<main class="main-container">
<div class="main-content">
<div class="row justify-content-md-center">
<div class="col-md-6 col-lg-4">
<form class="card" action='addserver.php' method='post' enctype='multipart/form-data'>
<div class="card">
<h4 class="card-title"><strong>Add Server</strong></h4>
<?php echo "$error"; ?>
<div class="card-body">
<div class="form-group">
<input class="form-control" type="text" name='name' placeholder="https://example.com">
</div>
<div class="form-group">
<input class="form-control" type="text" name='port' placeholder="Default is 443">
</div>
<button name="update" type="submit" value="Update" class="btn btn-block btn-bold btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</div>
</div>
<?php
include("footer.php");
?>
</html>