-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathstep2a.php
More file actions
222 lines (178 loc) · 8.77 KB
/
Copy pathstep2a.php
File metadata and controls
222 lines (178 loc) · 8.77 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
<?php
error_reporting(0);
$var = isset($_POST['submit']) && isset($_POST['host-name'])
&& isset($_POST['database-name']) && isset($_POST['user-name'])
&& isset($_POST['database-type']);
if ($var) {
if (empty($_POST['host-name']) ||
empty($_POST['user-name']) ||
empty($_POST['database-type']) ||
empty($_POST['database-name'])) {
header('Location: step2.php?return=1&error_message=Please fill all the required fields.');
} else {
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Faveo HELPDESK</title>
<script type="text/javascript" src="js/jquery.js"></script>
<link rel="stylesheet" href="css/load-styles.css" type="text/css" media="all">
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="stylesheet" href="css/css.css" type="text/css" media="all">
<link rel="stylesheet" href="css/wc-setup.css" type="text/css" media="all">
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
<body class="wc-setup wp-core-ui">
<?php
define('PROBE_VERSION', '4.2');
define('PROBE_FOR', 'activeCollab 4.2 and Newer');
define('STATUS_OK', 'ok');
define('STATUS_WARNING', 'warning');
define('STATUS_ERROR', 'error');
$database_type = $_POST['database-type'];
$database_name = $_POST['database-name'];
$database_host = $_POST['host-name'];
$database_portno = $_POST['port-no'];
$database_username = $_POST['user-name'];
$database_password = $_POST['password'];
// Unit Testing
// echo "db" . $database_type."<br/>";
// echo $database_name."<br/>";
// echo $database_host."<br/>";
// echo $database_portno."<br/>";
// echo $database_username."<br/>";
// echo $database_password."<br/>";
class TestResult
{
public $message;
public $status;
public function __construct($message, $status = STATUS_OK)
{
$this->message = $message;
$this->status = $status;
}
} // TestResult
function check_have_inno($link)
{
// if($result = mysqli_query('SHOW ENGINES', $link)) {
if ($result = $link('SHOW ENGINES')) {
while ($engine = mysqli_fetch_assoc($result)) {
if (strtolower($engine['Engine']) == 'innodb' && in_array(strtolower($engine['Support']), ['yes', 'default'])) {
return true;
} // if
} // while
} // if
return true;
} // check_have_inno?>
<h1 id="wc-logo"><a href="http://www.faveohelpdesk.com" target="_blank"><img src="images/logo.png" alt="faveo"></a></h1>
<ol class="wc-setup-steps">
<li class="done">Environment Test</li>
<li class="active">Database Test</li>
<li class="">Ready</li>
</ol>
<div class="wc-setup-content">
<h1 style="text-align: center;">Database Setup</h1>
<p class="wc-setup-actions step">
This test will check prerequisites required to install Faveo
<br><br/>
<?php
$mysql_ok = true;
$results = [];
//if($connection = mysql_connect($database_host, $database_username, $database_password)) {
// $results[] = new TestResult('Connected to database as ' . $database_username . '@' . $database_host, STATUS_OK);
if ($connection = mysqli_connect($database_host, $database_username, $database_password)) {
$results[] = new TestResult('Connected to database as '.$database_username.'@'.$database_host, STATUS_OK);
//if(mysql_select_db($database_name, $connection)) {
// $results[] = new TestResult('Database "' . $database_username . '" selected', STATUS_OK);
$sql = "SELECT COUNT(DISTINCT `table_name`) FROM `information_schema`.`columns` WHERE `table_schema` = '$database_name'";
$res = mysqli_query($connection, $sql);
$value = mysqli_fetch_assoc($res);
foreach ($value as $val) {
if ($val == 0) {
$mysqli_version = $connection->server_version;
$results[] = new TestResult("Database '$database_name' looks fine.", STATUS_OK);
$mysql_ok = true;
if ($connection->select_db($database_name)) {
// $results[] = new TestResult('Database "' . $database_username . '" selected', STATUS_OK);
//$mysql_version = mysql_get_server_info($connection);
$mysqli_version = $connection->server_version;
$results[] = new TestResult('Connected to database as '.$database_username.'@'.$database_host, STATUS_OK);
if (version_compare($mysqli_version, '5.0') >= 0) {
$results[] = new TestResult('MySQL version is '.$mysqli_version, STATUS_OK);
$mysql_ok = true;
//$have_inno = check_have_inno($connection);
// if($have_inno) {
// $results[] = new TestResult('InnoDB support is enabled');
// } else {
// $results[] = new TestResult('No InnoDB support. Although activeCollab can use MyISAM storage engine InnoDB is HIGHLY recommended!', STATUS_WARNING);
// }
// } else {
} else {
$results[] = new TestResult('Your MySQL version is '.$mysqli_version.'. We recommend upgrading to at least MySQL5!', STATUS_ERROR);
$mysql_ok = false;
}
// if
} else {
$results[] = new TestResult('Failed to select database. MySQL said: '.mysqli_error($connection), STATUS_ERROR);
$mysql_ok = false;
} // if
} else {
$results[] = new TestResult('Faveo installation needs an empty database.', STATUS_ERROR);
$mysql_ok = false;
}
// code...
}
} else {
$results[] = new TestResult('Failed to connect to database. MySQL said: '.mysqli_connect_error($connection), STATUS_ERROR);
$mysql_ok = false;
} // if
// ---------------------------------------------------
// Validators
// ---------------------------------------------------
foreach ($results as $result) {
echo '<br/><span class="'.$result->status.'">'.$result->status.'</span> — '.$result->message.'';
} // foreach
?><br/>
<?php // if?>
<?php if ($mysql_ok) {
?>
<div class="woocommerce-message woocommerce-tracker" >
<p id="pass">Database connection successful. This system can run Faveo</p>
</div>
<?php
} else {
?>
<div class="woocommerce-message woocommerce-tracker " >
<p id="fail">Database connection unsuccessful. This system does not meet Faveo system requirements</p>
</div>
<?php
} // if?>
<form action="step3.php" method="post">
<div style="border-bottom: 1px solid #eee;">
<p class="wc-setup-actions step" >
<input type="submit" name="submit" id="submitme" class="button-primary button button-large button-next" value="Continue" <?php if ($mysql_ok !== null && $mysql_ok) {
} else {
?>disabled<?php
} ?>>
<a href="step2.php?return=1" class="button button-large button-next" style="float: left">Previous</a>
</p>
</div> </form>
<p class="wc-setup-actions step">
<br><span class="ok">Ok</span> — All Ok
<br><span class="warning">Warning</span> — Not a deal breaker, but it's recommended to have this installed for some features to work
<br><span class="error">Error</span> — Faveo HELPDESK require this feature and can't work without it
<br>
</p>
</div>
<p style="text-align: center;">Copyright © 2015 - <?php echo date('Y'); ?> · Ladybird Web Solution Pvt Ltd. All Rights Reserved. Powered by <a href="http://www.faveohelpdesk.com" target="_blank">Faveo</a></p>
</body>
</html>
<?php
}
} else {
header('Location: step2.php?return=1&error_message=Please fill all the required fields.');
}
?>