Table of Contents

Disabled Functions

If you use a cheap webhost, they may have disabled some PHP functions for “Security Reasons”, this will probably break DokuWiki with errors like

Warning: xyz() has been disabled for security reasons

The first thing you should do is ask your Webhoster to change this or see if you can find a better hoster. If this is not a possibility you sometimes may be able to replace those functions.

To do so you need to find a replacement which doesn't use any of the disabled functions and put it into your local.conf.php file, then you need to replace all calls to the disabled function with calls to your replacement in the whole DokuWiki code.

Below is a collection of a few replacements for functions used in DokuWiki:

readfile

Replaces readfile

function rpl_readfile($file){
    $handle=@fopen($file,"r");
    echo @fread($handle,filesize($file));
    @fclose($handle);
}

glob

Replaces glob (From php.net comment #71083)

/**
 * @author <BigueNique at yahoo dot ca>
 */
function rpl_glob($pattern, $flags=0) {
    $split=explode('/',$pattern);
    $match=array_pop($split);
    $path=implode('/',$split);
    if (($dir=opendir($path))!==false) {
        $glob=array();
        while(($file=readdir($dir))!==false) {
            if (fnmatch($match,$file)) {
                if ((is_dir("$path/$file"))||(!($flags&GLOB_ONLYDIR))) {
                    if ($flags&GLOB_MARK) $file.='/';
                    $glob[]=$file;
                }
            }
        }
        closedir($dir);
        if (!($flags&GLOB_NOSORT)) sort($glob);
        return $glob;
    } else {
        return false;
    }   
}
 
/**
 * @author <soywiz at php dot net>
 */
if (!function_exists('fnmatch')) {
    function fnmatch($pattern, $string) {
        return @preg_match('/^' . strtr(addcslashes($pattern, '\\.+^$(){}=!<>|'), array('*' => '.*', '?' => '.?')) . '$/i', $string);
    }
}