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