-
Notifications
You must be signed in to change notification settings - Fork 8
/
install.php
209 lines (169 loc) · 5.78 KB
/
install.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
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
<?php
session_start();
ob_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width">
<title>Faucet Installer</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link href="//cdn.epay.info/css/flipclock.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="templates/style/css/style.css">
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
</head>
<body>
<div class="container" style="padding-top:50px;">
<?php if(!isset($_GET['step'])){ ?>
<div class="panel panel-primary">
<div class="panel-heading">Faucet Installer</div>
<div class="panel-body">
Hi<br>
Thank you for using this installer to begin a your new faucet with <a href="http://epay.info" target="_blank">ePay.info</a> <br>
We aim to improve the quality of this script over time, so remember to check the repository <a href="https://github.com/epayinfo/simple_faucet" target="_blank">here</a> on regular basis to get the last updates.<br>
Begin installing by clicking on the next step.
</div>
<div class="panel-footer">
<a href="?step=2" class="btn btn-success pull-right">Next</a>
<div class="clearfix"></div>
</div>
</div>
<?php }elseif($_GET['step']==2){
chmod( 'templates_c', 0777 );
chmod( 'ads/', 0777 );
chmod( 'configs/dbinfo.php', 0666 );
chmod( 'configs/prizes.php', 0666 );
chmod( 'configs/configs.php', 0666 );
if(isset($_POST['dbname'])){
class SystemComponent{
private $settings;
function getSetting(){
$settings['dbhost']=$_POST['dbhost'];
$settings['dbusername']=$_POST['uname'];
$settings['dbpassword']=$_POST['pwd'];
$settings['dbname']=$_POST['dbname'];
return $settings;
}
}
require_once "includes/dbconnector.class.php";
$db=new DbConnector;
if($db->check_connection()){
$dbhost=$_POST['dbhost'];
$dbusername=$_POST['uname'];
$dbpassword=$_POST['pwd'];
$dbname=$_POST['dbname'];
function generateRandomString($length = 25) {
$characters = 'abcdefghijklmnopqrstuvwxyz123456789';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$_SESSION['info']['admin']=generateRandomString();
$adminpass=hash('SHA256',$_SESSION['info']['admin']);
$content = <<<END
<?php
class SystemComponent{
private \$settings;
function getSetting(){
\$settings['dbhost']='$dbhost';
\$settings['dbusername']='$dbusername';
\$settings['dbpassword']='$dbpassword';
\$settings['dbname']='$dbname';
\$settings['adminpass']='$adminpass';
return \$settings;
}
}
END;
$fp = fopen('configs/dbinfo.php',"w");
fwrite($fp,$content);
fclose($fp);
$sql=fopen('install.sql','r');
$schema=fread($sql,filesize("install.sql"));
$queries = explode( ';', $schema );
$queries = array_filter( $queries );
array_pop($queries);
foreach($queries as $q)
$db->query($q);
fclose($sql);
header('Location: install.php?step=3');
die();
}else{
$_SESSION['error']['db']=true;
header('Location: install.php?step=2');
die();
}
}else{
?>
<div class="panel panel-primary">
<div class="panel-heading">Faucet Installer - Database</div>
<form action="" method="post">
<div class="panel-body">
Below you should enter your database connection details. If you’re not sure about these, contact your host.
<?php if(isset($_SESSION['error']['db'])){ ?>
<div class="alert alert-danger">
Unable to connect to database.
</div>
<?php unset($_SESSION['error']); } ?>
<div class="form-group">
<label for="dbname">Database Name</label>
<input class="form-control" name="dbname" type="text" size="25" value="myfaucet" />
<small>The name of the database you want to run your faucet in.</small>
</div>
<div class="form-group">
<label for="uname">Database Username</label>
<input class="form-control" name="uname" type="text" size="25" placeholder="username" />
<small>Your MySQL username.</small>
</div>
<div class="form-group">
<label for="pwd">Database Password</label>
<input class="form-control" name="pwd" type="text" size="25" placeholder="password" />
<small>Your MySQL password.</small>
</div>
<div class="form-group">
<label for="dbhost">Database Host</label>
<input class="form-control" name="dbhost" type="text" size="25" value="localhost" />
<small>You should be able to get this info from your web host, if <code>localhost</code> does not work.</small>
</div>
</div>
<div class="panel-footer">
<button type="submit" class="btn btn-success pull-right">Next</button>
<div class="clearfix"></div>
</div>
</form>
</div>
<?php
}
}elseif($_GET['step']==3){
@unlink('install.php');
@unlink('install.sql');
?>
<div class="panel panel-primary">
<div class="panel-heading">Faucet Installer - Finish</div>
<div class="panel-body">
Your installation has just been completed.
<br>
<center>
This is your administartion passphare:<br><br>
<strong><code style="font-size:24px"><?php echo $_SESSION['info']['admin'];?></code></strong>
<br><br>
<div class="col-md-4 col-md-push-4">
<a href="adm" class="btn btn-success btn-block">Go to Administartion</a>
</div>
</center>
<br>
<div class="clearfix"></div>
<strong>Make sure install.php and install.sql are deleted from you host.<br>
Admin passpharse will not be shown again even if you refresh this page. Save it somewhere safe.</strong>
</div>
</div>
<?php session_destroy(); } ?>
</div>
</body>
</html>