/
install.php
executable file
·174 lines (149 loc) · 4.36 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
<!DOCTYPE html>
<html>
<head>
<title>Installer</title>
<link rel="stylesheet" href="/application/assets/css/style.css" />
<style type="text/css">
body{
background:#292932;
}
.install_success_message{
display:none;
width:100%;
text-align:center;
}
.install_message{
display:none;
text-align:center;
}
#system_requirements{
font-weight:bold;
text-align:center;
padding:20px;
background: #22222c;
}
.success{
color:#98CB00;
}
.failed{
color:#DB3400;
}
h4{
text-align:center;
}
a{
width:300px;
margin:0px auto;
background:#98cb00;
padding:20px 0px;
border-radius:30px;
display:block;
color:#fff;
text-decoration:none;
font-size:18px;
display:block;
text-align:center;
border-bottom:2px solid #78ab00;
}
a:hover{
color:#fff;
}
</style>
</head>
<body>
<img src="/application/assets/img/logo.png" height="32" style="margin:20px auto; height:32px; width:auto; display:block" />
<h4>Hello Video Installation</h4>
<div id="system_requirements">
<?php
require __DIR__.'/application/bootstrap/autoload.php';
run_checks();
import_db();
function new_line(){
echo '<br />';
}
function run_checks(){
if(version_compare(PHP_VERSION , "5.4", ">=")){
echo '<span class="success">PHP 5.4 or greater installed (<i class="fa fa-check-square-o"></i> PASS)</span>';
} else {
echo '<span class="failed">Minumum version of PHP 5.4 is required (<i class="fa fa-times"></i> FAIL)</span>';
}
new_line();
if(!ini_get('safe_mode')){
echo '<span class="success">Safe mode is not enabled (<i class="fa fa-check-square-o"></i> PASS)</span>';
} else {
echo '<span class="failed">Safe mode is enabled (<i class="fa fa-times"></i> FAIL)</span>';
}
new_line();
if(defined('PDO::ATTR_DRIVER_NAME')){
echo '<span class="success">PDO Driver is enabled (<i class="fa fa-check-square-o"></i> PASS)</span>';
} else {
echo '<span class="failed">PDO Driver is not enabled (<i class="fa fa-times"></i> FAIL)</span>';
}
new_line();
if(extension_loaded('mcrypt')){
echo '<span class="success">Mcrypt library is available (<i class="fa fa-check-square-o"></i> PASS)</span>';
} else {
echo '<span class="failed">Mcrypt library is not available (<i class="fa fa-times"></i> FAIL)</span>';
}
new_line();
if(extension_loaded('gd')){
echo '<span class="success">GD library is available (<i class="fa fa-check-square-o"></i> PASS)</span>';
} else {
echo '<span class="failed">GD library is not available (<i class="fa fa-times"></i> FAIL)</span>';
}
new_line();
if(function_exists('curl_init')){
echo '<span class="success">Curl library is available (<i class="fa fa-check-square-o"></i> PASS)</span>';
} else {
echo '<span class="failed">Curl library is not available (<i class="fa fa-times"></i> FAIL)</span>';
}
new_line();
}
function import_db(){
// Name of the file
$filename = 'application/database/dump.sql';
Dotenv::load(__DIR__);
// MySQL host
$mysql_host = getenv('DB_HOST');
// MySQL username
$mysql_username = getenv('DB_USERNAME');
// MySQL password
$mysql_password = getenv('DB_PASSWORD');
// Database name
$mysql_database = getenv('DB_DATABASE');
// Connect to MySQL server
$connection = mysqli_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error());
// Select database
if(!mysqli_select_db($connection, $mysql_database)){
die('Error selecting MySQL database: ' . mysql_error());
}
// Temporary variable, used to store current query
$templine = '';
// Read in entire file
$lines = file($filename);
// Loop through each line
foreach ($lines as $line)
{
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '')
continue;
// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';')
{
// Perform the query
mysqli_query($connection, $templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysqli_error() . '<br /><br />');
// Reset temp variable to empty
$templine = '';
}
}
echo '<span class="success">Successfully Imported Database (<i class="fa fa-check-square-o"></i> PASS)</span>';
new_line();
}
?>
</div>
<h4>Success!!! Make sure to delete the install.php file</h4>
<a href="/">Visit Your New Site</a>
</body>
</html>