-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.php
93 lines (84 loc) · 3.33 KB
/
action.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
<?php
if (isset($_POST['submit'])){
if (empty($_POST['wp_dir']) || empty($_POST['wp_db'])) {
?>
<div class="alert alert-danger" role="alert" id="dialog" >
<p >Form fields can't be empty!</p>
</div>
<?php
}else {
//Setting user input & sanitazing
$user_input = $_POST['wp_dir'];
$userWPdb_input = $_POST['wp_db'];
$userWPDir = sanitUserInput($user_input);
$userWPdb = sanitUserInput($userWPdb_input);
if ($conn->select_db($userWPdb) === false) {
//Creating directory
if (empty($errors) == true){
chdir ("../");
if (!file_exists($userWPDir) && !is_dir($userWPDir)){
mkdir($userWPDir);
if (file_exists($userWPDir) && is_dir($userWPDir)) {
?>
<div class="alert alert-success" role="alert">
Directory has been created. Now Setting up WordPress.
</div>
<?php
if (is_dir_empty($userWPDir) == TRUE) {
chdir ("./" . $userWPDir);
include('includes/inc_install.php');
//Setting rest of DB
// Create database
$sql = "CREATE DATABASE IF NOT EXISTS $userWPdb";
if ($conn->query($sql) === TRUE) {
echo "Your Word Press site and DB info below:";
?>
<div class="alert alert-success text-left" role="alert">
<?php
echo "<p>SQL DB name: " . "<strong>" . $userWPdb ."</strong>" . "</p>";
echo "<p>Site name: " . "<strong>" . $userWPDir . "</strong>". "</p>";
echo "URL: ";
echo "<a href=\"$srv$user$userWPDir\" target=\"_blank\" >$srv$userWPDir</a>";
?>
</div>
<?php
echo "<hr />";
} else {
?>
<div class="alert alert-danger" role="alert">
<?php echo "Error creating database: " . $conn->error; ?>
</div>
<?php
$errors[]=" ";
header("Refresh:5");
}
}
}else {
?>
<div class="alert alert-danger" role="alert">
<p>Something went wrong | could not create directory.</p>
</div>
<?php
$errors[]=" ";
}
}else {
?>
<div class="alert alert-danger" role="alert">
<strong><?php echo "\"$userWPDir\"";?> directory already exists! We can't overwrite it.</strong>
</div>
<?php
$errors[]=" ";
}
}
}else {
?>
<div class="alert alert-danger" role="alert">
<strong><?php echo "<p>Database \"$userWPdb\" already exist! </p>";?></strong>
</div>
<?php
$errors[]=" ";
}
}
$conn->close();
}
?>