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