-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit-database.php
More file actions
219 lines (183 loc) · 5.76 KB
/
Copy pathcommit-database.php
File metadata and controls
219 lines (183 loc) · 5.76 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
$action="action=create-database-wxz12079wZKJH457HQQU56789IUHHB67890RGHHXCEXCTC";
# this file is responsible for creating a database if does not exist
$uri=$_SERVER['REQUEST_URI'];
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
/* background-color: black; */
background-color:#3333;
}
* {
box-sizing: border-box;
}
/* Add padding to containers */
.container {
padding: 16px;
background-color: white;
width:600px;
margin:0px auto;
box-shadow:0px 0px 10px black;
}
/* Full-width input fields */
input[type=text], input[type=password],select {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
border: none;
background: #f1f1f1;
}
input[type=text]:focus, input[type=password]:focus {
background-color: #ddd;
outline: none;
}
select:focus, input[type=password]:focus {
background-color: white;
outline: none;
}
/* Overwrite default styles of hr */
hr {
border: 1px solid #f1f1f1;
margin-bottom: 25px;
}
/* Set a style for the submit button */
.registerbtn {
background-color: #4CAF50;
color: white;
padding: 16px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
}
.registerbtn:hover {
opacity: 1;
}
/* Add a blue text color to links */
a {
color: blue;
}
label{
display:block;
}
/* Set a grey background color and center the text of the "sign in" section */
.signin {
background-color: #f1f1f1;
text-align: center;
}
</style>
</head>
<body>
<?php
$host_info=explode(":",$_SERVER['HTTP_HOST']);
$hostname=$host_info[0];
$portno=$host_info[1];
?>
<?php
$dbx=[];
$a=isset($_GET['attempt'])?$_GET['attempt']:0;
if(isset($_POST['dbsubmit'])){
unset($_POST['dbsubmit']);
foreach($_POST as $key => $value):
if($value=="__BLANK__"){
$dbx[]="";
}
else{
$dbx[]=$value;
}
echo "<br/>";
endforeach;
$dbhost=$dbx[0];
$dbuser=$dbx[1];
$dbpass=$dbx[2];
$dbname=$dbx[3];
$dbport=$dbx[4];
@$conn=mysqli_connect($dbhost,$dbuser,$dbpass);
if($conn){
$sql="CREATE DATABASE IF NOT EXISTS $dbname";
if(!mysqli_query($conn,$sql)){
die();
exit;
}
#########################################################################
######################| code for dbconnection file |##############
$code="";
$code.="<?php";
$code.="\n";
$code.="#Host name for the Connecting with the mysqlserver";
$code.='$db["driver_name"]="MYSQL"';
$code.="\n";
$code.='$db["sqli"]="true"; #use of sqli instead of sql is recommended';
$code.="\n";
$code.='$db["host"]="'.$dbhost.'"; #use of host-name';
$code.="\n";
$code.='$db["user"]="'.$dbuser.'"; #userName for Connection with Database Engine';
$code.="\n";
$code.='$db["pass"]="'.$dbpass.'"; #password for the Connection with the Database';
$code.="\n";
$code.='$db["db"]="'.$dbname.'"; #db name is Important if database is not avaliable the we need to create Database;';
$code.="\n";
$code.="\n";
$code.="\n";
$code.="\n";
$code.="\n";
$code.="?>";
#########################################################################
######################| End of code for dbconnection file |##############
$fptr=fopen("module/db_init/__init__.php","w");
fwrite($fptr,$code);
fclose($fptr);
echo "<script>alert('database Created successfully');window.location.href='home'</script>";
}
else{
$msg="";
$status=1;
}
}
?>
<form action="<?php echo $action."?attempt=$a";?>" method="post">
<div class="container">
<?php
if($a>=3){
die("<h3>Your maximum attempts expired!!</h3>
<hr/><samp style='font-size:16px;'>For further assitance contact awnishkumar at <b>+91-8299502081</b> or mail at <b>awnishmmg.a41@gmail.com</b></samp>");
}
if(isset($status)){
die("<span style='color:red;'><b>Invalid Hostname or credentials</span><a href='".$action."?attempt=".($a+1)."'> try Again ? </a></b>");
}
?>
<h1><samp>Set Up Database Configuration</samp></h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="email"><b>Hostname *</b></label> <samp style="color:red;">Donot change if root is default username </samp>
<input type="text" placeholder="Database Hostname" name="hostname" value="<?php echo $hostname; ?>" required/>
<label for="email"><b>TargetDb username *</b></label> <samp style="color:red;">Donot change if root is default username </samp>
<input type="text" placeholder="Database username" name="username" value="root" required>
<label for="psw"><b>Password</b></label>
<samp style="color:red;">Donot change if root is default __Blank__ for empty Password </samp>
<input type="text" placeholder="Database Password" name="password" value="__BLANK__" required>
<label for="psw-repeat"><b>Database name</b></label>
<input type="text" placeholder="Database name" name="dbname" required>
<label><b>Port No</b> [default] </label>
<select name="mysql_port">
<option value="">choose</option>
<option value="3306" selected>default 3306/3307 Driver mysql</option>
<option value="3308">default 3306 Driver posgrel</option>
<option value="1322">default 3306 Driver mariadb</option>
<option value="1380">default 3306 Driver Oracle</option>
<option value="144277">default 3306 Driver mongodb</option>
</select>
<hr>
<p><b><samp>click below to finally set connection with your target machine(Server)</samp></b></p>
<button type="submit" class="registerbtn" name="dbsubmit">SET UP Connection >></button>
</div>
</form>
</body>
</html>