include("diff2.php"); $STARTSEITE = "Dokumentation"; $PAGEDIRECTORY = "pages/"; $IPBLACKLIST = "ipblacklist/"; $IPBLACKLISTFILE = $IPBLACKLIST . $HTTP_SERVER_VARS{REMOTE_ADDR}; $FROM = "wiki@linvdr.org"; $TO = "tom@harhar.net"; $VERSION = "0.1"; $pagename = $_GET['pagename']; function OpenFile($filename) { global $PAGEDIRECTORY, $text; $file = $PAGEDIRECTORY . $filename; if(!file_exists($file)) return; $f = fopen($PAGEDIRECTORY . $filename, "r"); if(!$f) return; while(!feof($f)) { $text .= fread($f, 1024); } fclose($f); } function SaveFile($filename, $text) { global $PAGEDIRECTORY; $date = time(); $file = sprintf("%s:%s", $filename, $date); $f = fopen($PAGEDIRECTORY . $file, "w"); if(!$f) return; $result = fwrite($f, $text); fclose($f); $symlink = $PAGEDIRECTORY . $filename; if(file_exists($symlink)) unlink($symlink); symlink($file, $symlink); return(0); } function Pipe($command) { if(!$command) return; $p = popen($command, "r"); while(!feof($p)) { $buffer .= fread($p, 1024); } pclose($p); return($buffer); } function Revisions($files, $pagename) { global $PAGEDIRECTORY; $revisions = array(); foreach($files as $file) { if(preg_match("/^$pagename\:\d+$/", $file)) { array_push($revisions, $file); } } rsort($revisions); return($revisions); } # XXX obsolete function Diff($pagename, $version1, $version2) { global $PAGEDIRECTORY; $version1_file = sprintf("%s%s:%s", $PAGEDIRECTORY, $pagename, $version1); $version2_file = sprintf("%s%s:%s", $PAGEDIRECTORY, $pagename, $version2); if(!file_exists($version1_file)) return; if(!file_exists($version2_file)) return; $p = popen("diff -Nuhr \"$version1_file\" \"$version2_file\"", "r"); while(!feof($p)) { $buffer .= fread($p, 1024); } return($buffer); } function Diff2($pagename, $version1, $version2) { global $PAGEDIRECTORY; $version1_file = sprintf("%s%s:%s", $PAGEDIRECTORY, $pagename, $version1); $version2_file = sprintf("%s%s:%s", $PAGEDIRECTORY, $pagename, $version2); if(!file_exists($version1_file)) return; if(!file_exists($version2_file)) return; $version1 = Pipe("lynx -force-html -dump \"$version1_file\""); $version2 = Pipe("lynx -force-html -dump \"$version2_file\""); return(PHPDiff($version2, $version1)); } ## # ## #if(file_exists($IPBLACKLISTFILE)) { # print("You don't exist. Go away!"); #mail($TO, "Anfrage von gesperrter IP: " . $HTTP_SERVER_VARS{REMOTE_ADDR}, var_export($HTTP_POST_VARS, true) . var_export($HTTP_SERVER_VARS, true), "From: $FROM"); # exit(1); #} if(!$pagename) { $pagename = $STARTSEITE; } else { if(preg_match("/[^a-zA-Z0-9\._-]/", $pagename)) { $pagename = $STARTSEITE; } } if($edit) { print("Speichern abgeschaltet. Zu viel Missbrauch!\n"); exit; $topic = "LinVDR $pagename"; include("../top.php"); OpenFile($pagename); ?>
include("../bottom.php"); } elseif($save) { print("Speichern abgeschaltet. Zu viel Missbrauch!\n"); exit; if(strlen($TEXT) > 20) { // $blacklistfile = fopen("blacklist", "r"); if(!$blacklistfile) return; while(!feof($blacklistfile)) { $blacklist .= fread($blacklistfile, 1024); } $blacklistedwordfound = false; foreach(explode("\n", $blacklist) as $blacklistedword) { if(strlen($blacklistedword) > 0) { if(preg_match("/$blacklistedword/", $TEXT)) { $blacklistedwordfound = true; } } } if(!$blacklistedwordfound) SaveFile($pagename, stripslashes($TEXT)); else { mail($TO, "Blacklisted word von: " . $HTTP_SERVER_VARS{REMOTE_ADDR}, var_export($HTTP_POST_VARS, true) . var_export($HTTP_SERVER_VARS, true), "From: $FROM"); $ipblacklistfilehandle = fopen($IPBLACKLISTFILE, "a"); if($ipblacklistfilehandle) { #fwrite($ipblacklistfile, $HTTP_SERVER_VARS{REMOTE_ADDR} . "\n"); fclose($ipblacklistfilehandle); } } } header(sprintf("Location: %s?pagename=%s", $PHP_SELF, $pagename)); exit; } elseif($changelog) { $topic = "LinVDR Changelog"; include("../top.php"); $difftime = time() - (86400 * 7); $d = opendir($PAGEDIRECTORY); $files = array(); while($file = readdir($d)) { if($file != "." && $file != "..") { array_push($files, $file); } } closedir($d); foreach($files as $file) { if(is_link($PAGEDIRECTORY . $file)) { $revisions = Revisions($files, $file); $history = array(); array_push($history, sprintf("%s");
if($pure) {
print(nl2br(htmlspecialchars(Diff($pagename, $version1, $version2))));
} else {
print(nl2br(Diff2($pagename, $version1, $version2)));
}
print("
");
include("../bottom.php");
} else {
$topic = "LinVDR $pagename";
include("../top.php");
OpenFile($pagename);
if($text) {
print($text);
?>