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 * Dokuwiki installation assistance
14 * @author Chris Smith <chris@jalakai.co.uk>
17 if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__
).'/');
18 if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC
.'conf/');
19 if(!defined('DOKU_LOCAL')) define('DOKU_LOCAL',DOKU_INC
.'conf/');
21 // load and initialize the core system
22 require_once(DOKU_INC
.'inc/init.php');
24 // check for error reporting override or set error reporting to sane values
25 if (!defined('DOKU_E_LEVEL')) { error_reporting(E_ALL ^ E_NOTICE
); }
26 else { error_reporting(DOKU_E_LEVEL
); }
29 require_once(DOKU_INC
.'inc/lang/en/lang.php');
30 if(isset($_REQUEST['l']) && !is_array($_REQUEST['l'])) {
31 $LC = preg_replace('/[^a-z\-]+/','',$_REQUEST['l']);
33 if(empty($LC)) $LC = 'en';
34 if($LC && $LC != 'en' ) {
35 require_once(DOKU_INC
.'inc/lang/'.$LC.'/lang.php');
38 // initialise variables ...
42 header('Content-Type: text/html; charset=utf-8');
45 <html lang
="<?php echo $LC?>" dir
="<?php echo $lang['direction']?>">
47 <meta charset
="utf-8" />
48 <title
><?php
echo $lang['i_installer']?
></title
>
50 body
{ width
: 90%
; margin
: 0 auto
; font
: 84% Verdana
, Helvetica
, Arial
, sans
-serif
; }
53 code
{ font
-size
: 110%
; color
: #800000; }
54 fieldset
{ border
: none
}
55 label
{ display
: block
; margin
-top
: 0.5em
; }
56 select
.text
, input
.text
{ width
: 30em
; margin
: 0 0.5em
; }
57 a
{text
-decoration
: none
}
61 var cb
= document
.getElementById('acl');
62 var fs
= document
.getElementById('acldep');
63 if(!cb ||
!fs
) return;
65 fs
.style
.display
= '';
67 fs
.style
.display
= 'none';
70 window
.onload
= function(){
72 var cb
= document
.getElementById('acl');
73 if(cb
) cb
.onchange
= acltoggle
;
78 <h1 style
="float:left">
79 <img src
="lib/exe/fetch.php?media=wiki:dokuwiki-128.png"
80 style
="vertical-align: middle;" alt
="" height
="64" width
="64" />
81 <?php
echo $lang['i_installer']?
>
83 <div style
="float:right; margin: 1em;">
88 <div style
="float: right; width: 34%;">
90 if(file_exists(DOKU_INC
.'inc/lang/'.$LC.'/install.html')){
91 include(DOKU_INC
.'inc/lang/'.$LC.'/install.html');
93 print "<div lang=\"en\" dir=\"ltr\">\n";
94 include(DOKU_INC
.'inc/lang/en/install.html');
99 background: transparent
100 url(data/dont-panic-if-you-see-this-in-your-logs-it-means-your-directory-permissions-are-correct.png)
102 display: block; width:380px; height:73px; border:none; clear:both;"
104 href
="http://www.dokuwiki.org/security#web_access_security"></a
>
107 <div style
="float: left; width: 58%;">
110 if(! (check_functions() && check_permissions()) ){
111 echo '<p>'.$lang['i_problems'].'</p>';
114 }elseif(!check_configs()){
115 echo '<p>'.$lang['i_modified'].'</p>';
117 }elseif(check_data($_REQUEST['d'])){
118 // check_data has sanitized all input parameters
119 if(!store_data($_REQUEST['d'])){
120 echo '<p>'.$lang['i_failure'].'</p>';
123 echo '<p>'.$lang['i_success'].'</p>';
127 print_form($_REQUEST['d']);
129 } catch (Exception
$e) {
130 echo 'Caught exception: ', $e->getMessage(), "\n";
136 <div style
="clear: both">
137 <a href
="http://dokuwiki.org/"><img src
="lib/tpl/dokuwiki/images/button-dw.png" alt
="driven by DokuWiki" /></a
>
138 <a href
="http://php.net"><img src
="lib/tpl/dokuwiki/images/button-php.gif" alt
="powered by PHP" /></a
>
145 * Print the input form
147 * @param array $d submitted entry 'd' of request data
149 function print_form($d){
153 include(DOKU_CONF
.'license.php');
155 if(!is_array($d)) $d = array();
156 $d = array_map('hsc',$d);
158 if(!isset($d['acl'])) $d['acl']=1;
159 if(!isset($d['pop'])) $d['pop']=1;
162 <form action
="" method
="post">
163 <input type
="hidden" name
="l" value
="<?php echo $LC ?>" />
165 <label
for="title"><?php
echo $lang['i_wikiname']?
>
166 <input type
="text" name
="d[title]" id
="title" value
="<?php echo $d['title'] ?>" style
="width: 20em;" />
169 <fieldset style
="margin-top: 1em;">
171 <input type
="checkbox" name
="d[acl]" id
="acl" <?php
echo(($d['acl'] ?
' checked="checked"' : ''));?
> />
172 <?php
echo $lang['i_enableacl']?
></label
>
174 <fieldset id
="acldep">
175 <label
for="superuser"><?php
echo $lang['i_superuser']?
></label
>
176 <input
class="text" type
="text" name
="d[superuser]" id
="superuser"
177 value
="<?php echo $d['superuser'] ?>" />
179 <label
for="fullname"><?php
echo $lang['fullname']?
></label
>
180 <input
class="text" type
="text" name
="d[fullname]" id
="fullname"
181 value
="<?php echo $d['fullname'] ?>" />
183 <label
for="email"><?php
echo $lang['email']?
></label
>
184 <input
class="text" type
="text" name
="d[email]" id
="email" value
="<?php echo $d['email'] ?>" />
186 <label
for="password"><?php
echo $lang['pass']?
></label
>
187 <input
class="text" type
="password" name
="d[password]" id
="password" />
189 <label
for="confirm"><?php
echo $lang['passchk']?
></label
>
190 <input
class="text" type
="password" name
="d[confirm]" id
="confirm" />
192 <label
for="policy"><?php
echo $lang['i_policy']?
></label
>
193 <select
class="text" name
="d[policy]" id
="policy">
194 <option value
="0" <?php
echo ($d['policy'] == 0)?
'selected="selected"':'' ?
>><?php
195 echo $lang['i_pol0']?
></option
>
196 <option value
="1" <?php
echo ($d['policy'] == 1)?
'selected="selected"':'' ?
>><?php
197 echo $lang['i_pol1']?
></option
>
198 <option value
="2" <?php
echo ($d['policy'] == 2)?
'selected="selected"':'' ?
>><?php
199 echo $lang['i_pol2']?
></option
>
202 <label
for="allowreg">
203 <input type
="checkbox" name
="d[allowreg]" id
="allowreg" <?php
204 echo(($d['allowreg'] ?
' checked="checked"' : ''));?
> />
205 <?php
echo $lang['i_allowreg']?
>
211 <p
><?php
echo $lang['i_license']?
></p
>
213 array_push($license,array('name' => $lang['i_license_none'], 'url'=>''));
214 if(empty($d['license'])) $d['license'] = 'cc-by-sa';
215 foreach($license as $key => $lic){
216 echo '<label for="lic_'.$key.'">';
217 echo '<input type="radio" name="d[license]" value="'.hsc($key).'" id="lic_'.$key.'"'.
218 (($d['license'] === $key)?
' checked="checked"':'').'>';
219 echo hsc($lic['name']);
220 if($lic['url']) echo ' <a href="'.$lic['url'].'" target="_blank"><sup>[?]</sup></a>';
227 <p
><?php
echo $lang['i_pop_field']?
></p
>
229 <input type
="checkbox" name
="d[pop]" id
="pop" <?php
230 echo(($d['pop'] ?
' checked="checked"' : ''));?
> />
231 <?php
echo $lang['i_pop_label']?
>
232 <a href
="http://www.dokuwiki.org/popularity" target
="_blank"><sup
>[?
]</sup
></a
>
237 <fieldset id
="process">
238 <button type
="submit" name
="submit"><?php
echo $lang['btn_save']?
></button
>
244 function print_retry() {
248 <form action
="" method
="get">
250 <input type
="hidden" name
="l" value
="<?php echo $LC ?>" />
251 <button type
="submit"><?php
echo $lang['i_retry'];?
></button
>
258 * Check validity of data
260 * @author Andreas Gohr
265 function check_data(&$d){
266 static $form_default = array(
276 'license' => 'cc-by-sa'
281 if(!is_array($d)) $d = array();
282 foreach($d as $k => $v) {
289 //autolowercase the username
290 $d['superuser'] = isset($d['superuser']) ?
strtolower($d['superuser']) : "";
294 if(isset($_REQUEST['submit'])) {
298 if(empty($d['title'])){
299 $error[] = sprintf($lang['i_badval'],$lang['i_wikiname']);
302 if(isset($d['acl'])){
303 if(!preg_match('/^[a-z0-9_]+$/',$d['superuser'])){
304 $error[] = sprintf($lang['i_badval'],$lang['i_superuser']);
307 if(empty($d['password'])){
308 $error[] = sprintf($lang['i_badval'],$lang['pass']);
311 elseif(!isset($d['confirm']) ||
$d['confirm'] != $d['password']){
312 $error[] = sprintf($lang['i_badval'],$lang['passchk']);
315 if(empty($d['fullname']) ||
strstr($d['fullname'],':')){
316 $error[] = sprintf($lang['i_badval'],$lang['fullname']);
319 if(empty($d['email']) ||
strstr($d['email'],':') ||
!strstr($d['email'],'@')){
320 $error[] = sprintf($lang['i_badval'],$lang['email']);
324 // Since default = 1, browser won't send acl=0 when user untick acl
328 $d = array_merge($form_default, $d);
333 * Writes the data to the config files
335 * @author Chris Smith <chris@jalakai.co.uk>
340 function store_data($d){
343 $d['policy'] = (int) $d['policy'];
350 * Dokuwiki's Main Configuration File - Local Settings
351 * Auto-generated by install script
356 // add any config options set by a previous installer
357 $preset = __DIR__
.'/install.conf';
358 if(file_exists($preset)){
359 $output .= "# preset config options\n";
360 $output .= file_get_contents($preset);
362 $output .= "# options selected in installer\n";
366 $output .= '$conf[\'title\'] = \''.addslashes($d['title'])."';\n";
367 $output .= '$conf[\'lang\'] = \''.addslashes($LC)."';\n";
368 $output .= '$conf[\'license\'] = \''.addslashes($d['license'])."';\n";
370 $output .= '$conf[\'useacl\'] = 1'.";\n";
371 $output .= "\$conf['superuser'] = '@admin';\n";
374 $output .= '$conf[\'disableactions\'] = \'register\''.";\n";
376 $ok = $ok && fileWrite(DOKU_LOCAL
.'local.php',$output);
380 $phash = new \dokuwiki\
PassHash();
381 $pass = $phash->hash_bcrypt($d['password']);
383 // create users.auth.php
387 # Don't modify the lines above
391 # Auto-generated by install script
395 # login:passwordhash:Real Name:email:groups,comma,separated
398 // --- user:bcryptpasswordhash:Real Name:email:groups,comma,seperated
399 $output = $output."\n".join(":",array($d['superuser'], $pass, $d['fullname'], $d['email'], 'admin,user'))."\n";
400 $ok = $ok && fileWrite(DOKU_LOCAL
.'users.auth.php', $output);
402 // create acl.auth.php
406 # Don't modify the lines above
408 # Access Control Lists
410 # Auto-generated by install script
414 if($d['policy'] == 2){
415 $output .= "* @ALL 0\n";
416 $output .= "* @user 8\n";
417 }elseif($d['policy'] == 1){
418 $output .= "* @ALL 1\n";
419 $output .= "* @user 8\n";
421 $output .= "* @ALL 8\n";
423 $ok = $ok && fileWrite(DOKU_LOCAL
.'acl.auth.php', $output);
426 // enable popularity submission
428 @touch
(DOKU_INC
.'data/cache/autosubmit.txt');
431 // disable auth plugins til needed
435 * Local plugin enable/disable settings
437 * Auto-generated by install script
441 \$plugins['authad'] = 0;
442 \$plugins['authldap'] = 0;
443 \$plugins['authmysql'] = 0;
444 \$plugins['authpgsql'] = 0;
447 $ok = $ok && fileWrite(DOKU_LOCAL
.'plugins.local.php', $output);
453 * Write the given content to a file
455 * @author Chris Smith <chris@jalakai.co.uk>
457 * @param string $filename
458 * @param string $data
461 function fileWrite($filename, $data) {
465 if (($fp = @fopen
($filename, 'wb')) === false) {
466 $filename = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $filename);
467 $error[] = sprintf($lang['i_writeerr'],$filename);
471 if (!empty($data)) { fwrite($fp, $data); }
478 * check installation dependent local config files and tests for a known
479 * unmodified main config file
481 * @author Chris Smith <chris@jalakai.co.uk>
485 function check_configs(){
491 $config_files = array(
492 'local' => DOKU_LOCAL
.'local.php',
493 'users' => DOKU_LOCAL
.'users.auth.php',
494 'auth' => DOKU_LOCAL
.'acl.auth.php'
497 // configs shouldn't exist
498 foreach ($config_files as $file) {
499 if (file_exists($file) && filesize($file)) {
500 $file = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $file);
501 $error[] = sprintf($lang['i_confexists'],$file);
510 * Check other installation dir/file permission requirements
512 * @author Chris Smith <chris@jalakai.co.uk>
516 function check_permissions(){
521 'conf' => DOKU_LOCAL
,
522 'data' => DOKU_INC
.'data',
523 'pages' => DOKU_INC
.'data/pages',
524 'attic' => DOKU_INC
.'data/attic',
525 'media' => DOKU_INC
.'data/media',
526 'media_attic' => DOKU_INC
.'data/media_attic',
527 'media_meta' => DOKU_INC
.'data/media_meta',
528 'meta' => DOKU_INC
.'data/meta',
529 'cache' => DOKU_INC
.'data/cache',
530 'locks' => DOKU_INC
.'data/locks',
531 'index' => DOKU_INC
.'data/index',
532 'tmp' => DOKU_INC
.'data/tmp'
536 foreach($dirs as $dir){
537 if(!file_exists("$dir/.") ||
!is_writable($dir)){
538 $dir = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}', $dir);
539 $error[] = sprintf($lang['i_permfail'],$dir);
547 * Check the availability of functions used in DokuWiki and the PHP version
549 * @author Andreas Gohr <andi@splitbrain.org>
553 function check_functions(){
558 if(version_compare(phpversion(),'5.6.0','<')){
559 $error[] = sprintf($lang['i_phpver'],phpversion(),'5.6.0');
563 if(ini_get('mbstring.func_overload') != 0){
564 $error[] = $lang['i_mbfuncoverload'];
570 } catch (\Exception
$th) {
571 // If an appropriate source of randomness cannot be found, an Exception will be thrown by PHP 7+
572 // this exception is also thrown by paragonie/random_compat for PHP 5.6 support
573 $error[] = $lang['i_urandom'];
577 if(ini_get('mbstring.func_overload') != 0){
578 $error[] = $lang['i_mbfuncoverload'];
582 $funcs = explode(' ','addslashes call_user_func chmod copy fgets '.
583 'file file_exists fseek flush filesize ftell fopen '.
584 'glob header ignore_user_abort ini_get mkdir '.
585 'ob_start opendir parse_ini_file readfile realpath '.
586 'rename rmdir serialize session_start unlink usleep '.
587 'preg_replace file_get_contents htmlspecialchars_decode '.
588 'spl_autoload_register stream_select fsockopen pack xml_parser_create');
590 if (!function_exists('mb_substr')) {
591 $funcs[] = 'utf8_encode';
592 $funcs[] = 'utf8_decode';
595 if(!function_exists('mail')){
596 if(strpos(ini_get('disable_functions'),'mail') !== false) {
597 $disabled = $lang['i_disabled'];
602 $error[] = sprintf($lang['i_funcnmail'],$disabled);
605 foreach($funcs as $func){
606 if(!function_exists($func)){
607 $error[] = sprintf($lang['i_funcna'],$func);
615 * Print language selection
617 * @author Andreas Gohr <andi@splitbrain.org>
623 $dir = DOKU_INC
.'inc/lang';
628 while (($file = readdir($dh)) !== false) {
629 if(preg_match('/^[\._]/',$file)) continue;
630 if(is_dir($dir.'/'.$file) && file_exists($dir.'/'.$file.'/lang.php')){
637 echo '<form action="">';
638 echo $lang['i_chooselang'];
639 echo ': <select name="l" onchange="submit()">';
640 foreach($langs as $l){
641 $sel = ($l == $LC) ?
'selected="selected"' : '';
642 echo '<option value="'.$l.'" '.$sel.'>'.$l.'</option>';
645 echo '<button type="submit">'.$lang['btn_update'].'</button>';
650 * Print global error array
652 * @author Andreas Gohr <andi@splitbrain.org>
654 function print_errors(){
658 foreach ($error as $err){
659 echo "<li>$err</li>";