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