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(',','&',$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 .= '&'.$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 * num : return 'num' entries 480 * num = 0: return count of entries set by $conf['recent'] 481 * num = -1: return all available entries 482 * 483 * @author Andreas Gohr <andi@splitbrain.org> 484 */ 485function getRecents($num=0,$incdel=false){ 486 global $conf; 487 $recent = array(); 488 if(!$num) $num = $conf['recent']; 489 490 if(!@is_readable($conf['changelog'])){ 491 msg($conf['changelog'].' is not readable',-1); 492 return $recent; 493 } 494 495 $loglines = file($conf['changelog']); 496 rsort($loglines); //reverse sort on timestamp 497 498 foreach ($loglines as $line){ 499 $line = rtrim($line); //remove newline 500 if(empty($line)) continue; //skip empty lines 501 $info = split("\t",$line); //split into parts 502 //add id if not in yet and file still exists and is allowed to read 503 if(!$recent[$info[2]] && 504 (@file_exists(wikiFN($info[2])) || $incdel) && 505 (auth_quickaclcheck($info[2]) >= AUTH_READ) 506 ){ 507 $recent[$info[2]]['date'] = $info[0]; 508 $recent[$info[2]]['ip'] = $info[1]; 509 $recent[$info[2]]['user'] = $info[3]; 510 $recent[$info[2]]['sum'] = $info[4]; 511 $recent[$info[2]]['del'] = !@file_exists(wikiFN($info[2])); 512 } 513 if($num != -1 && count($recent) >= $num){ 514 break; //finish if enough items found 515 } 516 } 517 return $recent; 518} 519 520/** 521 * gets additonal informations for a certain pagerevison 522 * from the changelog 523 * 524 * @author Andreas Gohr <andi@splitbrain.org> 525 */ 526function getRevisionInfo($id,$rev){ 527 global $conf; 528 529 if(!$rev) return(null); 530 531 $info = array(); 532 if(!@is_readable($conf['changelog'])){ 533 msg($conf['changelog'].' is not readable',-1); 534 return $recent; 535 } 536 $loglines = file($conf['changelog']); 537 $loglines = preg_grep("/$rev\t\d+\.\d+\.\d+\.\d+\t$id\t/",$loglines); 538 $loglines = array_reverse($loglines); //reverse sort on timestamp (shouldn't be needed) 539 $line = split("\t",$loglines[0]); 540 $info['date'] = $line[0]; 541 $info['ip'] = $line[1]; 542 $info['user'] = $line[3]; 543 $info['sum'] = $line[4]; 544 return $info; 545} 546 547/** 548 * Saves a wikitext by calling io_saveFile 549 * 550 * @author Andreas Gohr <andi@splitbrain.org> 551 */ 552function saveWikiText($id,$text,$summary){ 553 global $conf; 554 global $lang; 555 umask($conf['umask']); 556 // ignore if no changes were made 557 if($text == rawWiki($id,'')){ 558 return; 559 } 560 561 $file = wikiFN($id); 562 $old = saveOldRevision($id); 563 564 if (empty($text)){ 565 // remove empty files 566 @unlink($file); 567 $del = true; 568 //autoset summary on deletion 569 if(empty($summary)) $summary = $lang['deleted']; 570 //remove empty namespaces 571 io_sweepNS($id); 572 }else{ 573 // save file (datadir is created in io_saveFile) 574 io_saveFile($file,$text); 575 $del = false; 576 } 577 578 addLogEntry(@filemtime($file),$id,$summary); 579 notify($id,$old,$summary); 580 581 //purge cache on add by updating the purgefile 582 if($conf['purgeonadd'] && (!$old || $del)){ 583 io_saveFile($conf['datadir'].'/_cache/purgefile',time()); 584 } 585} 586 587/** 588 * moves the current version to the attic and returns its 589 * revision date 590 * 591 * @author Andreas Gohr <andi@splitbrain.org> 592 */ 593function saveOldRevision($id){ 594 global $conf; 595 umask($conf['umask']); 596 $oldf = wikiFN($id); 597 if(!@file_exists($oldf)) return ''; 598 $date = filemtime($oldf); 599 $newf = wikiFN($id,$date); 600 if(substr($newf,-3)=='.gz'){ 601 io_saveFile($newf,rawWiki($id)); 602 }else{ 603 io_makeFileDir($newf); 604 copy($oldf, $newf); 605 } 606 return $date; 607} 608 609/** 610 * Sends a notify mail to the wikiadmin when a page was 611 * changed 612 * 613 * @author Andreas Gohr <andi@splitbrain.org> 614 */ 615function notify($id,$rev="",$summary=""){ 616 global $lang; 617 global $conf; 618 $hdrs =''; 619 if(empty($conf['notify'])) return; //notify enabled? 620 621 $text = rawLocale('mailtext'); 622 $text = str_replace('@DATE@',date($conf['dformat']),$text); 623 $text = str_replace('@BROWSER@',$_SERVER['HTTP_USER_AGENT'],$text); 624 $text = str_replace('@IPADDRESS@',$_SERVER['REMOTE_ADDR'],$text); 625 $text = str_replace('@HOSTNAME@',gethostbyaddr($_SERVER['REMOTE_ADDR']),$text); 626 $text = str_replace('@NEWPAGE@',wl($id,'',true),$text); 627 $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text); 628 $text = str_replace('@SUMMARY@',$summary,$text); 629 $text = str_replace('@USER@',$_SERVER['REMOTE_USER'],$text); 630 631 if($rev){ 632 $subject = $lang['mail_changed'].' '.$id; 633 $text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",true),$text); 634 require_once("inc/DifferenceEngine.php"); 635 $df = new Diff(split("\n",rawWiki($id,$rev)), 636 split("\n",rawWiki($id))); 637 $dformat = new UnifiedDiffFormatter(); 638 $diff = $dformat->format($df); 639 }else{ 640 $subject=$lang['mail_newpage'].' '.$id; 641 $text = str_replace('@OLDPAGE@','none',$text); 642 $diff = rawWiki($id); 643 } 644 $text = str_replace('@DIFF@',$diff,$text); 645 646 mail_send($conf['notify'],$subject,$text,$conf['mailfrom']); 647} 648 649/** 650 * Return a list of available page revisons 651 * 652 * @author Andreas Gohr <andi@splitbrain.org> 653 */ 654function getRevisions($id){ 655 $revd = dirname(wikiFN($id,'foo')); 656 $revs = array(); 657 $clid = cleanID($id); 658 if(strrpos($clid,':')) $clid = substr($clid,strrpos($clid,':')+1); //remove path 659 660 if (is_dir($revd) && $dh = opendir($revd)) { 661 while (($file = readdir($dh)) !== false) { 662 if (is_dir($revd.'/'.$file)) continue; 663 if (preg_match('/^'.$clid.'\.(\d+)\.txt(\.gz)?$/',$file,$match)){ 664 $revs[]=$match[1]; 665 } 666 } 667 closedir($dh); 668 } 669 rsort($revs); 670 return $revs; 671} 672 673/** 674 * extracts the query from a google referer 675 * 676 * @todo should be more generic and support yahoo et al 677 * @author Andreas Gohr <andi@splitbrain.org> 678 */ 679function getGoogleQuery(){ 680 $url = parse_url($_SERVER['HTTP_REFERER']); 681 682 if(!preg_match("#google\.#i",$url['host'])) return ''; 683 $query = array(); 684 parse_str($url['query'],$query); 685 686 return $query['q']; 687} 688 689/** 690 * Try to set correct locale 691 * 692 * @deprecated No longer used 693 * @author Andreas Gohr <andi@splitbrain.org> 694 */ 695function setCorrectLocale(){ 696 global $conf; 697 global $lang; 698 699 $enc = strtoupper($lang['encoding']); 700 foreach ($lang['locales'] as $loc){ 701 //try locale 702 if(@setlocale(LC_ALL,$loc)) return; 703 //try loceale with encoding 704 if(@setlocale(LC_ALL,"$loc.$enc")) return; 705 } 706 //still here? try to set from environment 707 @setlocale(LC_ALL,""); 708} 709 710/** 711 * Return the human readable size of a file 712 * 713 * @param int $size A file size 714 * @param int $dec A number of decimal places 715 * @author Martin Benjamin <b.martin@cybernet.ch> 716 * @author Aidan Lister <aidan@php.net> 717 * @version 1.0.0 718 */ 719function filesize_h($size, $dec = 1){ 720 $sizes = array('B', 'KB', 'MB', 'GB'); 721 $count = count($sizes); 722 $i = 0; 723 724 while ($size >= 1024 && ($i < $count - 1)) { 725 $size /= 1024; 726 $i++; 727 } 728 729 return round($size, $dec) . ' ' . $sizes[$i]; 730} 731 732/** 733 * Run a few sanity checks 734 * 735 * @author Andreas Gohr <andi@splitbrain.org> 736 */ 737function getVersion(){ 738 //import version string 739 if(@file_exists('VERSION')){ 740 //official release 741 return 'Release '.trim(io_readfile('VERSION')); 742 }elseif(is_dir('_darcs')){ 743 //darcs checkout 744 $inv = file('_darcs/inventory'); 745 $inv = preg_grep('#andi@splitbrain\.org\*\*\d{14}#',$inv); 746 $cur = array_pop($inv); 747 preg_match('#\*\*(\d{4})(\d{2})(\d{2})#',$cur,$matches); 748 return 'Darcs '.$matches[1].'-'.$matches[2].'-'.$matches[3]; 749 }else{ 750 return 'snapshot?'; 751 } 752} 753 754/** 755 * Run a few sanity checks 756 * 757 * @author Andreas Gohr <andi@splitbrain.org> 758 */ 759function check(){ 760 global $conf; 761 global $INFO; 762 763 msg('DokuWiki version: '.getVersion(),1); 764 765 if(version_compare(phpversion(),'4.3.0','<')){ 766 msg('Your PHP version is too old ('.phpversion().' vs. 4.3.+ recommended)',-1); 767 }elseif(version_compare(phpversion(),'4.3.10','<')){ 768 msg('Consider upgrading PHP to 4.3.10 or higher for security reasons (your version: '.phpversion().')',0); 769 }else{ 770 msg('PHP version '.phpversion(),1); 771 } 772 773 if(is_writable($conf['changelog'])){ 774 msg('Changelog is writable',1); 775 }else{ 776 msg('Changelog is not writable',-1); 777 } 778 779 if(is_writable($conf['datadir'])){ 780 msg('Datadir is writable',1); 781 }else{ 782 msg('Datadir is not writable',-1); 783 } 784 785 if(is_writable($conf['olddir'])){ 786 msg('Attic is writable',1); 787 }else{ 788 msg('Attic is not writable',-1); 789 } 790 791 if(is_writable($conf['mediadir'])){ 792 msg('Mediadir is writable',1); 793 }else{ 794 msg('Mediadir is not writable',-1); 795 } 796 797 if(is_writable('conf/users.auth.php')){ 798 msg('conf/users.auth.php is writable',1); 799 }else{ 800 msg('conf/users.auth.php is not writable',0); 801 } 802 803 if(function_exists('mb_strpos')){ 804 if(defined('UTF8_NOMBSTRING')){ 805 msg('mb_string extension is available but will not be used',0); 806 }else{ 807 msg('mb_string extension is available and will be used',1); 808 } 809 }else{ 810 msg('mb_string extension not available - PHP only replacements will be used',0); 811 } 812 813 msg('Your current permission for this page is '.$INFO['perm'],0); 814 815 if(is_writable($INFO['filepath'])){ 816 msg('The current page is writable by the webserver',0); 817 }else{ 818 msg('The current page is not writable by the webserver',0); 819 } 820 821 if($INFO['writable']){ 822 msg('The current page is writable by you',0); 823 }else{ 824 msg('The current page is not writable you',0); 825 } 826} 827 828 829//Setup VIM: ex: et ts=2 enc=utf-8 : 830