installer updates
Restructured and cleaned up installer with full I18N support. Needs testing. darcs-hash:20060726201047-7ad00-e4f66cb356a47453d2f56ef948bc8e2194a8303d.gz
This commit is contained in:
parent
e61d3d86ef
commit
472483168f
|
@ -0,0 +1,24 @@
|
|||
<p>This page assists in the first time installation and configuration of
|
||||
<a href="http://wiki.splitbrain.org">Dokuwiki</a>. More info on this
|
||||
installer is available on it's own
|
||||
<a href="http://wiki.splitbrain.org/wiki:installer">documentation page</a>.</p>
|
||||
|
||||
<p>DokuWiki uses ordinary files for the storage of wiki pages and other
|
||||
information associated with those pages (e.g. images, search indexes, old
|
||||
revisions, etc). In order to operate successfully DokuWiki
|
||||
<strong>must</strong> have write access to the directories that hold those
|
||||
files. This installer is not capable of setting up directory permissions. That
|
||||
normally needs to be done directly on a command shell or if you are using hosting,
|
||||
through FTP or your hosting control panel (e.g. cPanel).</p>
|
||||
|
||||
<p>This installer will setup your DokuWiki configuration for
|
||||
<acronym title="access control list">ACL</acronym>, which in turn allows administrator
|
||||
login and access to DokuWiki's admin menu for installing plugins, managing
|
||||
users, managing access to wiki pages and alteration of configuration settings.
|
||||
It isn't required for DokuWiki to operate, however it will make Dokuwiki easier
|
||||
to administer.</p>
|
||||
|
||||
<p>Experienced users or users with special setup requirements should use these links
|
||||
for details concerning
|
||||
<a href="http://wiki.splitbrain.org/wiki:install">installation instructions</a>
|
||||
and <a href="http://wiki.splitbrain.org/wiki:config">configuration settings</a>.</p>
|
|
@ -195,4 +195,26 @@ $lang['unsubscribe_error'] = 'Error removing %s from subscription list for %s';
|
|||
$lang['authmodfailed'] = 'Bad user authentication configuration. Please inform your Wiki Admin.';
|
||||
$lang['authtempfail'] = 'User authentication is temporarily unavailable. If this situation persists, please inform your Wiki Admin.';
|
||||
|
||||
/* installer strings */
|
||||
$lang['i_chooselang'] = 'Choose your language';
|
||||
$lang['i_installer'] = 'DokuWiki Installer';
|
||||
$lang['i_wikiname'] = 'Wiki Name';
|
||||
$lang['i_enableacl'] = 'Enable ACL (recommended)';
|
||||
$lang['i_superuser'] = 'Superuser';
|
||||
$lang['i_problems'] = 'The installer found some problems, indicated below. You can not continue until you fixed them.';
|
||||
$lang['i_modified'] = 'For security reasons this script will only work with a new and unmodified Dokuwiki installation.
|
||||
You should either re-extract the files from the downloaded package or consult the complete
|
||||
<a href="http://wiki.splitbrain.org/wiki:install">Dokuwiki installation instructions</a>';
|
||||
$lang['i_funcna'] = 'PHP function <code>%s</code> is not available. Maybe your provider disabled it for some reason?';
|
||||
$lang['i_permfail'] = '<code>%s</code> is not writable by DokuWiki. You need to fix the permission settings of this directory!';
|
||||
$lang['i_confexists'] = '<code>%s</code> already exists';
|
||||
$lang['i_writeerr'] = 'Unable to create <code>%s</code>. You will need to check directory/file permissions and create the file manually.';
|
||||
$lang['i_badhash'] = 'unrecognised or modified dokuwiki.php (hash=<code>%s</code>)';
|
||||
$lang['i_badval'] = '<code>%s</code> - illegal or empty value';
|
||||
$lang['i_success'] = 'The configuration was finished successfully. You may delete the install.php file now. Continue to
|
||||
<a href="doku.php">your new DokuWiki</a>.';
|
||||
$lang['i_failure'] = 'Some errors occured while writing the configuration files. You may need to fix them manually before
|
||||
you can use <a href="doku.php">your new DokuWiki</a>.';
|
||||
|
||||
|
||||
//Setup VIM: ex: et ts=2 enc=utf-8 :
|
||||
|
|
799
install.php
799
install.php
|
@ -9,90 +9,430 @@ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__)).'/');
|
|||
if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/');
|
||||
if(!defined('DOKU_LOCAL')) define('DOKU_LOCAL',DOKU_INC.'conf/');
|
||||
|
||||
if(!defined('DEBUG')) define('DEBUG', false);
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// important settings ...
|
||||
// installation dependent local config file list
|
||||
$config_files = array(
|
||||
'local' => DOKU_LOCAL.'local.php',
|
||||
'users' => DOKU_LOCAL.'users.auth.php',
|
||||
'auth' => DOKU_LOCAL.'acl.auth.php'
|
||||
);
|
||||
|
||||
// other installation dir/file permission requirements
|
||||
$install_permissions = array(
|
||||
'data' => 'data',
|
||||
'pages' => 'data/pages',
|
||||
'attic' => 'data/attic',
|
||||
'media' => 'data/media',
|
||||
'meta' => 'data/meta',
|
||||
'cache' => 'data/cache',
|
||||
'locks' => 'data/locks',
|
||||
'changelog' => 'data/changes.log'
|
||||
);
|
||||
|
||||
// array use to verify unchanged dokuwiki.php files, 'version' => 'md5 hash'
|
||||
$dokuwiki_php = DOKU_CONF.'dokuwiki.php';
|
||||
$dokuwiki_hash = array(
|
||||
'2005-09-22' => 'e33223e957b0b0a130d0520db08f8fb7',
|
||||
'2006-03-05' => '51295727f79ab9af309a2fd9e0b61acc',
|
||||
'2006-03-09' => '51295727f79ab9af309a2fd9e0b61acc',
|
||||
);
|
||||
// kill magic quotes
|
||||
if (get_magic_quotes_gpc() && !defined('MAGIC_QUOTES_STRIPPED')) {
|
||||
if (!empty($_GET)) remove_magic_quotes($_GET);
|
||||
if (!empty($_POST)) remove_magic_quotes($_POST);
|
||||
if (!empty($_COOKIE)) remove_magic_quotes($_COOKIE);
|
||||
if (!empty($_REQUEST)) remove_magic_quotes($_REQUEST);
|
||||
@ini_set('magic_quotes_gpc', 0);
|
||||
define('MAGIC_QUOTES_STRIPPED',1);
|
||||
}
|
||||
@set_magic_quotes_runtime(0);
|
||||
@ini_set('magic_quotes_sybase',0);
|
||||
|
||||
// language strings
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// initialise variables ...
|
||||
|
||||
$msg = array();
|
||||
$error = array();
|
||||
$debug = array();
|
||||
$process_form = false;
|
||||
|
||||
// form variables with default values
|
||||
$title = "";
|
||||
$location = true;
|
||||
$data = "./data";
|
||||
$changeslog = true;
|
||||
$acl = true;
|
||||
$superuser = "";
|
||||
$fullname = "";
|
||||
$email = "";
|
||||
|
||||
// check for dokuwiki
|
||||
// (for now assume included with Dokuwiki install & resident in dokuwiki root folder)
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// check for virgin dokuwiki installation
|
||||
$virgin_install = true;
|
||||
|
||||
// $config_files mustn't exist
|
||||
foreach ($config_files as $file) {
|
||||
if (@file_exists($file)) {
|
||||
$virgin_install = false;
|
||||
$file = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}', $file);
|
||||
$msg[] = "<span class=\"file\">$file</span> exists"; }
|
||||
}
|
||||
|
||||
// main dokuwiki config file (conf/dokuwiki.php) must not have been modified
|
||||
$installation_hash = md5(@file_get_contents($dokuwiki_php));
|
||||
if (!in_array($installation_hash, $dokuwiki_hash)) {
|
||||
$virgin_install = false;
|
||||
$msg[] = "unrecognised or modified dokuwiki.php -- hash=$installation_hash";
|
||||
}
|
||||
// ------------------------------------------------------------------------------------
|
||||
// check for other basic installation & configuration details (to be nice)
|
||||
|
||||
$changeslog_exists = @file_exists(DOKU_INC.'data/changes.log');
|
||||
|
||||
if (!is_writable(DOKU_CONF)) {
|
||||
$file = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}', DOKU_CONF);
|
||||
$error[] = "<span class=\"file\">$file</span> must be writable by the web server.";
|
||||
require_once(DOKU_INC.'inc/lang/en/lang.php');
|
||||
$LC = preg_replace('/[^a-z\-]+/','',$_REQUEST['l']);
|
||||
if(!$LC) $LC = 'en';
|
||||
if($LC && $LC != 'en' ) {
|
||||
require_once(DOKU_INC.'inc/lang/'.$LC.'/lang.php');
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// utility functions
|
||||
// initialise variables ...
|
||||
$error = array();
|
||||
|
||||
$dokuwiki_hash = array(
|
||||
'2005-09-22' => 'e33223e957b0b0a130d0520db08f8fb7',
|
||||
'2006-03-05' => '51295727f79ab9af309a2fd9e0b61acc',
|
||||
'2006-03-09' => '51295727f79ab9af309a2fd9e0b61acc',
|
||||
'devel' => '732131839d559198b985e183eefe9a63',
|
||||
);
|
||||
|
||||
|
||||
|
||||
// begin output
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $LC?>"
|
||||
lang="<?php echo $LC?>" dir="<?php echo $lang['direction']?>">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>DokuWiki Installer</title>
|
||||
<style type="text/css">
|
||||
body { width: 90%; margin: 0 auto; font: 84% Verdana, Helvetica, Arial, sans-serif; }
|
||||
img { border: none }
|
||||
br.cl { clear:both; }
|
||||
code { font-size: 110%; color: #008000; }
|
||||
fieldset { border: none }
|
||||
label { display: block;}
|
||||
input.text { width: 30em; margin: 0 0.5em; }
|
||||
</style>
|
||||
<script type="text/javascript" language="javascript">
|
||||
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">
|
||||
<img src="http://wiki.splitbrain.org/_media/wiki:dokuwiki-64.png"
|
||||
style="vertical-align: middle;" alt="" />
|
||||
<?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
|
||||
if(@file_exists(DOKU_INC.'inc/lang/'.$LC.'/install.html')){
|
||||
include(DOKU_INC.'inc/lang/'.$LC.'/install.html');
|
||||
}else{
|
||||
include(DOKU_INC.'inc/lang/en/install.html');
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div style="float: left; width: 58%;">
|
||||
<?php
|
||||
if(! (check_functions() && check_permissions()) ){
|
||||
echo '<p>'.$lang['i_problems'].'</p>';
|
||||
print_errors();
|
||||
}elseif(!check_configs()){
|
||||
echo '<p>'.$lang['i_modified'].'</p>';
|
||||
print_errors();
|
||||
}elseif($_REQUEST['submit']){
|
||||
if(!check_data($_REQUEST['d'])){
|
||||
print_errors();
|
||||
print_form($_REQUEST['d']);
|
||||
}elseif(!store_data($_REQUEST['d'])){
|
||||
echo '<p>'.$lang['i_failure'].'</p>';
|
||||
print_errors();
|
||||
}else{
|
||||
echo '<p>'.$lang['i_success'].'</p>';
|
||||
}
|
||||
}else{
|
||||
print_form($_REQUEST['d']);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div style="clear: both">
|
||||
<a href="http://wiki.splitbrain.org/wiki:dokuwiki"><img src="lib/tpl/default/images/button-dw.png" alt="driven by DokuWiki" /></a>
|
||||
<a href="http://www.php.net"><img src="lib/tpl/default/images/button-php.gif" alt="powered by PHP" /></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Print the input form
|
||||
*/
|
||||
function print_form($d){
|
||||
global $lang;
|
||||
global $LC;
|
||||
|
||||
if(!is_array($d)) $d = array();
|
||||
$d = array_map('htmlspecialchars',$d);
|
||||
|
||||
if(!isset($d['acl'])) $d['acl']=1;
|
||||
|
||||
?>
|
||||
<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">
|
||||
<input type="checkbox" name="d[acl]" id="acl" <?php echo(($d['acl'] ? 'checked="checked"' : ''));?> />
|
||||
<?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" />
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
</fieldset>
|
||||
<fieldset id="process">
|
||||
<input class="button" type="submit" name="submit" value="<?php echo $lang['btn_save']?>" />
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Check validity of data
|
||||
*
|
||||
* @author Andreas Gohr
|
||||
*/
|
||||
function check_data($d){
|
||||
global $lang;
|
||||
global $error;
|
||||
|
||||
$ok = true;
|
||||
|
||||
// check input
|
||||
if(empty($d['title'])){
|
||||
$error[] = sprintf($lang['i_badval'],$lang['i_wikiname']);
|
||||
$ok = false;
|
||||
}
|
||||
if($d['acl']){
|
||||
if(!preg_match('/^[a-z1-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;
|
||||
}
|
||||
if($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['fullname'],':')){
|
||||
$error[] = sprintf($lang['i_badval'],$lang['email']);
|
||||
$ok = false;
|
||||
}
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the data to the config files
|
||||
*
|
||||
* @author Chris Smith <chris@jalakai.co.uk>
|
||||
*/
|
||||
function store_data($d){
|
||||
$ok = true;
|
||||
|
||||
// create changes.log
|
||||
if (!@file_exists(DOKU_INC.'data/changes.log')){
|
||||
$ok = $ok && fileWrite(DOKU_INC.'data/changes.log','');
|
||||
}
|
||||
|
||||
// create local.php
|
||||
$now = date('r');
|
||||
$output = <<<EOT
|
||||
<?php
|
||||
/**
|
||||
* Dokuwiki's Main Configuration File - Local Settings
|
||||
* Auto-generated by install script
|
||||
* Date: $now
|
||||
*/
|
||||
|
||||
EOT;
|
||||
$output .= '$conf[\'title\'] = \''.addslashes($d['title'])."';\n";
|
||||
if($d['acl']){
|
||||
$output .= '$conf[\'useacl\'] = 1'.";\n";
|
||||
$output .= '$conf[\'superuser\'] = \''.$d['superuser']."';\n";
|
||||
}
|
||||
$ok = $ok && fileWrite(DOKU_LOCAL.'local.php',$output);
|
||||
|
||||
|
||||
if ($d['acl']) {
|
||||
// create users.auth.php
|
||||
// --- user:MD5password:Real Name:email:groups,comma,seperated
|
||||
$output = join(":",array($d['superuser'], md5($d['password']), $d['fullname'], $d['email'], 'users'));
|
||||
$output = @file_get_contents(DOKU_CONF.'users.auth.php.dist')."\n$output\n";
|
||||
$ok = $ok && fileWrite(DOKU_LOCAL.'users.auth.php', $output);
|
||||
|
||||
// create acl.auth.php
|
||||
$output = @file_get_contents(DOKU_CONF.'acl.auth.php.dist');
|
||||
$ok = $ok && fileWrite(DOKU_LOCAL.'acl.auth.php', $output);
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the given content to a file
|
||||
*
|
||||
* @author Chris Smith <chris@jalakai.co.uk>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
if (!empty($data)) { fwrite($fp, $data); }
|
||||
fclose($fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check installation dependent local config files and tests for a known
|
||||
* unmodified main config file
|
||||
*
|
||||
* @author Chris Smith <chris@jalakai.co.uk>
|
||||
*/
|
||||
function check_configs(){
|
||||
global $error;
|
||||
global $lang;
|
||||
global $dokuwiki_hash;
|
||||
|
||||
$ok = true;
|
||||
|
||||
$config_files = array(
|
||||
'local' => DOKU_LOCAL.'local.php',
|
||||
'users' => DOKU_LOCAL.'users.auth.php',
|
||||
'auth' => DOKU_LOCAL.'acl.auth.php'
|
||||
);
|
||||
|
||||
|
||||
// main dokuwiki config file (conf/dokuwiki.php) must not have been modified
|
||||
$installation_hash = md5(@file_get_contents(DOKU_CONF.'dokuwiki.php'));
|
||||
if (!in_array($installation_hash, $dokuwiki_hash)) {
|
||||
$error[] = sprintf($lang['i_badhash'],$installation_hash);
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
// configs shouldn't exist
|
||||
foreach ($config_files as $file) {
|
||||
if (@file_exists($file)) {
|
||||
$file = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $file);
|
||||
$error[] = sprintf($lang['i_confexists'],$file);
|
||||
$ok = false;
|
||||
}
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check other installation dir/file permission requirements
|
||||
*
|
||||
* @author Chris Smith <chris@jalakai.co.uk>
|
||||
*/
|
||||
function check_permissions(){
|
||||
global $error;
|
||||
global $lang;
|
||||
|
||||
$dirs = array(
|
||||
'conf' => DOKU_LOCAL,
|
||||
'data' => DOKU_INC.'data',
|
||||
'pages' => DOKU_INC.'data/pages',
|
||||
'attic' => DOKU_INC.'data/attic',
|
||||
'media' => DOKU_INC.'data/media',
|
||||
'meta' => DOKU_INC.'data/meta',
|
||||
'cache' => DOKU_INC.'data/cache',
|
||||
'locks' => DOKU_INC.'data/locks',
|
||||
);
|
||||
|
||||
$ok = true;
|
||||
foreach($dirs as $dir){
|
||||
if(!@file_exists("$dir/.") || !@is_writable($dir)){
|
||||
$dir = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $dir);
|
||||
$error[] = sprintf($lang['i_permfail'],$dir);
|
||||
$ok = false;
|
||||
}
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the availability of functions used in DokuWiki
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function check_functions(){
|
||||
global $error;
|
||||
global $lang;
|
||||
$funcs = explode(' ','addslashes basename call_user_func chmod copy fgets '.
|
||||
'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 '.
|
||||
'rename rmdir serialize session_start unlink usleep');
|
||||
|
||||
$ok = true;
|
||||
foreach($funcs as $func){
|
||||
if(!function_exists($func)){
|
||||
$error[] = sprintf($lang['i_funcna'],$func);
|
||||
$ok = false;
|
||||
}
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
if(is_dir($dir.'/'.$file) && @file_exists($dir.'/'.$file.'/lang.php')){
|
||||
$langs[] = $file;
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
sort($langs);
|
||||
|
||||
|
||||
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>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '<input type="submit" value="'.$lang['btn_update'].'" />';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Print gloabl error array
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function print_errors(){
|
||||
global $error;
|
||||
echo '<ul>';
|
||||
foreach ($error as $err){
|
||||
echo "<li>$err</li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
/**
|
||||
* remove magic quotes recursivly
|
||||
|
@ -109,302 +449,3 @@ function remove_magic_quotes(&$array) {
|
|||
}
|
||||
}
|
||||
|
||||
function cleanText($var, $default, $regex, $msg) {
|
||||
global $error;
|
||||
|
||||
$value = isset($_REQUEST[$var]) ? $_REQUEST[$var] : $default;
|
||||
|
||||
if ($regex) {
|
||||
if (!preg_match($regex, $value)) {
|
||||
$error[] = "$var - illegal/unrecognised value";
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function fileWrite($name, $filename, $data) {
|
||||
global $error;
|
||||
|
||||
if (($fp = @fopen($filename, 'wb')) === false) {
|
||||
$filename = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}', $filename);
|
||||
$error[] = "Unable to create $name (<span class=\"file\">$filename</span>). You will need to check directory/file permissions and create the file manually.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($data)) { fwrite($fp, $data); }
|
||||
fclose($fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// form processing ...
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
if (!$virgin_install) {
|
||||
$msg[] = "unable to apply updates, installation already modified";
|
||||
|
||||
} else {
|
||||
// apply updates per form instructions
|
||||
$process_form = true;
|
||||
|
||||
if (get_magic_quotes_gpc()) {
|
||||
if (!empty($_REQUEST)) remove_magic_quotes($_REQUEST);
|
||||
}
|
||||
|
||||
$title = cleanText('title', '', '');
|
||||
$location = isset($_REQUEST['location']);
|
||||
$data = cleanText('data', '', '');
|
||||
$changeslog = isset($_REQUEST['changeslog']);
|
||||
$acl = isset($_REQUEST['acl']);
|
||||
$superuser = cleanText('superuser','','/\S+/');
|
||||
$password = cleanText('password','','/\S+/');
|
||||
$confirm = cleanText('confirm','','/^'.preg_quote($password,'/').'$/');
|
||||
$fullname = cleanText('fullname','','');
|
||||
$email = cleanText('email','','');
|
||||
|
||||
$debug = compact('title','location','data','changeslog','acl','superuser','password','confirm');
|
||||
|
||||
if (empty($error)) {
|
||||
// all incoming data is ok ... lets do ...
|
||||
// create changes.log
|
||||
if (!$changeslog_exists) {
|
||||
$filename = realpath((empty($data) || ($data{0} != "/")) ? DOKU_INC.$data : $data).'/changes.log';
|
||||
fileWrite('changeslog',$filename, '');
|
||||
}
|
||||
|
||||
// create local.php
|
||||
$output = "";
|
||||
if (!empty($title)) $output .= '$conf[\'title\'] = \''.addslashes($title)."';\n";
|
||||
if (!empty($data)) $output .= '$conf[\'data\'] = \''.$data."';\n";
|
||||
if ($acl) $output .= '$conf[\'useacl\'] = 1'.";\n";
|
||||
if (!empty($superuser)) $output .= '$conf[\'superuser\'] = \''.$superuser."';\n";
|
||||
|
||||
if (!empty($output)) {
|
||||
$output = '<'.'?php
|
||||
/*
|
||||
* Dokuwiki\'s Main Configuration File - Local Settings
|
||||
* Auto-generated by install script
|
||||
* Date: '.date('r').'
|
||||
*/'."\n".$output;
|
||||
fileWrite('local configuration settings file',DOKU_LOCAL.'local.php',$output);
|
||||
}
|
||||
|
||||
if ($acl) {
|
||||
// create users.auth.php
|
||||
// --- user:MD5password:Real Name:email:groups,comma,seperated
|
||||
$output = (!empty($superuser)) ? join(":",array($superuser, md5($password), $fullname, $email, 'users')) : "";
|
||||
$output = @file_get_contents(DOKU_CONF.'users.auth.php.dist')."\n$output\n";
|
||||
|
||||
fileWrite('acl user file', DOKU_LOCAL.'users.auth.php', $output);
|
||||
|
||||
// create acl.auth.php
|
||||
$output = @file_get_contents(DOKU_CONF.'acl.auth.php.dist');
|
||||
fileWrite('acl authorisations file', DOKU_LOCAL.'acl.auth.php', $output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
$show_form = !$process_form && $virgin_install && empty($error);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
|
||||
<title>Dokuwiki Installer</title>
|
||||
<style type="text/css">
|
||||
<!--/*--><![CDATA[/*><!--*/
|
||||
|
||||
html {margin: 0; padding: 0;}
|
||||
body {
|
||||
width: 90%;
|
||||
margin: 0 auto;
|
||||
font: 84% Verdana, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.abbr {
|
||||
border-bottom: 2px dotted #444;
|
||||
}
|
||||
|
||||
.alert .file {
|
||||
color: #a03333;
|
||||
}
|
||||
|
||||
.error .file {
|
||||
color: #c33;
|
||||
}
|
||||
|
||||
h1 img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
form, fieldset {
|
||||
margin: 1em 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
ul {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
form .field {
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
label span {
|
||||
display: block;
|
||||
}
|
||||
|
||||
label input.text {
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
#instructions {
|
||||
float: right;
|
||||
width: 34%;
|
||||
}
|
||||
|
||||
#details {
|
||||
float: left;
|
||||
width: 58%;
|
||||
}
|
||||
|
||||
#process {
|
||||
margin: 1.5em 0;
|
||||
}
|
||||
|
||||
#debug, #footer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
#acl, #files {
|
||||
border: 1px solid #ccc;
|
||||
padding: 0.5em 0 1em 0;
|
||||
}
|
||||
|
||||
fieldset.dependent {
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
|
||||
/*]]>*/-->
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
<!--//--><![CDATA[//><!--
|
||||
|
||||
|
||||
//--><!]]>
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1><img src="http://wiki.splitbrain.org/_media/wiki:dokuwiki-64.png" alt="" />Dokuwiki Installer</h1>
|
||||
<div id="instructions">
|
||||
<p>This page assists in the installation and configuration of <a href="http://wiki.splitbrain.org">Dokuwiki</a>.</p>
|
||||
<p>Dokuwiki uses ordinary files for the storage of wiki pages and other information associated with those pages
|
||||
(e.g. images, search indexes, old revisions, etc). In order to operate successfully Dokuwiki <strong>must</strong>
|
||||
have write access to the directories that hold those files. This installer is not capable of setting up directory
|
||||
permissions, that normally needs to be done directly or if you are using hosting, through your hosting
|
||||
control panel (e.g. cPanel).</p>
|
||||
<p>This installer will setup your Dokuwiki configuration for <span class="abbr" title="access control list">ACL</span>,
|
||||
which in turn allows administrator login and access to Dokuwiki's admin menu for installing plugins, managing
|
||||
users, managing access to wiki pages and alteration of configuration settings. It isn't required for Dokuwiki to
|
||||
operate, however it will make Dokuwiki easier to administer.</p>
|
||||
<p>Use these links for details concerning <a href="http://wiki.splitbrain.org/wiki:installation">installation instructions</a>
|
||||
and <a href="http://wiki.splitbrain.org/wiki:configuration">configuration settings</a>.</p>
|
||||
</div>
|
||||
<div id="details">
|
||||
<?php if (!$virgin_install) { ?>
|
||||
<p>Modified installation detected.</p>
|
||||
<ul class="alert">
|
||||
<?php foreach ($msg as $text) { ?>
|
||||
<li><?php echo $text?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<p>For security reasons this script will only work with a new & unmodified Dokuwiki installation.
|
||||
You should either re-extract the files from the downloaded package or consult the complete
|
||||
<a href="http://wiki.splitbrain.org/wiki:install">Dokuwiki installation instructions</a></p>
|
||||
<?php } /* end if (!virgin_install) */ ?>
|
||||
<?php if (!$process_form && !empty($error)) { ?>
|
||||
<p>One or more incorrect directory/file permissions were found.</p>
|
||||
<ul class="error">
|
||||
<?php foreach ($error as $text) { ?>
|
||||
<li><?php echo $text ?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<p>In order to complete this installation the above directories and files need to have their
|
||||
permissions altered as indicated. Please correct the above problems before trying again.</p>
|
||||
<?php } /* end if (!$process_form && !empty($error)) */ ?>
|
||||
<?php if ($process_form) { ?>
|
||||
<?php if (empty($error)) { ?>
|
||||
<p>Configuration updated successfully.</p>
|
||||
<p>Now that your initial dokuwiki configuration has been set you should delete this file to prevent its further use
|
||||
which may damage your dokuwiki installation and/or configuration.</p>
|
||||
<p>Use this link to visit your new <a href="doku.php" title="my new dokuWiki">wiki</a></p>
|
||||
<?php } else { ?>
|
||||
<p>The following errors were encountered ... </p>
|
||||
<ul class="error">
|
||||
<?php foreach ($error as $text) { ?>
|
||||
<li><?php echo $text?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<p>return to <a href="install.php">installation form</a></p>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php if ($show_form) { ?>
|
||||
<form action="" method="post">
|
||||
<fieldset id="wiki">
|
||||
<div class="field"><label><span> Wiki Name </span><input class="text" type="text" name="title" value="<?php echo $title ?>" /></label></div>
|
||||
<fieldset id="acl">
|
||||
<div class="field"><label><input class="checkbox" type="checkbox" name="acl" <?php echo(($acl ? 'checked="checked"' : ''));?> /> Enable ACL </label></div>
|
||||
<fieldset class="dependent">
|
||||
<div class="field"><label><span> Superuser </span><input class="text" type="text" name="superuser" value="<?php echo $superuser ?>" /></label></div>
|
||||
<div class="field"><label><span> Full name </span><input class="text" type="text" name="fullname" value="<?php echo $fullname ?>" /></label></div>
|
||||
<div class="field"><label><span> Email Address </span><input class="text" type="text" name="email" value="<?php echo $email ?>" /></label></div>
|
||||
<div class="field"><label><span> Superuser password </span><input class="text" type="password" name="password" /></label></div>
|
||||
<div class="field"><label><span> Confirm password </span><input class="text" type="password" name="confirm" /></label></div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<fieldset id="files">
|
||||
<div class="field"><label><input class="checkbox" type="checkbox" name="location" <?php echo(($location ? 'checked="checked"' : ''));?> />Use default wiki location</label></div>
|
||||
<fieldset class="dependent">
|
||||
<div class="field"><label><span> Wiki Location </span><input class="text" type="text" name="data" value="<?php echo $data ?>" /></label></div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<?php if (!$changeslog_exists) { ?>
|
||||
<div class="field"><label><input class="checkbox" type="checkbox" name="changeslog" <?php echo(($changeslog ? 'checked="checked"' : ''));?> />Create changes.log file</label></div>
|
||||
<?php } ?>
|
||||
</fieldset>
|
||||
<fieldset id="process">
|
||||
<input class="button" type="submit" name="submit" value="Process Configuration Changes" />
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div><!-- #details -->
|
||||
<?php if (DEBUG) { ?>
|
||||
<div id="debug">
|
||||
<pre>
|
||||
<?php print_r($_REQUEST); print_r($debug); print_r($error); ?>
|
||||
</pre>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div id="footer">
|
||||
<a href="http://wiki.splitbrain.org"><img src="lib/tpl/default/images/button-dw.png" alt="powered by dokuwiki" /></a>
|
||||
<a href="http://www.php.net"><img src="lib/tpl/default/images/button-php.gif" alt="powered by php" /></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue