add contents

This commit is contained in:
Trevor Batley
2025-10-09 15:04:29 +11:00
parent 170362eec1
commit bce7dd054a
2537 changed files with 301282 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
#!/bin/bash
# This script is under public domain do with it whatever you want (yes, that includes eating it).
if [ $# -lt 1 ]; then
echo "Usage: $(basename $0) [animal domain or directory]"
exit 1
fi
ANIMAL=${PWD}/${1}
ANIMAL_TITLE=$1
if [ -d $ANIMAL ]; then
echo "ERROR: $ANIMAL exists already!"
exit 1
fi
echo ">> adding animal $1"
echo ">> creating directory structure ..."
mkdir -p ${ANIMAL}/{data/{attic,cache,index,locks,media,media_attic,media_meta,meta,pages,tmp},conf}
find ${ANIMAL}/ -type d -exec chmod 777 {} \;
touch ${ANIMAL}/conf/{local.php,local.protected.php,acl.auth.php,users.auth.php,plugins.local.php}
chmod 666 ${ANIMAL}/conf/{local.php,acl.auth.php,users.auth.php,plugins.local.php}
echo ">> creating basic configuration ..."
echo "<?php
\$conf['title'] = '${ANIMAL_TITLE}';
\$conf['lang'] = 'en';
\$conf['useacl'] = 1;
\$conf['animal'] = '${ANIMAL_TITLE}';
\$conf['animal_inc'] = '${ANIMAL}/';
\$conf['superuser'] = '@admin';" > ${ANIMAL}/conf/local.php
echo ">> setting fixed configuration ..."
echo "<?php
\$conf['savedir'] = DOKU_CONF.'../data';
\$conf['updatecheck'] = 0;" > ${ANIMAL}/conf/local.protected.php
echo ">> setting basic permissions ..."
echo "# <?php exit()?>
* @admin 255
* @ALL 1" > ${ANIMAL}/conf/acl.auth.php
echo ">> adding admin user ..."
echo '# <?php exit()?>
admin:$1$cce258b2$U9o5nK0z4MhTfB5QlKF23/:admin:admin@mail.org:admin,user' > ${ANIMAL}/conf/users.auth.php
echo ">> IMPORTANT: Don't forget to change your admin username + password!"
echo ">> finished!"
echo ">> bye!"
exit 0
# vim:ts=4:sw=4:noet:enc=utf-8:

View File

@@ -0,0 +1,61 @@
#!/bin/bash
# This script is under public domain do with it whatever you want (yes, that includes eating it).
if [ $# -lt 1 ]; then
echo "Usage: $(basename $0) [animal domain or directory]"
exit 1
fi
# set_basedir
# Author: Myron Turner
set_basedir() {
BARN=`pwd | awk -F/ '{ print $NF }'`
echo "'/"$BARN"/$1/'"
}
ANIMAL=${PWD}/${1}
ANIMAL_TITLE=$1
if [ -d $ANIMAL ]; then
echo "ERROR: $ANIMAL exists already!"
exit 1
fi
echo ">> adding animal $1"
echo ">> creating directory structure ..."
mkdir -p ${ANIMAL}/{data/{attic,cache,index,locks,media,media_attic,media_meta,meta,pages,tmp},conf}
find ${ANIMAL}/ -type d -exec chmod 777 {} \;
touch ${ANIMAL}/conf/{local.php,local.protected.php,acl.auth.php,users.auth.php,plugins.local.php}
chmod 666 ${ANIMAL}/conf/{local.php,acl.auth.php,users.auth.php,plugins.local.php}
echo ">> creating basic configuration ..."
echo "<?php
\$conf['title'] = '${ANIMAL_TITLE}';
\$conf['lang'] = 'en';
\$conf['useacl'] = 1;
\$conf['animal'] = '${ANIMAL_TITLE}';
\$conf['animal_inc'] = '${ANIMAL}/';
\$conf['superuser'] = '@admin';" > ${ANIMAL}/conf/local.php
echo ">> setting fixed configuration ..."
echo "<?php
\$conf['savedir'] = DOKU_CONF.'../data';
\$conf['basedir'] = `set_basedir $1`;
\$conf['updatecheck'] = 0;" > ${ANIMAL}/conf/local.protected.php
echo ">> setting basic permissions ..."
echo "# <?php exit()?>
* @admin 255
* @ALL 1" > ${ANIMAL}/conf/acl.auth.php
echo ">> adding admin user ..."
echo '# <?php exit()?>
admin:$1$cce258b2$U9o5nK0z4MhTfB5QlKF23/:admin:admin@mail.org:admin,user' > ${ANIMAL}/conf/users.auth.php
echo ">> IMPORTANT: Don't forget to change your admin username + password!"
echo ">> finished!"
echo ">> bye!"
exit 0
# vim:ts=4:sw=4:noet:enc=utf-8:

View File

@@ -0,0 +1,524 @@
<?php
/**
* DokuWiki StyleSheet creator
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../../').'/');
require_once(DOKU_INC.'inc/init.php');
// ---------------------- functions ------------------------------
/**
* Output all needed Styles
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_ckg_out($path, $tpl = "")
{
global $conf;
global $lang;
global $config_cascade;
global $INPUT;
$copy = $INPUT->str('ckg_save_ss',FALSE);
chdir($path);
$mediatypes = array('screen', 'all');
$type = '';
if(!$tpl) {
$tpl = $conf['template'];
if($copy) {
$copy_path = DOKU_PLUGIN . 'ckgedit/ckeditor/css/_style.css';
msg($copy_path,1);
}
}
// load styl.ini
$styleini = css_ckg_styleini($tpl);
// if old 'default' userstyle setting exists, make it 'screen' userstyle for backwards compatibility
if (isset($config_cascade['userstyle']['default'])) {
$config_cascade['userstyle']['screen'] = $config_cascade['userstyle']['default'];
}
// Array of needed files and their web locations, the latter ones
// are needed to fix relative paths in the stylesheets
$files = array();
foreach($mediatypes as $mediatype) {
$files[$mediatype] = array();
// load core styles
$files[$mediatype][DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/';
// load template styles
if (isset($styleini['stylesheets'][$mediatype])) {
$files[$mediatype] = array_merge($files[$mediatype], $styleini['stylesheets'][$mediatype]);
}
// load user styles
if(!empty($config_cascade['userstyle'][$mediatype])) {
foreach($config_cascade['userstyle'][$mediatype] as $userstyle) {
$files[$mediatype][$userstyle] = DOKU_BASE;
}
}
}
$css="";
// build the stylesheet
foreach ($mediatypes as $mediatype) {
// print the default classes for interwiki links and file downloads
if ($mediatype == 'screen') {
$css .= '@media screen {';
css_ckg_interwiki($css);
css_ckg_filetypes($css);
$css .= '}';
}
$xcl = 'plugins|popup|fileuploader|toc|search|recent|diff|edit|form|admin|manager|media|modal';
// load files
$css_ckg_content = '';
foreach($files[$mediatype] as $file => $location) {
if(preg_match('#' .$xcl . '#',$file) ) {
continue;
}
$display = str_replace(fullpath(DOKU_INC), '', fullpath($file));
$css_ckg_content .= "\n/* XXXXXXXXX $display XXXXXXXXX */\n";
$css_ckg_content .= css_ckg_loadfile($file, $location);
}
switch ($mediatype) {
case 'screen':
$css .= NL.'@media screen { /* START screen styles */'.NL.$css_ckg_content.NL.'} /* /@media END screen styles */'.NL;
break;
case 'all':
default:
$css .= NL.'/* START rest styles */ '.NL.$css_ckg_content.NL.'/* END rest styles */'.NL;
break;
}
}
// apply style replacements
$css = css_ckg_applystyle($css, $styleini['replacements']);
// parse less
$css = css_ckg_parseless($css);
// embed small images right into the stylesheet
if($conf['cssdatauri']){
$base = preg_quote(DOKU_BASE,'#');
$css = preg_replace_callback('#(url\([ \'"]*)('.$base.')(.*?(?:\.(png|gif)))#i','css_ckg_datauri',$css);
}
$css = preg_replace("/(\#?|\.?|div\.)dokuwiki\.?/", '', $css);
$css = "@import 'additional.css';\n/* template: $tpl */\n@media screen {\n.$tpl{color:#ccc;}\n}\n" . $css;
$css .= '
span.multi_p_open {
display: block;
}
body,html {
background-color: #fff;
background-image:none;
}
blockquote {
padding-left: .5em;
margin-left: 1.5em;
}
' . "\n";
if( io_saveFile($path . 'Styles/_style.css' ,$css)) {
if(isset($copy_path)) { ;
$retv = io_saveFile($copy_path,$css);
if(!$retv) msg("failed: " . $copy_path);
}
return 0;
}
else {
return 1;
}
}
/**
* Uses phpless to parse LESS in our CSS
*
* most of this function is error handling to show a nice useful error when
* LESS compilation fails
*
* @param $css
* @return string
*/
function css_ckg_parseless($css) {
$less = new lessc();
$less->importDir[] = DOKU_INC;
try {
return $less->compile($css);
} catch(Exception $e) {
// get exception message
$msg = str_replace(array("\n", "\r", "'"), array(), $e->getMessage());
// try to use line number to find affected file
if(preg_match('/line: (\d+)$/', $msg, $m)){
$msg = substr($msg, 0, -1* strlen($m[0])); //remove useless linenumber
$lno = $m[1];
// walk upwards to last include
$lines = explode("\n", $css);
for($i=$lno-1; $i>=0; $i--){
if(preg_match('/\/(\* XXXXXXXXX )(.*?)( XXXXXXXXX \*)\//', $lines[$i], $m)){
// we found it, add info to message
$msg .= ' in '.$m[2].' at line '.($lno-$i);
break;
}
}
}
// something went wrong
$error = 'A fatal error occured during compilation of the CSS files. '.
'If you recently installed a new plugin or template it '.
'might be broken and you should try disabling it again. ['.$msg.']';
msg($error);
exit;
}
}
/**
* Does placeholder replacements in the style according to
* the ones defined in a templates style.ini file
*
* This also adds the ini defined placeholders as less variables
* (sans the surrounding __ and with a ini_ prefix)
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_ckg_applystyle($css, $replacements) {
// we convert ini replacements to LESS variable names
// and build a list of variable: value; pairs
$less = '';
foreach((array) $replacements as $key => $value) {
$lkey = trim($key, '_');
$lkey = '@ini_'.$lkey;
$less .= "$lkey: $value;\n";
$replacements[$key] = $lkey;
}
// we now replace all old ini replacements with LESS variables
$css = strtr($css, $replacements);
// now prepend the list of LESS variables as the very first thing
$css = $less.$css;
return $css;
}
/**
* Load style ini contents
*
* Loads and merges style.ini files from template and config and prepares
* the stylesheet modes
*
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $tpl the used template
* @return array with keys 'stylesheets' and 'replacements'
*/
function css_ckg_styleini($tpl) {
$stylesheets = array(); // mode, file => base
$replacements = array(); // placeholder => value
// load template's style.ini
$incbase = tpl_incdir($tpl);
$webbase = tpl_basedir($tpl);
$ini = $incbase.'style.ini';
if(file_exists($ini)){
$data = parse_ini_file($ini, true);
// stylesheets
if(is_array($data['stylesheets'])) foreach($data['stylesheets'] as $file => $mode){
$stylesheets[$mode][$incbase.$file] = $webbase;
}
// replacements
if(is_array($data['replacements'])){
$replacements = array_merge($replacements, css_ckg_fixreplacementurls($data['replacements'],$webbase));
}
}
// load configs's style.ini
$webbase = DOKU_BASE;
$ini = DOKU_CONF."tpl/$tpl/style.ini";
$incbase = dirname($ini).'/';
if(file_exists($ini)){
$data = parse_ini_file($ini, true);
// stylesheets
if(isset($data['stylesheets']) && is_array($data['stylesheets'])) foreach($data['stylesheets'] as $file => $mode){
$stylesheets[$mode][$incbase.$file] = $webbase;
}
// replacements
if(isset($data['replacements']) && is_array($data['replacements'])){
$replacements = array_merge($replacements, css_ckg_fixreplacementurls($data['replacements'],$webbase));
}
}
return array(
'stylesheets' => $stylesheets,
'replacements' => $replacements
);
}
/**
* Amend paths used in replacement relative urls, refer FS#2879
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
function css_ckg_fixreplacementurls($replacements, $location) {
foreach($replacements as $key => $value) {
$replacements[$key] = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$value);
}
return $replacements;
}
/**
* Prints classes for interwikilinks
*
* Interwiki links have two classes: 'interwiki' and 'iw_$name>' where
* $name is the identifier given in the config. All Interwiki links get
* an default style with a default icon. If a special icon is available
* for an interwiki URL it is set in it's own class. Both classes can be
* overwritten in the template or userstyles.
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_ckg_interwiki(&$css){
// default style
$css .= 'a.interwiki {';
$css .= ' background: transparent url('.DOKU_BASE.'lib/images/interwiki.png) 0px 1px no-repeat;';
$css .= ' padding: 1px 0px 1px 16px;';
$css .= '}';
// additional styles when icon available
$iwlinks = getInterwiki();
foreach(array_keys($iwlinks) as $iw){
$class = preg_replace('/[^_\-a-z0-9]+/i','_',$iw);
if(@file_exists(DOKU_INC.'lib/images/interwiki/'.$iw.'.png')){
$css .= "a.iw_$class {";
$css .= ' background-image: url('.DOKU_BASE.'lib/images/interwiki/'.$iw.'.png)';
$css .= '}';
}elseif(@file_exists(DOKU_INC.'lib/images/interwiki/'.$iw.'.gif')){
$css .= "a.iw_$class {";
$css .= ' background-image: url('.DOKU_BASE.'lib/images/interwiki/'.$iw.'.gif)';
$css .= '}';
}
}
}
/**
* Prints classes for file download links
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_ckg_filetypes(&$css){
// default style
$css .= '.mediafile {';
$css .= ' background: transparent url('.DOKU_BASE.'lib/images/fileicons/file.png) 0px 1px no-repeat;';
$css .= ' padding-left: 18px;';
$css .= ' padding-bottom: 1px;';
$css .= '}';
// additional styles when icon available
// scan directory for all icons
$exts = array();
if($dh = opendir(DOKU_INC.'lib/images/fileicons')){
while(false !== ($file = readdir($dh))){
if(preg_match('/([_\-a-z0-9]+(?:\.[_\-a-z0-9]+)*?)\.(png|gif)/i',$file,$match)){
$ext = strtolower($match[1]);
$type = '.'.strtolower($match[2]);
if($ext!='file' && (!isset($exts[$ext]) || $type=='.png')){
$exts[$ext] = $type;
}
}
}
closedir($dh);
}
foreach($exts as $ext=>$type){
$class = preg_replace('/[^_\-a-z0-9]+/','_',$ext);
$css .= ".mf_$class {";
$css .= ' background-image: url('.DOKU_BASE.'lib/images/fileicons/'.$ext.$type.')';
$css .= '}';
}
}
/**
* Loads a given file and fixes relative URLs with the
* given location prefix
*/
function css_ckg_loadfile($file,$location=''){
$css_ckg_file = new DokuCssFile($file);
return $css_ckg_file->load($location);
}
/**
* Helper class to abstract loading of css/less files
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
class DokuCssFile {
protected $filepath; // file system path to the CSS/Less file
protected $location; // base url location of the CSS/Less file
private $relative_path = null;
public function __construct($file) {
$this->filepath = $file;
}
/**
* Load the contents of the css/less file and adjust any relative paths/urls (relative to this file) to be
* relative to the dokuwiki root: the web root (DOKU_BASE) for most files; the file system root (DOKU_INC)
* for less files.
*
* @param string $location base url for this file
* @return string the CSS/Less contents of the file
*/
public function load($location='') {
if (!file_exists($this->filepath)) return '';
$css = io_readFile($this->filepath);
if (!$location) return $css;
$this->location = $location;
$css = preg_replace_callback('#(url\( *)([\'"]?)(.*?)(\2)( *\))#',array($this,'replacements'),$css);
$css = preg_replace_callback('#(@import\s+)([\'"])(.*?)(\2)#',array($this,'replacements'),$css);
return $css;
}
/**
* Get the relative file system path of this file, relative to dokuwiki's root folder, DOKU_INC
*
* @return string relative file system path
*/
private function getRelativePath(){
if (is_null($this->relative_path)) {
$basedir = array(DOKU_INC);
$basedir = array_map('preg_quote_cb', $basedir);
$regex = '/^('.join('|',$basedir).')/';
$this->relative_path = preg_replace($regex, '', dirname($this->filepath));
}
return $this->relative_path;
}
/**
* preg_replace callback to adjust relative urls from relative to this file to relative
* to the appropriate dokuwiki root location as described in the code
*
* @param array see http://php.net/preg_replace_callback
* @return string see http://php.net/preg_replace_callback
*/
public function replacements($match) {
// not a relative url? - no adjustment required
if (preg_match('#^(/|data:|https?://)#',$match[3])) {
return $match[0];
}
// a less file import? - requires a file system location
else if (substr($match[3],-5) == '.less') {
if ($match[3]{0} != '/') {
$match[3] = $this->getRelativePath() . '/' . $match[3];
}
}
// everything else requires a url adjustment
else {
$match[3] = $this->location . $match[3];
}
return join('',array_slice($match,1));
}
}
/**
* Convert local image URLs to data URLs if the filesize is small
*
* Callback for preg_replace_callback
*/
function css_ckg_datauri($match){
global $conf;
$pre = unslash($match[1]);
$base = unslash($match[2]);
$url = unslash($match[3]);
$ext = unslash($match[4]);
$local = DOKU_INC.$url;
$size = @filesize($local);
if($size && $size < $conf['cssdatauri']){
$data = base64_encode(file_get_contents($local));
}
if($data){
$url = 'data:image/'.$ext.';base64,'.$data;
}else{
$url = $base.$url;
}
return $pre.$url;
}
/**
* Very simple CSS optimizer
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_ckg_compress($css){
//strip comments through a callback
$css = preg_replace_callback('#(/\*)(.*?)(\*/)#s','css_ckg_comment_cb',$css);
//strip (incorrect but common) one line comments
$css = preg_replace('/(?<!:)\/\/.*$/m','',$css);
// strip whitespaces
$css = preg_replace('![\r\n\t ]+!',' ',$css);
$css = preg_replace('/ ?([;,{}\/]) ?/','\\1',$css);
$css = preg_replace('/ ?: /',':',$css);
// number compression
$css = preg_replace('/([: ])0+(\.\d+?)0*((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2$3', $css); // "0.1em" to ".1em", "1.10em" to "1.1em"
$css = preg_replace('/([: ])\.(0)+((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2', $css); // ".0em" to "0"
$css = preg_replace('/([: ]0)0*(\.0*)?((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1', $css); // "0.0em" to "0"
$css = preg_replace('/([: ]\d+)(\.0*)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$3', $css); // "1.0em" to "1em"
$css = preg_replace('/([: ])0+(\d+|\d*\.\d+)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$2$3', $css); // "001em" to "1em"
// shorten attributes (1em 1em 1em 1em -> 1em)
$css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width|radius)):)([\w\.]+)( \2)+(?=[;\}]| !)/', '$1$2', $css); // "1em 1em 1em 1em" to "1em"
$css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width)):)([\w\.]+) ([\w\.]+) \2 \3(?=[;\}]| !)/', '$1$2 $3', $css); // "1em 2em 1em 2em" to "1em 2em"
// shorten colors
$css = preg_replace("/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3(?=[^\{]*[;\}])/", "#\\1\\2\\3", $css);
return $css;
}
/**
* Callback for css_ckg_compress()
*
* Keeps short comments (< 5 chars) to maintain typical browser hacks
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_ckg_comment_cb($matches){
if(strlen($matches[2]) > 4) return '';
return $matches[0];
}

View File

@@ -0,0 +1,24 @@
<?php
define('DOKU_INC', realpath(dirname(__FILE__)) . '/../../../../');
require_once(DOKU_INC.'inc/init.php');
require_once(DOKU_INC.'inc/io.php');
global $INPUT;
$cname = $INPUT->str('draft_id');
$cname = urldecode($cname);
if(!preg_match("#/data/cache/\w/[a-f0-9]{32}\.draft$#i", $cname)) return;
$ckgedit_cname = $cname . '.fckl';
if(file_exists($cname)) {
io_lock($cname);
if(file_exists($ckgedit_cname)) {
unlink($ckgedit_cname);
}
unlink($cname);
exit;
}
echo "done";

View File

@@ -0,0 +1,54 @@
if (opener != null && opener.CKEDITOR !== undefined) {
window.onload = function () {
var _action = '?ns=&edid=wiki__text&onselect=ckg_edit_mediaman_insert&ckg_media=img&CKEditor=wiki__text&CKEditorFuncNum=1&langCode=en';
if ((location.search.split("ckg_media=")[1]||"").split("&")[0] == "link") {
_action = '?ns=&edid=wiki__text&onselect=ckg_edit_mediaman_insertlink&ckg_media=link&CKEditor=wiki__text&CKEditorFuncNum=1&langCode=en';
jQuery(".select").on("click", function(event) {
var $link, id;
event.preventDefault();
$link = jQuery(this);
id = $link.attr("id").substr(2);
dw_mediamanager.insert(id);
return;
});
} else if ((location.search.split("ckg_media=")[1]||"").split("&")[0] == "img") {
jQuery("#media__linkbtn4").css("display", "none");
ckg_nonimage_overlay();
}
/* update search form action */
var valu = jQuery("#dw__mediasearch input[type='text").val();
if(valu == ""){
var url = jQuery("form#dw__mediasearch").attr('action');
jQuery("form#dw__mediasearch").attr('action', url+_action);
};
jQuery(document).ajaxComplete(function() {
ckg_nonimage_overlay();
jQuery("form[action]").each(function(index, val){
var url = jQuery(this).attr('action');
url = url + _action;
jQuery(this).attr('action',url);
});
});
};
if(!opener.oDokuWiki_FCKEditorInstanceInLinkDialog) {
jQuery( ".odd, .even" ).each( function( index, element ){
if(!this.title.match(/\.(jpg|jpeg|png|tiff?|gif)$/)){
jQuery( this ).html(LANG.plugins.ckgedit.mediamgr_notice+": <b>" + this.title +"</b>");
}
});
}
}
function ckg_nonimage_overlay() {
if ((location.search.split("ckg_media=")[1]||"").split("&")[0] !== "img") {
return;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
var SafeFN={plain:"-./[_0123456789abcdefghijklmnopqrstuvwxyz",pre_indicator:"%",post_indicator:"]",changeSafeBase:function(a,c,b){if(isNaN(c)||c<2||c>36||isNaN(b)||b<2||b>36){throw (new RangeError("Illegal radix. Radices must be integers between 2 and 36, inclusive."))}a=parseInt(a,c);if(c==36){return a}return a.toString(b)},get_u_array:function(b){var c=new Array();for(var a=0;a<b.length;a++){c[a]=b.charCodeAt(a)}return c},safe_to_unicode:function(f){var a=new Array();var e=new RegExp("(?=["+this.pre_indicator+"\\"+this.post_indicator+"])");var b=f.split(e);var g=false;for(var c=0;c<b.length;c++){var d=b[c];if(d.charAt(0)!=this.pre_indicator){var h=g?1:0;for(j=h;j<d.length;j++){a.push(d.charCodeAt(j))}g=false}else{if(d.length==1){a.push(d.charCodeAt(0));g=true}else{a.push(32+this.changeSafeBase(d.slice(1),36,10));g=true}}}return a},unicode_to_safe:function(a){var e="";var g=false;var f=this.plain+this.post_indicator;for(var c=0;c<a.length;c++){codepoint=a[c];var b="";if(String.fromCharCode(codepoint)!="\\"){var d=new RegExp(String.fromCharCode(codepoint));var b=f.match(d)}if(codepoint<127&&b){if(g){e+=this.post_indicator;g=false}e+=String.fromCharCode(codepoint)}else{if(codepoint==this.pre_indicator.charCodeAt(0)){e+=this.pre_indicator;g=true}else{e+=this.pre_indicator+this.changeSafeBase((codepoint-32),10,36);g=true}}}if(g){e+=this.post_indicator}return e},encode:function(a){return this.unicode_to_safe(this.get_u_array(a))},decode:function(b){var a=this.safe_to_unicode(b);var d=new Array();for(var c=0;c<a.length;c++){d[c]=this.code2utf(a[c])}return this.utf8Decode(d.join(""))},chr:function(a){return String.fromCharCode(a)},code2utf:function(a){if(a<128){return this.chr(a)}if(a<2048){return this.chr(192+(a>>6))+this.chr(128+(a&63))}if(a<65536){return this.chr(224+(a>>12))+this.chr(128+((a>>6)&63))+this.chr(128+(a&63))}if(a<2097152){return this.chr(240+(a>>18))+this.chr(128+((a>>12)&63))+this.chr(128+((a>>6)&63))+this.chr(128+(a&63))}},_utf8Decode:function(g){var f=new Array();var e,b,a,h,c=0;for(var d=0;d<g.length;){e=g.charCodeAt(d++);if(e>127){b=g.charCodeAt(d++)}if(e>223){a=g.charCodeAt(d++)}if(e>239){h=g.charCodeAt(d++)}if(e<128){f[c++]=this.chr(e)}else{if(e<224){f[c++]=this.chr(((e-192)<<6)+(b-128))}else{if(e<240){f[c++]=this.chr(((e-224)<<12)+((b-128)<<6)+(a-128))}else{f[c++]=this.chr(((e-240)<<18)+((b-128)<<12)+((a-128)<<6)+(h-128))}}}}return f.join("")},utf8Decode:function(d){var c=new Array();var e=0;var a="";var b=0;while((e=d.search(/[^\x00-\x7F]/))!=-1){a=d.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0];c[b++]=d.substr(0,e)+this._utf8Decode(a);d=d.substr(e+a.length)}c[b++]=d;return c.join("")}};function SafeFN_encode(a){return SafeFN.encode(a)}function SafeFN_decode(a){return SafeFN.decode(a)}function dwikiUTF8_encodeFN(a,b){if(b=="utf-8"){return a}if(a.match(/^[a-zA-Z0-9\/_\-\.%\]]+$/)){return a}if(b=="safe"){return SafeFN_encode(a)}a=encodeURIComponent(a);a=a.replace(/%2F/g,"/");return a}function dwikiUTF8_decodeFN(a,b){if(b=="utf-8"){return a}if(b=="safe"){return SafeFN_decode(a)}return decodeURIComponent(a)};

View File

@@ -0,0 +1,273 @@
/**
* Upgraded
* !!Do not modify the above line!!
*/
/**
* SafeFN is a Javascript implementation of Christopher Smith's php
* SafeFN class which was written for Dokuwiki
*
* @author Myron Turner <turnermm@shaw.ca>
* @copyright Myron Turner (C) GPL 2 or greater
*/
var SafeFN = {
plain: '-./[_0123456789abcdefghijklmnopqrstuvwxyz', // these characters aren't converted
pre_indicator: '%',
post_indicator:']',
/**
* convert numbers from base 10 to base 36 and base 36 to base 10
*
* @param string representing an integer or integer num number to be converted
* @param integer from base from which to convert
* @param integer to base to which to convert
*
* @return array int an array of unicode codepoints
*
* @author Myron Turner <turnermm02@shaw.ca>
*/
changeSafeBase: function(num, from, to) {
if(isNaN(from) || from < 2 || from > 36 || isNaN(to) || to < 2 || to > 36) {
throw (new RangeError("Illegal radix. Radices must be integers between 2 and 36, inclusive."));
}
num = parseInt(num, from);
if(from == 36) return num;
return num.toString(to);
},
/**
* convert a UTF8 string into an array of unicode code points
*
* @param UTF8 string
* @return array int an array of unicode codepoints
*
* @author Myron Turner <turnermm02@shaw.ca>
*/
get_u_array: function(utf8str) {
var unicode_array = new Array();
for (var i=0; i<utf8str.length; i++) {
unicode_array[i] = utf8str.charCodeAt(i);;
}
return unicode_array;
},
/**
* convert a 'safe_filename' string into an array of unicode codepoints
*
* @param string safe a filename in 'safe_filename' format
* @return array int an array of unicode codepoints
* @author Christopher Smith <chris@jalakai.co.uk>
* @author Myron Turner<turnermm02@shaw.ca>
*/
safe_to_unicode: function(safe) {
var unicode = new Array();
var regex = new RegExp('(?=[' + this.pre_indicator + '\\' + this.post_indicator + '])');
var split_array = safe.split(regex);
var converted = false;
for (var i = 0; i<split_array.length; i++ ) {
var sub = split_array[i];
if (sub.charAt(0) != this.pre_indicator) { // i.e. sub.charAt(0) != '%'
var start = converted?1:0;
for (j=start; j < sub.length; j++) {
unicode.push(sub.charCodeAt(j));
}
converted = false;
} else if (sub.length==1) {
unicode.push(sub.charCodeAt(0));
converted = true;
} else {
unicode.push(32 + this.changeSafeBase(sub.slice(1),36,10));
converted = true;
}
}
return unicode;
},
/**
* convert an array of unicode codepoints into 'safe_filename' format
*
* @param array int $unicode an array of unicode codepoints
* @return string the unicode represented in 'safe_filename' format
*
* @author Christopher Smith <chris@jalakai.co.uk>
* @author Myron Turner <turnermm02@shaw.ca>
*/
unicode_to_safe: function (unicode) {
var safe = '';
var converted = false;
var plain_str = this.plain + this.post_indicator;
for (var i=0; i< unicode.length; i++) {
codepoint = unicode[i];
var match = '';
if(String.fromCharCode(codepoint) != '\\') {
var regex = new RegExp(String.fromCharCode(codepoint));
var match = plain_str.match(regex);
}
if (codepoint < 127 && match) {
if (converted) {
safe += this.post_indicator;
converted = false;
}
safe += String.fromCharCode(codepoint);
} else if (codepoint == this.pre_indicator.charCodeAt(0)) {
safe += this.pre_indicator;
converted = true;
} else {
safe += this.pre_indicator + this.changeSafeBase((codepoint-32), 10, 36);
converted = true;
}
}
if(converted) safe += this.post_indicator;
return safe;
},
/**
* Convert an UTF-8 string to a safe ASCII String
*
*
* @param string filename a utf8 string, should only include printable characters - not 0x00-0x1f
* @return string an encoded representation of filename using only 'safe' ASCII characters
*
* @author Myron Turner <turnermm02@shaw.ca>
*/
encode: function(filename) {
return this.unicode_to_safe(this.get_u_array(filename));
},
/**
* decode a 'safe' encoded file name and return a UTF8 string
*
* @param string filename a 'safe' encoded ASCII string,
* @return string decoded utf8 string
*
* @author Myron Turner <turnermm02@shaw.ca>
*/
decode: function (filename) {
var unic = this.safe_to_unicode(filename);
// convert unicode code points to utf8
var str = new Array();
for (var i=0; i < unic.length; i++) {
str[i] = this.code2utf(unic[i]);
}
// return the decoded string
return this.utf8Decode(str.join(''));
},
/* UTF8 encoding/decoding functions
* Copyright (c) 2006 by Ali Farhadi.
* released under the terms of the Gnu Public License.
* see the GPL for details.
*
* Email: ali[at]farhadi[dot]ir
* Website: http://farhadi.ir/
*/
//an alias of String.fromCharCode
chr: function (code)
{
return String.fromCharCode(code);
},
//returns utf8 encoded charachter of a unicode value.
//code must be a number indicating the Unicode value.
//returned value is a string between 1 and 4 charachters.
code2utf: function (code)
{
if (code < 128) return this.chr(code);
if (code < 2048) return this.chr(192+(code>>6)) + this.chr(128+(code&63));
if (code < 65536) return this.chr(224+(code>>12)) + this.chr(128+((code>>6)&63)) + this.chr(128+(code&63));
if (code < 2097152) return this.chr(240+(code>>18)) + this.chr(128+((code>>12)&63)) + this.chr(128+((code>>6)&63)) + this.chr(128+(code&63));
},
//it is a private function for internal use in utf8Decode function
_utf8Decode: function (utf8str)
{
var str = new Array();
var code,code2,code3,code4,j = 0;
for (var i=0; i<utf8str.length; ) {
code = utf8str.charCodeAt(i++);
if (code > 127) code2 = utf8str.charCodeAt(i++);
if (code > 223) code3 = utf8str.charCodeAt(i++);
if (code > 239) code4 = utf8str.charCodeAt(i++);
if (code < 128) str[j++]= this.chr(code);
else if (code < 224) str[j++] = this.chr(((code-192)<<6) + (code2-128));
else if (code < 240) str[j++] = this.chr(((code-224)<<12) + ((code2-128)<<6) + (code3-128));
else str[j++] = this.chr(((code-240)<<18) + ((code2-128)<<12) + ((code3-128)<<6) + (code4-128));
}
return str.join('');
},
//Decodes a UTF8 formated string
utf8Decode: function (utf8str)
{
var str = new Array();
var pos = 0;
var tmpStr = '';
var j=0;
while ((pos = utf8str.search(/[^\x00-\x7F]/)) != -1) {
tmpStr = utf8str.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0];
str[j++]= utf8str.substr(0, pos) + this._utf8Decode(tmpStr);
utf8str = utf8str.substr(pos + tmpStr.length);
}
str[j++] = utf8str;
return str.join('');
}
};
function SafeFN_encode(filename) {
return SafeFN.encode(filename);
}
function SafeFN_decode(filename) {
return SafeFN.decode(filename);
}
function dwikiUTF8_encodeFN(file, encoding){
if(encoding == 'utf-8') return file;
if(file.match(/^[a-zA-Z0-9\/_\-\.%\]]+$/)){
return file;
}
if(encoding == 'safe'){
return SafeFN_encode(file);
}
file = encodeURIComponent(file);
file = file.replace(/%2F/g,'/');
return file;
}
function dwikiUTF8_decodeFN(file, encoding){
if(encoding == 'utf-8') return file;
if(encoding == 'safe'){
return SafeFN_decode(file);
}
return decodeURIComponent(file);
}

View File

@@ -0,0 +1 @@
var SafeFN={plain:"-./[_0123456789abcdefghijklmnopqrstuvwxyz",pre_indicator:"%",post_indicator:"]",changeSafeBase:function(a,c,b){if(isNaN(c)||c<2||c>36||isNaN(b)||b<2||b>36){throw (new RangeError("Illegal radix. Radices must be integers between 2 and 36, inclusive."))}a=parseInt(a,c);if(c==36){return a}return a.toString(b)},get_u_array:function(b){var c=new Array();for(var a=0;a<b.length;a++){c[a]=b.charCodeAt(a)}return c},safe_to_unicode:function(f){var a=new Array();var e=new RegExp("(?=["+this.pre_indicator+"\\"+this.post_indicator+"])");var b=f.split(e);var g=false;for(var c=0;c<b.length;c++){var d=b[c];if(d.charAt(0)!=this.pre_indicator){var h=g?1:0;for(j=h;j<d.length;j++){a.push(d.charCodeAt(j))}g=false}else{if(d.length==1){a.push(d.charCodeAt(0));g=true}else{a.push(32+this.changeSafeBase(d.slice(1),36,10));g=true}}}return a},unicode_to_safe:function(a){var e="";var g=false;var f=this.plain+this.post_indicator;for(var c=0;c<a.length;c++){codepoint=a[c];var b="";if(String.fromCharCode(codepoint)!="\\"){var d=new RegExp(String.fromCharCode(codepoint));var b=f.match(d)}if(codepoint<127&&b){if(g){e+=this.post_indicator;g=false}e+=String.fromCharCode(codepoint)}else{if(codepoint==this.pre_indicator.charCodeAt(0)){e+=this.pre_indicator;g=true}else{e+=this.pre_indicator+this.changeSafeBase((codepoint-32),10,36);g=true}}}if(g){e+=this.post_indicator}return e},encode:function(a){return this.unicode_to_safe(this.get_u_array(a))},decode:function(b){var a=this.safe_to_unicode(b);var d=new Array();for(var c=0;c<a.length;c++){d[c]=this.code2utf(a[c])}return this.utf8Decode(d.join(""))},chr:function(a){return String.fromCharCode(a)},code2utf:function(a){if(a<128){return this.chr(a)}if(a<2048){return this.chr(192+(a>>6))+this.chr(128+(a&63))}if(a<65536){return this.chr(224+(a>>12))+this.chr(128+((a>>6)&63))+this.chr(128+(a&63))}if(a<2097152){return this.chr(240+(a>>18))+this.chr(128+((a>>12)&63))+this.chr(128+((a>>6)&63))+this.chr(128+(a&63))}},_utf8Decode:function(g){var f=new Array();var e,b,a,h,c=0;for(var d=0;d<g.length;){e=g.charCodeAt(d++);if(e>127){b=g.charCodeAt(d++)}if(e>223){a=g.charCodeAt(d++)}if(e>239){h=g.charCodeAt(d++)}if(e<128){f[c++]=this.chr(e)}else{if(e<224){f[c++]=this.chr(((e-192)<<6)+(b-128))}else{if(e<240){f[c++]=this.chr(((e-224)<<12)+((b-128)<<6)+(a-128))}else{f[c++]=this.chr(((e-240)<<18)+((b-128)<<12)+((a-128)<<6)+(h-128))}}}}return f.join("")},utf8Decode:function(d){var c=new Array();var e=0;var a="";var b=0;while((e=d.search(/[^\x00-\x7F]/))!=-1){a=d.match(/([^\x00-\x7F]+[\x00-\x7F]{0,10})+/)[0];c[b++]=d.substr(0,e)+this._utf8Decode(a);d=d.substr(e+a.length)}c[b++]=d;return c.join("")}};function SafeFN_encode(a){return SafeFN.encode(a)}function SafeFN_decode(a){return SafeFN.decode(a)}function dwikiUTF8_encodeFN(a,b){if(b=="utf-8"){return a}if(a.match(/^[a-zA-Z0-9\/_\-\.%\]]+$/)){return a}if(b=="safe"){return SafeFN_encode(a)}a=encodeURIComponent(a);a=a.replace(/%2F/g,"/");return a}function dwikiUTF8_decodeFN(a,b){if(b=="utf-8"){return a}if(b=="safe"){return SafeFN_decode(a)}return decodeURIComponent(a)};

