-function wiki_clean_tmp() {
- // clean old tmp files (more than one hour)
- $wiki_work_dir = wiki_work_dir();
- $dh = opendir(wiki_work_dir());
- $time = time();
- while (($file = readdir($dh)) !== false) {
- if (strpos($file, 'temp_') === 0) {
- $created = filectime($wiki_work_dir.'/'.$file);
- if ($time-$created > 60 * 60)
- @unlink($wiki_work_dir.'/'.$file);
+function wiki_set_perms($n, $pr, $pw)
+{
+ $file = wiki_work_dir().'/'.str_replace('/', '.', $n);
+ if (!file_exists($file))
+ return false;
+
+ $p = $pr . ':' . $pw;
+
+ $lines = explode("\n", file_get_contents($file));
+ foreach ($lines as $i => $line) {
+ list($k, $v) = explode('=', $line, 2);
+ if ($k == 'platal_perms') {
+ $lines[$i] = 'platal_perms='.$p;
+ wiki_putfile($file, join("\n", $lines));
+ return true;