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