View File

@@ -0,0 +1,22 @@
<?php
/**
* Support samesite cookie flag in both php 7.2 (current production) and php >= 7.3 (when we get there)
* From: https://github.com/GoogleChromeLabs/samesite-examples/blob/master/php.md and https://stackoverflow.com/a/46971326/2308553
*/
function setcookieSameSite($name, $value, $expire=0, $path ='/', $domain="", $httponly="HttpOnly", $secure=false, $samesite="Lax")
{
if (PHP_VERSION_ID < 70300) {
setcookie($name, $value, $expire, "$path; samesite=$samesite", $domain, $secure, $httponly);
}
else {
setcookie($name, $value, [
'expires' => $expire,
'path' => $path,
'domain' => $domain,
'samesite' => $samesite,
'secure' => $secure,
'httponly' => $httponly,
]);
}
}
?>

View File

@@ -0,0 +1,51 @@
var this_debug;
function show_rowspans(rows) {
if(!useComplexTables) return;
var str = "";
for(var i=0; i < rows.length; i++) {
str+="ROW" + i + "\n";
for(var col=0; col<rows[i].length; col++) {
str += "[" + col + "]";
str+= "text="+rows[i][col].text + " ";
str+=" type="+rows[i][col].type + " ";
str+= " rowspan=" +rows[i][col].rowspan + " ";
str+= " colspan=" +rows[i][col].colspan + " ";
}
str += "\n";
}
this_debug(str,'show_rowspans');
str = "";
for(var i=0; i < rows.length; i++) {
for(var col=0; col<rows[i].length; col++) {
str+= "|"+rows[i][col].text + " ";
}
str += "|\n";
}
this_debug(str,'show_rowspans');
}
function debug_row(rows,row,col,which) {
var not_found = "";
try {
this_debug("row:"+row
+",column:"+col
+", rowspans:"+ rows[row][col].rowspan
+", colspans:"+ rows[row][col].colspan
+", text:"+rows[row][col].text,
which);
}catch(ex) {
not_found+="row:"+row +",column:"+col;
}
if(not_found) this_debug(not_found,"not_found");
}
<?php } ?>