reformatting at top level

This commit is contained in:
Gerrit Uitslag 2023-08-31 00:55:36 +02:00
parent 5a5ec05346
commit ff84abad8a
4 changed files with 297 additions and 266 deletions

View File

@ -16,40 +16,40 @@ $updateVersion = "55";
// xdebug_start_profiling();
if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__.'/');
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/');
// define all DokuWiki globals here (needed within test requests but also helps to keep track)
global $ACT, $INPUT, $QUERY, $ID, $REV, $DATE_AT, $IDX,
$DATE, $RANGE, $HIGH, $TEXT, $PRE, $SUF, $SUM, $INFO, $JSINFO;
global $ACT, $INPUT, $QUERY, $ID, $REV, $DATE_AT, $IDX,
$DATE, $RANGE, $HIGH, $TEXT, $PRE, $SUF, $SUM, $INFO, $JSINFO;
if(isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])) {
$ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO']));
} elseif(!empty($_REQUEST['idx'])) {
} elseif (!empty($_REQUEST['idx'])) {
$ACT = 'index';
} elseif(isset($_REQUEST['do'])) {
} elseif (isset($_REQUEST['do'])) {
$ACT = $_REQUEST['do'];
} else {
$ACT = 'show';
}
// load and initialize the core system
require_once(DOKU_INC.'inc/init.php');
require_once(DOKU_INC . 'inc/init.php');
//import variables
$INPUT->set('id', str_replace("\xC2\xAD", '', $INPUT->str('id'))); //soft-hyphen
$QUERY = trim($INPUT->str('q'));
$ID = getID();
$QUERY = trim($INPUT->str('q'));
$ID = getID();
$REV = $INPUT->int('rev');
$REV = $INPUT->int('rev');
$DATE_AT = $INPUT->str('at');
$IDX = $INPUT->str('idx');
$DATE = $INPUT->int('date');
$IDX = $INPUT->str('idx');
$DATE = $INPUT->int('date');
$RANGE = $INPUT->str('range');
$HIGH = $INPUT->param('s');
if(empty($HIGH)) $HIGH = getGoogleQuery();
$HIGH = $INPUT->param('s');
if (empty($HIGH)) $HIGH = getGoogleQuery();
if($INPUT->post->has('wikitext')) {
if ($INPUT->post->has('wikitext')) {
$TEXT = cleanText($INPUT->post->str('wikitext'));
}
$PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
@ -58,13 +58,13 @@ $SUM = $INPUT->post->str('summary');
//parse DATE_AT
if($DATE_AT) {
if ($DATE_AT) {
$date_parse = strtotime($DATE_AT);
if($date_parse) {
if ($date_parse) {
$DATE_AT = $date_parse;
} else { // check for UNIX Timestamp
$date_parse = @date('Ymd', $DATE_AT);
if(!$date_parse || $date_parse === '19700101') {
if (!$date_parse || $date_parse === '19700101') {
msg(sprintf($lang['unable_to_parse_date'], hsc($DATE_AT)));
$DATE_AT = null;
}
@ -72,7 +72,7 @@ if($DATE_AT) {
}
//check for existing $REV related to $DATE_AT
if($DATE_AT) {
if ($DATE_AT) {
$pagelog = new PageChangeLog($ID);
$rev_t = $pagelog->getLastRevisionAt($DATE_AT);
if ($rev_t === '') {
@ -100,13 +100,13 @@ if($DATE_AT) {
$INFO = pageinfo();
// handle debugging
if($conf['allowdebug'] && $ACT == 'debug') {
if ($conf['allowdebug'] && $ACT == 'debug') {
html_debug();
exit;
}
//send 404 for missing pages if configured or ID has special meaning to bots
if(!$INFO['exists'] &&
if (!$INFO['exists'] &&
($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
($ACT == 'show' || (!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
) {
@ -114,7 +114,7 @@ if(!$INFO['exists'] &&
}
//prepare breadcrumbs (initialize a static var)
if($conf['breadcrumbs']) breadcrumbs();
if ($conf['breadcrumbs']) breadcrumbs();
// check upstream
checkUpdateMessages();

138
feed.php
View File

@ -34,13 +34,13 @@ $opt = rss_parseOptions();
// the feed is dynamic - we need a cache for each combo
// (but most people just use the default feed so it's still effective)
$key = implode('', array_values($opt)) . '$' . $INPUT->server->str('REMOTE_USER')
$key = implode('', array_values($opt)) . '$' . $INPUT->server->str('REMOTE_USER')
. '$' . $INPUT->server->str('HTTP_HOST') . $INPUT->server->str('SERVER_PORT');
$cache = new Cache($key, '.feed');
// prepare cache depends
$depends['files'] = getConfigFiles('main');
$depends['age'] = $conf['rss_update'];
$depends['age'] = $conf['rss_update'];
$depends['purge'] = $INPUT->bool('purge');
// check cacheage and deliver if nothing has changed since last
@ -59,21 +59,21 @@ if ($cache->useCache($depends)) {
}
// create new feed
$rss = new UniversalFeedCreator();
$rss->title = $conf['title'] . (($opt['namespace']) ? ' ' . $opt['namespace'] : '');
$rss->link = DOKU_URL;
$rss = new UniversalFeedCreator();
$rss->title = $conf['title'] . (($opt['namespace']) ? ' ' . $opt['namespace'] : '');
$rss->link = DOKU_URL;
$rss->syndicationURL = DOKU_URL . 'feed.php';
$rss->cssStyleSheet = DOKU_URL . 'lib/exe/css.php?s=feed';
$rss->cssStyleSheet = DOKU_URL . 'lib/exe/css.php?s=feed';
$image = new FeedImage();
$image = new FeedImage();
$image->title = $conf['title'];
$image->url = tpl_getMediaFile([':wiki:favicon.ico', ':favicon.ico', 'images/favicon.ico'], true);
$image->link = DOKU_URL;
$rss->image = $image;
$image->url = tpl_getMediaFile([':wiki:favicon.ico', ':favicon.ico', 'images/favicon.ico'], true);
$image->link = DOKU_URL;
$rss->image = $image;
$data = null;
$data = null;
$modes = [
'list' => 'rssListNamespace',
'list' => 'rssListNamespace',
'search' => 'rssSearch',
'recent' => 'rssRecentChanges'
];
@ -82,10 +82,10 @@ if (isset($modes[$opt['feed_mode']])) {
$data = $modes[$opt['feed_mode']]($opt);
} else {
$eventData = [
'opt' => &$opt,
'opt' => &$opt,
'data' => &$data,
];
$event = new Event('FEED_MODE_UNKNOWN', $eventData);
$event = new Event('FEED_MODE_UNKNOWN', $eventData);
if ($event->advise_before(true)) {
echo sprintf('<error>Unknown feed mode %s</error>', hsc($opt['feed_mode']));
exit;
@ -123,9 +123,9 @@ function rss_parseOptions()
// properties for implementing own feeds
// One of: list, search, recent
'feed_mode' => ['str', 'mode', 'recent'],
'feed_mode' => ['str', 'mode', 'recent'],
// One of: diff, page, rev, current
'link_to' => ['str', 'linkto', $conf['rss_linkto']],
'link_to' => ['str', 'linkto', $conf['rss_linkto']],
// One of: abstract, diff, htmldiff, html
'item_content' => ['str', 'content', $conf['rss_content']],
@ -133,15 +133,15 @@ function rss_parseOptions()
// These are only used by certain feed_modes
// String, used for feed title, in list and rc mode
'namespace' => ['str', 'ns', null],
'namespace' => ['str', 'ns', null],
// Positive integer, only used in rc mode
'items' => ['int', 'num', $conf['recent']],
'items' => ['int', 'num', $conf['recent']],
// Boolean, only used in rc mode
'show_minor' => ['bool', 'minor', false],
'show_minor' => ['bool', 'minor', false],
// Boolean, only used in rc mode
'only_new' => ['bool', 'onlynewpages', false],
'only_new' => ['bool', 'onlynewpages', false],
// String, only used in list mode
'sort' => ['str', 'sort', 'natural'],
'sort' => ['str', 'sort', 'natural'],
// String, only used in search mode
'search_query' => ['str', 'q', null],
// One of: pages, media, both
@ -152,10 +152,10 @@ function rss_parseOptions()
$opt[$name] = $INPUT->{$val[0]}($val[1], $val[2], true);
}
$opt['items'] = max(0, (int) $opt['items']);
$opt['show_minor'] = (bool) $opt['show_minor'];
$opt['only_new'] = (bool) $opt['only_new'];
$opt['sort'] = valid_input_set('sort', ['default' => 'natural', 'date'], $opt);
$opt['items'] = max(0, (int)$opt['items']);
$opt['show_minor'] = (bool)$opt['show_minor'];
$opt['only_new'] = (bool)$opt['only_new'];
$opt['sort'] = valid_input_set('sort', ['default' => 'natural', 'date'], $opt);
$opt['guardmail'] = ($conf['mailguard'] != '' && $conf['mailguard'] != 'none');
@ -196,9 +196,9 @@ function rss_parseOptions()
/**
* Add recent changed pages to a feed object
*
* @param FeedCreator $rss the FeedCreator Object
* @param array $data the items to add
* @param array $opt the feed options
* @param FeedCreator $rss the FeedCreator Object
* @param array $data the items to add
* @param array $opt the feed options
* @author Andreas Gohr <andi@splitbrain.org>
*/
function rss_buildItems(&$rss, &$data, $opt)
@ -209,11 +209,11 @@ function rss_buildItems(&$rss, &$data, $opt)
global $auth;
$eventData = [
'rss' => &$rss,
'rss' => &$rss,
'data' => &$data,
'opt' => &$opt,
'opt' => &$opt,
];
$event = new Event('FEED_DATA_PROCESS', $eventData);
$event = new Event('FEED_DATA_PROCESS', $eventData);
if ($event->advise_before(false)) {
foreach ($data as $ditem) {
if (!is_array($ditem)) {
@ -222,7 +222,7 @@ function rss_buildItems(&$rss, &$data, $opt)
}
$item = new FeedItem();
$id = $ditem['id'];
$id = $ditem['id'];
if (empty($ditem['media'])) {
$meta = p_get_metadata($id);
} else {
@ -260,8 +260,8 @@ function rss_buildItems(&$rss, &$data, $opt)
$item->link = media_managerURL(
[
'image' => $id,
'ns' => getNS($id),
'rev' => $date
'ns' => getNS($id),
'rev' => $date
],
'&',
true
@ -274,9 +274,9 @@ function rss_buildItems(&$rss, &$data, $opt)
if ($ditem['media']) {
$item->link = media_managerURL(
[
'image' => $id,
'ns' => getNS($id),
'rev' => $date,
'image' => $id,
'ns' => getNS($id),
'rev' => $date,
'tab_details' => 'history'
],
'&',
@ -291,7 +291,7 @@ function rss_buildItems(&$rss, &$data, $opt)
$item->link = media_managerURL(
[
'image' => $id,
'ns' => getNS($id)
'ns' => getNS($id)
],
'&',
true
@ -305,11 +305,11 @@ function rss_buildItems(&$rss, &$data, $opt)
if ($ditem['media']) {
$item->link = media_managerURL(
[
'image' => $id,
'ns' => getNS($id),
'rev' => $date,
'image' => $id,
'ns' => getNS($id),
'rev' => $date,
'tab_details' => 'history',
'mediado' => 'diff'
'mediado' => 'diff'
],
'&',
true
@ -325,21 +325,21 @@ function rss_buildItems(&$rss, &$data, $opt)
case 'htmldiff':
if ($ditem['media']) {
$medialog = new MediaChangeLog($id);
$revs = $medialog->getRevisions(0, 1);
$rev = $revs[0];
$src_r = '';
$src_l = '';
$revs = $medialog->getRevisions(0, 1);
$rev = $revs[0];
$src_r = '';
$src_l = '';
if ($size = media_image_preview_size($id, '', new JpegMeta(mediaFN($id)), 300)) {
$more = 'w=' . $size[0] . '&h=' . $size[1] . '&t=' . @filemtime(mediaFN($id));
$more = 'w=' . $size[0] . '&h=' . $size[1] . '&t=' . @filemtime(mediaFN($id));
$src_r = ml($id, $more, true, '&amp;', true);
}
if ($rev && $size = media_image_preview_size(
$id,
$rev,
new JpegMeta(mediaFN($id, $rev)),
300
)) {
$id,
$rev,
new JpegMeta(mediaFN($id, $rev)),
300
)) {
$more = 'rev=' . $rev . '&w=' . $size[0] . '&h=' . $size[1];
$src_l = ml($id, $more, true, '&amp;', true);
}
@ -355,8 +355,8 @@ function rss_buildItems(&$rss, &$data, $opt)
} else {
require_once(DOKU_INC . 'inc/DifferenceEngine.php');
$pagelog = new PageChangeLog($id);
$revs = $pagelog->getRevisions(0, 1);
$rev = $revs[0];
$revs = $pagelog->getRevisions(0, 1);
$rev = $revs[0];
if ($rev) {
$df = new Diff(
@ -372,7 +372,7 @@ function rss_buildItems(&$rss, &$data, $opt)
if ($opt['item_content'] == 'htmldiff') {
// note: no need to escape diff output, TableDiffFormatter provides 'safe' html
$tdf = new TableDiffFormatter();
$tdf = new TableDiffFormatter();
$content = '<table>';
$content .= '<tr><th colspan="2" width="50%">' . $rev . '</th>';
$content .= '<th colspan="2" width="50%">' . $lang['current'] . '</th></tr>';
@ -380,7 +380,7 @@ function rss_buildItems(&$rss, &$data, $opt)
$content .= '</table>';
} else {
// note: diff output must be escaped, UnifiedDiffFormatter provides plain text
$udf = new UnifiedDiffFormatter();
$udf = new UnifiedDiffFormatter();
$content = "<pre>\n" . hsc($udf->format($df)) . "\n</pre>";
}
}
@ -388,8 +388,8 @@ function rss_buildItems(&$rss, &$data, $opt)
case 'html':
if ($ditem['media']) {
if ($size = media_image_preview_size($id, '', new JpegMeta(mediaFN($id)))) {
$more = 'w=' . $size[0] . '&h=' . $size[1] . '&t=' . @filemtime(mediaFN($id));
$src = ml($id, $more, true, '&amp;', true);
$more = 'w=' . $size[0] . '&h=' . $size[1] . '&t=' . @filemtime(mediaFN($id));
$src = ml($id, $more, true, '&amp;', true);
$content = '<img src="' . $src . '" alt="' . $id . '" />';
} else {
$content = '';
@ -409,7 +409,7 @@ function rss_buildItems(&$rss, &$data, $opt)
// make URLs work when canonical is not set, regexp instead of rerendering!
if (!$conf['canonical']) {
$base = preg_quote(DOKU_REL, '/');
$base = preg_quote(DOKU_REL, '/');
$content = preg_replace(
'/(<a href|<img src)="(' . $base . ')/s',
'$1="' . DOKU_URL,
@ -423,8 +423,8 @@ function rss_buildItems(&$rss, &$data, $opt)
default:
if (isset($ditem['media'])) {
if ($size = media_image_preview_size($id, '', new JpegMeta(mediaFN($id)))) {
$more = 'w=' . $size[0] . '&h=' . $size[1] . '&t=' . @filemtime(mediaFN($id));
$src = ml($id, $more, true, '&amp;', true);
$more = 'w=' . $size[0] . '&h=' . $size[1] . '&t=' . @filemtime(mediaFN($id));
$src = ml($id, $more, true, '&amp;', true);
$content = '<img src="' . $src . '" alt="' . $id . '" />';
} else {
$content = '';
@ -439,10 +439,10 @@ function rss_buildItems(&$rss, &$data, $opt)
# FIXME should the user be pulled from metadata as well?
$user = @$ditem['user']; // the @ spares time repeating lookup
if (blank($user)) {
$item->author = 'Anonymous';
$item->author = 'Anonymous';
$item->authorEmail = 'anonymous@undisclosed.example.com';
} else {
$item->author = $user;
$item->author = $user;
$item->authorEmail = $user . '@undisclosed.example.com';
// get real user name if configured
@ -474,12 +474,12 @@ function rss_buildItems(&$rss, &$data, $opt)
// finally add the item to the feed object, after handing it to registered plugins
$evdata = [
'item' => &$item,
'opt' => &$opt,
'item' => &$item,
'opt' => &$opt,
'ditem' => &$ditem,
'rss' => &$rss
'rss' => &$rss
];
$evt = new Event('FEED_ITEM_ADD', $evdata);
$evt = new Event('FEED_ITEM_ADD', $evdata);
if ($evt->advise_before()) {
$rss->addItem($item);
}
@ -521,9 +521,9 @@ function rssListNamespace($opt)
$ns = ':' . cleanID($opt['namespace']);
$ns = utf8_encodeFN(str_replace(':', '/', $ns));
$data = [];
$data = [];
$search_opts = [
'depth' => 1,
'depth' => 1,
'pagesonly' => true,
'listfiles' => true
];

View File

@ -42,49 +42,78 @@ $error = [];
// begin output
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html lang="<?php echo $LC?>" dir="<?php echo $lang['direction']?>">
<head>
<meta charset="utf-8" />
<title><?php echo $lang['i_installer']?></title>
<style>
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: #800000; }
fieldset { border: none }
label { display: block; margin-top: 0.5em; }
select.text, input.text { width: 30em; margin: 0 0.5em; }
a {text-decoration: none}
</style>
<script>
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';
<!DOCTYPE html>
<html lang="<?php echo $LC ?>" dir="<?php echo $lang['direction'] ?>">
<head>
<meta charset="utf-8"/>
<title><?php echo $lang['i_installer'] ?></title>
<style>
body {
width: 90%;
margin: 0 auto;
font: 84% Verdana, Helvetica, Arial, sans-serif;
}
}
window.onload = function(){
acltoggle();
var cb = document.getElementById('acl');
if(cb) cb.onchange = acltoggle;
};
</script>
</head>
<body style="">
img {
border: none
}
br.cl {
clear: both;
}
code {
font-size: 110%;
color: #800000;
}
fieldset {
border: none
}
label {
display: block;
margin-top: 0.5em;
}
select.text, input.text {
width: 30em;
margin: 0 0.5em;
}
a {
text-decoration: none
}
</style>
<script>
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="lib/exe/fetch.php?media=wiki:dokuwiki-128.png"
style="vertical-align: middle;" alt="" height="64" width="64" />
<?php echo $lang['i_installer']?>
style="vertical-align: middle;" alt="" height="64" width="64"/>
<?php echo $lang['i_installer'] ?>
</h1>
<div style="float:right; margin: 1em;">
<?php langsel()?>
<?php langsel() ?>
</div>
<br class="cl" />
<br class="cl"/>
<div style="float: right; width: 34%;">
<?php
@ -108,7 +137,7 @@ header('Content-Type: text/html; charset=utf-8');
<div style="float: left; width: 58%;">
<?php
try {
if (! (check_functions() && check_permissions())) {
if (!(check_functions() && check_permissions())) {
echo '<p>' . $lang['i_problems'] . '</p>';
print_errors();
print_retry();
@ -128,18 +157,18 @@ header('Content-Type: text/html; charset=utf-8');
print_form($_REQUEST['d']);
}
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>
</div>
<div style="clear: both">
<a href="http://dokuwiki.org/"><img src="lib/tpl/dokuwiki/images/button-dw.png" alt="driven by DokuWiki" /></a>
<a href="http://php.net"><img src="lib/tpl/dokuwiki/images/button-php.gif" alt="powered by PHP" /></a>
</div>
</body>
</html>
<div style="clear: both">
<a href="http://dokuwiki.org/"><img src="lib/tpl/dokuwiki/images/button-dw.png" alt="driven by DokuWiki"/></a>
<a href="http://php.net"><img src="lib/tpl/dokuwiki/images/button-php.gif" alt="powered by PHP"/></a>
</div>
</body>
</html>
<?php
/**
@ -162,83 +191,84 @@ function print_form($d)
?>
<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>
<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 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'] ?>" />
<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="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="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="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" />
<label for="confirm"><?php echo $lang['passchk'] ?></label>
<input class="text" type="password" name="d[confirm]" id="confirm"/>
<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>
<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>
<label for="allowreg">
<input type="checkbox" name="d[allowreg]" id="allowreg" <?php
echo(($d['allowreg'] ? ' checked="checked"' : ''));?> />
<?php echo $lang['i_allowreg']?>
<label for="allowreg">
<input type="checkbox" name="d[allowreg]" id="allowreg" <?php
echo(($d['allowreg'] ? ' checked="checked"' : '')); ?> />
<?php echo $lang['i_allowreg'] ?>
</label>
</fieldset>
</fieldset>
<fieldset>
<p><?php echo $lang['i_license'] ?></p>
<?php
$license[] = ['name' => $lang['i_license_none'], 'url' => ''];
if (empty($d['license'])) $d['license'] = 'cc-by-sa';
foreach ($license as $key => $lic) {
echo '<label for="lic_' . $key . '">';
echo '<input type="radio" name="d[license]" value="' . hsc($key) . '" id="lic_' . $key . '"' .
(($d['license'] === $key) ? ' checked="checked"' : '') . '>';
echo hsc($lic['name']);
if ($lic['url']) echo ' <a href="' . $lic['url'] . '" target="_blank"><sup>[?]</sup></a>';
echo '</label>';
}
?>
</fieldset>
<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"' : '')); ?> />
<?php echo $lang['i_pop_label'] ?>
<a href="http://www.dokuwiki.org/popularity" target="_blank"><sup>[?]</sup></a>
</label>
</fieldset>
</fieldset>
<fieldset>
<p><?php echo $lang['i_license']?></p>
<?php
$license[] = ['name' => $lang['i_license_none'], 'url' => ''];
if (empty($d['license'])) $d['license'] = 'cc-by-sa';
foreach ($license as $key => $lic) {
echo '<label for="lic_' . $key . '">';
echo '<input type="radio" name="d[license]" value="' . hsc($key) . '" id="lic_' . $key . '"' .
(($d['license'] === $key) ? ' checked="checked"' : '') . '>';
echo hsc($lic['name']);
if ($lic['url']) echo ' <a href="' . $lic['url'] . '" target="_blank"><sup>[?]</sup></a>';
echo '</label>';
}
?>
</fieldset>
<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"' : ''));?> />
<?php echo $lang['i_pop_label']?>
<a href="http://www.dokuwiki.org/popularity" target="_blank"><sup>[?]</sup></a>
</label>
<fieldset id="process">
<button type="submit" name="submit"><?php echo $lang['btn_save'] ?></button>
</fieldset>
</fieldset>
<fieldset id="process">
<button type="submit" name="submit"><?php echo $lang['btn_save']?></button>
</fieldset>
</form>
<?php
}
@ -249,10 +279,10 @@ function print_retry()
global $LC;
?>
<form action="" method="get">
<fieldset>
<input type="hidden" name="l" value="<?php echo $LC ?>" />
<button type="submit"><?php echo $lang['i_retry'];?></button>
</fieldset>
<fieldset>
<input type="hidden" name="l" value="<?php echo $LC ?>"/>
<button type="submit"><?php echo $lang['i_retry']; ?></button>
</fieldset>
</form>
<?php
}
@ -260,24 +290,24 @@ function print_retry()
/**
* Check validity of data
*
* @author Andreas Gohr
*
* @param array $d
* @return bool ok?
* @author Andreas Gohr
*
*/
function check_data(&$d)
{
static $form_default = [
'title' => '',
'acl' => '1',
'title' => '',
'acl' => '1',
'superuser' => '',
'fullname' => '',
'email' => '',
'password' => '',
'confirm' => '',
'policy' => '0',
'allowreg' => '0',
'license' => 'cc-by-sa'
'fullname' => '',
'email' => '',
'password' => '',
'confirm' => '',
'policy' => '0',
'allowreg' => '0',
'license' => 'cc-by-sa'
];
global $lang;
global $error;
@ -300,27 +330,27 @@ function check_data(&$d)
// check input
if (empty($d['title'])) {
$error[] = sprintf($lang['i_badval'], $lang['i_wikiname']);
$ok = false;
$ok = false;
}
if (isset($d['acl'])) {
if (empty($d['superuser']) || ($d['superuser'] !== cleanID($d['superuser']))) {
$error[] = sprintf($lang['i_badval'], $lang['i_superuser']);
$ok = false;
$ok = false;
}
if (empty($d['password'])) {
$error[] = sprintf($lang['i_badval'], $lang['pass']);
$ok = false;
$ok = false;
} elseif (!isset($d['confirm']) || $d['confirm'] != $d['password']) {
$error[] = sprintf($lang['i_badval'], $lang['passchk']);
$ok = false;
$ok = false;
}
if (empty($d['fullname']) || strstr($d['fullname'], ':')) {
$error[] = sprintf($lang['i_badval'], $lang['fullname']);
$ok = false;
$ok = false;
}
if (empty($d['email']) || strstr($d['email'], ':') || !strstr($d['email'], '@')) {
$error[] = sprintf($lang['i_badval'], $lang['email']);
$ok = false;
$ok = false;
}
} else {
// Since default = 1, browser won't send acl=0 when user untick acl
@ -334,19 +364,20 @@ function check_data(&$d)
/**
* Writes the data to the config files
*
* @author Chris Smith <chris@jalakai.co.uk>
*
* @param array $d
* @return bool
* @throws Exception
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
function store_data($d)
{
global $LC;
$ok = true;
$d['policy'] = (int) $d['policy'];
$d['policy'] = (int)$d['policy'];
// create local.php
$now = gmdate('r');
$now = gmdate('r');
$output = <<<EOT
<?php
/**
@ -421,13 +452,13 @@ EOT;
EOT;
if ($d['policy'] == 2) {
$output .= "* @ALL 0\n";
$output .= "* @user 8\n";
$output .= "* @ALL 0\n";
$output .= "* @user 8\n";
} elseif ($d['policy'] == 1) {
$output .= "* @ALL 1\n";
$output .= "* @user 8\n";
$output .= "* @ALL 1\n";
$output .= "* @user 8\n";
} else {
$output .= "* @ALL 8\n";
$output .= "* @ALL 8\n";
}
$ok = $ok && fileWrite(DOKU_LOCAL . 'acl.auth.php', $output);
}
@ -461,11 +492,11 @@ EOT;
/**
* Write the given content to a file
*
* @author Chris Smith <chris@jalakai.co.uk>
*
* @param string $filename
* @param string $data
* @return bool
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
function fileWrite($filename, $data)
{
@ -474,7 +505,7 @@ function fileWrite($filename, $data)
if (($fp = @fopen($filename, 'wb')) === false) {
$filename = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}/', $filename);
$error[] = sprintf($lang['i_writeerr'], $filename);
$error[] = sprintf($lang['i_writeerr'], $filename);
return false;
}
@ -490,9 +521,9 @@ function fileWrite($filename, $data)
* check installation dependent local config files and tests for a known
* unmodified main config file
*
* @author Chris Smith <chris@jalakai.co.uk>
*
* @return bool
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
function check_configs()
{
@ -504,15 +535,15 @@ function check_configs()
$config_files = [
'local' => DOKU_LOCAL . 'local.php',
'users' => DOKU_LOCAL . 'users.auth.php',
'auth' => DOKU_LOCAL . 'acl.auth.php'
'auth' => DOKU_LOCAL . 'acl.auth.php'
];
// configs shouldn't exist
foreach ($config_files as $file) {
if (file_exists($file) && filesize($file)) {
$file = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}/', $file);
$file = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}/', $file);
$error[] = sprintf($lang['i_confexists'], $file);
$ok = false;
$ok = false;
}
}
return $ok;
@ -522,9 +553,9 @@ function check_configs()
/**
* Check other installation dir/file permission requirements
*
* @author Chris Smith <chris@jalakai.co.uk>
*
* @return bool
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
function check_permissions()
{
@ -532,26 +563,26 @@ function check_permissions()
global $lang;
$dirs = [
'conf' => DOKU_LOCAL,
'data' => DOKU_INC . 'data',
'pages' => DOKU_INC . 'data/pages',
'attic' => DOKU_INC . 'data/attic',
'media' => DOKU_INC . 'data/media',
'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'
'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'
];
$ok = true;
foreach ($dirs as $dir) {
if (!file_exists("$dir/.") || !is_writable($dir)) {
$dir = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}', $dir);
$dir = str_replace($_SERVER['DOCUMENT_ROOT'], '{DOCUMENT_ROOT}', $dir);
$error[] = sprintf($lang['i_permfail'], $dir);
$ok = false;
$ok = false;
}
}
return $ok;
@ -560,9 +591,9 @@ function check_permissions()
/**
* Check the availability of functions used in DokuWiki and the PHP version
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @return bool
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function check_functions()
{
@ -582,7 +613,7 @@ function check_functions()
try {
random_bytes(1);
} catch (\Exception $th) {
} catch (Exception $th) {
// If an appropriate source of randomness cannot be found, an Exception will be thrown by PHP 7+
$error[] = $lang['i_urandom'];
$ok = false;
@ -594,12 +625,12 @@ function check_functions()
}
$funcs = explode(' ', 'addslashes call_user_func chmod copy fgets ' .
'file file_exists fseek flush filesize ftell fopen ' .
'glob header ignore_user_abort ini_get mkdir ' .
'ob_start opendir parse_ini_file readfile realpath ' .
'rename rmdir serialize session_start unlink usleep ' .
'preg_replace file_get_contents htmlspecialchars_decode ' .
'spl_autoload_register stream_select fsockopen pack xml_parser_create');
'file file_exists fseek flush filesize ftell fopen ' .
'glob header ignore_user_abort ini_get mkdir ' .
'ob_start opendir parse_ini_file readfile realpath ' .
'rename rmdir serialize session_start unlink usleep ' .
'preg_replace file_get_contents htmlspecialchars_decode ' .
'spl_autoload_register stream_select fsockopen pack xml_parser_create');
if (!function_exists('mb_substr')) {
$funcs[] = 'utf8_encode';
@ -635,7 +666,7 @@ function langsel()
global $LC;
$dir = DOKU_INC . 'inc/lang';
$dh = opendir($dir);
$dh = opendir($dir);
if (!$dh) return;
$langs = [];

View File

@ -1,9 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; URL=../" />
<meta name="robots" content="noindex" />
<title>nothing here...</title>
<meta http-equiv="refresh" content="0; URL=../"/>
<meta name="robots" content="noindex"/>
<title>nothing here...</title>
</head>
<body>
<!-- this is just here to prevent directory browsing -->