3 /*><div style="width:60%; margin: auto; background-color: #fcc;
4 border: 1px solid #faa; padding: 0.5em 1em;">
5 <h1 style="font-size: 120%">No PHP Support</h1>
7 It seems this server has no PHP support enabled. You will need to
8 enable PHP before you can install and run DokuWiki. Contact your hosting
9 provider if you're unsure what this means.
13 use dokuwiki\PassHash
;
15 if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__
. '/');
16 if (!defined('DOKU_CONF')) define('DOKU_CONF', DOKU_INC
. 'conf/');
17 if (!defined('DOKU_LOCAL')) define('DOKU_LOCAL', DOKU_INC
. 'conf/');
19 // load and initialize the core system
20 require_once(DOKU_INC
. 'inc/init.php');
21 require_once(DOKU_INC
. 'inc/pageutils.php');
23 // check for error reporting override or set error reporting to sane values
24 if (!defined('DOKU_E_LEVEL')) {
25 error_reporting(E_ALL ^ E_NOTICE
);
27 error_reporting(DOKU_E_LEVEL
);
31 require_once(DOKU_INC
. 'inc/lang/en/lang.php');
32 if (isset($_REQUEST['l']) && !is_array($_REQUEST['l'])) {
33 $LC = preg_replace('/[^a-z\-]+/', '', $_REQUEST['l']);
35 if (empty($LC)) $LC = 'en';
36 if ($LC && $LC != 'en') {
37 require_once(DOKU_INC
. 'inc/lang/' . $LC . '/lang.php');
40 // initialise variables ...
44 header('Content-Type: text/html; charset=utf-8');
47 <html lang
="<?php echo $LC ?>" dir
="<?php echo $lang['direction'] ?>">
49 <meta charset
="utf-8"/>
50 <title
><?php
echo $lang['i_installer'] ?
></title
>
55 font
: 84% Verdana
, Helvetica
, Arial
, sans
-serif
;
80 select
.text
, input
.text
{
90 function acltoggle() {
91 var cb
= document
.getElementById('acl');
92 var fs
= document
.getElementById('acldep');
93 if (!cb ||
!fs
) return;
95 fs
.style
.display
= '';
97 fs
.style
.display
= 'none';
101 window
.onload
= function () {
103 var cb
= document
.getElementById('acl');
104 if (cb
) cb
.onchange
= acltoggle
;
109 <h1 style
="float:left">
110 <img src
="lib/exe/fetch.php?media=wiki:dokuwiki-128.png"
111 style
="vertical-align: middle;" alt
="" height
="64" width
="64"/>
112 <?php
echo $lang['i_installer'] ?
>
114 <div style
="float:right; margin: 1em;">
119 <div style
="float: right; width: 34%;">
121 if (file_exists(DOKU_INC
. 'inc/lang/' . $LC . '/install.html')) {
122 include(DOKU_INC
. 'inc/lang/' . $LC . '/install.html');
124 echo "<div lang=\"en\" dir=\"ltr\">\n";
125 include(DOKU_INC
. 'inc/lang/en/install.html');
130 background: transparent
131 url(data/dont-panic-if-you-see-this-in-your-logs-it-means-your-directory-permissions-are-correct.png)
133 display: block; width:380px; height:73px; border:none; clear:both;"
135 href
="https://www.dokuwiki.org/security#web_access_security"></a
>
138 <div style
="float: left; width: 58%;">
141 if (!(check_functions() && check_permissions())) {
142 echo '<p>' . $lang['i_problems'] . '</p>';
145 } elseif (!check_configs()) {
146 echo '<p>' . $lang['i_modified'] . '</p>';
148 } elseif (check_data($_REQUEST['d'])) {
149 // check_data has sanitized all input parameters
150 if (!store_data($_REQUEST['d'])) {
151 echo '<p>' . $lang['i_failure'] . '</p>';
154 echo '<p>' . $lang['i_success'] . '</p>';
158 print_form($_REQUEST['d']);
160 } catch (Exception
$e) {
161 echo 'Caught exception: ', $e->getMessage(), "\n";
167 <div style
="clear: both">
168 <a href
="https://dokuwiki.org/"><img src
="lib/tpl/dokuwiki/images/button-dw.png" alt
="driven by DokuWiki"/></a
>
169 <a href
="https://php.net"><img src
="lib/tpl/dokuwiki/images/button-php.gif" alt
="powered by PHP"/></a
>
176 * Print the input form
178 * @param array $d submitted entry 'd' of request data
180 function print_form($d)
185 include(DOKU_CONF
. 'license.php');
187 if (!is_array($d)) $d = [];
188 $d = array_map('hsc', $d);
190 if (!isset($d['acl'])) $d['acl'] = 1;
191 if (!isset($d['pop'])) $d['pop'] = 1;
194 <form action
="" method
="post">
195 <input type
="hidden" name
="l" value
="<?php echo $LC ?>"/>
197 <label
for="title"><?php
echo $lang['i_wikiname'] ?
>
198 <input type
="text" name
="d[title]" id
="title" value
="<?php echo $d['title'] ?>" style
="width: 20em;"/>
201 <fieldset style
="margin-top: 1em;">
203 <input type
="checkbox" name
="d[acl]"
204 id
="acl" <?php
echo(($d['acl'] ?
' checked="checked"' : '')); ?
> />
205 <?php
echo $lang['i_enableacl'] ?
></label
>
207 <fieldset id
="acldep">
208 <label
for="superuser"><?php
echo $lang['i_superuser'] ?
></label
>
209 <input
class="text" type
="text" name
="d[superuser]" id
="superuser"
210 value
="<?php echo $d['superuser'] ?>"/>
212 <label
for="fullname"><?php
echo $lang['fullname'] ?
></label
>
213 <input
class="text" type
="text" name
="d[fullname]" id
="fullname"
214 value
="<?php echo $d['fullname'] ?>"/>
216 <label
for="email"><?php
echo $lang['email'] ?
></label
>
217 <input
class="text" type
="text" name
="d[email]" id
="email" value
="<?php echo $d['email'] ?>"/>
219 <label
for="password"><?php
echo $lang['pass'] ?
></label
>
220 <input
class="text" type
="password" name
="d[password]" id
="password"/>
222 <label
for="confirm"><?php
echo $lang['passchk'] ?
></label
>
223 <input
class="text" type
="password" name
="d[confirm]" id
="confirm"/>
225 <label
for="policy"><?php
echo $lang['i_policy'] ?
></label
>
226 <select
class="text" name
="d[policy]" id
="policy">
227 <option value
="0" <?php
echo ($d['policy'] == 0) ?
'selected="selected"' : '' ?
>><?php
228 echo $lang['i_pol0'] ?
></option
>
229 <option value
="1" <?php
echo ($d['policy'] == 1) ?
'selected="selected"' : '' ?
>><?php
230 echo $lang['i_pol1'] ?
></option
>
231 <option value
="2" <?php
echo ($d['policy'] == 2) ?
'selected="selected"' : '' ?
>><?php
232 echo $lang['i_pol2'] ?
></option
>
235 <label
for="allowreg">
236 <input type
="checkbox" name
="d[allowreg]" id
="allowreg" <?php
237 echo(($d['allowreg'] ?
' checked="checked"' : '')); ?
> />
238 <?php
echo $lang['i_allowreg'] ?
>
244 <p
><?php
echo $lang['i_license'] ?
></p
>
246 $license[] = ['name' => $lang['i_license_none'], 'url' => ''];
247 if (empty($d['license'])) $d['license'] = 'cc-by-sa';
248 foreach ($license as $key => $lic) {
249 echo '<label for="lic_' . $key . '">';
250 echo '<input type="radio" name="d[license]" value="' . hsc($key) . '" id="lic_' . $key . '"' .
251 (($d['license'] === $key) ?
' checked="checked"' : '') . '>';
252 echo hsc($lic['name']);
253 if ($lic['url']) echo ' <a href="' . $lic['url'] . '" target="_blank"><sup>[?]</sup></a>';
260 <p
><?php
echo $lang['i_pop_field'] ?
></p
>
262 <input type
="checkbox" name
="d[pop]" id
="pop" <?php
263 echo(($d['pop'] ?
' checked="checked"' : '')); ?
> />
264 <?php
echo $lang['i_pop_label'] ?
>
265 <a href
="https://www.dokuwiki.org/popularity" target
="_blank"><sup
>[?
]</sup
></a
>
270 <fieldset id
="process">
271 <button type
="submit" name
="submit"><?php
echo $lang['btn_save'] ?
></button
>
277 function print_retry()
282 <form action
="" method
="get">
284 <input type
="hidden" name
="l" value
="<?php echo $LC ?>"/>
285 <button type
="submit"><?php
echo $lang['i_retry']; ?
></button
>
292 * Check validity of data
296 * @author Andreas Gohr
299 function check_data(&$d)
301 static $form_default = [
311 'license' => 'cc-by-sa'
316 if (!is_array($d)) $d = [];
317 foreach ($d as $k => $v) {
320 else $d[$k] = (string)$v;
323 //autolowercase the username
324 $d['superuser'] = isset($d['superuser']) ?
strtolower($d['superuser']) : "";
328 if (isset($_REQUEST['submit'])) {
332 if (empty($d['title'])) {
333 $error[] = sprintf($lang['i_badval'], $lang['i_wikiname']);
336 if (isset($d['acl'])) {
337 if (empty($d['superuser']) ||
($d['superuser'] !== cleanID($d['superuser']))) {
338 $error[] = sprintf($lang['i_badval'], $lang['i_superuser']);
341 if (empty($d['password'])) {
342 $error[] = sprintf($lang['i_badval'], $lang['pass']);
344 } elseif (!isset($d['confirm']) ||
$d['confirm'] != $d['password']) {
345 $error[] = sprintf($lang['i_badval'], $lang['passchk']);
348 if (empty($d['fullname']) ||
strstr($d['fullname'], ':')) {
349 $error[] = sprintf($lang['i_badval'], $lang['fullname']);
352 if (empty($d['email']) ||
strstr($d['email'], ':') ||
!strstr($d['email'], '@')) {
353 $error[] = sprintf($lang['i_badval'], $lang['email']);
357 // Since default = 1, browser won't send acl=0 when user untick acl
361 $d = array_merge($form_default, $d);
366 * Writes the data to the config files
372 * @author Chris Smith <chris@jalakai.co.uk>
374 function store_data($d)
378 $d['policy'] = (int)$d['policy'];
385 * Dokuwiki's Main Configuration File - Local Settings
386 * Auto-generated by install script
391 // add any config options set by a previous installer
392 $preset = __DIR__
. '/install.conf';
393 if (file_exists($preset)) {
394 $output .= "# preset config options\n";
395 $output .= file_get_contents($preset);
397 $output .= "# options selected in installer\n";
401 $output .= '$conf[\'title\'] = \'' . addslashes($d['title']) . "';\n";
402 $output .= '$conf[\'lang\'] = \'' . addslashes($LC) . "';\n";
403 $output .= '$conf[\'license\'] = \'' . addslashes($d['license']) . "';\n";
405 $output .= '$conf[\'useacl\'] = 1' . ";\n";
406 $output .= "\$conf['superuser'] = '@admin';\n";
408 if (!$d['allowreg']) {
409 $output .= '$conf[\'disableactions\'] = \'register\'' . ";\n";
411 $ok = $ok && fileWrite(DOKU_LOCAL
. 'local.php', $output);
415 $phash = new PassHash();
416 $pass = $phash->hash_bcrypt($d['password']);
418 // create users.auth.php
422 # Don't modify the lines above
426 # Auto-generated by install script
430 # login:passwordhash:Real Name:email:groups,comma,separated
433 // --- user:bcryptpasswordhash:Real Name:email:groups,comma,seperated
434 $output = $output . "\n" . implode(':', [
441 $ok = $ok && fileWrite(DOKU_LOCAL
. 'users.auth.php', $output);
443 // create acl.auth.php
447 # Don't modify the lines above
449 # Access Control Lists
451 # Auto-generated by install script
455 if ($d['policy'] == 2) {
456 $output .= "* @ALL 0\n";
457 $output .= "* @user 8\n";
458 } elseif ($d['policy'] == 1) {
459 $output .= "* @ALL 1\n";
460 $output .= "* @user 8\n";
462 $output .= "* @ALL 8\n";
464 $ok = $ok && fileWrite(DOKU_LOCAL
. 'acl.auth.php', $output);
467 // enable popularity submission
468 if (isset($d['pop']) && $d['pop']) {
469 @touch
(DOKU_INC
. 'data/cache/autosubmit.txt');
472 // disable auth plugins til needed
476 * Local plugin enable/disable settings
478 * Auto-generated by install script
482 \$plugins['authad'] = 0;
483 \$plugins['authldap'] = 0;
484 \$plugins['authmysql'] = 0;
485 \$plugins['authpgsql'] = 0;
488 $ok = $ok && fileWrite(DOKU_LOCAL
. 'plugins.local.php', $output);
494 * Write the given content to a file
496 * @param string $filename
497 * @param string $data
500 * @author Chris Smith <chris@jalakai.co.uk>
502 function fileWrite($filename, $data)
507 if (($fp = @fopen
($filename, 'wb')) === false) {
508 $filename = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}/', $filename);
509 $error[] = sprintf($lang['i_writeerr'], $filename);
522 * check installation dependent local config files and tests for a known
523 * unmodified main config file
527 * @author Chris Smith <chris@jalakai.co.uk>
529 function check_configs()
537 'local' => DOKU_LOCAL
. 'local.php',
538 'users' => DOKU_LOCAL
. 'users.auth.php',
539 'auth' => DOKU_LOCAL
. 'acl.auth.php'
542 // configs shouldn't exist
543 foreach ($config_files as $file) {
544 if (file_exists($file) && filesize($file)) {
545 $file = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}/', $file);
546 $error[] = sprintf($lang['i_confexists'], $file);
555 * Check other installation dir/file permission requirements
559 * @author Chris Smith <chris@jalakai.co.uk>
561 function check_permissions()
567 'conf' => DOKU_LOCAL
,
568 'data' => DOKU_INC
. 'data',
569 'pages' => DOKU_INC
. 'data/pages',
570 'attic' => DOKU_INC
. 'data/attic',
571 'media' => DOKU_INC
. 'data/media',
572 'media_attic' => DOKU_INC
. 'data/media_attic',
573 'media_meta' => DOKU_INC
. 'data/media_meta',
574 'meta' => DOKU_INC
. 'data/meta',
575 'cache' => DOKU_INC
. 'data/cache',
576 'locks' => DOKU_INC
. 'data/locks',
577 'index' => DOKU_INC
. 'data/index',
578 'tmp' => DOKU_INC
. 'data/tmp'
582 foreach ($dirs as $dir) {
583 if (!file_exists("$dir/.") ||
!is_writable($dir)) {
584 $dir = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}', $dir);
585 $error[] = sprintf($lang['i_permfail'], $dir);
593 * Check the availability of functions used in DokuWiki and the PHP version
597 * @author Andreas Gohr <andi@splitbrain.org>
599 function check_functions()
605 if (version_compare(phpversion(), '7.4.0', '<')) {
606 $error[] = sprintf($lang['i_phpver'], phpversion(), '7.4.0');
610 if (ini_get('mbstring.func_overload') != 0) {
611 $error[] = $lang['i_mbfuncoverload'];
617 } catch (Exception
$th) {
618 // If an appropriate source of randomness cannot be found, an Exception will be thrown by PHP 7+
619 $error[] = $lang['i_urandom'];
623 if (ini_get('mbstring.func_overload') != 0) {
624 $error[] = $lang['i_mbfuncoverload'];
628 $funcs = explode(' ', 'addslashes call_user_func chmod copy fgets ' .
629 'file file_exists fseek flush filesize ftell fopen ' .
630 'glob header ignore_user_abort ini_get mkdir ' .
631 'ob_start opendir parse_ini_file readfile realpath ' .
632 'rename rmdir serialize session_start unlink usleep ' .
633 'preg_replace file_get_contents htmlspecialchars_decode ' .
634 'spl_autoload_register stream_select fsockopen pack xml_parser_create');
636 if (!function_exists('mb_substr')) {
637 $funcs[] = 'utf8_encode';
638 $funcs[] = 'utf8_decode';
641 if (!function_exists('mail')) {
642 if (strpos(ini_get('disable_functions'), 'mail') !== false) {
643 $disabled = $lang['i_disabled'];
647 $error[] = sprintf($lang['i_funcnmail'], $disabled);
650 foreach ($funcs as $func) {
651 if (!function_exists($func)) {
652 $error[] = sprintf($lang['i_funcna'], $func);
660 * Print language selection
662 * @author Andreas Gohr <andi@splitbrain.org>
669 $dir = DOKU_INC
. 'inc/lang';
674 while (($file = readdir($dh)) !== false) {
675 if (preg_match('/^[._]/', $file)) continue;
676 if (is_dir($dir . '/' . $file) && file_exists($dir . '/' . $file . '/lang.php')) {
683 echo '<form action="">';
684 echo $lang['i_chooselang'];
685 echo ': <select name="l" onchange="submit()">';
686 foreach ($langs as $l) {
687 $sel = ($l == $LC) ?
'selected="selected"' : '';
688 echo '<option value="' . $l . '" ' . $sel . '>' . $l . '</option>';
691 echo '<button type="submit">' . $lang['btn_update'] . '</button>';
696 * Print global error array
698 * @author Andreas Gohr <andi@splitbrain.org>
700 function print_errors()
703 if (!empty($error)) {
705 foreach ($error as $err) {
706 echo "<li>$err</li>";