-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
226 lines (218 loc) · 11.1 KB
/
Copy pathinstall.php
File metadata and controls
226 lines (218 loc) · 11.1 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
220
221
222
223
224
225
226
<?php
/*
*Author: Pradeep Rajput
*Email: prithviraj.rudraksh@gmail.com
*Website: ----------
*File: Install
*/
// start session
if (session_id() == "") session_start();
$isSecure = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$isSecure = true;
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
$isSecure = true;
}
$path = str_replace('/install.php', '', $_SERVER['PHP_SELF']);
if(isset($_POST['install'])){
$secure='';
if(!empty($_POST['issecure']) && $_POST['issecure']=='true')
$secure='';
else
$secure='#';
$htaccess = sprintf(file_get_contents('./install/htaccess.tmp'),$secure,$_POST['webroot']);
$cFile = fopen('./.htaccess', 'w');
fwrite($cFile, $htaccess);
fclose($cFile);
$htaccess = sprintf(file_get_contents('./install/htaccessapi.tmp'),$secure,$_POST['webroot'].'/api');
$cFile = fopen('./api/.htaccess', 'w');
fwrite($cFile, $htaccess);
fclose($cFile);
$config = sprintf(file_get_contents('./install/config.tmp'),$_POST['db_host'],$_POST['db_port'],$_POST['db_user'],$_POST['db_pass'],$_POST['db_base'],$_POST['db_prefix']);
$cFile = fopen('./config.php', 'w');
fwrite($cFile, $config);
fclose($cFile);
$_SESSION['install'] = $_POST;
header('location:./install/');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="Phindart: A PHP Framework!">
<meta name="keywords" content="Phindart, Phindart PHP Framework,Phindart Framework">
<title>Phindart</title>
<!-- Materialize -->
<link href="./themes/materialize/css/materialize.min.css" rel="stylesheet" />
<link href="./themes/materialize/css/phindart.css" rel="stylesheet" />
<link href="./plugs/material-icons/material-icons.css" rel="stylesheet" />
<script src="./plugs/jquery-3.2.1.min.js"></script>
<script src="./themes/materialize/js/materialize.min.js"></script>
<style>
.row{
margin-bottom: 0px;
}
</style>
<script>
$(document).ready(function(){
$('#db_base').focusout(function(){
$.ajax({
url: './install/dbcheck.php',
method: 'post',
data:{host:$('#db_host').val(),user:$('#db_user').val(),pass:$('#db_pass').val(),port:$('#db_port').val(),db:$('#db_base').val()},
success: function(data){
$('#note').html(data);
}
});
});
$('#issecure').change(function(){
if(this.checked)
$('#base').val("https://<?=$_SERVER['HTTP_HOST'].$path ?>/");
else
$('#base').val("http://<?=$_SERVER['HTTP_HOST'].$path ?>/");
});
});
</script>
</head>
<body>
<div class="valign-wrapper" style="height: 100%">
<form method="post">
<div class="row">
<div class="col s12 m4">
<div class="card">
<div class="card-content">
<h5 class="center-align">Prerequisites</h5>
<p>If any one of these items not supported(Marked as <b>No</b>) then please take action to correct them.</p>
<ul class="collection">
<li class="collection-item"><div>PHP Version >= 7.0<span class="secondary-content"><?=phpversion()>=7.0?'Yes':'No'?></span></div></li>
<li class="collection-item"><div>Database support(PDO, PDO_MySql)<span class="secondary-content"><?=(extension_loaded('pdo') && extension_loaded('pdo_mysql'))?'Yes':'No'?></span></div></li>
<li class="collection-item"><div>XML support<span class="secondary-content"><?=extension_loaded('xml')?'Yes':'No'?></span></div></li>
<li class="collection-item"><div>JSON support<span class="secondary-content"><?=extension_loaded('json')?'Yes':'No'?></span></div></li>
<li class="collection-item"><div>URL Rewrite support<span class="secondary-content"><?=in_array('mod_rewrite', apache_get_modules())?'Yes':'No'?></span></div></li>
<li class="collection-item"><div>Configuration PHP writeable<span class="secondary-content"><?=is_writable ( './' )?'Yes':'No'?></span></div></li>
</ul>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card">
<div class="card-content">
<h5 class="center-align">Database Configuration</h5>
<div class="row">
<div class="input-field col m6">
<input id="db_host" type="text" name="db_host" value="localhost" required>
<label for="db_host">DB Host</label>
</div>
<div class="input-field col m6">
<input id="db_port" type="text" name="db_port" value="3306" required>
<label for="db_port">DB Port</label>
</div>
</div>
<div class="row">
<div class="input-field col m6">
<input id="db_user" type="text" name="db_user" value="root" required>
<label for="db_user">DB User</label>
</div>
<div class="input-field col m6">
<input id="db_pass" type="password" name="db_pass">
<label for="db_pass">DB Password</label>
</div>
</div>
<div class="row">
<div class="input-field col m12">
<input id="db_base" type="text" name="db_base" required>
<label for="db_base">DB Name</label>
<p class="red-text" id="note"></p>
</div>
</div>
<div class="row">
<div class="input-field col m12">
<input id="db_prefix" type="text" name="db_prefix">
<label for="db_prefix">DB Prefix</label>
</div>
</div>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card">
<div class="card-content">
<h5 class="center-align">Other Configuration</h5>
<div class="row">
<div class="input-field col m6">
<input id="webroot" type="text" name="webroot" value="<?=$path?>" required>
<label for="timezone">Website Root</label>
</div>
<div class="input-field col m6">
<input id="issecure" type="checkbox" name="issecure" value="true" <?=$isSecure ? 'checked' : ''?>/>
<label for="issecure">Is Secure?</label>
</div>
</div>
<div class="row">
<div class="input-field col m6">
<input id="timezone" type="text" name="timezone" value="Asia/Kolkata" required>
<label for="timezone">Timezone</label>
</div>
<div class="input-field col m6">
<input id="logo" type="text" name="logo" value="Phindart" required>
<label for="logo">Brand Name</label>
</div>
</div>
<div class="row">
<div class="input-field col m6">
<input id="title" type="text" name="title" value="Phindart" required>
<label for="title">Title</label>
</div>
<div class="input-field col m6">
<input id="description" type="text" name="description" value="Phindart: A PHP Framework!" required>
<label for="description">Description</label>
</div>
</div>
<div class="row">
<div class="input-field col m6">
<input id="keys" type="text" name="keys" value="Phindart, Phindart PHP Framework,Phindart Framework" required>
<label for="keys">Keys</label>
</div>
<div class="input-field col m6">
<input id="copyright" type="text" name="copyright" value="2017-2018 © All rights reserved." required>
<label for="copyright">Copyright</label>
</div>
</div>
<div class="row">
<div class="input-field col m12">
<input id="base" type="text" name="base" value="<?=$isSecure ? 'https' : 'http'?>://<?=$_SERVER['HTTP_HOST'].$path ?>/" required>
<label for="base">Websit URL</label>
</div>
</div>
<div class="row">
<div class="input-field col m6">
<input id="username" type="text" name="username" value="admin" required>
<label for="username">Username</label>
</div>
<div class="input-field col m6">
<input id="password" type="password" name="password" required>
<label for="password">Password</label>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="input-field col s12 center-align">
<button class="btn waves-effect waves-light airtel-red round-btn" name="install" type="submit">Submit
</button>
<button class="modal-action modal-close waves-effect waves-green btn round-btn airtel-red" type="reset">Close
</button>
</div>
</div>
</form>
</div>
</body>
</html>