2006-07-24 20:54:04 +02:00
< ? php
2018-02-14 14:09:08 +01:00
/*>< div style = " width:60%; margin: auto; background-color: #fcc;
border : 1 px 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 >*/
2006-07-24 20:54:04 +02:00
/**
2009-10-20 23:23:38 +02:00
* Dokuwiki installation assistance
2006-07-24 20:54:04 +02:00
*
2009-10-20 23:23:38 +02:00
* @ author Chris Smith < chris @ jalakai . co . uk >
2006-07-24 20:54:04 +02:00
*/
2007-09-30 22:11:33 +02:00
if ( ! defined ( 'DOKU_INC' )) define ( 'DOKU_INC' , dirname ( __FILE__ ) . '/' );
2006-07-24 20:54:04 +02:00
if ( ! defined ( 'DOKU_CONF' )) define ( 'DOKU_CONF' , DOKU_INC . 'conf/' );
if ( ! defined ( 'DOKU_LOCAL' )) define ( 'DOKU_LOCAL' , DOKU_INC . 'conf/' );
2017-02-20 08:51:31 +01:00
// load and initialize the core system
require_once ( DOKU_INC . 'inc/init.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
if ( ! defined ( 'DOKU_E_LEVEL' )) { error_reporting ( E_ALL ^ E_NOTICE ); }
else { error_reporting ( DOKU_E_LEVEL ); }
2006-07-24 20:54:04 +02:00
// language strings
2006-07-26 22:10:47 +02:00
require_once ( DOKU_INC . 'inc/lang/en/lang.php' );
2012-06-25 00:24:07 +02:00
if ( isset ( $_REQUEST [ 'l' ]) && ! is_array ( $_REQUEST [ 'l' ])) {
$LC = preg_replace ( '/[^a-z\-]+/' , '' , $_REQUEST [ 'l' ]);
}
if ( empty ( $LC )) $LC = 'en' ;
2006-07-26 22:10:47 +02:00
if ( $LC && $LC != 'en' ) {
require_once ( DOKU_INC . 'inc/lang/' . $LC . '/lang.php' );
}
2006-07-24 20:54:04 +02:00
// initialise variables ...
$error = array ();
2006-07-26 22:10:47 +02:00
// begin output
header ( 'Content-Type: text/html; charset=utf-8' );
?>
2012-07-14 13:10:08 +02:00
<! DOCTYPE html >
< html lang = " <?php echo $LC ?> " dir = " <?php echo $lang['direction'] ?> " >
2006-07-26 22:10:47 +02:00
< head >
2012-07-14 13:10:08 +02:00
< meta charset = " utf-8 " />
2006-08-02 20:04:43 +02:00
< title >< ? php echo $lang [ 'i_installer' ] ?> </title>
2006-07-26 22:10:47 +02:00
< style type = " text/css " >
body { width : 90 % ; margin : 0 auto ; font : 84 % Verdana , Helvetica , Arial , sans - serif ; }
img { border : none }
br . cl { clear : both ; }
2006-09-30 19:01:21 +02:00
code { font - size : 110 % ; color : #800000; }
2006-07-26 22:10:47 +02:00
fieldset { border : none }
2006-07-29 01:29:30 +02:00
label { display : block ; margin - top : 0.5 em ; }
2006-07-28 11:36:53 +02:00
select . text , input . text { width : 30 em ; margin : 0 0.5 em ; }
2010-06-26 15:59:59 +02:00
a { text - decoration : none }
2006-07-26 22:10:47 +02:00
</ style >
2012-07-05 23:58:24 +02:00
< script type = " text/javascript " >
2006-07-26 22:10:47 +02:00
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 = " " >
< h1 style = " float:left " >
2013-04-19 09:35:02 +02:00
< img src = " lib/exe/fetch.php?media=wiki:dokuwiki-128.png "
style = " vertical-align: middle; " alt = " " height = " 64 " width = " 64 " />
2006-07-26 22:10:47 +02:00
< ? php echo $lang [ 'i_installer' ] ?>
</ h1 >
< div style = " float:right; margin: 1em; " >
< ? php langsel () ?>
</ div >
< br class = " cl " />
< div style = " float: right; width: 34%; " >
< ? php
2015-01-07 10:47:45 +01:00
if ( file_exists ( DOKU_INC . 'inc/lang/' . $LC . '/install.html' )){
2006-07-26 22:10:47 +02:00
include ( DOKU_INC . 'inc/lang/' . $LC . '/install.html' );
} else {
2006-07-28 11:39:13 +02:00
print " <div lang= \" en \" dir= \" ltr \" > \n " ;
2006-07-26 22:10:47 +02:00
include ( DOKU_INC . 'inc/lang/en/install.html' );
2006-07-28 11:39:13 +02:00
print " </div> \n " ;
2006-07-26 22:10:47 +02:00
}
?>
2017-12-06 06:15:21 +01: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;
2010-09-09 15:39:55 +02:00
display : block ; width : 380 px ; height : 73 px ; border : none ; clear : both ; "
target = " _blank "
href = " http://www.dokuwiki.org/security#web_access_security " ></ a >
2006-07-26 22:10:47 +02:00
</ div >
< div style = " float: left; width: 58%; " >
< ? php
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
try {
if ( ! ( check_functions () && check_permissions ()) ){
echo '<p>' . $lang [ 'i_problems' ] . '</p>' ;
2006-07-26 22:10:47 +02:00
print_errors ();
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_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>' ;
print_errors ();
} else {
echo '<p>' . $lang [ 'i_success' ] . '</p>' ;
}
2006-07-26 22:10:47 +02:00
} else {
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 ();
print_form ( $_REQUEST [ 'd' ]);
2006-07-26 22:10:47 +02:00
}
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
} catch ( Exception $e ) {
echo 'Caught exception: ' , $e -> getMessage (), " \n " ;
2006-07-26 22:10:47 +02:00
}
?>
</ div >
2010-09-09 15:39:55 +02:00
2006-07-26 22:10:47 +02:00
< div style = " clear: both " >
2013-07-22 00:21:00 +02:00
< a href = " http://dokuwiki.org/ " >< img src = " lib/tpl/dokuwiki/images/button-dw.png " alt = " driven by DokuWiki " /></ a >
2016-06-14 08:48:12 +02:00
< a href = " http://php.net " >< img src = " lib/tpl/dokuwiki/images/button-php.gif " alt = " powered by PHP " /></ a >
2006-07-26 22:10:47 +02:00
</ div >
</ body >
</ html >
< ? 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
*/
2006-07-26 22:10:47 +02:00
function print_form ( $d ){
global $lang ;
global $LC ;
2006-07-24 20:54:04 +02:00
2010-06-26 15:59:59 +02:00
include ( DOKU_CONF . 'license.php' );
2006-07-26 22:10:47 +02:00
if ( ! is_array ( $d )) $d = array ();
2017-08-01 12:03:01 +02:00
$d = array_map ( 'hsc' , $d );
2006-07-24 20:54:04 +02:00
2006-07-26 22:10:47 +02:00
if ( ! isset ( $d [ 'acl' ])) $d [ 'acl' ] = 1 ;
2012-12-07 17:46:16 +01:00
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 " >
< 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 " >
2012-07-14 13:46:37 +02:00
< input type = " checkbox " name = " d[acl] " id = " acl " < ? php echo (( $d [ 'acl' ] ? ' checked="checked"' : '' )); ?> />
2006-07-26 22:10:47 +02:00
< ? 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 " />
2006-07-28 11:36:53 +02:00
< 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 >
2010-06-26 15:59:59 +02:00
2013-11-17 21:53:46 +01:00
< label for = " allowreg " >
< input type = " checkbox " name = " d[allowreg] " id = " allowreg " < ? php echo (( $d [ 'allowreg' ] ? ' checked="checked"' : '' )); ?> />
< ? php echo $lang [ 'i_allowreg' ] ?>
2013-11-09 20:51:29 +01:00
</ label >
2006-07-26 22:10:47 +02:00
</ fieldset >
</ fieldset >
2010-06-26 15:59:59 +02:00
< fieldset >
< p >< ? php echo $lang [ 'i_license' ] ?> </p>
< ? php
2012-07-18 01:45:48 +02:00
array_push ( $license , array ( 'name' => $lang [ 'i_license_none' ], 'url' => '' ));
2012-06-25 01:13:59 +02:00
if ( empty ( $d [ 'license' ])) $d [ 'license' ] = 'cc-by-sa' ;
2010-06-26 15:59:59 +02:00
foreach ( $license as $key => $lic ){
echo '<label for="lic_' . $key . '">' ;
2017-08-01 12:03:01 +02:00
echo '<input type="radio" name="d[license]" value="' . hsc ( $key ) . '" id="lic_' . $key . '"' .
2012-07-18 01:45:48 +02:00
(( $d [ 'license' ] === $key ) ? ' checked="checked"' : '' ) . '>' ;
2017-08-01 12:03:01 +02:00
echo hsc ( $lic [ 'name' ]);
2010-06-26 15:59:59 +02:00
if ( $lic [ 'url' ]) echo ' <a href="' . $lic [ 'url' ] . '" target="_blank"><sup>[?]</sup></a>' ;
echo '</label>' ;
}
?>
</ fieldset >
2012-12-07 17:46:16 +01:00
< 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"' : '' )); ?> />
2012-12-16 20:25:46 +01:00
< ? php echo $lang [ 'i_pop_label' ] ?> <a href="http://www.dokuwiki.org/popularity" target="_blank"><sup>[?]</sup></a>
2012-12-07 17:46:16 +01:00
</ label >
</ fieldset >
2006-07-26 22:10:47 +02:00
</ fieldset >
< fieldset id = " process " >
2015-07-12 20:05:43 +02:00
< button type = " submit " name = " submit " >< ? php echo $lang [ 'btn_save' ] ?> </button>
2006-07-26 22:10:47 +02:00
</ fieldset >
</ form >
< ? php
2006-07-24 20:54:04 +02:00
}
2006-09-30 19:01:21 +02: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 " >
< fieldset >
2008-05-04 12:15:46 +02:00
< input type = " hidden " name = " l " value = " <?php echo $LC ?> " />
2015-07-12 20:05:43 +02:00
< button type = " submit " >< ? php echo $lang [ 'i_retry' ]; ?> </button>
2006-09-30 19:01:21 +02:00
</ fieldset >
</ 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
*
* @ author Andreas Gohr
2014-10-01 15:32:05 +02:00
*
* @ param array $d
* @ return bool ok ?
2006-07-26 22:10:47 +02:00
*/
2006-10-04 20:35:16 +02:00
function check_data ( & $d ){
2012-06-25 00:24:07 +02:00
static $form_default = array (
'title' => '' ,
2012-06-25 01:13:59 +02:00
'acl' => '1' ,
2012-06-25 00:24:07 +02:00
'superuser' => '' ,
'fullname' => '' ,
'email' => '' ,
'password' => '' ,
'confirm' => '' ,
'policy' => '0' ,
2013-11-17 21:53:46 +01:00
'allowreg' => '0' ,
2012-06-25 00:24:07 +02:00
'license' => 'cc-by-sa'
);
2006-07-26 22:10:47 +02:00
global $lang ;
global $error ;
2006-07-24 20:54:04 +02:00
2012-06-25 00:24:07 +02:00
if ( ! is_array ( $d )) $d = array ();
foreach ( $d as $k => $v ) {
if ( is_array ( $v ))
unset ( $d [ $k ]);
else
$d [ $k ] = ( string ) $v ;
}
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
2012-06-25 00:24:07 +02:00
if ( isset ( $_REQUEST [ 'submit' ])) {
$ok = true ;
// check input
if ( empty ( $d [ 'title' ])){
$error [] = sprintf ( $lang [ 'i_badval' ], $lang [ 'i_wikiname' ]);
2006-07-26 22:10:47 +02:00
$ok = false ;
}
2012-06-25 00:24:07 +02:00
if ( isset ( $d [ 'acl' ])){
if ( ! preg_match ( '/^[a-z0-9_]+$/' , $d [ 'superuser' ])){
$error [] = sprintf ( $lang [ 'i_badval' ], $lang [ 'i_superuser' ]);
$ok = false ;
}
if ( empty ( $d [ 'password' ])){
$error [] = sprintf ( $lang [ 'i_badval' ], $lang [ 'pass' ]);
$ok = false ;
}
elseif ( ! isset ( $d [ 'confirm' ]) || $d [ 'confirm' ] != $d [ 'password' ]){
$error [] = sprintf ( $lang [ 'i_badval' ], $lang [ 'passchk' ]);
$ok = false ;
}
if ( empty ( $d [ 'fullname' ]) || strstr ( $d [ 'fullname' ], ':' )){
$error [] = sprintf ( $lang [ 'i_badval' ], $lang [ 'fullname' ]);
$ok = false ;
}
if ( empty ( $d [ 'email' ]) || strstr ( $d [ 'email' ], ':' ) || ! strstr ( $d [ 'email' ], '@' )){
$error [] = sprintf ( $lang [ 'i_badval' ], $lang [ 'email' ]);
$ok = false ;
}
2019-03-13 18:54:14 +01:00
} else {
// 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
*
* @ author Chris Smith < chris @ jalakai . co . uk >
2014-10-01 15:32:05 +02:00
*
* @ param array $d
* @ return bool
2006-07-26 22:10:47 +02: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 ;
2006-07-28 11:36:53 +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
2010-10-24 09:50: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
$preset = __DIR__ . '/install.conf' ;
if ( file_exists ( $preset )){
$output .= " # preset config options \n " ;
$output .= file_get_contents ( $preset );
$output .= " \n \n " ;
$output .= " # options selected in installer \n " ;
@ unlink ( $preset );
}
2006-07-26 22:10:47 +02:00
$output .= '$conf[\'title\'] = \'' . addslashes ( $d [ 'title' ]) . " '; \n " ;
2006-07-28 11:40:28 +02:00
$output .= '$conf[\'lang\'] = \'' . addslashes ( $LC ) . " '; \n " ;
2010-06-26 15:59:59 +02:00
$output .= '$conf[\'license\'] = \'' . addslashes ( $d [ 'license' ]) . " '; \n " ;
2006-07-26 22:10:47 +02:00
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
}
2013-11-17 21:53:46 +01:00
if ( ! $d [ 'allowreg' ]){
2013-11-17 20:55:02 +01:00
$output .= '$conf[\'disableactions\'] = \'register\'' . " ; \n " ;
2013-11-09 21:07:14 +01:00
}
2006-07-26 22:10:47 +02: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
$phash = new PassHash ();
$pass = $phash -> hash_smd5 ( $d [ 'password' ]);
2006-07-24 20:54:04 +02:00
// create users.auth.php
2012-06-23 14:55:21 +02:00
// --- user:SMD5password:Real Name:email:groups,comma,seperated
2013-11-09 21:07:14 +01:00
$output = join ( " : " , array ( $d [ 'superuser' ], $pass , $d [ 'fullname' ], $d [ 'email' ], 'admin,user' ));
2006-07-24 20:54:04 +02:00
$output = @ file_get_contents ( DOKU_CONF . 'users.auth.php.dist' ) . " \n $output\n " ;
2006-07-26 22:10:47 +02: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 ;
if ( $d [ 'policy' ] == 2 ){
$output .= " * @ALL 0 \n " ;
2013-11-09 21:07:14 +01:00
$output .= " * @user 8 \n " ;
2006-07-29 01:29:30 +02:00
} elseif ( $d [ 'policy' ] == 1 ){
2006-07-28 11:36:53 +02:00
$output .= " * @ALL 1 \n " ;
2013-11-09 21:07:14 +01:00
$output .= " * @user 8 \n " ;
2006-07-28 11:36:53 +02:00
} else {
$output .= " * @ALL 8 \n " ;
}
2006-07-26 22:10:47 +02: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
if ( $d [ 'pop' ]){
@ touch ( DOKU_INC . 'data/cache/autosubmit.txt' );
}
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 ;
$ok = $ok && fileWrite ( DOKU_LOCAL . 'plugins.local.php' , $output );
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
*
* @ author Chris Smith < chris @ jalakai . co . uk >
2014-10-01 15:32:05 +02:00
*
* @ param string $filename
* @ param string $data
* @ return bool
2006-07-26 22:10:47 +02:00
*/
function fileWrite ( $filename , $data ) {
global $error ;
global $lang ;
if (( $fp = @ fopen ( $filename , 'wb' )) === false ) {
$filename = str_replace ( $_SERVER [ 'DOCUMENT_ROOT' ], '{DOCUMENT_ROOT}/' , $filename );
$error [] = sprintf ( $lang [ 'i_writeerr' ], $filename );
return false ;
}
2006-07-24 20:54:04 +02:00
2006-07-26 22:10:47 +02:00
if ( ! empty ( $data )) { fwrite ( $fp , $data ); }
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
*
* @ author Chris Smith < chris @ jalakai . co . uk >
2014-10-01 15:32:05 +02:00
*
* @ return bool
2006-07-26 22:10:47 +02:00
*/
function check_configs (){
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
2006-07-26 22:10:47 +02:00
$config_files = array (
'local' => DOKU_LOCAL . 'local.php' ,
'users' => DOKU_LOCAL . 'users.auth.php' ,
'auth' => DOKU_LOCAL . 'acl.auth.php'
);
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 )) {
2006-07-26 22:10:47 +02:00
$file = str_replace ( $_SERVER [ 'DOCUMENT_ROOT' ], '{DOCUMENT_ROOT}/' , $file );
$error [] = sprintf ( $lang [ 'i_confexists' ], $file );
$ok = false ;
}
}
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
*
* @ author Chris Smith < chris @ jalakai . co . uk >
2014-10-01 15:32:05 +02:00
*
* @ return bool
2006-07-26 22:10:47 +02:00
*/
function check_permissions (){
global $error ;
global $lang ;
$dirs = array (
2012-01-10 10:44:28 +01:00
'conf' => DOKU_LOCAL ,
'data' => DOKU_INC . 'data' ,
'pages' => DOKU_INC . 'data/pages' ,
'attic' => DOKU_INC . 'data/attic' ,
'media' => DOKU_INC . 'data/media' ,
'media_attic' => DOKU_INC . 'data/media_attic' ,
'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'
2006-07-26 22:10:47 +02:00
);
$ok = true ;
foreach ( $dirs as $dir ){
2015-01-07 10:47:45 +01:00
if ( ! file_exists ( " $dir /. " ) || ! is_writable ( $dir )){
2006-09-30 19:01:21 +02:00
$dir = str_replace ( $_SERVER [ 'DOCUMENT_ROOT' ], '{DOCUMENT_ROOT}' , $dir );
2006-07-26 22:10:47 +02:00
$error [] = sprintf ( $lang [ 'i_permfail' ], $dir );
$ok = false ;
}
}
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
*
* @ author Andreas Gohr < andi @ splitbrain . org >
2014-10-01 15:32:05 +02:00
*
* @ return bool
2006-07-26 22:10:47 +02:00
*/
function check_functions (){
global $error ;
global $lang ;
2006-11-05 21:44:20 +01:00
$ok = true ;
2017-03-31 09:29:40 +02:00
if ( version_compare ( phpversion (), '5.6.0' , '<' )){
$error [] = sprintf ( $lang [ 'i_phpver' ], phpversion (), '5.6.0' );
2006-11-05 21:44:20 +01:00
$ok = false ;
}
2014-05-24 19:58:29 +02:00
if ( ini_get ( 'mbstring.func_overload' ) != 0 ){
$error [] = $lang [ 'i_mbfuncoverload' ];
$ok = false ;
}
2012-07-28 10:40:48 +02:00
$funcs = explode ( ' ' , 'addslashes call_user_func chmod copy fgets ' .
2006-07-26 22:10:47 +02:00
'file file_exists fseek flush filesize ftell fopen ' .
'glob header ignore_user_abort ini_get mail mkdir ' .
'ob_start opendir parse_ini_file readfile realpath ' .
2007-01-04 21:18:22 +01:00
'rename rmdir serialize session_start unlink usleep ' .
2010-11-24 16:33:47 +01:00
'preg_replace file_get_contents htmlspecialchars_decode ' .
2013-03-31 20:44:06 +02:00
'spl_autoload_register stream_select fsockopen pack' );
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
}
2006-07-26 22:10:47 +02:00
foreach ( $funcs as $func ){
if ( ! function_exists ( $func )){
$error [] = sprintf ( $lang [ 'i_funcna' ], $func );
$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 >
*/
function langsel (){
global $lang ;
global $LC ;
$dir = DOKU_INC . 'inc/lang' ;
$dh = opendir ( $dir );
if ( ! $dh ) return ;
$langs = array ();
while (( $file = readdir ( $dh )) !== false ) {
if ( preg_match ( '/^[\._]/' , $file )) continue ;
2015-01-07 10:47: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()">' ;
foreach ( $langs as $l ){
$sel = ( $l == $LC ) ? 'selected="selected"' : '' ;
echo '<option value="' . $l . '" ' . $sel . '>' . $l . '</option>' ;
}
2006-07-29 01:29:30 +02:00
echo '</select> ' ;
2015-07-12 20:05:43 +02: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 >
*/
function print_errors (){
global $error ;
2012-06-25 00:24:07 +02:00
if ( ! empty ( $error )) {
echo '<ul>' ;
foreach ( $error as $err ){
echo " <li> $err </li> " ;
}
echo '</ul>' ;
2006-07-26 22:10:47 +02:00
}
2006-07-24 20:54:04 +02:00
}