2006-07-24 20:54:04 +02:00
|
|
|
<?php
|
2023-08-31 22:44:40 +02:00
|
|
|
|
2018-02-14 14:09:08 +01:00
|
|
|
/*><div style="width:60%; margin: auto; background-color: #fcc;
|
|
|
|
border: 1px solid #faa; padding: 0.5em 1em;">
|
|
|
|
<h1 style="font-size: 120%">No PHP Support</h1>
|
|
|
|
|
|
|
|
It seems this server has no PHP support enabled. You will need to
|
|
|
|
enable PHP before you can install and run DokuWiki. Contact your hosting
|
|
|
|
provider if you're unsure what this means.
|
|
|
|
|
|
|
|
</div>*/
|
2023-08-30 14:51:30 +02:00
|
|
|
|
|
|
|
use dokuwiki\PassHash;
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/');
|
2022-02-15 22:48:45 +01:00
|
|
|
if (!defined('DOKU_CONF')) define('DOKU_CONF', DOKU_INC . 'conf/');
|
|
|
|
if (!defined('DOKU_LOCAL')) define('DOKU_LOCAL', DOKU_INC . 'conf/');
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2017-02-20 08:51:31 +01:00
|
|
|
// load and initialize the core system
|
2022-02-15 22:48:45 +01:00
|
|
|
require_once(DOKU_INC . 'inc/init.php');
|
2022-02-15 23:17:04 +01:00
|
|
|
require_once(DOKU_INC . 'inc/pageutils.php');
|
2012-06-23 14:55:21 +02:00
|
|
|
|
2006-07-28 11:04:04 +02:00
|
|
|
// check for error reporting override or set error reporting to sane values
|
2022-02-15 22:48:45 +01:00
|
|
|
if (!defined('DOKU_E_LEVEL')) {
|
|
|
|
error_reporting(E_ALL ^ E_NOTICE);
|
|
|
|
} else {
|
|
|
|
error_reporting(DOKU_E_LEVEL);
|
|
|
|
}
|
2006-07-28 11:04:04 +02:00
|
|
|
|
2006-07-24 20:54:04 +02:00
|
|
|
// language strings
|
2022-02-15 22:48:45 +01:00
|
|
|
require_once(DOKU_INC . 'inc/lang/en/lang.php');
|
|
|
|
if (isset($_REQUEST['l']) && !is_array($_REQUEST['l'])) {
|
|
|
|
$LC = preg_replace('/[^a-z\-]+/', '', $_REQUEST['l']);
|
2012-06-25 00:24:07 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
if (empty($LC)) $LC = 'en';
|
|
|
|
if ($LC && $LC != 'en') {
|
|
|
|
require_once(DOKU_INC . 'inc/lang/' . $LC . '/lang.php');
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
2006-07-24 20:54:04 +02:00
|
|
|
|
|
|
|
// initialise variables ...
|
2023-08-30 14:48:22 +02:00
|
|
|
$error = [];
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
// begin output
|
|
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
|
|
?>
|
2023-08-31 00:55:36 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="<?php echo $LC ?>" dir="<?php echo $lang['direction'] ?>">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8"/>
|
|
|
|
<title><?php echo $lang['i_installer'] ?></title>
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
width: 90%;
|
|
|
|
margin: 0 auto;
|
|
|
|
font: 84% Verdana, Helvetica, Arial, sans-serif;
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
2023-08-31 00:55:36 +02:00
|
|
|
|
|
|
|
img {
|
|
|
|
border: none
|
|
|
|
}
|
|
|
|
|
|
|
|
br.cl {
|
|
|
|
clear: both;
|
|
|
|
}
|
|
|
|
|
|
|
|
code {
|
|
|
|
font-size: 110%;
|
|
|
|
color: #800000;
|
|
|
|
}
|
|
|
|
|
|
|
|
fieldset {
|
|
|
|
border: none
|
|
|
|
}
|
|
|
|
|
|
|
|
label {
|
|
|
|
display: block;
|
|
|
|
margin-top: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
select.text, input.text {
|
|
|
|
width: 30em;
|
|
|
|
margin: 0 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
a {
|
|
|
|
text-decoration: none
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
function acltoggle() {
|
|
|
|
var cb = document.getElementById('acl');
|
|
|
|
var fs = document.getElementById('acldep');
|
|
|
|
if (!cb || !fs) return;
|
|
|
|
if (cb.checked) {
|
|
|
|
fs.style.display = '';
|
|
|
|
} else {
|
|
|
|
fs.style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.onload = function () {
|
|
|
|
acltoggle();
|
|
|
|
var cb = document.getElementById('acl');
|
|
|
|
if (cb) cb.onchange = acltoggle;
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body style="">
|
2006-07-26 22:10:47 +02:00
|
|
|
<h1 style="float:left">
|
2013-04-19 09:35:02 +02:00
|
|
|
<img src="lib/exe/fetch.php?media=wiki:dokuwiki-128.png"
|
2023-08-31 00:55:36 +02:00
|
|
|
style="vertical-align: middle;" alt="" height="64" width="64"/>
|
|
|
|
<?php echo $lang['i_installer'] ?>
|
2006-07-26 22:10:47 +02:00
|
|
|
</h1>
|
|
|
|
<div style="float:right; margin: 1em;">
|
2023-08-31 00:55:36 +02:00
|
|
|
<?php langsel() ?>
|
2006-07-26 22:10:47 +02:00
|
|
|
</div>
|
2023-08-31 00:55:36 +02:00
|
|
|
<br class="cl"/>
|
2006-07-26 22:10:47 +02:00
|
|
|
|
|
|
|
<div style="float: right; width: 34%;">
|
|
|
|
<?php
|
2022-02-15 22:48:45 +01:00
|
|
|
if (file_exists(DOKU_INC . 'inc/lang/' . $LC . '/install.html')) {
|
|
|
|
include(DOKU_INC . 'inc/lang/' . $LC . '/install.html');
|
|
|
|
} else {
|
2023-08-31 22:00:27 +02:00
|
|
|
echo "<div lang=\"en\" dir=\"ltr\">\n";
|
2022-02-15 22:48:45 +01:00
|
|
|
include(DOKU_INC . 'inc/lang/en/install.html');
|
2023-08-31 22:00:27 +02:00
|
|
|
echo "</div>\n";
|
2022-02-15 22:48:45 +01:00
|
|
|
}
|
2006-07-26 22:10:47 +02:00
|
|
|
?>
|
2018-04-27 19:07:43 +02:00
|
|
|
<a style="
|
|
|
|
background: transparent
|
|
|
|
url(data/dont-panic-if-you-see-this-in-your-logs-it-means-your-directory-permissions-are-correct.png)
|
|
|
|
left top no-repeat;
|
|
|
|
display: block; width:380px; height:73px; border:none; clear:both;"
|
2010-09-09 15:39:55 +02:00
|
|
|
target="_blank"
|
2023-08-31 00:59:34 +02:00
|
|
|
href="https://www.dokuwiki.org/security#web_access_security"></a>
|
2006-07-26 22:10:47 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div style="float: left; width: 58%;">
|
|
|
|
<?php
|
2022-02-15 22:48:45 +01:00
|
|
|
try {
|
2023-08-31 00:55:36 +02:00
|
|
|
if (!(check_functions() && check_permissions())) {
|
2022-02-15 22:48:45 +01:00
|
|
|
echo '<p>' . $lang['i_problems'] . '</p>';
|
|
|
|
print_errors();
|
|
|
|
print_retry();
|
|
|
|
} elseif (!check_configs()) {
|
|
|
|
echo '<p>' . $lang['i_modified'] . '</p>';
|
|
|
|
print_errors();
|
|
|
|
} elseif (check_data($_REQUEST['d'])) {
|
|
|
|
// check_data has sanitized all input parameters
|
|
|
|
if (!store_data($_REQUEST['d'])) {
|
|
|
|
echo '<p>' . $lang['i_failure'] . '</p>';
|
Add simple catch-all to left install.php div
Background: I was trying to install DokuWiki in my chrooted OpenBSD webserver. The install seemed funky (generated config but not ACLs), and the installer page, instead of even showing any errors, was just blank after submitting initial parameters. Long story short, I edited install.php to approximately this effect, and finally got a visible error, which let me find out that I needed to create $CHROOT/dev/{a,u,s,}random. I would have found that out a lot sooner and torn out a lot less of my beautiful hair if something like this were already in place. After all, the installation phase is where one expects many edge cases and whatnot. Would help newcomers with strange environments to make more actionable forum posts crying for help. Please consider.
2018-04-24 11:35:41 +02:00
|
|
|
print_errors();
|
2022-02-15 22:48:45 +01:00
|
|
|
} else {
|
|
|
|
echo '<p>' . $lang['i_success'] . '</p>';
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
} else {
|
|
|
|
print_errors();
|
|
|
|
print_form($_REQUEST['d']);
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
} catch (Exception $e) {
|
2023-08-31 00:55:36 +02:00
|
|
|
echo 'Caught exception: ', $e->getMessage(), "\n";
|
2022-02-15 22:48:45 +01:00
|
|
|
}
|
2006-07-26 22:10:47 +02:00
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
2010-09-09 15:39:55 +02:00
|
|
|
|
2023-08-31 00:55:36 +02:00
|
|
|
<div style="clear: both">
|
2023-08-31 00:59:34 +02:00
|
|
|
<a href="https://dokuwiki.org/"><img src="lib/tpl/dokuwiki/images/button-dw.png" alt="driven by DokuWiki"/></a>
|
|
|
|
<a href="https://php.net"><img src="lib/tpl/dokuwiki/images/button-php.gif" alt="powered by PHP"/></a>
|
2023-08-31 00:55:36 +02:00
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|
2006-07-26 22:10:47 +02:00
|
|
|
<?php
|
2006-07-24 20:54:04 +02:00
|
|
|
|
|
|
|
/**
|
2006-07-26 22:10:47 +02:00
|
|
|
* Print the input form
|
2014-10-01 15:32:05 +02:00
|
|
|
*
|
|
|
|
* @param array $d submitted entry 'd' of request data
|
2006-07-24 20:54:04 +02:00
|
|
|
*/
|
2022-02-15 22:48:45 +01:00
|
|
|
function print_form($d)
|
|
|
|
{
|
2006-07-26 22:10:47 +02:00
|
|
|
global $lang;
|
|
|
|
global $LC;
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
include(DOKU_CONF . 'license.php');
|
2010-06-26 15:59:59 +02:00
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
if (!is_array($d)) $d = [];
|
2022-02-15 22:48:45 +01:00
|
|
|
$d = array_map('hsc', $d);
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
if (!isset($d['acl'])) $d['acl'] = 1;
|
|
|
|
if (!isset($d['pop'])) $d['pop'] = 1;
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
?>
|
|
|
|
<form action="" method="post">
|
2023-08-31 00:55:36 +02:00
|
|
|
<input type="hidden" name="l" value="<?php echo $LC ?>"/>
|
|
|
|
<fieldset>
|
|
|
|
<label for="title"><?php echo $lang['i_wikiname'] ?>
|
|
|
|
<input type="text" name="d[title]" id="title" value="<?php echo $d['title'] ?>" style="width: 20em;"/>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<fieldset style="margin-top: 1em;">
|
|
|
|
<label for="acl">
|
|
|
|
<input type="checkbox" name="d[acl]"
|
|
|
|
id="acl" <?php echo(($d['acl'] ? ' checked="checked"' : '')); ?> />
|
|
|
|
<?php echo $lang['i_enableacl'] ?></label>
|
|
|
|
|
|
|
|
<fieldset id="acldep">
|
|
|
|
<label for="superuser"><?php echo $lang['i_superuser'] ?></label>
|
|
|
|
<input class="text" type="text" name="d[superuser]" id="superuser"
|
|
|
|
value="<?php echo $d['superuser'] ?>"/>
|
|
|
|
|
|
|
|
<label for="fullname"><?php echo $lang['fullname'] ?></label>
|
|
|
|
<input class="text" type="text" name="d[fullname]" id="fullname"
|
|
|
|
value="<?php echo $d['fullname'] ?>"/>
|
|
|
|
|
|
|
|
<label for="email"><?php echo $lang['email'] ?></label>
|
|
|
|
<input class="text" type="text" name="d[email]" id="email" value="<?php echo $d['email'] ?>"/>
|
|
|
|
|
|
|
|
<label for="password"><?php echo $lang['pass'] ?></label>
|
|
|
|
<input class="text" type="password" name="d[password]" id="password"/>
|
|
|
|
|
|
|
|
<label for="confirm"><?php echo $lang['passchk'] ?></label>
|
|
|
|
<input class="text" type="password" name="d[confirm]" id="confirm"/>
|
|
|
|
|
|
|
|
<label for="policy"><?php echo $lang['i_policy'] ?></label>
|
|
|
|
<select class="text" name="d[policy]" id="policy">
|
|
|
|
<option value="0" <?php echo ($d['policy'] == 0) ? 'selected="selected"' : '' ?>><?php
|
|
|
|
echo $lang['i_pol0'] ?></option>
|
|
|
|
<option value="1" <?php echo ($d['policy'] == 1) ? 'selected="selected"' : '' ?>><?php
|
|
|
|
echo $lang['i_pol1'] ?></option>
|
|
|
|
<option value="2" <?php echo ($d['policy'] == 2) ? 'selected="selected"' : '' ?>><?php
|
|
|
|
echo $lang['i_pol2'] ?></option>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<label for="allowreg">
|
|
|
|
<input type="checkbox" name="d[allowreg]" id="allowreg" <?php
|
|
|
|
echo(($d['allowreg'] ? ' checked="checked"' : '')); ?> />
|
|
|
|
<?php echo $lang['i_allowreg'] ?>
|
|
|
|
</label>
|
|
|
|
</fieldset>
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
<fieldset>
|
|
|
|
<p><?php echo $lang['i_license'] ?></p>
|
|
|
|
<?php
|
|
|
|
$license[] = ['name' => $lang['i_license_none'], 'url' => ''];
|
|
|
|
if (empty($d['license'])) $d['license'] = 'cc-by-sa';
|
|
|
|
foreach ($license as $key => $lic) {
|
|
|
|
echo '<label for="lic_' . $key . '">';
|
|
|
|
echo '<input type="radio" name="d[license]" value="' . hsc($key) . '" id="lic_' . $key . '"' .
|
|
|
|
(($d['license'] === $key) ? ' checked="checked"' : '') . '>';
|
|
|
|
echo hsc($lic['name']);
|
|
|
|
if ($lic['url']) echo ' <a href="' . $lic['url'] . '" target="_blank"><sup>[?]</sup></a>';
|
|
|
|
echo '</label>';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
<fieldset>
|
|
|
|
<p><?php echo $lang['i_pop_field'] ?></p>
|
|
|
|
<label for="pop">
|
|
|
|
<input type="checkbox" name="d[pop]" id="pop" <?php
|
|
|
|
echo(($d['pop'] ? ' checked="checked"' : '')); ?> />
|
|
|
|
<?php echo $lang['i_pop_label'] ?>
|
2023-08-31 00:59:34 +02:00
|
|
|
<a href="https://www.dokuwiki.org/popularity" target="_blank"><sup>[?]</sup></a>
|
2013-11-09 20:51:29 +01:00
|
|
|
</label>
|
2006-07-26 22:10:47 +02:00
|
|
|
</fieldset>
|
|
|
|
|
2010-06-26 15:59:59 +02:00
|
|
|
</fieldset>
|
2023-08-31 00:55:36 +02:00
|
|
|
<fieldset id="process">
|
|
|
|
<button type="submit" name="submit"><?php echo $lang['btn_save'] ?></button>
|
2012-12-07 17:46:16 +01:00
|
|
|
</fieldset>
|
2006-07-26 22:10:47 +02:00
|
|
|
</form>
|
|
|
|
<?php
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
function print_retry()
|
|
|
|
{
|
2010-01-15 19:50:13 +01:00
|
|
|
global $lang;
|
|
|
|
global $LC;
|
|
|
|
?>
|
2006-09-30 19:01:21 +02:00
|
|
|
<form action="" method="get">
|
2023-08-31 00:55:36 +02:00
|
|
|
<fieldset>
|
|
|
|
<input type="hidden" name="l" value="<?php echo $LC ?>"/>
|
|
|
|
<button type="submit"><?php echo $lang['i_retry']; ?></button>
|
|
|
|
</fieldset>
|
2006-09-30 19:01:21 +02:00
|
|
|
</form>
|
2010-01-15 19:50:13 +01:00
|
|
|
<?php
|
2006-09-30 19:01:21 +02:00
|
|
|
}
|
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
/**
|
|
|
|
* Check validity of data
|
|
|
|
*
|
2014-10-01 15:32:05 +02:00
|
|
|
* @param array $d
|
|
|
|
* @return bool ok?
|
2023-08-31 00:55:36 +02:00
|
|
|
* @author Andreas Gohr
|
|
|
|
*
|
2006-07-26 22:10:47 +02:00
|
|
|
*/
|
2022-02-15 22:48:45 +01:00
|
|
|
function check_data(&$d)
|
|
|
|
{
|
2023-08-30 14:48:22 +02:00
|
|
|
static $form_default = [
|
2023-08-31 00:55:36 +02:00
|
|
|
'title' => '',
|
|
|
|
'acl' => '1',
|
2012-06-25 00:24:07 +02:00
|
|
|
'superuser' => '',
|
2023-08-31 00:55:36 +02:00
|
|
|
'fullname' => '',
|
|
|
|
'email' => '',
|
|
|
|
'password' => '',
|
|
|
|
'confirm' => '',
|
|
|
|
'policy' => '0',
|
|
|
|
'allowreg' => '0',
|
|
|
|
'license' => 'cc-by-sa'
|
2023-08-30 14:48:22 +02:00
|
|
|
];
|
2006-07-26 22:10:47 +02:00
|
|
|
global $lang;
|
|
|
|
global $error;
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
if (!is_array($d)) $d = [];
|
2022-02-15 22:48:45 +01:00
|
|
|
foreach ($d as $k => $v) {
|
|
|
|
if (is_array($v))
|
2012-06-25 00:24:07 +02:00
|
|
|
unset($d[$k]);
|
2022-02-15 22:48:45 +01:00
|
|
|
else $d[$k] = (string)$v;
|
2012-06-25 00:24:07 +02:00
|
|
|
}
|
|
|
|
|
2006-10-04 20:35:16 +02:00
|
|
|
//autolowercase the username
|
2012-06-25 00:24:07 +02:00
|
|
|
$d['superuser'] = isset($d['superuser']) ? strtolower($d['superuser']) : "";
|
2006-10-04 20:35:16 +02:00
|
|
|
|
2012-06-25 00:24:07 +02:00
|
|
|
$ok = false;
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
if (isset($_REQUEST['submit'])) {
|
2012-06-25 00:24:07 +02:00
|
|
|
$ok = true;
|
|
|
|
|
|
|
|
// check input
|
2022-02-15 22:48:45 +01:00
|
|
|
if (empty($d['title'])) {
|
|
|
|
$error[] = sprintf($lang['i_badval'], $lang['i_wikiname']);
|
2023-08-31 00:55:36 +02:00
|
|
|
$ok = false;
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
if (isset($d['acl'])) {
|
2022-02-15 23:17:04 +01:00
|
|
|
if (empty($d['superuser']) || ($d['superuser'] !== cleanID($d['superuser']))) {
|
2022-02-15 22:48:45 +01:00
|
|
|
$error[] = sprintf($lang['i_badval'], $lang['i_superuser']);
|
2023-08-31 00:55:36 +02:00
|
|
|
$ok = false;
|
2012-06-25 00:24:07 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
if (empty($d['password'])) {
|
|
|
|
$error[] = sprintf($lang['i_badval'], $lang['pass']);
|
2023-08-31 00:55:36 +02:00
|
|
|
$ok = false;
|
2022-02-15 22:48:45 +01:00
|
|
|
} elseif (!isset($d['confirm']) || $d['confirm'] != $d['password']) {
|
|
|
|
$error[] = sprintf($lang['i_badval'], $lang['passchk']);
|
2023-08-31 00:55:36 +02:00
|
|
|
$ok = false;
|
2012-06-25 00:24:07 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
if (empty($d['fullname']) || strstr($d['fullname'], ':')) {
|
|
|
|
$error[] = sprintf($lang['i_badval'], $lang['fullname']);
|
2023-08-31 00:55:36 +02:00
|
|
|
$ok = false;
|
2012-06-25 00:24:07 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
if (empty($d['email']) || strstr($d['email'], ':') || !strstr($d['email'], '@')) {
|
|
|
|
$error[] = sprintf($lang['i_badval'], $lang['email']);
|
2023-08-31 00:55:36 +02:00
|
|
|
$ok = false;
|
2012-06-25 00:24:07 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
} else {
|
2019-03-13 18:54:14 +01:00
|
|
|
// Since default = 1, browser won't send acl=0 when user untick acl
|
|
|
|
$d['acl'] = '0';
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
|
|
|
}
|
2012-06-25 00:24:07 +02:00
|
|
|
$d = array_merge($form_default, $d);
|
2006-07-26 22:10:47 +02:00
|
|
|
return $ok;
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
/**
|
|
|
|
* Writes the data to the config files
|
|
|
|
*
|
2014-10-01 15:32:05 +02:00
|
|
|
* @param array $d
|
|
|
|
* @return bool
|
2023-08-31 00:55:36 +02:00
|
|
|
* @throws Exception
|
|
|
|
*
|
|
|
|
* @author Chris Smith <chris@jalakai.co.uk>
|
2006-07-26 22:10:47 +02:00
|
|
|
*/
|
2022-02-15 22:48:45 +01:00
|
|
|
function store_data($d)
|
|
|
|
{
|
2006-07-28 11:40:28 +02:00
|
|
|
global $LC;
|
2006-07-26 22:10:47 +02:00
|
|
|
$ok = true;
|
2023-08-31 00:55:36 +02:00
|
|
|
$d['policy'] = (int)$d['policy'];
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
// create local.php
|
2023-08-31 00:55:36 +02:00
|
|
|
$now = gmdate('r');
|
2006-07-26 22:10:47 +02:00
|
|
|
$output = <<<EOT
|
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Dokuwiki's Main Configuration File - Local Settings
|
|
|
|
* Auto-generated by install script
|
|
|
|
* Date: $now
|
|
|
|
*/
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
EOT;
|
2014-06-22 00:00:41 +02:00
|
|
|
// add any config options set by a previous installer
|
2022-02-15 22:48:45 +01:00
|
|
|
$preset = __DIR__ . '/install.conf';
|
|
|
|
if (file_exists($preset)) {
|
2014-06-22 00:00:41 +02:00
|
|
|
$output .= "# preset config options\n";
|
|
|
|
$output .= file_get_contents($preset);
|
|
|
|
$output .= "\n\n";
|
|
|
|
$output .= "# options selected in installer\n";
|
|
|
|
@unlink($preset);
|
|
|
|
}
|
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
$output .= '$conf[\'title\'] = \'' . addslashes($d['title']) . "';\n";
|
|
|
|
$output .= '$conf[\'lang\'] = \'' . addslashes($LC) . "';\n";
|
|
|
|
$output .= '$conf[\'license\'] = \'' . addslashes($d['license']) . "';\n";
|
|
|
|
if ($d['acl']) {
|
|
|
|
$output .= '$conf[\'useacl\'] = 1' . ";\n";
|
2006-09-17 17:46:59 +02:00
|
|
|
$output .= "\$conf['superuser'] = '@admin';\n";
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
if (!$d['allowreg']) {
|
|
|
|
$output .= '$conf[\'disableactions\'] = \'register\'' . ";\n";
|
2013-11-09 21:07:14 +01:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
$ok = $ok && fileWrite(DOKU_LOCAL . 'local.php', $output);
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
if ($d['acl']) {
|
2012-06-23 14:55:21 +02:00
|
|
|
// hash the password
|
2023-08-30 14:48:22 +02:00
|
|
|
$phash = new PassHash();
|
2020-06-08 22:29:09 +02:00
|
|
|
$pass = $phash->hash_bcrypt($d['password']);
|
2012-06-23 14:55:21 +02:00
|
|
|
|
2006-07-24 20:54:04 +02:00
|
|
|
// create users.auth.php
|
2019-09-14 04:27:21 +02:00
|
|
|
$output = <<<EOT
|
|
|
|
# users.auth.php
|
|
|
|
# <?php exit()?>
|
|
|
|
# Don't modify the lines above
|
|
|
|
#
|
|
|
|
# Userfile
|
|
|
|
#
|
|
|
|
# Auto-generated by install script
|
|
|
|
# Date: $now
|
|
|
|
#
|
|
|
|
# Format:
|
|
|
|
# login:passwordhash:Real Name:email:groups,comma,separated
|
|
|
|
|
|
|
|
EOT;
|
2020-06-10 02:16:25 +02:00
|
|
|
// --- user:bcryptpasswordhash:Real Name:email:groups,comma,seperated
|
2023-08-30 14:48:22 +02:00
|
|
|
$output = $output . "\n" . implode(':', [
|
2022-04-28 09:20:06 +02:00
|
|
|
$d['superuser'],
|
|
|
|
$pass,
|
|
|
|
$d['fullname'],
|
|
|
|
$d['email'],
|
|
|
|
'admin,user',
|
|
|
|
]) . "\n";
|
2022-02-15 22:48:45 +01:00
|
|
|
$ok = $ok && fileWrite(DOKU_LOCAL . 'users.auth.php', $output);
|
2006-07-24 20:54:04 +02:00
|
|
|
|
|
|
|
// create acl.auth.php
|
2006-07-28 11:36:53 +02:00
|
|
|
$output = <<<EOT
|
|
|
|
# acl.auth.php
|
|
|
|
# <?php exit()?>
|
|
|
|
# Don't modify the lines above
|
|
|
|
#
|
|
|
|
# Access Control Lists
|
|
|
|
#
|
|
|
|
# Auto-generated by install script
|
|
|
|
# Date: $now
|
|
|
|
|
|
|
|
EOT;
|
2022-02-15 22:48:45 +01:00
|
|
|
if ($d['policy'] == 2) {
|
2023-08-31 00:55:36 +02:00
|
|
|
$output .= "* @ALL 0\n";
|
|
|
|
$output .= "* @user 8\n";
|
2022-02-15 22:48:45 +01:00
|
|
|
} elseif ($d['policy'] == 1) {
|
2023-08-31 00:55:36 +02:00
|
|
|
$output .= "* @ALL 1\n";
|
|
|
|
$output .= "* @user 8\n";
|
2022-02-15 22:48:45 +01:00
|
|
|
} else {
|
2023-08-31 00:55:36 +02:00
|
|
|
$output .= "* @ALL 8\n";
|
2006-07-28 11:36:53 +02:00
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
$ok = $ok && fileWrite(DOKU_LOCAL . 'acl.auth.php', $output);
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
2012-12-07 17:46:16 +01:00
|
|
|
|
|
|
|
// enable popularity submission
|
2022-02-15 22:48:45 +01:00
|
|
|
if (isset($d['pop']) && $d['pop']) {
|
|
|
|
@touch(DOKU_INC . 'data/cache/autosubmit.txt');
|
2012-12-07 17:46:16 +01:00
|
|
|
}
|
|
|
|
|
2013-02-16 20:24:25 +01:00
|
|
|
// disable auth plugins til needed
|
|
|
|
$output = <<<EOT
|
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Local plugin enable/disable settings
|
|
|
|
*
|
|
|
|
* Auto-generated by install script
|
|
|
|
* Date: $now
|
|
|
|
*/
|
|
|
|
|
|
|
|
\$plugins['authad'] = 0;
|
|
|
|
\$plugins['authldap'] = 0;
|
|
|
|
\$plugins['authmysql'] = 0;
|
|
|
|
\$plugins['authpgsql'] = 0;
|
|
|
|
|
|
|
|
EOT;
|
2022-02-15 22:48:45 +01:00
|
|
|
$ok = $ok && fileWrite(DOKU_LOCAL . 'plugins.local.php', $output);
|
2013-02-16 20:24:25 +01:00
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
return $ok;
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
/**
|
|
|
|
* Write the given content to a file
|
|
|
|
*
|
2014-10-01 15:32:05 +02:00
|
|
|
* @param string $filename
|
|
|
|
* @param string $data
|
|
|
|
* @return bool
|
2023-08-31 00:55:36 +02:00
|
|
|
*
|
|
|
|
* @author Chris Smith <chris@jalakai.co.uk>
|
2006-07-26 22:10:47 +02:00
|
|
|
*/
|
2022-02-15 22:48:45 +01:00
|
|
|
function fileWrite($filename, $data)
|
|
|
|
{
|
2006-07-26 22:10:47 +02:00
|
|
|
global $error;
|
|
|
|
global $lang;
|
|
|
|
|
|
|
|
if (($fp = @fopen($filename, 'wb')) === false) {
|
2022-02-15 22:48:45 +01:00
|
|
|
$filename = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}/', $filename);
|
2023-08-31 00:55:36 +02:00
|
|
|
$error[] = sprintf($lang['i_writeerr'], $filename);
|
2006-07-26 22:10:47 +02:00
|
|
|
return false;
|
|
|
|
}
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
if (!empty($data)) {
|
|
|
|
fwrite($fp, $data);
|
|
|
|
}
|
2006-07-26 22:10:47 +02:00
|
|
|
fclose($fp);
|
|
|
|
return true;
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
/**
|
|
|
|
* check installation dependent local config files and tests for a known
|
|
|
|
* unmodified main config file
|
|
|
|
*
|
2014-10-01 15:32:05 +02:00
|
|
|
* @return bool
|
2023-08-31 00:55:36 +02:00
|
|
|
*
|
|
|
|
* @author Chris Smith <chris@jalakai.co.uk>
|
2006-07-26 22:10:47 +02:00
|
|
|
*/
|
2022-02-15 22:48:45 +01:00
|
|
|
function check_configs()
|
|
|
|
{
|
2006-07-26 22:10:47 +02:00
|
|
|
global $error;
|
|
|
|
global $lang;
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
$ok = true;
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
$config_files = [
|
2022-02-15 22:48:45 +01:00
|
|
|
'local' => DOKU_LOCAL . 'local.php',
|
|
|
|
'users' => DOKU_LOCAL . 'users.auth.php',
|
2023-08-31 00:55:36 +02:00
|
|
|
'auth' => DOKU_LOCAL . 'acl.auth.php'
|
2023-08-30 14:48:22 +02:00
|
|
|
];
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
// configs shouldn't exist
|
|
|
|
foreach ($config_files as $file) {
|
2015-01-07 10:47:45 +01:00
|
|
|
if (file_exists($file) && filesize($file)) {
|
2023-08-31 00:55:36 +02:00
|
|
|
$file = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}/', $file);
|
2022-02-15 22:48:45 +01:00
|
|
|
$error[] = sprintf($lang['i_confexists'], $file);
|
2023-08-31 00:55:36 +02:00
|
|
|
$ok = false;
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $ok;
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
/**
|
|
|
|
* Check other installation dir/file permission requirements
|
|
|
|
*
|
2014-10-01 15:32:05 +02:00
|
|
|
* @return bool
|
2023-08-31 00:55:36 +02:00
|
|
|
*
|
|
|
|
* @author Chris Smith <chris@jalakai.co.uk>
|
2006-07-26 22:10:47 +02:00
|
|
|
*/
|
2022-02-15 22:48:45 +01:00
|
|
|
function check_permissions()
|
|
|
|
{
|
2006-07-26 22:10:47 +02:00
|
|
|
global $error;
|
|
|
|
global $lang;
|
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
$dirs = [
|
2023-08-31 00:55:36 +02:00
|
|
|
'conf' => DOKU_LOCAL,
|
|
|
|
'data' => DOKU_INC . 'data',
|
|
|
|
'pages' => DOKU_INC . 'data/pages',
|
|
|
|
'attic' => DOKU_INC . 'data/attic',
|
|
|
|
'media' => DOKU_INC . 'data/media',
|
2022-02-15 22:48:45 +01:00
|
|
|
'media_attic' => DOKU_INC . 'data/media_attic',
|
2023-08-31 00:55:36 +02:00
|
|
|
'media_meta' => DOKU_INC . 'data/media_meta',
|
|
|
|
'meta' => DOKU_INC . 'data/meta',
|
|
|
|
'cache' => DOKU_INC . 'data/cache',
|
|
|
|
'locks' => DOKU_INC . 'data/locks',
|
|
|
|
'index' => DOKU_INC . 'data/index',
|
|
|
|
'tmp' => DOKU_INC . 'data/tmp'
|
2023-08-30 14:48:22 +02:00
|
|
|
];
|
2006-07-26 22:10:47 +02:00
|
|
|
|
|
|
|
$ok = true;
|
2022-02-15 22:48:45 +01:00
|
|
|
foreach ($dirs as $dir) {
|
|
|
|
if (!file_exists("$dir/.") || !is_writable($dir)) {
|
2023-08-31 00:55:36 +02:00
|
|
|
$dir = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}', $dir);
|
2022-02-15 22:48:45 +01:00
|
|
|
$error[] = sprintf($lang['i_permfail'], $dir);
|
2023-08-31 00:55:36 +02:00
|
|
|
$ok = false;
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $ok;
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
/**
|
2006-11-05 21:44:20 +01:00
|
|
|
* Check the availability of functions used in DokuWiki and the PHP version
|
2006-07-26 22:10:47 +02:00
|
|
|
*
|
2014-10-01 15:32:05 +02:00
|
|
|
* @return bool
|
2023-08-31 00:55:36 +02:00
|
|
|
*
|
|
|
|
* @author Andreas Gohr <andi@splitbrain.org>
|
2006-07-26 22:10:47 +02:00
|
|
|
*/
|
2022-02-15 22:48:45 +01:00
|
|
|
function check_functions()
|
|
|
|
{
|
2006-07-26 22:10:47 +02:00
|
|
|
global $error;
|
|
|
|
global $lang;
|
2006-11-05 21:44:20 +01:00
|
|
|
$ok = true;
|
|
|
|
|
2023-06-09 21:10:11 +02:00
|
|
|
if (version_compare(phpversion(), '7.4.0', '<')) {
|
|
|
|
$error[] = sprintf($lang['i_phpver'], phpversion(), '7.4.0');
|
2006-11-05 21:44:20 +01:00
|
|
|
$ok = false;
|
|
|
|
}
|
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
if (ini_get('mbstring.func_overload') != 0) {
|
2014-05-24 19:58:29 +02:00
|
|
|
$error[] = $lang['i_mbfuncoverload'];
|
2020-02-29 05:36:35 +01:00
|
|
|
$ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
random_bytes(1);
|
2023-08-31 00:55:36 +02:00
|
|
|
} catch (Exception $th) {
|
2020-02-29 05:36:35 +01:00
|
|
|
// If an appropriate source of randomness cannot be found, an Exception will be thrown by PHP 7+
|
|
|
|
$error[] = $lang['i_urandom'];
|
|
|
|
$ok = false;
|
|
|
|
}
|
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
if (ini_get('mbstring.func_overload') != 0) {
|
2020-02-29 05:36:35 +01:00
|
|
|
$error[] = $lang['i_mbfuncoverload'];
|
2014-05-24 19:58:29 +02:00
|
|
|
$ok = false;
|
|
|
|
}
|
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
$funcs = explode(' ', 'addslashes call_user_func chmod copy fgets ' .
|
2023-08-31 00:55:36 +02:00
|
|
|
'file file_exists fseek flush filesize ftell fopen ' .
|
|
|
|
'glob header ignore_user_abort ini_get mkdir ' .
|
|
|
|
'ob_start opendir parse_ini_file readfile realpath ' .
|
|
|
|
'rename rmdir serialize session_start unlink usleep ' .
|
|
|
|
'preg_replace file_get_contents htmlspecialchars_decode ' .
|
|
|
|
'spl_autoload_register stream_select fsockopen pack xml_parser_create');
|
2006-07-26 22:10:47 +02:00
|
|
|
|
2006-09-30 19:01:21 +02:00
|
|
|
if (!function_exists('mb_substr')) {
|
2010-01-15 19:50:13 +01:00
|
|
|
$funcs[] = 'utf8_encode';
|
|
|
|
$funcs[] = 'utf8_decode';
|
2006-09-30 19:01:21 +02:00
|
|
|
}
|
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
if (!function_exists('mail')) {
|
|
|
|
if (strpos(ini_get('disable_functions'), 'mail') !== false) {
|
2020-05-17 05:24:21 +02:00
|
|
|
$disabled = $lang['i_disabled'];
|
2022-02-15 22:48:45 +01:00
|
|
|
} else {
|
2020-05-17 05:24:21 +02:00
|
|
|
$disabled = "";
|
|
|
|
}
|
2022-02-15 22:48:45 +01:00
|
|
|
$error[] = sprintf($lang['i_funcnmail'], $disabled);
|
2020-05-17 05:24:21 +02:00
|
|
|
}
|
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
foreach ($funcs as $func) {
|
|
|
|
if (!function_exists($func)) {
|
|
|
|
$error[] = sprintf($lang['i_funcna'], $func);
|
2006-07-26 22:10:47 +02:00
|
|
|
$ok = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $ok;
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
/**
|
|
|
|
* Print language selection
|
|
|
|
*
|
|
|
|
* @author Andreas Gohr <andi@splitbrain.org>
|
|
|
|
*/
|
2022-02-15 22:48:45 +01:00
|
|
|
function langsel()
|
|
|
|
{
|
2006-07-26 22:10:47 +02:00
|
|
|
global $lang;
|
|
|
|
global $LC;
|
|
|
|
|
2022-02-15 22:48:45 +01:00
|
|
|
$dir = DOKU_INC . 'inc/lang';
|
2023-08-31 00:55:36 +02:00
|
|
|
$dh = opendir($dir);
|
2022-02-15 22:48:45 +01:00
|
|
|
if (!$dh) return;
|
2006-07-26 22:10:47 +02:00
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
$langs = [];
|
2006-07-26 22:10:47 +02:00
|
|
|
while (($file = readdir($dh)) !== false) {
|
2023-08-31 00:59:34 +02:00
|
|
|
if (preg_match('/^[._]/', $file)) continue;
|
2022-02-15 22:48:45 +01:00
|
|
|
if (is_dir($dir . '/' . $file) && file_exists($dir . '/' . $file . '/lang.php')) {
|
2006-07-26 22:10:47 +02:00
|
|
|
$langs[] = $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($dh);
|
|
|
|
sort($langs);
|
2006-07-24 20:54:04 +02:00
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
echo '<form action="">';
|
|
|
|
echo $lang['i_chooselang'];
|
|
|
|
echo ': <select name="l" onchange="submit()">';
|
2022-02-15 22:48:45 +01:00
|
|
|
foreach ($langs as $l) {
|
2006-07-26 22:10:47 +02:00
|
|
|
$sel = ($l == $LC) ? 'selected="selected"' : '';
|
2022-02-15 22:48:45 +01:00
|
|
|
echo '<option value="' . $l . '" ' . $sel . '>' . $l . '</option>';
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
2006-07-29 01:29:30 +02:00
|
|
|
echo '</select> ';
|
2022-02-15 22:48:45 +01:00
|
|
|
echo '<button type="submit">' . $lang['btn_update'] . '</button>';
|
2006-07-26 22:10:47 +02:00
|
|
|
echo '</form>';
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|
|
|
|
|
2006-07-26 22:10:47 +02:00
|
|
|
/**
|
2009-11-04 11:01:15 +01:00
|
|
|
* Print global error array
|
2006-07-26 22:10:47 +02:00
|
|
|
*
|
|
|
|
* @author Andreas Gohr <andi@splitbrain.org>
|
|
|
|
*/
|
2022-02-15 22:48:45 +01:00
|
|
|
function print_errors()
|
|
|
|
{
|
2006-07-26 22:10:47 +02:00
|
|
|
global $error;
|
2022-02-15 22:48:45 +01:00
|
|
|
if (!empty($error)) {
|
2012-06-25 00:24:07 +02:00
|
|
|
echo '<ul>';
|
2022-02-15 22:48:45 +01:00
|
|
|
foreach ($error as $err) {
|
2012-06-25 00:24:07 +02:00
|
|
|
echo "<li>$err</li>";
|
|
|
|
}
|
|
|
|
echo '</ul>';
|
2006-07-26 22:10:47 +02:00
|
|
|
}
|
2006-07-24 20:54:04 +02:00
|
|
|
}
|