-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
206 lines (185 loc) · 9.62 KB
/
Copy pathinstall.php
File metadata and controls
206 lines (185 loc) · 9.62 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
<?php
/* PowerNews is a PHP and mySQL based newsscript - www.powerscripts.org */
/* Copyright (C) 2001-2026 PowerScripts */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, */
/* MA 02111-1307 USA */
/* Include config file */
header('Content-Type: text/html; charset=UTF-8');
@include __DIR__ . '/pninc/config.inc.php';
@include __DIR__ . '/pnadmin/functions.inc.php';
/* Needed PHP Version */
$need_php_version = '8.2.0';
/* Needed mySQL Version */
$need_mysql_version = '10.3';
/* Current PowerNews version */
$thisversion = '3.11';
?>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PowerNews Installation</title>
<link href="./assets/bootstrap/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container my-4">
<div class="card shadow-sm">
<h1 class="card-header h5 mb-0">PowerNews Installation</h1>
<div class="card-body">
<?php
$installLockFile = __DIR__ . '/pninc/install.lock';
if (isset($_POST['install']) && $_POST['install'] == 'YES') {
if (file_exists($installLockFile)) {
http_response_code(403);
?>
<div class="alert alert-warning" role="alert">
<strong>Installation bereits erfolgt.</strong><br>
Zum Neuinstallieren bitte <code>pninc/install.lock</code> entfernen.
</div>
<?php
} else {
$sqlCommands = readDump('powernews.sql');
$counter = count($sqlCommands);
for ($i = 0; $i < $counter; ++$i) {
mysqli_query($pn_handler, $sqlCommands[$i]);
}
?>
<div class="alert alert-success">
<p class="mb-1"><?php echo count($sqlCommands); ?> mySQL Befehle ausgeführt.</p>
<p class="mb-1">Tabellenstruktur erstellt.</p>
<p class="mb-1">Standardkonfiguration geladen.</p>
</div>
<?php
// Create admin user with random bcrypt password (BUG-003)
$adminNickname = 'admin';
$adminEmail = 'admin@localhost';
$adminPassword = bin2hex(random_bytes(8));
$adminHash = password_hash($adminPassword, PASSWORD_DEFAULT);
$nowTs = time();
$stmt = mysqli_prepare($pn_handler, "INSERT INTO pn_users (nickname, email, password, registered, showemail, status) VALUES (?, ?, ?, ?, 'NO', 'Activated')");
if ($stmt) {
mysqli_stmt_bind_param($stmt, 'sssi', $adminNickname, $adminEmail, $adminHash, $nowTs);
mysqli_stmt_execute($stmt);
$adminId = mysqli_insert_id($pn_handler);
$stmt2 = mysqli_prepare($pn_handler, "INSERT INTO pn_permissions (userid, canreadtemplates, canwritetemplates, canreadconfig, canwriteconfig, canreadusers, canwriteusers, canreadpermissions, canwritepermissions, canreadcategories, canwritecategories, canreadnews, canwritenews, canreadcomments, canwritecomments) VALUES (?, 'YES','YES','YES','YES','YES','YES','YES','YES','YES','YES','YES','YES','YES','YES')");
if ($stmt2) {
mysqli_stmt_bind_param($stmt2, 'i', $adminId);
mysqli_stmt_execute($stmt2);
}
?>
<div class="alert alert-info">
<strong>Admin-Zugang erstellt:</strong><br>
Nickname: <code><?php echo htmlspecialchars($adminNickname); ?></code><br>
Passwort: <code><?php echo htmlspecialchars($adminPassword); ?></code><br>
<strong class="text-danger">Bitte sofort notieren und nach erstem Login im Profil ändern.</strong>
</div>
<?php
}
@file_put_contents($installLockFile, 'installed ' . date('c'));
?>
<div class="alert alert-success mb-0">
Installation erfolgreich! Bitte löschen Sie die <strong>install.php</strong> und die <strong>update.php</strong> —
<a href="./pnadmin/" class="alert-link">Adminbereich</a>.
</div>
<?php
}
} else {
?>
<p>
Bitte fahren Sie mit der Installation von PowerNews nur fort, wenn alle Vorraussetzungen erfüllt (grün) sind. Für die einzelnen Installationsschritte lesen Sie bitte die
<a href="readme.html" target="_blank" rel="noopener noreferrer">ReadMe</a>.
</p>
<div class="table-responsive">
<table class="table align-middle">
<thead>
<tr>
<th></th>
<th>Benötigt</th>
<th>Vorhanden</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>PHP Version</strong></td>
<td><?php echo $need_php_version; ?> oder höher</td>
<td>
<?php
if (phpversion() >= $need_php_version) {
?><span class="badge text-bg-success"><?php echo phpversion(); ?></span><?php
} else {
$error = 'PHP VERSION';
?><span class="badge text-bg-danger"><?php echo phpversion(); ?></span><?php
}
?>
</td>
</tr>
<tr>
<td><strong>upload_max_filesize</strong> (nur für Bildupload)</td>
<td>> 0M</td>
<td>
<?php
$uploadMax = get_cfg_var('upload_max_filesize');
if (is_array($uploadMax)) {
$uploadMax = (string) ($uploadMax[0] ?? '0');
} elseif ($uploadMax === false) {
$uploadMax = '0';
}
if ((int) $uploadMax > 0) {
?><span class="badge text-bg-success"><?php echo htmlspecialchars($uploadMax); ?></span><?php
} else {
?><span class="badge text-bg-danger"><?php echo htmlspecialchars($uploadMax); ?></span><?php
}
?>
</td>
</tr>
<tr>
<td><strong>mySQL</strong></td>
<td><?php echo $need_mysql_version; ?> oder höher</td>
<td>
<?php
if (isset($pn_handler)) {
$server_version = mysqli_get_server_info($pn_handler);
$version_parts = explode('-', $server_version);
$numeric_version = $version_parts[0];
if (version_compare($numeric_version, $need_mysql_version, '>=')) {
?><span class="badge text-bg-success"><?php echo htmlspecialchars($numeric_version); ?></span><?php
} else {
$error = 'MYSQL';
?><span class="badge text-bg-danger"><?php echo htmlspecialchars($numeric_version); ?></span><?php
}
} else {
?><span class="badge text-bg-danger">Unknown version</span><?php
}
?>
</td>
</tr>
</tbody>
</table>
</div>
<?php if (!isset($error)) { ?>
<form action="install.php" method="post">
<input type="hidden" name="install" value="YES">
<button type="submit" class="btn btn-primary">Installieren</button>
</form>
<?php
}
}
?>
</div>
</div>
<p class="text-center text-muted small mt-4 mb-0">PowerNews <?php echo htmlspecialchars($thisversion); ?> © Copyright 2002 by <a href="https://www.powerscripts.org" target="_blank" rel="noopener noreferrer">PowerScripts</a></p>
</div>
<script src="./assets/bootstrap/bootstrap.bundle.min.js"></script>
</body>
</html>