forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
349 lines (333 loc) · 20.3 KB
/
index.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<?php
require_once '../objects/functions.php';
require_once '../locale/function.php';
//var_dump($_SERVER);exit;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Install AVideo</title>
<script src="../node_modules/jquery/dist/jquery.min.js" type="text/javascript"></script>
<link rel="icon" href="../view/img/favicon.png">
<link href="../view/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="../view/bootstrap/bootstrapSelectPicker/css/bootstrap-select.min.css" rel="stylesheet" type="text/css"/>
<link href="../node_modules/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"/>
<link href="../view/css/flagstrap/css/flags.css" rel="stylesheet" type="text/css"/>
<style>
.bootstrap-select{
width: 100% !important;
}
</style>
</head>
<body>
<?php
if (file_exists('../videos/configuration.php')) {
require_once '../videos/configuration.php'; ?>
<div class="container">
<h3 class="alert alert-success">
<span class="glyphicon glyphicon-ok-circle"></span>
Your system is installed, remove the <code><?php echo $global['systemRootPath']; ?>install</code> directory to continue
<hr>
<a href="<?php echo getHomePageURL(); ?>" class="btn btn-success btn-lg center-block">Go to the main page</a>
</h3>
</div>
<?php
} else {
?>
<div class="container">
<img src="../view/img/logo.png" alt="Logo" class="img img-responsive center-block"/>
<div class="row">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading"><i class="fas fa-tasks"></i> Check list</div>
<div class="panel-body">
<?php
if (isApache()) {
?>
<div class="alert alert-success">
<span class="glyphicon glyphicon-check"></span>
<strong><?php echo $_SERVER['SERVER_SOFTWARE']; ?> is Present</strong>
</div>
<?php
} else {
?>
<div class="alert alert-danger">
<span class="glyphicon glyphicon-unchecked"></span>
<strong>Your server is <?php echo $_SERVER['SERVER_SOFTWARE']; ?>, you must install Apache</strong>
</div>
<?php
} ?>
<?php
if (isPHP('7.3')) {
?>
<div class="alert alert-success">
<span class="glyphicon glyphicon-check"></span>
<strong>PHP <?php echo PHP_VERSION; ?> is present.</strong>
</div>
<?php
} else {
?>
<div class="alert alert-warning">
<span class="glyphicon glyphicon-exclamation-sign"></span>
<strong>Your PHP version is <?php echo PHP_VERSION; ?>. PHP 7.3 or newer is required.</strong>
</div>
<?php
} ?>
<?php
if (checkVideosDir()) {
?>
<div class="alert alert-success">
<span class="glyphicon glyphicon-check"></span>
<strong>Your videos directory is writable</strong>
</div>
<?php
} else {
?>
<div class="alert alert-danger">
<span class="glyphicon glyphicon-unchecked"></span>
<strong>Your videos directory must be writable</strong>
<details>
<?php
$dir = getPathToApplication() . "videos";
if (!file_exists($dir)) {
?>
The video directory does not exists, AVideo had no permition to create it, you must create it manualy!
<br>
<pre><code>sudo mkdir <?php echo $dir; ?></code></pre>
<?php
} ?>
<br>
Then you can set the permissions (www-data means apache user).
<br>
<pre><code>sudo chown www-data:www-data <?php echo $dir; ?> && sudo chmod 777 <?php echo $dir; ?> </code></pre>
</details>
</div>
<?php
}
$pathToPHPini = php_ini_loaded_file();
if (empty($pathToPHPini)) {
$pathToPHPini = "/etc/php/7.0/cli/php.ini";
} ?>
<?php
if (check_post_max_size()) {
?>
<div class="alert alert-success">
<span class="glyphicon glyphicon-check"></span>
<strong>Your post_max_size is <?php echo ini_get('post_max_size'); ?></strong>
</div>
<?php
} else {
?>
<div class="alert alert-danger">
<span class="glyphicon glyphicon-unchecked"></span>
<strong>Your post_max_size is <?php echo ini_get('post_max_size'); ?>, it must be at least 100M</strong>
<details>
Edit the <code>php.ini</code> file
<br>
<pre><code>sudo nano <?php echo $pathToPHPini; ?></code></pre>
</details>
</div>
<?php
} ?>
<?php
if (check_upload_max_filesize()) {
?>
<div class="alert alert-success">
<span class="glyphicon glyphicon-check"></span>
<strong>Your upload_max_filesize is <?php echo ini_get('upload_max_filesize'); ?></strong>
</div>
<?php
} else {
?>
<div class="alert alert-danger">
<span class="glyphicon glyphicon-unchecked"></span>
<strong>Your upload_max_filesize is <?php echo ini_get('upload_max_filesize'); ?>, it must be at least 100M</strong>
<details>
Edit the <code>php.ini</code> file
<br>
<pre><code>sudo nano <?php echo $pathToPHPini; ?></code></pre>
</details>
</div>
<?php
} ?>
</div>
</div>
</div>
<form id="configurationForm">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading"><i class="fas fa-play-circle"></i> Site Configuration</div>
<div class="panel-body">
<div class="form-group">
<label for="webSiteRootURL">Your Site URL</label>
<input type="text" class="form-control" id="webSiteRootURL" placeholder="Enter your URL (http://yoursite.com)" value="<?php echo getURLToApplication(); ?>" required="required">
</div>
<div class="form-group">
<label for="systemRootPath">System Path to Application</label>
<input type="text" class="form-control" id="systemRootPath" placeholder="System Path to Application (/var/www/[application_path])" value="<?php echo getPathToApplication(); ?>" required="required">
</div>
<div class="row">
<div class="form-group col-md-8">
<label for="webSiteTitle">Title of your Web Site</label>
<input type="text" class="form-control" id="webSiteTitle" placeholder="Enter the title of your Web Site" value="AVideo" required="required">
</div>
<div class="form-group col-md-4">
<label for="mainLanguage">Language</label><br>
<select class="selectpicker" id="mainLanguage">
<?php
global $global;
include_once '../objects/bcp47.php';
$dir = "../locale/";
$flags = [];
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..' && $entry != 'index.php' && $entry != 'function.php' && $entry != 'save.php') {
$flags[] = str_replace('.php', '', $entry);
}
}
closedir($handle);
}
sort($flags);
foreach ($flags as $flag) {
//var_dump($global['bcp47'][$flag]);
$fileEx = $global['bcp47'][$flag]['flag'];
echo "<option data-content='<span class=\"flagstrap-icon flagstrap-$fileEx\"></span> {$global['bcp47'][$flag]['label']}' value=\"$fileEx\" " . (('us' == $fileEx) ? " selected" : "") . ">{$global['bcp47'][$flag]['label']}</option>";
} ?>
</select>
</div>
</div>
<div class="form-group">
<label for="contactEmail">Contact E-mail</label>
<input type="email" class="form-control" id="contactEmail" placeholder="Enter e-mail contact of your Web Site" required="required">
</div>
<div class="form-group">
<label for="systemAdminPass">System Admin password</label>
<?php
getInputPassword("systemAdminPass", 'class="form-control" required="required"', __("Enter System Admin password")); ?>
</div>
<div class="form-group">
<label for="confirmSystemAdminPass">Confirm System Admin password</label>
<?php
getInputPassword("confirmSystemAdminPass", 'class="form-control" required="required"', __("Confirm System Admin password")); ?>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading"><i class="fas fa-database"></i> Database</div>
<div class="panel-body">
<div class="form-group">
<label for="databaseHost">Database Host</label>
<input type="text" class="form-control" id="databaseHost" placeholder="Enter Database Host" value="localhost" required="required">
</div>
<div class="form-group">
<label for="databasePort">Database Port</label>
<input type="text" class="form-control" id="databasePort" placeholder="Enter Database Port" value="3306" required="required">
</div>
<div class="form-group">
<label for="databaseUser">Database User</label>
<input type="text" class="form-control" id="databaseUser" placeholder="Enter Database User" value="root" required="required">
</div>
<div class="form-group">
<label for="databasePass">Database Password</label>
<?php
getInputPassword("databasePass", 'class="form-control"', __("Enter Database Password")); ?>
</div>
<div class="form-group">
<label for="databaseName">Database Name</label>
<input type="text" class="form-control" id="databaseName" placeholder="Enter Database Name" value="avideo" required="required">
</div>
<div class="form-group">
<label for="createTables">Do you want to create database and tables?</label><br>
<select class="selectpicker" id="createTables">
<option value="2">Create database and tables</option>
<option value="1">Create only tables (Do not create database)</option>
<option value="0">Do not create any, I will import the script manually</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<button type="submit" class="btn btn-primary btn-block"><i class="fas fa-cogs"></i> Install now</button>
</div>
</form>
</div>
</div>
<?php
} ?>
<script src="../view/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="../view/bootstrap/bootstrapSelectPicker/js/bootstrap-select.min.js" type="text/javascript"></script>
<script src="../node_modules/sweetalert/dist/sweetalert.min.js" type="text/javascript"></script>
<script src="../node_modules/jquery-lazy/jquery.lazy.min.js" type="text/javascript"></script>
<script src="../node_modules/jquery-lazy/jquery.lazy.plugins.min.js" type="text/javascript"></script>
<script src="../node_modules/js-cookie/dist/js.cookie.js" type="text/javascript"></script>
<script src="../view/js/script.js" type="text/javascript"></script>
<script>
$(function () {
$('.selectpicker').selectpicker();
$('#configurationForm').submit(function (evt) {
evt.preventDefault();
var systemAdminPass = $('#systemAdminPass').val();
var confirmSystemAdminPass = $('#confirmSystemAdminPass').val();
if (!systemAdminPass) {
avideoAlert("Sorry!", "Your System Admin Password can not be blank!", "error");
return false;
}
if (systemAdminPass != confirmSystemAdminPass) {
avideoAlert("Sorry!", "Your System Admin Password must be confirmed!", "error");
return false;
}
modal.showPleaseWait();
var webSiteRootURL = $('#webSiteRootURL').val();
var systemRootPath = $('#systemRootPath').val();
var webSiteTitle = $('#webSiteTitle').val();
var databaseHost = $('#databaseHost').val();
var databasePort = $('#databasePort').val();
var databaseUser = $('#databaseUser').val();
var databasePass = $('#databasePass').val();
var databaseName = $('#databaseName').val();
var mainLanguage = $('#mainLanguage').val();
var contactEmail = $('#contactEmail').val();
var createTables = $('#createTables').val();
$.ajax({
url: webSiteRootURL + 'install/checkConfiguration.php',
data: {
webSiteRootURL: webSiteRootURL,
systemRootPath: systemRootPath,
webSiteTitle: webSiteTitle,
databaseHost: databaseHost,
databasePort: databasePort,
databaseUser: databaseUser,
databasePass: databasePass,
databaseName: databaseName,
mainLanguage: mainLanguage,
systemAdminPass: systemAdminPass,
contactEmail: contactEmail,
createTables: createTables
},
type: 'post',
success: function (response) {
modal.hidePleaseWait();
if (response.error) {
avideoAlert("Sorry!", response.error, "error");
} else {
avideoAlert("Congratulations!", response.error, "success");
window.location.reload(false);
}
},
error: function (xhr, ajaxOptions, thrownError) {
modal.hidePleaseWait();
if (xhr.status == 404) {
avideoAlert("Sorry!", "Your Site URL is wrong!", "error");
} else {
avideoAlert("Sorry!", "Unknown error!", "error");
}
}
});
});
});
</script>
</body>
</html>