2 /*><div style="width:60%; margin: auto; background-color: #fcc;
3 border: 1px solid #faa; padding: 0.5em 1em;">
4 <h1 style="font-size: 120%">No PHP Support</h1>
6 It seems this server has no PHP support enabled. You will need to
7 enable PHP before you can install and run DokuWiki. Contact your hosting
8 provider if you're unsure what this means.
12 use dokuwiki\PassHash
;
14 if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__
. '/');
15 if (!defined('DOKU_CONF')) define('DOKU_CONF', DOKU_INC
. 'conf/');
16 if (!defined('DOKU_LOCAL')) define('DOKU_LOCAL', DOKU_INC
. 'conf/');
18 // load and initialize the core system
19 require_once(DOKU_INC
. 'inc/init.php');
20 require_once(DOKU_INC
. 'inc/pageutils.php');
22 // check for error reporting override or set error reporting to sane values
23 if (!defined('DOKU_E_LEVEL')) {
24 error_reporting(E_ALL ^ E_NOTICE
);
26 error_reporting(DOKU_E_LEVEL
);
30 require_once(DOKU_INC
. 'inc/lang/en/lang.php');
31 if (isset($_REQUEST['l']) && !is_array($_REQUEST['l'])) {
32 $LC = preg_replace('/[^a-z\-]+/', '', $_REQUEST['l']);
34 if (empty($LC)) $LC = 'en';
35 if ($LC && $LC != 'en') {
36 require_once(DOKU_INC
. 'inc/lang/' . $LC . '/lang.php');
39 // initialise variables ...
43 header('Content-Type: text/html; charset=utf-8');
46 <html lang
="<?php echo $LC?>" dir
="<?php echo $lang['direction']?>">
48 <meta charset
="utf-8" />
49 <title
><?php
echo $lang['i_installer']?
></title
>
51 body
{ width
: 90%
; margin
: 0 auto
; font
: 84% Verdana
, Helvetica
, Arial
, sans
-serif
; }
54 code
{ font
-size
: 110%
; color
: #800000; }
55 fieldset
{ border
: none
}
56 label
{ display
: block
; margin
-top
: 0.5em
; }
57 select
.text
, input
.text
{ width
: 30em
; margin
: 0 0.5em
; }
58 a
{text
-decoration
: none
}
62 var cb
= document
.getElementById('acl');
63 var fs
= document
.getElementById('acldep');
64 if(!cb ||
!fs
) return;
66 fs
.style
.display
= '';
68 fs
.style
.display
= 'none';
71 window
.onload
= function(){
73 var cb
= document
.getElementById('acl');
74 if(cb
) cb
.onchange
= acltoggle
;
79 <h1 style
="float:left">
80 <img src
="lib/exe/fetch.php?media=wiki:dokuwiki-128.png"
81 style
="vertical-align: middle;" alt
="" height
="64" width
="64" />
82 <?php
echo $lang['i_installer']?
>
84 <div style
="float:right; margin: 1em;">
89 <div style
="float: right; width: 34%;">
91 if (file_exists(DOKU_INC
. 'inc/lang/' . $LC . '/install.html')) {
92 include(DOKU_INC
. 'inc/lang/' . $LC . '/install.html');
94 print "<div lang=\"en\" dir=\"ltr\">\n";
95 include(DOKU_INC
. 'inc/lang/en/install.html');
100 background: transparent
101 url(data/dont-panic-if-you-see-this-in-your-logs-it-means-your-directory-permissions-are-correct.png)
103 display: block; width:380px; height:73px; border:none; clear:both;"
105 href
="http://www.dokuwiki.org/security#web_access_security"></a
>
108 <div style
="float: left; width: 58%;">
111 if (! (check_functions() && check_permissions())) {
112 echo '<p>' . $lang['i_problems'] . '</p>';
115 } elseif (!check_configs()) {
116 echo '<p>' . $lang['i_modified'] . '</p>';
118 } elseif (check_data($_REQUEST['d'])) {
119 // check_data has sanitized all input parameters
120 if (!store_data($_REQUEST['d'])) {
121 echo '<p>' . $lang['i_failure'] . '</p>';
124 echo '<p>' . $lang['i_success'] . '</p>';
128 print_form($_REQUEST['d']);
130 } catch (Exception
$e) {
131 echo 'Caught exception: ', $e->getMessage(), "\n";
137 <div style
="clear: both">
138 <a href
="http://dokuwiki.org/"><img src
="lib/tpl/dokuwiki/images/button-dw.png" alt
="driven by DokuWiki" /></a
>
139 <a href
="http://php.net"><img src
="lib/tpl/dokuwiki/images/button-php.gif" alt
="powered by PHP" /></a
>
146 * Print the input form
148 * @param array $d submitted entry 'd' of request data
150 function print_form($d)
155 include(DOKU_CONF
. 'license.php');
157 if (!is_array($d)) $d = [];
158 $d = array_map('hsc', $d);
160 if (!isset($d['acl'])) $d['acl'] = 1;
161 if (!isset($d['pop'])) $d['pop'] = 1;
164 <form action
="" method
="post">
165 <input type
="hidden" name
="l" value
="<?php echo $LC ?>" />
167 <label
for="title"><?php
echo $lang['i_wikiname']?
>
168 <input type
="text" name
="d[title]" id
="title" value
="<?php echo $d['title'] ?>" style
="width: 20em;" />
171 <fieldset style
="margin-top: 1em;">
173 <input type
="checkbox" name
="d[acl]" id
="acl" <?php
echo(($d['acl'] ?
' checked="checked"' : ''));?
> />
174 <?php
echo $lang['i_enableacl']?
></label
>
176 <fieldset id
="acldep">
177 <label
for="superuser"><?php
echo $lang['i_superuser']?
></label
>
178 <input
class="text" type
="text" name
="d[superuser]" id
="superuser"
179 value
="<?php echo $d['superuser'] ?>" />
181 <label
for="fullname"><?php
echo $lang['fullname']?
></label
>
182 <input
class="text" type
="text" name
="d[fullname]" id
="fullname"
183 value
="<?php echo $d['fullname'] ?>" />
185 <label
for="email"><?php
echo $lang['email']?
></label
>
186 <input
class="text" type
="text" name
="d[email]" id
="email" value
="<?php echo $d['email'] ?>" />
188 <label
for="password"><?php
echo $lang['pass']?
></label
>
189 <input
class="text" type
="password" name
="d[password]" id
="password" />
191 <label
for="confirm"><?php
echo $lang['passchk']?
></label
>
192 <input
class="text" type
="password" name
="d[confirm]" id
="confirm" />
194 <label
for="policy"><?php
echo $lang['i_policy']?
></label
>
195 <select
class="text" name
="d[policy]" id
="policy">
196 <option value
="0" <?php
echo ($d['policy'] == 0) ?
'selected="selected"' : '' ?
>><?php
197 echo $lang['i_pol0']?
></option
>
198 <option value
="1" <?php
echo ($d['policy'] == 1) ?
'selected="selected"' : '' ?
>><?php
199 echo $lang['i_pol1']?
></option
>
200 <option value
="2" <?php
echo ($d['policy'] == 2) ?
'selected="selected"' : '' ?
>><?php
201 echo $lang['i_pol2']?
></option
>
204 <label
for="allowreg">
205 <input type
="checkbox" name
="d[allowreg]" id
="allowreg" <?php
206 echo(($d['allowreg'] ?
' checked="checked"' : ''));?
> />
207 <?php
echo $lang['i_allowreg']?
>
213 <p
><?php
echo $lang['i_license']?
></p
>
215 $license[] = ['name' => $lang['i_license_none'], 'url' => ''];
216 if (empty($d['license'])) $d['license'] = 'cc-by-sa';
217 foreach ($license as $key => $lic) {
218 echo '<label for="lic_' . $key . '">';
219 echo '<input type="radio" name="d[license]" value="' . hsc($key) . '" id="lic_' . $key . '"' .
220 (($d['license'] === $key) ?
' checked="checked"' : '') . '>';
221 echo hsc($lic['name']);
222 if ($lic['url']) echo ' <a href="' . $lic['url'] . '" target="_blank"><sup>[?]</sup></a>';
229 <p
><?php
echo $lang['i_pop_field']?
></p
>
231 <input type
="checkbox" name
="d[pop]" id
="pop" <?php
232 echo(($d['pop'] ?
' checked="checked"' : ''));?
> />
233 <?php
echo $lang['i_pop_label']?
>
234 <a href
="http://www.dokuwiki.org/popularity" target
="_blank"><sup
>[?
]</sup
></a
>
239 <fieldset id
="process">
240 <button type
="submit" name
="submit"><?php
echo $lang['btn_save']?
></button
>
246 function print_retry()
251 <form action
="" method
="get">
253 <input type
="hidden" name
="l" value
="<?php echo $LC ?>" />
254 <button type
="submit"><?php
echo $lang['i_retry'];?
></button
>
261 * Check validity of data
263 * @author Andreas Gohr
268 function check_data(&$d)
270 static $form_default = [
280 'license' => 'cc-by-sa'
285 if (!is_array($d)) $d = [];
286 foreach ($d as $k => $v) {
289 else $d[$k] = (string)$v;
292 //autolowercase the username
293 $d['superuser'] = isset($d['superuser']) ?
strtolower($d['superuser']) : "";
297 if (isset($_REQUEST['submit'])) {
301 if (empty($d['title'])) {
302 $error[] = sprintf($lang['i_badval'], $lang['i_wikiname']);
305 if (isset($d['acl'])) {
306 if (empty($d['superuser']) ||
($d['superuser'] !== cleanID($d['superuser']))) {
307 $error[] = sprintf($lang['i_badval'], $lang['i_superuser']);
310 if (empty($d['password'])) {
311 $error[] = sprintf($lang['i_badval'], $lang['pass']);
313 } elseif (!isset($d['confirm']) ||
$d['confirm'] != $d['password']) {
314 $error[] = sprintf($lang['i_badval'], $lang['passchk']);
317 if (empty($d['fullname']) ||
strstr($d['fullname'], ':')) {
318 $error[] = sprintf($lang['i_badval'], $lang['fullname']);
321 if (empty($d['email']) ||
strstr($d['email'], ':') ||
!strstr($d['email'], '@')) {
322 $error[] = sprintf($lang['i_badval'], $lang['email']);
326 // Since default = 1, browser won't send acl=0 when user untick acl
330 $d = array_merge($form_default, $d);
335 * Writes the data to the config files
337 * @author Chris Smith <chris@jalakai.co.uk>
342 function store_data($d)
346 $d['policy'] = (int) $d['policy'];
353 * Dokuwiki's Main Configuration File - Local Settings
354 * Auto-generated by install script
359 // add any config options set by a previous installer
360 $preset = __DIR__
. '/install.conf';
361 if (file_exists($preset)) {
362 $output .= "# preset config options\n";
363 $output .= file_get_contents($preset);
365 $output .= "# options selected in installer\n";
369 $output .= '$conf[\'title\'] = \'' . addslashes($d['title']) . "';\n";
370 $output .= '$conf[\'lang\'] = \'' . addslashes($LC) . "';\n";
371 $output .= '$conf[\'license\'] = \'' . addslashes($d['license']) . "';\n";
373 $output .= '$conf[\'useacl\'] = 1' . ";\n";
374 $output .= "\$conf['superuser'] = '@admin';\n";
376 if (!$d['allowreg']) {
377 $output .= '$conf[\'disableactions\'] = \'register\'' . ";\n";
379 $ok = $ok && fileWrite(DOKU_LOCAL
. 'local.php', $output);
383 $phash = new PassHash();
384 $pass = $phash->hash_bcrypt($d['password']);
386 // create users.auth.php
390 # Don't modify the lines above
394 # Auto-generated by install script
398 # login:passwordhash:Real Name:email:groups,comma,separated
401 // --- user:bcryptpasswordhash:Real Name:email:groups,comma,seperated
402 $output = $output . "\n" . implode(':', [
409 $ok = $ok && fileWrite(DOKU_LOCAL
. 'users.auth.php', $output);
411 // create acl.auth.php
415 # Don't modify the lines above
417 # Access Control Lists
419 # Auto-generated by install script
423 if ($d['policy'] == 2) {
424 $output .= "* @ALL 0\n";
425 $output .= "* @user 8\n";
426 } elseif ($d['policy'] == 1) {
427 $output .= "* @ALL 1\n";
428 $output .= "* @user 8\n";
430 $output .= "* @ALL 8\n";
432 $ok = $ok && fileWrite(DOKU_LOCAL
. 'acl.auth.php', $output);
435 // enable popularity submission
436 if (isset($d['pop']) && $d['pop']) {
437 @touch
(DOKU_INC
. 'data/cache/autosubmit.txt');
440 // disable auth plugins til needed
444 * Local plugin enable/disable settings
446 * Auto-generated by install script
450 \$plugins['authad'] = 0;
451 \$plugins['authldap'] = 0;
452 \$plugins['authmysql'] = 0;
453 \$plugins['authpgsql'] = 0;
456 $ok = $ok && fileWrite(DOKU_LOCAL
. 'plugins.local.php', $output);
462 * Write the given content to a file
464 * @author Chris Smith <chris@jalakai.co.uk>
466 * @param string $filename
467 * @param string $data
470 function fileWrite($filename, $data)
475 if (($fp = @fopen
($filename, 'wb')) === false) {
476 $filename = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}/', $filename);
477 $error[] = sprintf($lang['i_writeerr'], $filename);
490 * check installation dependent local config files and tests for a known
491 * unmodified main config file
493 * @author Chris Smith <chris@jalakai.co.uk>
497 function check_configs()
505 'local' => DOKU_LOCAL
. 'local.php',
506 'users' => DOKU_LOCAL
. 'users.auth.php',
507 'auth' => DOKU_LOCAL
. 'acl.auth.php'
510 // configs shouldn't exist
511 foreach ($config_files as $file) {
512 if (file_exists($file) && filesize($file)) {
513 $file = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}/', $file);
514 $error[] = sprintf($lang['i_confexists'], $file);
523 * Check other installation dir/file permission requirements
525 * @author Chris Smith <chris@jalakai.co.uk>
529 function check_permissions()
535 'conf' => DOKU_LOCAL
,
536 'data' => DOKU_INC
. 'data',
537 'pages' => DOKU_INC
. 'data/pages',
538 'attic' => DOKU_INC
. 'data/attic',
539 'media' => DOKU_INC
. 'data/media',
540 'media_attic' => DOKU_INC
. 'data/media_attic',
541 'media_meta' => DOKU_INC
. 'data/media_meta',
542 'meta' => DOKU_INC
. 'data/meta',
543 'cache' => DOKU_INC
. 'data/cache',
544 'locks' => DOKU_INC
. 'data/locks',
545 'index' => DOKU_INC
. 'data/index',
546 'tmp' => DOKU_INC
. 'data/tmp'
550 foreach ($dirs as $dir) {
551 if (!file_exists("$dir/.") ||
!is_writable($dir)) {
552 $dir = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}', $dir);
553 $error[] = sprintf($lang['i_permfail'], $dir);
561 * Check the availability of functions used in DokuWiki and the PHP version
563 * @author Andreas Gohr <andi@splitbrain.org>
567 function check_functions()
573 if (version_compare(phpversion(), '7.4.0', '<')) {
574 $error[] = sprintf($lang['i_phpver'], phpversion(), '7.4.0');
578 if (ini_get('mbstring.func_overload') != 0) {
579 $error[] = $lang['i_mbfuncoverload'];
585 } catch (\Exception
$th) {
586 // If an appropriate source of randomness cannot be found, an Exception will be thrown by PHP 7+
587 $error[] = $lang['i_urandom'];
591 if (ini_get('mbstring.func_overload') != 0) {
592 $error[] = $lang['i_mbfuncoverload'];
596 $funcs = explode(' ', 'addslashes call_user_func chmod copy fgets ' .
597 'file file_exists fseek flush filesize ftell fopen ' .
598 'glob header ignore_user_abort ini_get mkdir ' .
599 'ob_start opendir parse_ini_file readfile realpath ' .
600 'rename rmdir serialize session_start unlink usleep ' .
601 'preg_replace file_get_contents htmlspecialchars_decode ' .
602 'spl_autoload_register stream_select fsockopen pack xml_parser_create');
604 if (!function_exists('mb_substr')) {
605 $funcs[] = 'utf8_encode';
606 $funcs[] = 'utf8_decode';
609 if (!function_exists('mail')) {
610 if (strpos(ini_get('disable_functions'), 'mail') !== false) {
611 $disabled = $lang['i_disabled'];
615 $error[] = sprintf($lang['i_funcnmail'], $disabled);
618 foreach ($funcs as $func) {
619 if (!function_exists($func)) {
620 $error[] = sprintf($lang['i_funcna'], $func);
628 * Print language selection
630 * @author Andreas Gohr <andi@splitbrain.org>
637 $dir = DOKU_INC
. 'inc/lang';
642 while (($file = readdir($dh)) !== false) {
643 if (preg_match('/^[\._]/', $file)) continue;
644 if (is_dir($dir . '/' . $file) && file_exists($dir . '/' . $file . '/lang.php')) {
651 echo '<form action="">';
652 echo $lang['i_chooselang'];
653 echo ': <select name="l" onchange="submit()">';
654 foreach ($langs as $l) {
655 $sel = ($l == $LC) ?
'selected="selected"' : '';
656 echo '<option value="' . $l . '" ' . $sel . '>' . $l . '</option>';
659 echo '<button type="submit">' . $lang['btn_update'] . '</button>';
664 * Print global error array
666 * @author Andreas Gohr <andi@splitbrain.org>
668 function print_errors()
671 if (!empty($error)) {
673 foreach ($error as $err) {
674 echo "<li>$err</li>";