summaryrefslogtreecommitdiff
path: root/inc/init.php
diff options
context:
space:
mode:
authorjan <jan@jandecaluwe.com>2005-05-12 22:42:25 +0200
committerjan <jan@jandecaluwe.com>2005-05-12 22:42:25 +0200
commit8c4f28e8218f0ffb4c01bfd99c7420114b839c4e (patch)
tree7e555672525e915191303d319ded5dc70b64bfda /inc/init.php
parent7009a5a9c3eec40fc7ae8aba3932be002d157b98 (diff)
downloadrpg-8c4f28e8218f0ffb4c01bfd99c7420114b839c4e.tar.gz
rpg-8c4f28e8218f0ffb4c01bfd99c7420114b839c4e.tar.bz2
Turn sensitive files into scripts that exit immediately
darcs-hash:20050512204225-45605-bee22b4df3d23374bc4922ede8f48106ea217209.gz
Diffstat (limited to 'inc/init.php')
-rw-r--r--inc/init.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/inc/init.php b/inc/init.php
index 075469ddb..621466196 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -70,6 +70,10 @@
$conf['mediadir'] = realpath($conf['mediadir']);
if(!$conf['mediadir']) msg('Wrong mediadir! Check config!',-1);
+ // automatic upgrade to script versions of certain files
+ scriptify('conf/users.auth');
+ scriptify('conf/acl.auth');
+
/**
* remove magic quotes recursivly
*
@@ -135,6 +139,32 @@ function getBaseURL($abs=false){
return $proto.$host.$port.$dir;
}
+function scriptify($file) {
+ // checks
+ if (!is_readable($file)) {
+ return;
+ }
+ $fn = $file.'.php';
+ if (@file_exists($fn)) {
+ return;
+ }
+ $fh = fopen($fn, 'w');
+ if (!$fh) {
+ die($fn.' is not writable!');
+ }
+ // write php exit hack first
+ fwrite($fh, "# $fn\n");
+ fwrite($fh, '# <?php exit()?>'."\n");
+ fwrite($fh, "# Don't modify the lines above\n");
+ fwrite($fh, "#\n");
+ // copy existing lines
+ $lines = file($file);
+ foreach ($lines as $line){
+ fwrite($fh, $line);
+ }
+ $fclose($fh);
+}
+
//Setup VIM: ex: et ts=2 enc=utf-8 :