[dokuwiki] config manager local.php permissions

  • From: Otto Vainio <oiv@xxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Fri, 23 May 2008 10:25:53 +0300

Hi

While I was playing with .htaccess and some config options to get nicer urls for my dw setup I of course managed to set my dw setup inaccessible. I had to edit the local.php manually, but it was impossible, since it was only writable by apache. I had a small php script to set it writable to all. Included is a patch to config plugin config.class.php to change permissions of the local.php file with $conf['fperm'] values.

Here is also the small script to change the permissions to 0777 if you are unable to edit config values from dw.

brgds Otto


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html><head><title>Setting local.php permissions</title></head><body>
<?php
// Save this script to your dokuwiki root directory.
// The same place where your doku.php file is.
// Edit the line $F='.. to point to your conf dir if not the default.
//
// Uncomment the next line when you are done to prevent misuse.
//die("Sorry not allowed");

define("S_IFMT", 0xF000);
define("S_IFREG", 0x8000);
define("S_IFDIR", 0x4000);

$F="conf/local.php";
echo "Trying to fix permissions for local.php";
$oumask=umask(0);
chmod($F, 0777);


if (($tat = @lstat($F)) == false)
die("ERROR: failed to stat file $F");

$type = $tat[mode] & S_IFMT;
if (($type != S_IFREG) && ($type != S_IFDIR))
die("ERROR: expecting file or directory and found something else at $T");

$tat=stat($F);
print "<h3>File:$F</h3><br />";
print "type:".filetype($F) ."<br />\n";
print "size:".$tat[size]."<br />\n";
$perms=decoct(fileperms($F)) % 1000;
print "perms:" .$perms. "<br />\n";
echo "Owner id:".$tat['uid']."<br />\n";
echo "Group id:".$tat['gid']."<br />\n";
print "atime:".date("F d Y H:i:s.",$tat[atime])."<br />\n";
print "mtime:".date("F d Y H:i:s.",$tat[mtime])."<br />\n";
print "ctime:".date("F d Y H:i:s.",$tat[ctime])."<br />\n";
print "blksize:".$tat[blksize]."<br />\n";
print "blocks:".$tat[blocks]."<br />\n";
?>
</body>
</html>

Other related posts:

  • » [dokuwiki] config manager local.php permissions