xref: /dokuwiki/inc/common.php (revision 5749f1ce740e4cfd6d886e8d2fda6b8782389d33)
1<?php
2/**
3 * Common DokuWiki functions
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Andreas Gohr <andi@splitbrain.org>
7 */
8
9  if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
10  require_once(DOKU_INC.'conf/dokuwiki.php');
11  require_once(DOKU_INC.'inc/io.php');
12  require_once(DOKU_INC.'inc/utf8.php');
13  require_once(DOKU_INC.'inc/mail.php');
14  require_once(DOKU_INC.'inc/parserutils.php');
15
16/**
17 * Return info about the current document as associative
18 * array.
19 *
20 * @author Andreas Gohr <andi@splitbrain.org>
21 */
22function pageinfo(){
23  global $ID;
24  global $REV;
25  global $USERINFO;
26  global $conf;
27
28  if($_SERVER['REMOTE_USER']){
29    $info['user']     = $_SERVER['REMOTE_USER'];
30    $info['userinfo'] = $USERINFO;
31    $info['perm']     = auth_quickaclcheck($ID);
32  }else{
33    $info['user']     = '';
34    $info['perm']     = auth_aclcheck($ID,'',null);
35  }
36
37  $info['namespace'] = getNS($ID);
38  $info['locked']    = checklock($ID);
39  $info['filepath']  = realpath(wikiFN($ID,$REV));
40  $info['exists']    = @file_exists($info['filepath']);
41  if($REV && !$info['exists']){
42    //check if current revision was meant
43    $cur = wikiFN($ID);
44    if(@file_exists($cur) && (@filemtime($cur) == $REV)){
45      $info['filepath'] = realpath($cur);
46      $info['exists']   = true;
47      $REV = '';
48    }
49  }
50  $info['rev'] = $REV;
51  if($info['exists']){
52    $info['writable'] = (is_writable($info['filepath']) &&
53                         ($info['perm'] >= AUTH_EDIT));
54  }else{
55    $info['writable'] = ($info['perm'] >= AUTH_CREATE);
56  }
57  $info['editable']  = ($info['writable'] && empty($info['lock']));
58  $info['lastmod']   = @filemtime($info['filepath']);
59
60  //who's the editor
61  if($REV){
62    $revinfo = getRevisionInfo($ID,$REV);
63  }else{
64    $revinfo = getRevisionInfo($ID,$info['lastmod']);
65  }
66  $info['ip']     = $revinfo['ip'];
67  $info['user']   = $revinfo['user'];
68  $info['sum']    = $revinfo['sum'];
69  $info['editor'] = $revinfo['ip'];
70  if($revinfo['user']){
71    $info['editor'] = $revinfo['user'];
72  }else{
73    $info['editor'] = $revinfo['ip'];
74  }
75
76  return $info;
77}
78
79/**
80 * print a message
81 *
82 * If HTTP headers were not sent yet the message is added
83 * to the global message array else it's printed directly
84 * using html_msgarea()
85 *
86 *
87 * Levels can be:
88 *
89 * -1 error
90 *  0 info
91 *  1 success
92 *
93 * @author Andreas Gohr <andi@splitbrain.org>
94 * @see    html_msgarea
95 */
96function msg($message,$lvl=0){
97  global $MSG;
98  $errors[-1] = 'error';
99  $errors[0]  = 'info';
100  $errors[1]  = 'success';
101
102  if(!headers_sent()){
103    if(!isset($MSG)) $MSG = array();
104    $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message);
105  }else{
106    $MSG = array();
107    $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message);
108    html_msgarea();
109  }
110}
111
112/**
113 * This builds the breadcrumb trail and returns it as array
114 *
115 * @author Andreas Gohr <andi@splitbrain.org>
116 */
117function breadcrumbs(){
118  global $ID;
119  global $ACT;
120  global $conf;
121  $crumbs = $_SESSION[$conf['title']]['bc'];
122
123  //first visit?
124  if (!is_array($crumbs)){
125    $crumbs = array();
126  }
127  //we only save on show and existing wiki documents
128  $file = wikiFN($ID);
129  if($ACT != 'show' || !@file_exists($file)){
130    $_SESSION[$conf['title']]['bc'] = $crumbs;
131    return $crumbs;
132  }
133
134  // page names
135  $name = noNS($ID);
136  if ($conf['useheading']) {
137    // get page title
138    $title = p_get_first_heading($ID);
139    if ($title) {
140      $name = $title;
141    }
142  }
143
144  //remove ID from array
145  if (isset($crumbs[$ID])) {
146    unset($crumbs[$ID]);
147  }
148
149  //add to array
150  $crumbs[$ID] = $name;
151  //reduce size
152  while(count($crumbs) > $conf['breadcrumbs']){
153    array_shift($crumbs);
154  }
155  //save to session
156  $_SESSION[$conf['title']]['bc'] = $crumbs;
157  return $crumbs;
158}
159
160/**
161 * Filter for page IDs
162 *
163 * This is run on a ID before it is outputted somewhere
164 * currently used to replace the colon with something else
165 * on Windows systems and to have proper URL encoding
166 *
167 * Urlencoding is ommitted when the second parameter is false
168 *
169 * @author Andreas Gohr <andi@splitbrain.org>
170 */
171function idfilter($id,$ue=true){
172  global $conf;
173  if ($conf['useslash'] && $conf['userewrite']){
174    $id = strtr($id,':','/');
175  }elseif (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' &&
176      $conf['userewrite']) {
177    $id = strtr($id,':',';');
178  }
179  if($ue){
180    $id = urlencode($id);
181    $id = str_replace('%3A',':',$id); //keep as colon
182    $id = str_replace('%2F','/',$id); //keep as slash
183  }
184  return $id;
185}
186
187/**
188 * This builds a link to a wikipage
189 *
190 * It handles URL rewriting and adds additional parameter if
191 * given in $more
192 *
193 * @author Andreas Gohr <andi@splitbrain.org>
194 */
195function wl($id='',$more='',$abs=false){
196  global $conf;
197  $more = str_replace(',','&amp;',$more);
198
199  $id    = idfilter($id);
200  if($abs){
201    $xlink = DOKU_URL;
202  }else{
203    $xlink = DOKU_BASE;
204  }
205
206  if($conf['userewrite'] == 2){
207    $xlink .= DOKU_SCRIPT.'/'.$id;
208    if($more) $xlink .= '?'.$more;
209  }elseif($conf['userewrite']){
210    $xlink .= $id;
211    if($more) $xlink .= '?'.$more;
212  }else{
213    $xlink .= DOKU_SCRIPT.'?id='.$id;
214    if($more) $xlink .= '&amp;'.$more;
215  }
216
217  return $xlink;
218}
219
220/**
221 * Just builds a link to a script
222 *
223 * @todo   maybe obsolete
224 * @author Andreas Gohr <andi@splitbrain.org>
225 */
226function script($script='doku.php'){
227#  $link = getBaseURL();
228#  $link .= $script;
229#  return $link;
230  return DOKU_BASE.DOKU_SCRIPT;
231}
232
233/**
234 * Spamcheck against wordlist
235 *
236 * Checks the wikitext against a list of blocked expressions
237 * returns true if the text contains any bad words
238 *
239 * @author Andreas Gohr <andi@splitbrain.org>
240 */
241function checkwordblock(){
242  global $TEXT;
243  global $conf;
244
245  if(!$conf['usewordblock']) return false;
246
247  $blockfile = file('conf/wordblock.conf');
248  //how many lines to read at once (to work around some PCRE limits)
249  if(version_compare(phpversion(),'4.3.0','<')){
250    //old versions of PCRE define a maximum of parenthesises even if no
251    //backreferences are used - the maximum is 99
252    //this is very bad performancewise and may even be too high still
253    $chunksize = 40;
254  }else{
255    //read file in chunks of 600 - this should work around the
256    //MAX_PATTERN_SIZE in modern PCRE
257    $chunksize = 600;
258  }
259  while($blocks = array_splice($blockfile,0,$chunksize)){
260    $re = array();
261    #build regexp from blocks
262    foreach($blocks as $block){
263      $block = preg_replace('/#.*$/','',$block);
264      $block = trim($block);
265      if(empty($block)) continue;
266      $re[]  = $block;
267    }
268    if(preg_match('#('.join('|',$re).')#si',$TEXT)) return true;
269  }
270  return false;
271}
272
273/**
274 * Return the IP of the client
275 *
276 * Honours X-Forwarded-For Proxy Headers
277 *
278 * @author Andreas Gohr <andi@splitbrain.org>
279 */
280function clientIP(){
281  $my = $_SERVER['REMOTE_ADDR'];
282  if($_SERVER['HTTP_X_FORWARDED_FOR']){
283    $my .= ' ('.$_SERVER['HTTP_X_FORWARDED_FOR'].')';
284  }
285  return $my;
286}
287
288/**
289 * Checks if a given page is currently locked.
290 *
291 * removes stale lockfiles
292 *
293 * @author Andreas Gohr <andi@splitbrain.org>
294 */
295function checklock($id){
296  global $conf;
297  $lock = wikiFN($id).'.lock';
298
299  //no lockfile
300  if(!@file_exists($lock)) return false;
301
302  //lockfile expired
303  if((time() - filemtime($lock)) > $conf['locktime']){
304    unlink($lock);
305    return false;
306  }
307
308  //my own lock
309  $ip = io_readFile($lock);
310  if( ($ip == clientIP()) || ($ip == $_SERVER['REMOTE_USER']) ){
311    return false;
312  }
313
314  return $ip;
315}
316
317/**
318 * Lock a page for editing
319 *
320 * @author Andreas Gohr <andi@splitbrain.org>
321 */
322function lock($id){
323  $lock = wikiFN($id).'.lock';
324  if($_SERVER['REMOTE_USER']){
325    io_saveFile($lock,$_SERVER['REMOTE_USER']);
326  }else{
327    io_saveFile($lock,clientIP());
328  }
329}
330
331/**
332 * Unlock a page if it was locked by the user
333 *
334 * @author Andreas Gohr <andi@splitbrain.org>
335 * @return bool true if a lock was removed
336 */
337function unlock($id){
338  $lock = wikiFN($id).'.lock';
339  if(@file_exists($lock)){
340    $ip = io_readFile($lock);
341    if( ($ip == clientIP()) || ($ip == $_SERVER['REMOTE_USER']) ){
342      @unlink($lock);
343      return true;
344    }
345  }
346  return false;
347}
348
349/**
350 * convert line ending to unix format
351 *
352 * @see    formText() for 2crlf conversion
353 * @author Andreas Gohr <andi@splitbrain.org>
354 */
355function cleanText($text){
356  $text = preg_replace("/(\015\012)|(\015)/","\012",$text);
357  return $text;
358}
359
360/**
361 * Prepares text for print in Webforms by encoding special chars.
362 * It also converts line endings to Windows format which is
363 * pseudo standard for webforms.
364 *
365 * @see    cleanText() for 2unix conversion
366 * @author Andreas Gohr <andi@splitbrain.org>
367 */
368function formText($text){
369  $text = preg_replace("/\012/","\015\012",$text);
370  return htmlspecialchars($text);
371}
372
373/**
374 * Returns the specified local text in raw format
375 *
376 * @author Andreas Gohr <andi@splitbrain.org>
377 */
378function rawLocale($id){
379  return io_readFile(localeFN($id));
380}
381
382/**
383 * Returns the raw WikiText
384 *
385 * @author Andreas Gohr <andi@splitbrain.org>
386 */
387function rawWiki($id,$rev=''){
388  return io_readFile(wikiFN($id,$rev));
389}
390
391/**
392 * Returns the raw Wiki Text in three slices.
393 *
394 * The range parameter needs to have the form "from-to"
395 * and gives the range of the section in bytes - no
396 * UTF-8 awareness is needed.
397 * The returned order is prefix, section and suffix.
398 *
399 * @author Andreas Gohr <andi@splitbrain.org>
400 */
401function rawWikiSlices($range,$id,$rev=''){
402  list($from,$to) = split('-',$range,2);
403  $text = io_readFile(wikiFN($id,$rev));
404  if(!$from) $from = 0;
405  if(!$to)   $to   = strlen($text)+1;
406
407  $slices[0] = substr($text,0,$from-1);
408  $slices[1] = substr($text,$from-1,$to-$from);
409  $slices[2] = substr($text,$to);
410
411  return $slices;
412}
413
414/**
415 * Joins wiki text slices
416 *
417 * function to join the text slices with correct lineendings again.
418 * When the pretty parameter is set to true it adds additional empty
419 * lines between sections if needed (used on saving).
420 *
421 * @author Andreas Gohr <andi@splitbrain.org>
422 */
423function con($pre,$text,$suf,$pretty=false){
424
425  if($pretty){
426    if($pre && substr($pre,-1) != "\n") $pre .= "\n";
427    if($suf && substr($text,-1) != "\n") $text .= "\n";
428  }
429
430  if($pre) $pre .= "\n";
431  if($suf) $text .= "\n";
432  return $pre.$text.$suf;
433}
434
435/**
436 * print debug messages
437 *
438 * little function to print the content of a var
439 *
440 * @author Andreas Gohr <andi@splitbrain.org>
441 */
442function dbg($msg,$hidden=false){
443  (!$hidden) ? print '<pre class="dbg">' : print "<!--\n";
444  print_r($msg);
445  (!$hidden) ? print '</pre>' : print "\n-->";
446}
447
448/**
449 * Add's an entry to the changelog
450 *
451 * @author Andreas Gohr <andi@splitbrain.org>
452 */
453function addLogEntry($date,$id,$summary=""){
454  global $conf;
455  $id     = cleanID($id);//FIXME not needed anymore?
456
457  if(!@is_writable($conf['changelog'])){
458    msg($conf['changelog'].' is not writable!',-1);
459    return;
460  }
461
462  if(!$date) $date = time(); //use current time if none supplied
463  $remote = $_SERVER['REMOTE_ADDR'];
464  $user   = $_SERVER['REMOTE_USER'];
465
466  $logline = join("\t",array($date,$remote,$id,$user,$summary))."\n";
467
468  //FIXME: use adjusted io_saveFile instead
469  $fh = fopen($conf['changelog'],'a');
470  if($fh){
471    fwrite($fh,$logline);
472    fclose($fh);
473  }
474}
475
476/**
477 * returns an array of recently changed files using the
478 * changelog
479 * first   : first entry in array returned
480 * num     : return 'num' entries
481 *
482 * @author Andreas Gohr <andi@splitbrain.org>
483 */
484function getRecents($first,$num,$incdel=false){
485  global $conf;
486  $recent = array();
487  $names  = array();
488
489  if(!$num)
490    return $recent;
491
492  if(!@is_readable($conf['changelog'])){
493    msg($conf['changelog'].' is not readable',-1);
494    return $recent;
495  }
496
497  $loglines = file($conf['changelog']);
498  rsort($loglines); //reverse sort on timestamp
499
500  foreach ($loglines as $line){
501    $line = rtrim($line);        //remove newline
502    if(empty($line)) continue;   //skip empty lines
503    $info = split("\t",$line);   //split into parts
504    //add id if not in yet and file still exists and is allowed to read
505    if(!$names[$info[2]] &&
506       (@file_exists(wikiFN($info[2])) || $incdel) &&
507       (auth_quickaclcheck($info[2]) >= AUTH_READ)
508      ){
509      $names[$info[2]] = 1;
510      if(--$first >= 0) continue;  /* skip "first" entries */
511
512      $recent[$info[2]]['date'] = $info[0];
513      $recent[$info[2]]['ip']   = $info[1];
514      $recent[$info[2]]['user'] = $info[3];
515      $recent[$info[2]]['sum']  = $info[4];
516      $recent[$info[2]]['del']  = !@file_exists(wikiFN($info[2]));
517    }
518    if(count($recent) >= $num){
519      break; //finish if enough items found
520    }
521  }
522  return $recent;
523}
524
525/**
526 * gets additonal informations for a certain pagerevison
527 * from the changelog
528 *
529 * @author Andreas Gohr <andi@splitbrain.org>
530 */
531function getRevisionInfo($id,$rev){
532  global $conf;
533
534  if(!$rev) return(null);
535
536  $info = array();
537  if(!@is_readable($conf['changelog'])){
538    msg($conf['changelog'].' is not readable',-1);
539    return $recent;
540  }
541  $loglines = file($conf['changelog']);
542  $loglines = preg_grep("/$rev\t\d+\.\d+\.\d+\.\d+\t$id\t/",$loglines);
543  $loglines = array_reverse($loglines); //reverse sort on timestamp (shouldn't be needed)
544  $line = split("\t",$loglines[0]);
545  $info['date'] = $line[0];
546  $info['ip']   = $line[1];
547  $info['user'] = $line[3];
548  $info['sum']   = $line[4];
549  return $info;
550}
551
552/**
553 * Saves a wikitext by calling io_saveFile
554 *
555 * @author Andreas Gohr <andi@splitbrain.org>
556 */
557function saveWikiText($id,$text,$summary){
558  global $conf;
559  global $lang;
560  umask($conf['umask']);
561  // ignore if no changes were made
562  if($text == rawWiki($id,'')){
563    return;
564  }
565
566  $file = wikiFN($id);
567  $old  = saveOldRevision($id);
568
569  if (empty($text)){
570    // remove empty files
571    @unlink($file);
572    $del = true;
573    //autoset summary on deletion
574    if(empty($summary)) $summary = $lang['deleted'];
575    //remove empty namespaces
576    io_sweepNS($id);
577  }else{
578    // save file (datadir is created in io_saveFile)
579    io_saveFile($file,$text);
580    $del = false;
581  }
582
583  addLogEntry(@filemtime($file),$id,$summary);
584  notify($id,$old,$summary);
585
586  //purge cache on add by updating the purgefile
587  if($conf['purgeonadd'] && (!$old || $del)){
588    io_saveFile($conf['datadir'].'/_cache/purgefile',time());
589  }
590}
591
592/**
593 * moves the current version to the attic and returns its
594 * revision date
595 *
596 * @author Andreas Gohr <andi@splitbrain.org>
597 */
598function saveOldRevision($id){
599	global $conf;
600  umask($conf['umask']);
601  $oldf = wikiFN($id);
602  if(!@file_exists($oldf)) return '';
603  $date = filemtime($oldf);
604  $newf = wikiFN($id,$date);
605  if(substr($newf,-3)=='.gz'){
606    io_saveFile($newf,rawWiki($id));
607  }else{
608    io_makeFileDir($newf);
609    copy($oldf, $newf);
610  }
611  return $date;
612}
613
614/**
615 * Sends a notify mail to the wikiadmin when a page was
616 * changed
617 *
618 * @author Andreas Gohr <andi@splitbrain.org>
619 */
620function notify($id,$rev="",$summary=""){
621  global $lang;
622  global $conf;
623  $hdrs ='';
624  if(empty($conf['notify'])) return; //notify enabled?
625
626  $text = rawLocale('mailtext');
627  $text = str_replace('@DATE@',date($conf['dformat']),$text);
628  $text = str_replace('@BROWSER@',$_SERVER['HTTP_USER_AGENT'],$text);
629  $text = str_replace('@IPADDRESS@',$_SERVER['REMOTE_ADDR'],$text);
630  $text = str_replace('@HOSTNAME@',gethostbyaddr($_SERVER['REMOTE_ADDR']),$text);
631  $text = str_replace('@NEWPAGE@',wl($id,'',true),$text);
632  $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text);
633  $text = str_replace('@SUMMARY@',$summary,$text);
634  $text = str_replace('@USER@',$_SERVER['REMOTE_USER'],$text);
635
636  if($rev){
637    $subject = $lang['mail_changed'].' '.$id;
638    $text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",true),$text);
639    require_once("inc/DifferenceEngine.php");
640    $df  = new Diff(split("\n",rawWiki($id,$rev)),
641                    split("\n",rawWiki($id)));
642    $dformat = new UnifiedDiffFormatter();
643    $diff    = $dformat->format($df);
644  }else{
645    $subject=$lang['mail_newpage'].' '.$id;
646    $text = str_replace('@OLDPAGE@','none',$text);
647    $diff = rawWiki($id);
648  }
649  $text = str_replace('@DIFF@',$diff,$text);
650
651  mail_send($conf['notify'],$subject,$text,$conf['mailfrom']);
652}
653
654/**
655 * Return a list of available page revisons
656 *
657 * @author Andreas Gohr <andi@splitbrain.org>
658 */
659function getRevisions($id){
660  $revd = dirname(wikiFN($id,'foo'));
661  $revs = array();
662  $clid = cleanID($id);
663  if(strrpos($clid,':')) $clid = substr($clid,strrpos($clid,':')+1); //remove path
664
665  if (is_dir($revd) && $dh = opendir($revd)) {
666    while (($file = readdir($dh)) !== false) {
667      if (is_dir($revd.'/'.$file)) continue;
668      if (preg_match('/^'.$clid.'\.(\d+)\.txt(\.gz)?$/',$file,$match)){
669        $revs[]=$match[1];
670      }
671    }
672    closedir($dh);
673  }
674  rsort($revs);
675  return $revs;
676}
677
678/**
679 * extracts the query from a google referer
680 *
681 * @todo   should be more generic and support yahoo et al
682 * @author Andreas Gohr <andi@splitbrain.org>
683 */
684function getGoogleQuery(){
685  $url = parse_url($_SERVER['HTTP_REFERER']);
686
687  if(!preg_match("#google\.#i",$url['host'])) return '';
688  $query = array();
689  parse_str($url['query'],$query);
690
691  return $query['q'];
692}
693
694/**
695 * Try to set correct locale
696 *
697 * @deprecated No longer used
698 * @author     Andreas Gohr <andi@splitbrain.org>
699 */
700function setCorrectLocale(){
701  global $conf;
702  global $lang;
703
704  $enc = strtoupper($lang['encoding']);
705  foreach ($lang['locales'] as $loc){
706    //try locale
707    if(@setlocale(LC_ALL,$loc)) return;
708    //try loceale with encoding
709    if(@setlocale(LC_ALL,"$loc.$enc")) return;
710  }
711  //still here? try to set from environment
712  @setlocale(LC_ALL,"");
713}
714
715/**
716 * Return the human readable size of a file
717 *
718 * @param       int    $size   A file size
719 * @param       int    $dec    A number of decimal places
720 * @author      Martin Benjamin <b.martin@cybernet.ch>
721 * @author      Aidan Lister <aidan@php.net>
722 * @version     1.0.0
723 */
724function filesize_h($size, $dec = 1){
725  $sizes = array('B', 'KB', 'MB', 'GB');
726  $count = count($sizes);
727  $i = 0;
728
729  while ($size >= 1024 && ($i < $count - 1)) {
730    $size /= 1024;
731    $i++;
732  }
733
734  return round($size, $dec) . ' ' . $sizes[$i];
735}
736
737/**
738 * Run a few sanity checks
739 *
740 * @author Andreas Gohr <andi@splitbrain.org>
741 */
742function getVersion(){
743  //import version string
744  if(@file_exists('VERSION')){
745    //official release
746    return 'Release '.trim(io_readfile('VERSION'));
747  }elseif(is_dir('_darcs')){
748    //darcs checkout
749    $inv = file('_darcs/inventory');
750    $inv = preg_grep('#andi@splitbrain\.org\*\*\d{14}#',$inv);
751    $cur = array_pop($inv);
752    preg_match('#\*\*(\d{4})(\d{2})(\d{2})#',$cur,$matches);
753    return 'Darcs '.$matches[1].'-'.$matches[2].'-'.$matches[3];
754  }else{
755    return 'snapshot?';
756  }
757}
758
759/**
760 * Run a few sanity checks
761 *
762 * @author Andreas Gohr <andi@splitbrain.org>
763 */
764function check(){
765  global $conf;
766  global $INFO;
767
768  msg('DokuWiki version: '.getVersion(),1);
769
770  if(version_compare(phpversion(),'4.3.0','<')){
771    msg('Your PHP version is too old ('.phpversion().' vs. 4.3.+ recommended)',-1);
772  }elseif(version_compare(phpversion(),'4.3.10','<')){
773    msg('Consider upgrading PHP to 4.3.10 or higher for security reasons (your version: '.phpversion().')',0);
774  }else{
775    msg('PHP version '.phpversion(),1);
776  }
777
778  if(is_writable($conf['changelog'])){
779    msg('Changelog is writable',1);
780  }else{
781    msg('Changelog is not writable',-1);
782  }
783
784  if(is_writable($conf['datadir'])){
785    msg('Datadir is writable',1);
786  }else{
787    msg('Datadir is not writable',-1);
788  }
789
790  if(is_writable($conf['olddir'])){
791    msg('Attic is writable',1);
792  }else{
793    msg('Attic is not writable',-1);
794  }
795
796  if(is_writable($conf['mediadir'])){
797    msg('Mediadir is writable',1);
798  }else{
799    msg('Mediadir is not writable',-1);
800  }
801
802  if(is_writable('conf/users.auth.php')){
803    msg('conf/users.auth.php is writable',1);
804  }else{
805    msg('conf/users.auth.php is not writable',0);
806  }
807
808  if(function_exists('mb_strpos')){
809    if(defined('UTF8_NOMBSTRING')){
810      msg('mb_string extension is available but will not be used',0);
811    }else{
812      msg('mb_string extension is available and will be used',1);
813    }
814  }else{
815    msg('mb_string extension not available - PHP only replacements will be used',0);
816  }
817
818  msg('Your current permission for this page is '.$INFO['perm'],0);
819
820  if(is_writable($INFO['filepath'])){
821    msg('The current page is writable by the webserver',0);
822  }else{
823    msg('The current page is not writable by the webserver',0);
824  }
825
826  if($INFO['writable']){
827    msg('The current page is writable by you',0);
828  }else{
829    msg('The current page is not writable you',0);
830  }
831}
832
833
834//Setup VIM: ex: et ts=2 enc=utf-8 :
835