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
>
49 <style type
="text/css">
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
}
59 <script type
="text/javascript">
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');
98 <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;
99 display: block; width:380px; height:73px; border:none; clear:both;"
101 href
="http://www.dokuwiki.org/security#web_access_security"></a
>
104 <div style
="float: left; width: 58%;">
107 if(! (check_functions() && check_permissions()) ){
108 echo '<p>'.$lang['i_problems'].'</p>';
111 }elseif(!check_configs()){
112 echo '<p>'.$lang['i_modified'].'</p>';
114 }elseif(check_data($_REQUEST['d'])){
115 // check_data has sanitized all input parameters
116 if(!store_data($_REQUEST['d'])){
117 echo '<p>'.$lang['i_failure'].'</p>';
120 echo '<p>'.$lang['i_success'].'</p>';
124 print_form($_REQUEST['d']);
126 } catch (Exception
$e) {
127 echo 'Caught exception: ', $e->getMessage(), "\n";
133 <div style
="clear: both">
134 <a href
="http://dokuwiki.org/"><img src
="lib/tpl/dokuwiki/images/button-dw.png" alt
="driven by DokuWiki" /></a
>
135 <a href
="http://php.net"><img src
="lib/tpl/dokuwiki/images/button-php.gif" alt
="powered by PHP" /></a
>
142 * Print the input form
144 * @param array $d submitted entry 'd' of request data
146 function print_form($d){
150 include(DOKU_CONF
.'license.php');
152 if(!is_array($d)) $d = array();
153 $d = array_map('hsc',$d);
155 if(!isset($d['acl'])) $d['acl']=1;
156 if(!isset($d['pop'])) $d['pop']=1;
159 <form action
="" method
="post">
160 <input type
="hidden" name
="l" value
="<?php echo $LC ?>" />
162 <label
for="title"><?php
echo $lang['i_wikiname']?
>
163 <input type
="text" name
="d[title]" id
="title" value
="<?php echo $d['title'] ?>" style
="width: 20em;" />
166 <fieldset style
="margin-top: 1em;">
168 <input type
="checkbox" name
="d[acl]" id
="acl" <?php
echo(($d['acl'] ?
' checked="checked"' : ''));?
> />
169 <?php
echo $lang['i_enableacl']?
></label
>
171 <fieldset id
="acldep">
172 <label
for="superuser"><?php
echo $lang['i_superuser']?
></label
>
173 <input
class="text" type
="text" name
="d[superuser]" id
="superuser" value
="<?php echo $d['superuser'] ?>" />
175 <label
for="fullname"><?php
echo $lang['fullname']?
></label
>
176 <input
class="text" type
="text" name
="d[fullname]" id
="fullname" value
="<?php echo $d['fullname'] ?>" />
178 <label
for="email"><?php
echo $lang['email']?
></label
>
179 <input
class="text" type
="text" name
="d[email]" id
="email" value
="<?php echo $d['email'] ?>" />
181 <label
for="password"><?php
echo $lang['pass']?
></label
>
182 <input
class="text" type
="password" name
="d[password]" id
="password" />
184 <label
for="confirm"><?php
echo $lang['passchk']?
></label
>
185 <input
class="text" type
="password" name
="d[confirm]" id
="confirm" />
187 <label
for="policy"><?php
echo $lang['i_policy']?
></label
>
188 <select
class="text" name
="d[policy]" id
="policy">
189 <option value
="0" <?php
echo ($d['policy'] == 0)?
'selected="selected"':'' ?
>><?php
echo $lang['i_pol0']?
></option
>
190 <option value
="1" <?php
echo ($d['policy'] == 1)?
'selected="selected"':'' ?
>><?php
echo $lang['i_pol1']?
></option
>
191 <option value
="2" <?php
echo ($d['policy'] == 2)?
'selected="selected"':'' ?
>><?php
echo $lang['i_pol2']?
></option
>
194 <label
for="allowreg">
195 <input type
="checkbox" name
="d[allowreg]" id
="allowreg" <?php
echo(($d['allowreg'] ?
' checked="checked"' : ''));?
> />
196 <?php
echo $lang['i_allowreg']?
>
202 <p
><?php
echo $lang['i_license']?
></p
>
204 array_push($license,array('name' => $lang['i_license_none'], 'url'=>''));
205 if(empty($d['license'])) $d['license'] = 'cc-by-sa';
206 foreach($license as $key => $lic){
207 echo '<label for="lic_'.$key.'">';
208 echo '<input type="radio" name="d[license]" value="'.hsc($key).'" id="lic_'.$key.'"'.
209 (($d['license'] === $key)?
' checked="checked"':'').'>';
210 echo hsc($lic['name']);
211 if($lic['url']) echo ' <a href="'.$lic['url'].'" target="_blank"><sup>[?]</sup></a>';
218 <p
><?php
echo $lang['i_pop_field']?
></p
>
220 <input type
="checkbox" name
="d[pop]" id
="pop" <?php
echo(($d['pop'] ?
' checked="checked"' : ''));?
> />
221 <?php
echo $lang['i_pop_label']?
> <a href
="http://www.dokuwiki.org/popularity" target
="_blank"><sup
>[?
]</sup
></a
>
226 <fieldset id
="process">
227 <button type
="submit" name
="submit"><?php
echo $lang['btn_save']?
></button
>
233 function print_retry() {
237 <form action
="" method
="get">
239 <input type
="hidden" name
="l" value
="<?php echo $LC ?>" />
240 <button type
="submit"><?php
echo $lang['i_retry'];?
></button
>
247 * Check validity of data
249 * @author Andreas Gohr
254 function check_data(&$d){
255 static $form_default = array(
265 'license' => 'cc-by-sa'
270 if(!is_array($d)) $d = array();
271 foreach($d as $k => $v) {
278 //autolowercase the username
279 $d['superuser'] = isset($d['superuser']) ?
strtolower($d['superuser']) : "";
283 if(isset($_REQUEST['submit'])) {
287 if(empty($d['title'])){
288 $error[] = sprintf($lang['i_badval'],$lang['i_wikiname']);
291 if(isset($d['acl'])){
292 if(!preg_match('/^[a-z0-9_]+$/',$d['superuser'])){
293 $error[] = sprintf($lang['i_badval'],$lang['i_superuser']);
296 if(empty($d['password'])){
297 $error[] = sprintf($lang['i_badval'],$lang['pass']);
300 elseif(!isset($d['confirm']) ||
$d['confirm'] != $d['password']){
301 $error[] = sprintf($lang['i_badval'],$lang['passchk']);
304 if(empty($d['fullname']) ||
strstr($d['fullname'],':')){
305 $error[] = sprintf($lang['i_badval'],$lang['fullname']);
308 if(empty($d['email']) ||
strstr($d['email'],':') ||
!strstr($d['email'],'@')){
309 $error[] = sprintf($lang['i_badval'],$lang['email']);
314 $d = array_merge($form_default, $d);
319 * Writes the data to the config files
321 * @author Chris Smith <chris@jalakai.co.uk>
326 function store_data($d){
329 $d['policy'] = (int) $d['policy'];
336 * Dokuwiki's Main Configuration File - Local Settings
337 * Auto-generated by install script
342 // add any config options set by a previous installer
343 $preset = __DIR__
.'/install.conf';
344 if(file_exists($preset)){
345 $output .= "# preset config options\n";
346 $output .= file_get_contents($preset);
348 $output .= "# options selected in installer\n";
352 $output .= '$conf[\'title\'] = \''.addslashes($d['title'])."';\n";
353 $output .= '$conf[\'lang\'] = \''.addslashes($LC)."';\n";
354 $output .= '$conf[\'license\'] = \''.addslashes($d['license'])."';\n";
356 $output .= '$conf[\'useacl\'] = 1'.";\n";
357 $output .= "\$conf['superuser'] = '@admin';\n";
360 $output .= '$conf[\'disableactions\'] = \'register\''.";\n";
362 $ok = $ok && fileWrite(DOKU_LOCAL
.'local.php',$output);
366 $phash = new PassHash();
367 $pass = $phash->hash_smd5($d['password']);
369 // create users.auth.php
370 // --- user:SMD5password:Real Name:email:groups,comma,seperated
371 $output = join(":",array($d['superuser'], $pass, $d['fullname'], $d['email'], 'admin,user'));
372 $output = @file_get_contents
(DOKU_CONF
.'users.auth.php.dist')."\n$output\n";
373 $ok = $ok && fileWrite(DOKU_LOCAL
.'users.auth.php', $output);
375 // create acl.auth.php
379 # Don't modify the lines above
381 # Access Control Lists
383 # Auto-generated by install script
387 if($d['policy'] == 2){
388 $output .= "* @ALL 0\n";
389 $output .= "* @user 8\n";
390 }elseif($d['policy'] == 1){
391 $output .= "* @ALL 1\n";
392 $output .= "* @user 8\n";
394 $output .= "* @ALL 8\n";
396 $ok = $ok && fileWrite(DOKU_LOCAL
.'acl.auth.php', $output);
399 // enable popularity submission
401 @touch
(DOKU_INC
.'data/cache/autosubmit.txt');
404 // disable auth plugins til needed
408 * Local plugin enable/disable settings
410 * Auto-generated by install script
414 \$plugins['authad'] = 0;
415 \$plugins['authldap'] = 0;
416 \$plugins['authmysql'] = 0;
417 \$plugins['authpgsql'] = 0;
420 $ok = $ok && fileWrite(DOKU_LOCAL
.'plugins.local.php', $output);
426 * Write the given content to a file
428 * @author Chris Smith <chris@jalakai.co.uk>
430 * @param string $filename
431 * @param string $data
434 function fileWrite($filename, $data) {
438 if (($fp = @fopen
($filename, 'wb')) === false) {
439 $filename = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $filename);
440 $error[] = sprintf($lang['i_writeerr'],$filename);
444 if (!empty($data)) { fwrite($fp, $data); }
451 * check installation dependent local config files and tests for a known
452 * unmodified main config file
454 * @author Chris Smith <chris@jalakai.co.uk>
458 function check_configs(){
464 $config_files = array(
465 'local' => DOKU_LOCAL
.'local.php',
466 'users' => DOKU_LOCAL
.'users.auth.php',
467 'auth' => DOKU_LOCAL
.'acl.auth.php'
470 // configs shouldn't exist
471 foreach ($config_files as $file) {
472 if (file_exists($file) && filesize($file)) {
473 $file = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $file);
474 $error[] = sprintf($lang['i_confexists'],$file);
483 * Check other installation dir/file permission requirements
485 * @author Chris Smith <chris@jalakai.co.uk>
489 function check_permissions(){
494 'conf' => DOKU_LOCAL
,
495 'data' => DOKU_INC
.'data',
496 'pages' => DOKU_INC
.'data/pages',
497 'attic' => DOKU_INC
.'data/attic',
498 'media' => DOKU_INC
.'data/media',
499 'media_attic' => DOKU_INC
.'data/media_attic',
500 'media_meta' => DOKU_INC
.'data/media_meta',
501 'meta' => DOKU_INC
.'data/meta',
502 'cache' => DOKU_INC
.'data/cache',
503 'locks' => DOKU_INC
.'data/locks',
504 'index' => DOKU_INC
.'data/index',
505 'tmp' => DOKU_INC
.'data/tmp'
509 foreach($dirs as $dir){
510 if(!file_exists("$dir/.") ||
!is_writable($dir)){
511 $dir = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}', $dir);
512 $error[] = sprintf($lang['i_permfail'],$dir);
520 * Check the availability of functions used in DokuWiki and the PHP version
522 * @author Andreas Gohr <andi@splitbrain.org>
526 function check_functions(){
531 if(version_compare(phpversion(),'5.6.0','<')){
532 $error[] = sprintf($lang['i_phpver'],phpversion(),'5.6.0');
536 if(ini_get('mbstring.func_overload') != 0){
537 $error[] = $lang['i_mbfuncoverload'];
541 $funcs = explode(' ','addslashes call_user_func chmod copy fgets '.
542 'file file_exists fseek flush filesize ftell fopen '.
543 'glob header ignore_user_abort ini_get mail mkdir '.
544 'ob_start opendir parse_ini_file readfile realpath '.
545 'rename rmdir serialize session_start unlink usleep '.
546 'preg_replace file_get_contents htmlspecialchars_decode '.
547 'spl_autoload_register stream_select fsockopen pack');
549 if (!function_exists('mb_substr')) {
550 $funcs[] = 'utf8_encode';
551 $funcs[] = 'utf8_decode';
554 foreach($funcs as $func){
555 if(!function_exists($func)){
556 $error[] = sprintf($lang['i_funcna'],$func);
564 * Print language selection
566 * @author Andreas Gohr <andi@splitbrain.org>
572 $dir = DOKU_INC
.'inc/lang';
577 while (($file = readdir($dh)) !== false) {
578 if(preg_match('/^[\._]/',$file)) continue;
579 if(is_dir($dir.'/'.$file) && file_exists($dir.'/'.$file.'/lang.php')){
586 echo '<form action="">';
587 echo $lang['i_chooselang'];
588 echo ': <select name="l" onchange="submit()">';
589 foreach($langs as $l){
590 $sel = ($l == $LC) ?
'selected="selected"' : '';
591 echo '<option value="'.$l.'" '.$sel.'>'.$l.'</option>';
594 echo '<button type="submit">'.$lang['btn_update'].'</button>';
599 * Print global error array
601 * @author Andreas Gohr <andi@splitbrain.org>
603 function print_errors(){
607 foreach ($error as $err){
608 echo "<li>$err</li>";