15cfb8815Schris<?php 2*ac251797SAndreas Gohr/*><div style="width:60%; margin: auto; background-color: #fcc; 3*ac251797SAndreas Gohr border: 1px solid #faa; padding: 0.5em 1em;"> 4*ac251797SAndreas Gohr <h1 style="font-size: 120%">No PHP Support</h1> 5*ac251797SAndreas Gohr 6*ac251797SAndreas Gohr It seems this server has no PHP support enabled. You will need to 7*ac251797SAndreas Gohr enable PHP before you can install and run DokuWiki. Contact your hosting 8*ac251797SAndreas Gohr provider if you're unsure what this means. 9*ac251797SAndreas Gohr 10*ac251797SAndreas Gohr</div>*/ 115cfb8815Schris/** 125cfb8815Schris * Dokuwiki installation assistance 135cfb8815Schris * 145cfb8815Schris * @author Chris Smith <chris@jalakai.co.uk> 155cfb8815Schris */ 165cfb8815Schris 17d0a27cb0SAndreas Gohrif(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/'); 185cfb8815Schrisif(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/'); 195cfb8815Schrisif(!defined('DOKU_LOCAL')) define('DOKU_LOCAL',DOKU_INC.'conf/'); 205cfb8815Schris 2102bca5d4SYousong Zhou// load and initialize the core system 2202bca5d4SYousong Zhourequire_once(DOKU_INC.'inc/init.php'); 233791b589SAndreas Gohr 243545b2e0Schris// check for error reporting override or set error reporting to sane values 253545b2e0Schrisif (!defined('DOKU_E_LEVEL')) { error_reporting(E_ALL ^ E_NOTICE); } 263545b2e0Schriselse { error_reporting(DOKU_E_LEVEL); } 273545b2e0Schris 2847248316SAndreas Gohr// language strings 2947248316SAndreas Gohrrequire_once(DOKU_INC.'inc/lang/en/lang.php'); 304b530faaSTom N Harrisif(isset($_REQUEST['l']) && !is_array($_REQUEST['l'])) { 3147248316SAndreas Gohr $LC = preg_replace('/[^a-z\-]+/','',$_REQUEST['l']); 324b530faaSTom N Harris} 334b530faaSTom N Harrisif(empty($LC)) $LC = 'en'; 3447248316SAndreas Gohrif($LC && $LC != 'en' ) { 3547248316SAndreas Gohr require_once(DOKU_INC.'inc/lang/'.$LC.'/lang.php'); 3647248316SAndreas Gohr} 3747248316SAndreas Gohr 3847248316SAndreas Gohr// initialise variables ... 3947248316SAndreas Gohr$error = array(); 4047248316SAndreas Gohr 4147248316SAndreas Gohr$dokuwiki_hash = array( 4247248316SAndreas Gohr '2005-09-22' => 'e33223e957b0b0a130d0520db08f8fb7', 4347248316SAndreas Gohr '2006-03-05' => '51295727f79ab9af309a2fd9e0b61acc', 4447248316SAndreas Gohr '2006-03-09' => '51295727f79ab9af309a2fd9e0b61acc', 454dde32ddSAndreas Gohr '2006-11-06' => 'b3a8af76845977c2000d85d6990dd72b', 46e7f137b2SAndreas Gohr '2007-05-24' => 'd80f2740c84c4a6a791fd3c7a353536f', 4783666c1bSAndreas Gohr '2007-06-26' => 'b3ca19c7a654823144119980be73cd77', 48dd6510bdSAndreas Gohr '2008-05-04' => '1e5c42eac3219d9e21927c39e3240aad', 49b4353e51SAndreas Gohr '2009-02-14' => 'ec8c04210732a14fdfce0f7f6eead865', 5085d9abfcSAndreas Gohr '2009-12-25' => '993c4b2b385643efe5abf8e7010e11f4', 51c991623aSAdrian Lang '2010-11-07' => '7921d48195f4db21b8ead6d9bea801b8', 525ff12737SAdrian Lang '2011-05-25' => '4241865472edb6fa14a1227721008072', 53a5a71ecfSAdrian Lang '2011-11-10' => 'b46ff19a7587966ac4df61cbab1b8b31', 545371328cSAndreas Gohr '2012-01-25' => '72c083c73608fc43c586901fd5dabb74', 55c70d6ceeSAndreas Gohr '2012-09-10' => 'eb0b3fc90056fbc12bac6f49f7764df3', 562a5a1456SGuy Brand '2013-05-10' => '7b62b75245f57f122d3e0f8ed7989623', 578c4759c9SGuy Brand '2013-12-08' => '263c76af309fbf083867c18a34ff5214', 5875930869SGuy Brand '2014-05-05' => '263c76af309fbf083867c18a34ff5214', 59c8574e7dSGuy Brand '2015-08-10' => '263c76af309fbf083867c18a34ff5214', 602f7c97b3SGuy Brand '2016-06-26' => 'fd3abb6d89853dacb032907e619fbd73', 612f7c97b3SGuy Brand '2017-02-19' => 'e4f2f5a34c9dbcd96a5ecc8f2df25bd9' 6247248316SAndreas Gohr); 6347248316SAndreas Gohr 6447248316SAndreas Gohr 6547248316SAndreas Gohr// begin output 6647248316SAndreas Gohrheader('Content-Type: text/html; charset=utf-8'); 6747248316SAndreas Gohr?> 68c8839c22SAnika Henke<!DOCTYPE html> 69c8839c22SAnika Henke<html lang="<?php echo $LC?>" dir="<?php echo $lang['direction']?>"> 7047248316SAndreas Gohr<head> 71c8839c22SAnika Henke <meta charset="utf-8" /> 724208c142SAndreas Gohr <title><?php echo $lang['i_installer']?></title> 7347248316SAndreas Gohr <style type="text/css"> 7447248316SAndreas Gohr body { width: 90%; margin: 0 auto; font: 84% Verdana, Helvetica, Arial, sans-serif; } 7547248316SAndreas Gohr img { border: none } 7647248316SAndreas Gohr br.cl { clear:both; } 7770a6aa16Schris code { font-size: 110%; color: #800000; } 7847248316SAndreas Gohr fieldset { border: none } 799c70688aSchris label { display: block; margin-top: 0.5em; } 808af2e4bbSAndreas Gohr select.text, input.text { width: 30em; margin: 0 0.5em; } 8106361442SAndreas Gohr a {text-decoration: none} 8247248316SAndreas Gohr </style> 83e260f93bSAnika Henke <script type="text/javascript"> 8447248316SAndreas Gohr function acltoggle(){ 8547248316SAndreas Gohr var cb = document.getElementById('acl'); 8647248316SAndreas Gohr var fs = document.getElementById('acldep'); 8747248316SAndreas Gohr if(!cb || !fs) return; 8847248316SAndreas Gohr if(cb.checked){ 8947248316SAndreas Gohr fs.style.display = ''; 9047248316SAndreas Gohr }else{ 9147248316SAndreas Gohr fs.style.display = 'none'; 9247248316SAndreas Gohr } 9347248316SAndreas Gohr } 9447248316SAndreas Gohr window.onload = function(){ 9547248316SAndreas Gohr acltoggle(); 9647248316SAndreas Gohr var cb = document.getElementById('acl'); 9747248316SAndreas Gohr if(cb) cb.onchange = acltoggle; 9847248316SAndreas Gohr }; 9947248316SAndreas Gohr </script> 10047248316SAndreas Gohr</head> 10147248316SAndreas Gohr<body style=""> 10247248316SAndreas Gohr <h1 style="float:left"> 103c5270434SAndreas Gohr <img src="lib/exe/fetch.php?media=wiki:dokuwiki-128.png" 104c5270434SAndreas Gohr style="vertical-align: middle;" alt="" height="64" width="64" /> 10547248316SAndreas Gohr <?php echo $lang['i_installer']?> 10647248316SAndreas Gohr </h1> 10747248316SAndreas Gohr <div style="float:right; margin: 1em;"> 10847248316SAndreas Gohr <?php langsel()?> 10947248316SAndreas Gohr </div> 11047248316SAndreas Gohr <br class="cl" /> 11147248316SAndreas Gohr 11247248316SAndreas Gohr <div style="float: right; width: 34%;"> 11347248316SAndreas Gohr <?php 11479e79377SAndreas Gohr if(file_exists(DOKU_INC.'inc/lang/'.$LC.'/install.html')){ 11547248316SAndreas Gohr include(DOKU_INC.'inc/lang/'.$LC.'/install.html'); 11647248316SAndreas Gohr }else{ 117ca64d724Schris print "<div lang=\"en\" dir=\"ltr\">\n"; 11847248316SAndreas Gohr include(DOKU_INC.'inc/lang/en/install.html'); 119ca64d724Schris print "</div>\n"; 12047248316SAndreas Gohr } 12147248316SAndreas Gohr ?> 1223cd83762SDeathCamel57 <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; 123c8b43921SAndreas Gohr display: block; width:380px; height:73px; border:none; clear:both;" 124c8b43921SAndreas Gohr target="_blank" 125c8b43921SAndreas Gohr href="http://www.dokuwiki.org/security#web_access_security"></a> 12647248316SAndreas Gohr </div> 12747248316SAndreas Gohr 12847248316SAndreas Gohr <div style="float: left; width: 58%;"> 12947248316SAndreas Gohr <?php 13047248316SAndreas Gohr if(! (check_functions() && check_permissions()) ){ 13147248316SAndreas Gohr echo '<p>'.$lang['i_problems'].'</p>'; 13247248316SAndreas Gohr print_errors(); 13370a6aa16Schris print_retry(); 13447248316SAndreas Gohr }elseif(!check_configs()){ 13547248316SAndreas Gohr echo '<p>'.$lang['i_modified'].'</p>'; 13647248316SAndreas Gohr print_errors(); 1374b530faaSTom N Harris }elseif(check_data($_REQUEST['d'])){ 1384b530faaSTom N Harris // check_data has sanitized all input parameters 1394b530faaSTom N Harris if(!store_data($_REQUEST['d'])){ 14047248316SAndreas Gohr echo '<p>'.$lang['i_failure'].'</p>'; 14147248316SAndreas Gohr print_errors(); 14247248316SAndreas Gohr }else{ 14347248316SAndreas Gohr echo '<p>'.$lang['i_success'].'</p>'; 14447248316SAndreas Gohr } 14547248316SAndreas Gohr }else{ 1464b530faaSTom N Harris print_errors(); 14747248316SAndreas Gohr print_form($_REQUEST['d']); 14847248316SAndreas Gohr } 14947248316SAndreas Gohr ?> 15047248316SAndreas Gohr </div> 15147248316SAndreas Gohr 152c8b43921SAndreas Gohr 15347248316SAndreas Gohr<div style="clear: both"> 154654436fbSAnika Henke <a href="http://dokuwiki.org/"><img src="lib/tpl/dokuwiki/images/button-dw.png" alt="driven by DokuWiki" /></a> 15559752844SAnders Sandblad <a href="http://php.net"><img src="lib/tpl/dokuwiki/images/button-php.gif" alt="powered by PHP" /></a> 15647248316SAndreas Gohr</div> 15747248316SAndreas Gohr</body> 15847248316SAndreas Gohr</html> 15947248316SAndreas Gohr<?php 16047248316SAndreas Gohr 16147248316SAndreas Gohr/** 16247248316SAndreas Gohr * Print the input form 163253d4b48SGerrit Uitslag * 164253d4b48SGerrit Uitslag * @param array $d submitted entry 'd' of request data 16547248316SAndreas Gohr */ 16647248316SAndreas Gohrfunction print_form($d){ 16747248316SAndreas Gohr global $lang; 16847248316SAndreas Gohr global $LC; 16947248316SAndreas Gohr 17006361442SAndreas Gohr include(DOKU_CONF.'license.php'); 17106361442SAndreas Gohr 17247248316SAndreas Gohr if(!is_array($d)) $d = array(); 17365cc1598SPhy $d = array_map('hsc',$d); 17447248316SAndreas Gohr 17547248316SAndreas Gohr if(!isset($d['acl'])) $d['acl']=1; 1763a0852d9SAndreas Gohr if(!isset($d['pop'])) $d['pop']=1; 17747248316SAndreas Gohr 17847248316SAndreas Gohr ?> 17947248316SAndreas Gohr <form action="" method="post"> 18047248316SAndreas Gohr <input type="hidden" name="l" value="<?php echo $LC ?>" /> 18147248316SAndreas Gohr <fieldset> 18247248316SAndreas Gohr <label for="title"><?php echo $lang['i_wikiname']?> 18347248316SAndreas Gohr <input type="text" name="d[title]" id="title" value="<?php echo $d['title'] ?>" style="width: 20em;" /> 18447248316SAndreas Gohr </label> 18547248316SAndreas Gohr 18647248316SAndreas Gohr <fieldset style="margin-top: 1em;"> 18747248316SAndreas Gohr <label for="acl"> 18847248316SAndreas Gohr <input type="checkbox" name="d[acl]" id="acl" <?php echo(($d['acl'] ? ' checked="checked"' : ''));?> /> 18947248316SAndreas Gohr <?php echo $lang['i_enableacl']?></label> 19047248316SAndreas Gohr 19147248316SAndreas Gohr <fieldset id="acldep"> 19247248316SAndreas Gohr <label for="superuser"><?php echo $lang['i_superuser']?></label> 19347248316SAndreas Gohr <input class="text" type="text" name="d[superuser]" id="superuser" value="<?php echo $d['superuser'] ?>" /> 19447248316SAndreas Gohr 19547248316SAndreas Gohr <label for="fullname"><?php echo $lang['fullname']?></label> 19647248316SAndreas Gohr <input class="text" type="text" name="d[fullname]" id="fullname" value="<?php echo $d['fullname'] ?>" /> 19747248316SAndreas Gohr 19847248316SAndreas Gohr <label for="email"><?php echo $lang['email']?></label> 19947248316SAndreas Gohr <input class="text" type="text" name="d[email]" id="email" value="<?php echo $d['email'] ?>" /> 20047248316SAndreas Gohr 20147248316SAndreas Gohr <label for="password"><?php echo $lang['pass']?></label> 20247248316SAndreas Gohr <input class="text" type="password" name="d[password]" id="password" /> 20347248316SAndreas Gohr 20447248316SAndreas Gohr <label for="confirm"><?php echo $lang['passchk']?></label> 20547248316SAndreas Gohr <input class="text" type="password" name="d[confirm]" id="confirm" /> 2068af2e4bbSAndreas Gohr 2078af2e4bbSAndreas Gohr <label for="policy"><?php echo $lang['i_policy']?></label> 2088af2e4bbSAndreas Gohr <select class="text" name="d[policy]" id="policy"> 2098af2e4bbSAndreas Gohr <option value="0" <?php echo ($d['policy'] == 0)?'selected="selected"':'' ?>><?php echo $lang['i_pol0']?></option> 2108af2e4bbSAndreas Gohr <option value="1" <?php echo ($d['policy'] == 1)?'selected="selected"':'' ?>><?php echo $lang['i_pol1']?></option> 2118af2e4bbSAndreas Gohr <option value="2" <?php echo ($d['policy'] == 2)?'selected="selected"':'' ?>><?php echo $lang['i_pol2']?></option> 2128af2e4bbSAndreas Gohr </select> 21306361442SAndreas Gohr 214ab9346edSAnika Henke <label for="allowreg"> 215ab9346edSAnika Henke <input type="checkbox" name="d[allowreg]" id="allowreg" <?php echo(($d['allowreg'] ? ' checked="checked"' : ''));?> /> 216ab9346edSAnika Henke <?php echo $lang['i_allowreg']?> 21774850f29SAnika Henke </label> 21847248316SAndreas Gohr </fieldset> 21947248316SAndreas Gohr </fieldset> 22047248316SAndreas Gohr 22106361442SAndreas Gohr <fieldset> 22206361442SAndreas Gohr <p><?php echo $lang['i_license']?></p> 22306361442SAndreas Gohr <?php 224b1730bd2STom N Harris array_push($license,array('name' => $lang['i_license_none'], 'url'=>'')); 225ed856534STom N Harris if(empty($d['license'])) $d['license'] = 'cc-by-sa'; 22606361442SAndreas Gohr foreach($license as $key => $lic){ 22706361442SAndreas Gohr echo '<label for="lic_'.$key.'">'; 22865cc1598SPhy echo '<input type="radio" name="d[license]" value="'.hsc($key).'" id="lic_'.$key.'"'. 229b1730bd2STom N Harris (($d['license'] === $key)?' checked="checked"':'').'>'; 23065cc1598SPhy echo hsc($lic['name']); 23106361442SAndreas Gohr if($lic['url']) echo ' <a href="'.$lic['url'].'" target="_blank"><sup>[?]</sup></a>'; 23206361442SAndreas Gohr echo '</label>'; 23306361442SAndreas Gohr } 23406361442SAndreas Gohr ?> 23506361442SAndreas Gohr </fieldset> 23606361442SAndreas Gohr 2373a0852d9SAndreas Gohr <fieldset> 2383a0852d9SAndreas Gohr <p><?php echo $lang['i_pop_field']?></p> 2393a0852d9SAndreas Gohr <label for="pop"> 2403a0852d9SAndreas Gohr <input type="checkbox" name="d[pop]" id="pop" <?php echo(($d['pop'] ? ' checked="checked"' : ''));?> /> 241e93f702bSAndreas Gohr <?php echo $lang['i_pop_label']?> <a href="http://www.dokuwiki.org/popularity" target="_blank"><sup>[?]</sup></a> 2423a0852d9SAndreas Gohr </label> 2433a0852d9SAndreas Gohr </fieldset> 2443a0852d9SAndreas Gohr 24547248316SAndreas Gohr </fieldset> 24647248316SAndreas Gohr <fieldset id="process"> 247ae614416SAnika Henke <button type="submit" name="submit"><?php echo $lang['btn_save']?></button> 24847248316SAndreas Gohr </fieldset> 24947248316SAndreas Gohr </form> 25047248316SAndreas Gohr <?php 25147248316SAndreas Gohr} 25247248316SAndreas Gohr 25370a6aa16Schrisfunction print_retry() { 25470a6aa16Schris global $lang; 2559ad6da3dSAndreas Gohr global $LC; 25670a6aa16Schris ?> 25770a6aa16Schris <form action="" method="get"> 25870a6aa16Schris <fieldset> 2599ad6da3dSAndreas Gohr <input type="hidden" name="l" value="<?php echo $LC ?>" /> 260ae614416SAnika Henke <button type="submit"><?php echo $lang['i_retry'];?></button> 26170a6aa16Schris </fieldset> 26270a6aa16Schris </form> 26370a6aa16Schris <?php 26470a6aa16Schris} 26570a6aa16Schris 26647248316SAndreas Gohr/** 26747248316SAndreas Gohr * Check validity of data 26847248316SAndreas Gohr * 26947248316SAndreas Gohr * @author Andreas Gohr 270253d4b48SGerrit Uitslag * 271253d4b48SGerrit Uitslag * @param array $d 272253d4b48SGerrit Uitslag * @return bool ok? 27347248316SAndreas Gohr */ 274e2386079SAndreas Gohrfunction check_data(&$d){ 2754b530faaSTom N Harris static $form_default = array( 2764b530faaSTom N Harris 'title' => '', 277ed856534STom N Harris 'acl' => '1', 2784b530faaSTom N Harris 'superuser' => '', 2794b530faaSTom N Harris 'fullname' => '', 2804b530faaSTom N Harris 'email' => '', 2814b530faaSTom N Harris 'password' => '', 2824b530faaSTom N Harris 'confirm' => '', 2834b530faaSTom N Harris 'policy' => '0', 284ab9346edSAnika Henke 'allowreg' => '0', 2854b530faaSTom N Harris 'license' => 'cc-by-sa' 2864b530faaSTom N Harris ); 28747248316SAndreas Gohr global $lang; 28847248316SAndreas Gohr global $error; 28947248316SAndreas Gohr 2904b530faaSTom N Harris if(!is_array($d)) $d = array(); 2914b530faaSTom N Harris foreach($d as $k => $v) { 2924b530faaSTom N Harris if(is_array($v)) 2934b530faaSTom N Harris unset($d[$k]); 2944b530faaSTom N Harris else 2954b530faaSTom N Harris $d[$k] = (string)$v; 2964b530faaSTom N Harris } 297e2386079SAndreas Gohr 2984b530faaSTom N Harris //autolowercase the username 2994b530faaSTom N Harris $d['superuser'] = isset($d['superuser']) ? strtolower($d['superuser']) : ""; 3004b530faaSTom N Harris 3014b530faaSTom N Harris $ok = false; 3024b530faaSTom N Harris 3034b530faaSTom N Harris if(isset($_REQUEST['submit'])) { 30447248316SAndreas Gohr $ok = true; 30547248316SAndreas Gohr 30647248316SAndreas Gohr // check input 30747248316SAndreas Gohr if(empty($d['title'])){ 30847248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['i_wikiname']); 30947248316SAndreas Gohr $ok = false; 31047248316SAndreas Gohr } 3114b530faaSTom N Harris if(isset($d['acl'])){ 312d60813a2SGina Haeussge if(!preg_match('/^[a-z0-9_]+$/',$d['superuser'])){ 31347248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['i_superuser']); 31447248316SAndreas Gohr $ok = false; 31547248316SAndreas Gohr } 31647248316SAndreas Gohr if(empty($d['password'])){ 31747248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['pass']); 31847248316SAndreas Gohr $ok = false; 31947248316SAndreas Gohr } 3204b530faaSTom N Harris elseif(!isset($d['confirm']) || $d['confirm'] != $d['password']){ 32147248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['passchk']); 32247248316SAndreas Gohr $ok = false; 32347248316SAndreas Gohr } 32447248316SAndreas Gohr if(empty($d['fullname']) || strstr($d['fullname'],':')){ 32547248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['fullname']); 32647248316SAndreas Gohr $ok = false; 32747248316SAndreas Gohr } 328e2386079SAndreas Gohr if(empty($d['email']) || strstr($d['email'],':') || !strstr($d['email'],'@')){ 32947248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['email']); 33047248316SAndreas Gohr $ok = false; 33147248316SAndreas Gohr } 33247248316SAndreas Gohr } 3334b530faaSTom N Harris } 3344b530faaSTom N Harris $d = array_merge($form_default, $d); 33547248316SAndreas Gohr return $ok; 33647248316SAndreas Gohr} 33747248316SAndreas Gohr 33847248316SAndreas Gohr/** 33947248316SAndreas Gohr * Writes the data to the config files 34047248316SAndreas Gohr * 34147248316SAndreas Gohr * @author Chris Smith <chris@jalakai.co.uk> 342253d4b48SGerrit Uitslag * 343253d4b48SGerrit Uitslag * @param array $d 344253d4b48SGerrit Uitslag * @return bool 34547248316SAndreas Gohr */ 34647248316SAndreas Gohrfunction store_data($d){ 3470036aa89SAndreas Gohr global $LC; 34847248316SAndreas Gohr $ok = true; 3498af2e4bbSAndreas Gohr $d['policy'] = (int) $d['policy']; 35047248316SAndreas Gohr 35147248316SAndreas Gohr // create local.php 35224650a19SAndreas Gohr $now = gmdate('r'); 35347248316SAndreas Gohr $output = <<<EOT 35447248316SAndreas Gohr<?php 35547248316SAndreas Gohr/** 35647248316SAndreas Gohr * Dokuwiki's Main Configuration File - Local Settings 35747248316SAndreas Gohr * Auto-generated by install script 35847248316SAndreas Gohr * Date: $now 35947248316SAndreas Gohr */ 36047248316SAndreas Gohr 36147248316SAndreas GohrEOT; 3622613efa1SAndreas Gohr // add any config options set by a previous installer 3632613efa1SAndreas Gohr $preset = __DIR__.'/install.conf'; 3642613efa1SAndreas Gohr if(file_exists($preset)){ 3652613efa1SAndreas Gohr $output .= "# preset config options\n"; 3662613efa1SAndreas Gohr $output .= file_get_contents($preset); 3672613efa1SAndreas Gohr $output .= "\n\n"; 3682613efa1SAndreas Gohr $output .= "# options selected in installer\n"; 3692613efa1SAndreas Gohr @unlink($preset); 3702613efa1SAndreas Gohr } 3712613efa1SAndreas Gohr 37247248316SAndreas Gohr $output .= '$conf[\'title\'] = \''.addslashes($d['title'])."';\n"; 3730036aa89SAndreas Gohr $output .= '$conf[\'lang\'] = \''.addslashes($LC)."';\n"; 37406361442SAndreas Gohr $output .= '$conf[\'license\'] = \''.addslashes($d['license'])."';\n"; 37547248316SAndreas Gohr if($d['acl']){ 37647248316SAndreas Gohr $output .= '$conf[\'useacl\'] = 1'.";\n"; 377523d7ea6Schris $output .= "\$conf['superuser'] = '@admin';\n"; 37847248316SAndreas Gohr } 379ab9346edSAnika Henke if(!$d['allowreg']){ 38043c137edSAnika Henke $output .= '$conf[\'disableactions\'] = \'register\''.";\n"; 381d2ea6dc1SAnika Henke } 38247248316SAndreas Gohr $ok = $ok && fileWrite(DOKU_LOCAL.'local.php',$output); 38347248316SAndreas Gohr 38447248316SAndreas Gohr if ($d['acl']) { 3853791b589SAndreas Gohr // hash the password 3863791b589SAndreas Gohr $phash = new PassHash(); 3873791b589SAndreas Gohr $pass = $phash->hash_smd5($d['password']); 3883791b589SAndreas Gohr 38947248316SAndreas Gohr // create users.auth.php 3903791b589SAndreas Gohr // --- user:SMD5password:Real Name:email:groups,comma,seperated 391d2ea6dc1SAnika Henke $output = join(":",array($d['superuser'], $pass, $d['fullname'], $d['email'], 'admin,user')); 39247248316SAndreas Gohr $output = @file_get_contents(DOKU_CONF.'users.auth.php.dist')."\n$output\n"; 39347248316SAndreas Gohr $ok = $ok && fileWrite(DOKU_LOCAL.'users.auth.php', $output); 39447248316SAndreas Gohr 39547248316SAndreas Gohr // create acl.auth.php 3968af2e4bbSAndreas Gohr $output = <<<EOT 3978af2e4bbSAndreas Gohr# acl.auth.php 3988af2e4bbSAndreas Gohr# <?php exit()?> 3998af2e4bbSAndreas Gohr# Don't modify the lines above 4008af2e4bbSAndreas Gohr# 4018af2e4bbSAndreas Gohr# Access Control Lists 4028af2e4bbSAndreas Gohr# 4038af2e4bbSAndreas Gohr# Auto-generated by install script 4048af2e4bbSAndreas Gohr# Date: $now 4058af2e4bbSAndreas Gohr 4068af2e4bbSAndreas GohrEOT; 4078af2e4bbSAndreas Gohr if($d['policy'] == 2){ 4088af2e4bbSAndreas Gohr $output .= "* @ALL 0\n"; 409d2ea6dc1SAnika Henke $output .= "* @user 8\n"; 4109c70688aSchris }elseif($d['policy'] == 1){ 4118af2e4bbSAndreas Gohr $output .= "* @ALL 1\n"; 412d2ea6dc1SAnika Henke $output .= "* @user 8\n"; 4138af2e4bbSAndreas Gohr }else{ 4148af2e4bbSAndreas Gohr $output .= "* @ALL 8\n"; 4158af2e4bbSAndreas Gohr } 41647248316SAndreas Gohr $ok = $ok && fileWrite(DOKU_LOCAL.'acl.auth.php', $output); 41747248316SAndreas Gohr } 4183a0852d9SAndreas Gohr 4193a0852d9SAndreas Gohr // enable popularity submission 4203a0852d9SAndreas Gohr if($d['pop']){ 4213a0852d9SAndreas Gohr @touch(DOKU_INC.'data/cache/autosubmit.txt'); 4223a0852d9SAndreas Gohr } 4233a0852d9SAndreas Gohr 424c70d6ceeSAndreas Gohr // disable auth plugins til needed 425c70d6ceeSAndreas Gohr $output = <<<EOT 426c70d6ceeSAndreas Gohr<?php 427c70d6ceeSAndreas Gohr/* 428c70d6ceeSAndreas Gohr * Local plugin enable/disable settings 429c70d6ceeSAndreas Gohr * 430c70d6ceeSAndreas Gohr * Auto-generated by install script 431c70d6ceeSAndreas Gohr * Date: $now 432c70d6ceeSAndreas Gohr */ 433c70d6ceeSAndreas Gohr 434c70d6ceeSAndreas Gohr\$plugins['authad'] = 0; 435c70d6ceeSAndreas Gohr\$plugins['authldap'] = 0; 436c70d6ceeSAndreas Gohr\$plugins['authmysql'] = 0; 437c70d6ceeSAndreas Gohr\$plugins['authpgsql'] = 0; 438c70d6ceeSAndreas Gohr 439c70d6ceeSAndreas GohrEOT; 440c70d6ceeSAndreas Gohr $ok = $ok && fileWrite(DOKU_LOCAL.'plugins.local.php', $output); 441c70d6ceeSAndreas Gohr 44247248316SAndreas Gohr return $ok; 44347248316SAndreas Gohr} 44447248316SAndreas Gohr 44547248316SAndreas Gohr/** 44647248316SAndreas Gohr * Write the given content to a file 44747248316SAndreas Gohr * 44847248316SAndreas Gohr * @author Chris Smith <chris@jalakai.co.uk> 449253d4b48SGerrit Uitslag * 450253d4b48SGerrit Uitslag * @param string $filename 451253d4b48SGerrit Uitslag * @param string $data 452253d4b48SGerrit Uitslag * @return bool 45347248316SAndreas Gohr */ 45447248316SAndreas Gohrfunction fileWrite($filename, $data) { 45547248316SAndreas Gohr global $error; 45647248316SAndreas Gohr global $lang; 45747248316SAndreas Gohr 45847248316SAndreas Gohr if (($fp = @fopen($filename, 'wb')) === false) { 45947248316SAndreas Gohr $filename = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $filename); 46047248316SAndreas Gohr $error[] = sprintf($lang['i_writeerr'],$filename); 46147248316SAndreas Gohr return false; 46247248316SAndreas Gohr } 46347248316SAndreas Gohr 46447248316SAndreas Gohr if (!empty($data)) { fwrite($fp, $data); } 46547248316SAndreas Gohr fclose($fp); 46647248316SAndreas Gohr return true; 46747248316SAndreas Gohr} 46847248316SAndreas Gohr 46947248316SAndreas Gohr 47047248316SAndreas Gohr/** 47147248316SAndreas Gohr * check installation dependent local config files and tests for a known 47247248316SAndreas Gohr * unmodified main config file 47347248316SAndreas Gohr * 47447248316SAndreas Gohr * @author Chris Smith <chris@jalakai.co.uk> 475253d4b48SGerrit Uitslag * 476253d4b48SGerrit Uitslag * @return bool 47747248316SAndreas Gohr */ 47847248316SAndreas Gohrfunction check_configs(){ 47947248316SAndreas Gohr global $error; 48047248316SAndreas Gohr global $lang; 48147248316SAndreas Gohr global $dokuwiki_hash; 48247248316SAndreas Gohr 48347248316SAndreas Gohr $ok = true; 48447248316SAndreas Gohr 4855cfb8815Schris $config_files = array( 4865cfb8815Schris 'local' => DOKU_LOCAL.'local.php', 4875cfb8815Schris 'users' => DOKU_LOCAL.'users.auth.php', 4885cfb8815Schris 'auth' => DOKU_LOCAL.'acl.auth.php' 4895cfb8815Schris ); 4905cfb8815Schris 4915cfb8815Schris // main dokuwiki config file (conf/dokuwiki.php) must not have been modified 492aa248fb5SAndreas Gohr $installation_hash = md5(preg_replace("/(\015\012)|(\015)/","\012", 493aa248fb5SAndreas Gohr @file_get_contents(DOKU_CONF.'dokuwiki.php'))); 4945cfb8815Schris if (!in_array($installation_hash, $dokuwiki_hash)) { 49547248316SAndreas Gohr $error[] = sprintf($lang['i_badhash'],$installation_hash); 49647248316SAndreas Gohr $ok = false; 4975cfb8815Schris } 4985cfb8815Schris 49947248316SAndreas Gohr // configs shouldn't exist 50047248316SAndreas Gohr foreach ($config_files as $file) { 50179e79377SAndreas Gohr if (file_exists($file) && filesize($file)) { 50247248316SAndreas Gohr $file = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $file); 50347248316SAndreas Gohr $error[] = sprintf($lang['i_confexists'],$file); 50447248316SAndreas Gohr $ok = false; 50547248316SAndreas Gohr } 50647248316SAndreas Gohr } 50747248316SAndreas Gohr return $ok; 50847248316SAndreas Gohr} 50947248316SAndreas Gohr 51047248316SAndreas Gohr 51147248316SAndreas Gohr/** 51247248316SAndreas Gohr * Check other installation dir/file permission requirements 51347248316SAndreas Gohr * 51447248316SAndreas Gohr * @author Chris Smith <chris@jalakai.co.uk> 515253d4b48SGerrit Uitslag * 516253d4b48SGerrit Uitslag * @return bool 51747248316SAndreas Gohr */ 51847248316SAndreas Gohrfunction check_permissions(){ 51947248316SAndreas Gohr global $error; 52047248316SAndreas Gohr global $lang; 52147248316SAndreas Gohr 52247248316SAndreas Gohr $dirs = array( 52347248316SAndreas Gohr 'conf' => DOKU_LOCAL, 52447248316SAndreas Gohr 'data' => DOKU_INC.'data', 52547248316SAndreas Gohr 'pages' => DOKU_INC.'data/pages', 52647248316SAndreas Gohr 'attic' => DOKU_INC.'data/attic', 52747248316SAndreas Gohr 'media' => DOKU_INC.'data/media', 52849b78edaSAndreas Gohr 'media_attic' => DOKU_INC.'data/media_attic', 52949b78edaSAndreas Gohr 'media_meta' => DOKU_INC.'data/media_meta', 53047248316SAndreas Gohr 'meta' => DOKU_INC.'data/meta', 53147248316SAndreas Gohr 'cache' => DOKU_INC.'data/cache', 53247248316SAndreas Gohr 'locks' => DOKU_INC.'data/locks', 5339711045aSAndreas Gohr 'index' => DOKU_INC.'data/index', 534de33a58fSMichael Klier 'tmp' => DOKU_INC.'data/tmp' 53547248316SAndreas Gohr ); 53647248316SAndreas Gohr 53747248316SAndreas Gohr $ok = true; 53847248316SAndreas Gohr foreach($dirs as $dir){ 53979e79377SAndreas Gohr if(!file_exists("$dir/.") || !is_writable($dir)){ 54070a6aa16Schris $dir = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}', $dir); 54147248316SAndreas Gohr $error[] = sprintf($lang['i_permfail'],$dir); 54247248316SAndreas Gohr $ok = false; 54347248316SAndreas Gohr } 54447248316SAndreas Gohr } 54547248316SAndreas Gohr return $ok; 54647248316SAndreas Gohr} 54747248316SAndreas Gohr 54847248316SAndreas Gohr/** 5493afe5d1cSAndreas Gohr * Check the availability of functions used in DokuWiki and the PHP version 55047248316SAndreas Gohr * 55147248316SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 552253d4b48SGerrit Uitslag * 553253d4b48SGerrit Uitslag * @return bool 55447248316SAndreas Gohr */ 55547248316SAndreas Gohrfunction check_functions(){ 55647248316SAndreas Gohr global $error; 55747248316SAndreas Gohr global $lang; 5583afe5d1cSAndreas Gohr $ok = true; 5593afe5d1cSAndreas Gohr 5603476bb81SAndreas Gohr if(version_compare(phpversion(),'5.6.0','<')){ 5613476bb81SAndreas Gohr $error[] = sprintf($lang['i_phpver'],phpversion(),'5.6.0'); 5623afe5d1cSAndreas Gohr $ok = false; 5633afe5d1cSAndreas Gohr } 5643afe5d1cSAndreas Gohr 5657f413440SAndreas Gohr if(ini_get('mbstring.func_overload') != 0){ 5667f413440SAndreas Gohr $error[] = $lang['i_mbfuncoverload']; 5677f413440SAndreas Gohr $ok = false; 5687f413440SAndreas Gohr } 5697f413440SAndreas Gohr 5703009a773SAndreas Gohr $funcs = explode(' ','addslashes call_user_func chmod copy fgets '. 57147248316SAndreas Gohr 'file file_exists fseek flush filesize ftell fopen '. 57247248316SAndreas Gohr 'glob header ignore_user_abort ini_get mail mkdir '. 57347248316SAndreas Gohr 'ob_start opendir parse_ini_file readfile realpath '. 574bab4a8bdSAndreas Gohr 'rename rmdir serialize session_start unlink usleep '. 575d1d99bb9SAndreas Gohr 'preg_replace file_get_contents htmlspecialchars_decode '. 576ab38a322Slupo49 'spl_autoload_register stream_select fsockopen pack'); 57747248316SAndreas Gohr 57870a6aa16Schris if (!function_exists('mb_substr')) { 57970a6aa16Schris $funcs[] = 'utf8_encode'; 58070a6aa16Schris $funcs[] = 'utf8_decode'; 58170a6aa16Schris } 58270a6aa16Schris 58347248316SAndreas Gohr foreach($funcs as $func){ 58447248316SAndreas Gohr if(!function_exists($func)){ 58547248316SAndreas Gohr $error[] = sprintf($lang['i_funcna'],$func); 58647248316SAndreas Gohr $ok = false; 58747248316SAndreas Gohr } 58847248316SAndreas Gohr } 58947248316SAndreas Gohr return $ok; 59047248316SAndreas Gohr} 59147248316SAndreas Gohr 59247248316SAndreas Gohr/** 59347248316SAndreas Gohr * Print language selection 59447248316SAndreas Gohr * 59547248316SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 59647248316SAndreas Gohr */ 59747248316SAndreas Gohrfunction langsel(){ 59847248316SAndreas Gohr global $lang; 59947248316SAndreas Gohr global $LC; 60047248316SAndreas Gohr 60147248316SAndreas Gohr $dir = DOKU_INC.'inc/lang'; 60247248316SAndreas Gohr $dh = opendir($dir); 60347248316SAndreas Gohr if(!$dh) return; 60447248316SAndreas Gohr 60547248316SAndreas Gohr $langs = array(); 60647248316SAndreas Gohr while (($file = readdir($dh)) !== false) { 60747248316SAndreas Gohr if(preg_match('/^[\._]/',$file)) continue; 60879e79377SAndreas Gohr if(is_dir($dir.'/'.$file) && file_exists($dir.'/'.$file.'/lang.php')){ 60947248316SAndreas Gohr $langs[] = $file; 61047248316SAndreas Gohr } 61147248316SAndreas Gohr } 61247248316SAndreas Gohr closedir($dh); 61347248316SAndreas Gohr sort($langs); 61447248316SAndreas Gohr 61547248316SAndreas Gohr echo '<form action="">'; 61647248316SAndreas Gohr echo $lang['i_chooselang']; 61747248316SAndreas Gohr echo ': <select name="l" onchange="submit()">'; 61847248316SAndreas Gohr foreach($langs as $l){ 61947248316SAndreas Gohr $sel = ($l == $LC) ? 'selected="selected"' : ''; 62047248316SAndreas Gohr echo '<option value="'.$l.'" '.$sel.'>'.$l.'</option>'; 62147248316SAndreas Gohr } 62247248316SAndreas Gohr echo '</select> '; 623ae614416SAnika Henke echo '<button type="submit">'.$lang['btn_update'].'</button>'; 62447248316SAndreas Gohr echo '</form>'; 62547248316SAndreas Gohr} 62647248316SAndreas Gohr 62747248316SAndreas Gohr/** 628c66972f2SAdrian Lang * Print global error array 62947248316SAndreas Gohr * 63047248316SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 63147248316SAndreas Gohr */ 63247248316SAndreas Gohrfunction print_errors(){ 63347248316SAndreas Gohr global $error; 6344b530faaSTom N Harris if(!empty($error)) { 63547248316SAndreas Gohr echo '<ul>'; 63647248316SAndreas Gohr foreach ($error as $err){ 63747248316SAndreas Gohr echo "<li>$err</li>"; 63847248316SAndreas Gohr } 63947248316SAndreas Gohr echo '</ul>'; 64047248316SAndreas Gohr } 6414b530faaSTom N Harris} 642