There will be great changes in new version!
It is under heavy construction.
http://cleanmerchants.com/NigritudeUltramarine/
http://www-users.rwth-aachen.de/shaohui.li/wiki/index.php
-search functions
-bugs fixed
-better security
-some major changes
- new content replacement
- bugs fixed
- better alignment of forms
- new function of keeping the cookie
I have started to use CVS to update the code.
you can access freely in order to get the most updated version
Please use this version, 0.1.3 will include the fixed version.
<?php
include "timer.php";
include "config.php";
include "lang.php";
include "cookie.php";
$titlehead=$lang[titlehead][edit];
$page=$HTTP_POST_VARS[page];
if ($page==""){
$page=$HTTP_GET_VARS[page];
}
if ($page==""){
$page=$config[main];
}
if ((strpos($page, ".")!==false)or(strpos($page, "?")!==false)or(strpos($page, "=")!==false)or(strpos($page, "#")!==false)
or(strpos($page, "%23")!==false)or(strpos($page, "%3D")!==false)or(strpos($page, "%3F")!==false)){
include "top.php";
print $lang[illegalpagename];
include "bottom.php";
exit;
}
$spaceonlyprevent=str_replace(" ","",$page);
$spaceonlyprevent=str_replace("%20","",$spaceonlyprevent);
if ($spaceonlyprevent==""){
include "top.php";
print $lang[illegalpagename];
include "bottom.php";
exit;
}
$page=urldecode($page);
$page=utf8_decode($page);
$enpage=base64_encode($page);
if (strlen($page)>60){
include "top.php";
print strlen($page);
print $lang[nametoolong];
include "bottom.php";
exit;
}
if ($HTTP_GET_VARS[source]=="1"){
$handle = @fopen("./data/$enpage", "r");
$contents = @fread($handle, filesize("./data/$enpage"));
@fclose($handle);
list ($lasteditor,$lastedited,$contents) = split ("|\:|", $contents,3);
include "top.php";
print "<h2>$lang[sourcecode] - <a href=\"index.php?page=".rawurlencode(utf8_encode($page))."\">$page</a></h2>";
print "<tr><td>\n<textarea cols=\"80\" rows=\"25\">$contents</textarea>\n";
$mtime=gmdate("$config[time]",$lastedited+$config[timezone]*3600);
print "<br><font color=\"#AAAAAA\"><small>$lang[lasteditby] $lasteditor $lang[at] $mtime $config[timezonetxt] <a href=\"index.php?page=".rawurlencode(utf8_encode($page))."\">$page</a></small></font>\n";
include "bottom.php";
}else{
if ((($config[permission]==1)or
(($config[permission]==2)and($cookie[exist]==TRUE))or
(($config[permission]==3)and($cookie[exist]==TRUE)and($cookie[admin]==TRUE)))
and
((($config[protect][$page]==TRUE)and($cookie[exist]==TRUE)and($cookie[admin]==TRUE))or
($config[protect][$page]!=TRUE))){
if ($HTTP_POST_VARS[contents]==""){
$handle = @fopen("./data/$enpage", "r");
$contents = @fread($handle, filesize("./data/$enpage"));
@fclose($handle);
list ($lasteditor,$lastedited,$contents) = split ("|\:|", $contents,3);
include "top.php";
print "<h2>$lang[edit] $page</h2>\n";
print "<table><form action=\"edit.php\" method=\"POST\">\n";
print "<textarea name=\"contents\" cols=\"80\" rows=\"25\">$contents</textarea><br>\n";
print "<input name=\"page\" value=\"".rawurlencode(utf8_encode($page))."\" type=\"hidden\">\n";
print "<input name=\"time\" value=\"".time()."\" type=\"hidden\">\n";
print "<input name=\"submit\" type=\"submit\" value=\"$lang[save]\">\n";
print "<input name=\"preview\" type=\"submit\" value=\"$lang[preview]\">\n";
print "</form></table>\n";
include "bottom.php";
}elseif($HTTP_POST_VARS[preview]!=""){
$contents=stripslashes($HTTP_POST_VARS[contents]);
$contents=str_replace("</textarea>","",$contents);
include "top.php";
print "<h2>$lang[edit] $page</h2>\n";
print "<table><form action=\"edit.php\" method=\"POST\">\n";
print "<textarea name=\"contents\" cols=\"80\" rows=\"25\">$contents</textarea><br>\n";
print "<input name=\"page\" value=\"".rawurlencode(utf8_encode($page))."\" type=\"hidden\">\n";
print "<input name=\"time\" value=\"$HTTP_POST_VARS[time]\" type=\"hidden\">\n";
print "<input name=\"submit\" type=\"submit\" value=\"$lang[save]\">\n";
print "<input name=\"preview\" type=\"submit\" value=\"$lang[preview]\">\n";
print "</form></table>\n";
$contents=process($contents);
print "<h2><u>$lang[preview]</u></h2>\n<table width=\"100%\" border=\"0\" bgcolor=\"$config[tablecolor]\">";
print "<tr><td>\n$contents\n";
print "</td></tr></table>";
include "bottom.php";
}else{
if ($config[backup]>0){
$backuplist=list_backup($enpage);
for ($i = 0; $i < count($backuplist); $i++) {
$filename = explode(".", $backuplist[$i]);
if($filename[1]<(time()-$config[backup])){
if (!unlink("./backup/$backuplist[$i]")) {
include "top.php";
print $lang[failtodelbackup];
include "bottom.php";
exit;
}
}
}}
if (file_exists("./data/$enpage")){
$handle = @fopen("./data/$enpage", "r");
$contents = @fread($handle, filesize("./data/$enpage"));
@fclose($handle);
list ($lasteditor,$lastedited,$contents) = split ("|\:|", $contents,3);
if (!copy("./data/$enpage", "./backup/$enpage.$lastedited")) {
include "top.php";
print $lang[failtobackup];
include "bottom.php";
exit;
}
@chmod("./backup/$enpage.$lastedited", 0777);
}
$handle = @fopen("./data/$enpage", "r");
$oldcontents = @fread($handle, filesize("./data/$enpage"));
@fclose($handle);
list ($oldlasteditor,$oldlastedited,$oldcontents) = split ("|\:|", $oldcontents);
$contents=stripslashes($HTTP_POST_VARS[contents]);
$contents=str_replace("</textarea>","",$contents);
if ($oldcontents==$contents){
include "top.php";
print "$lang[editfailnochange]<br>\n";
print "<a href=\"edit.php?page=".rawurlencode(utf8_encode($page))."\">$lang[edit] $page</a>";
include "bottom.php";
exit;
}
if ($HTTP_POST_VARS[time]<=$oldlastedited){
include "top.php";
print "$lang[editfailhaschange]<br>\n";
print "<a href=\"edit.php?page=".rawurlencode(utf8_encode($page))."\">$lang[edit] $page</a>";
include "bottom.php";
exit;
}
$handle = @fopen ("./data/$enpage", "w") or die($lang[editfail]);
if ($cookie[id]==""){$editor=$HTTP_SERVER_VARS['REMOTE_ADDR'];}else{$editor=$cookie[id];}
fwrite($handle, $editor."|:|".time()."|:|".$contents);
fclose($handle);
@chmod("./data/$enpage", 0777);
header("Location: index.php?page=".rawurlencode(utf8_encode($page)));
include "top.php";
print "$lang[updatesuccess]<br>\n";
print "<a href=\"index.php?page=".rawurlencode(utf8_encode($page))."\">$page</a>";
include "bottom.php";
exit;
}
}else{
include "top.php";
print $lang[editnotallow];
print "\n<br><a href=\"index.php?page=".rawurlencode(utf8_encode($page))."\">$page</a>";
include "bottom.php";
exit;
}
}... read more
bugs fixed:potential space and special character problems, fixed version will be included in the next release
Here is the new version of edit.php
<?php
include "timer.php";
include "config.php";
include "lang.php";
include "cookie.php";
$titlehead=$lang[titlehead][edit];
$page=$HTTP_POST_VARS[page];
if ($page==""){
$page=$HTTP_GET_VARS[page];
}
if ($page==""){
$page=$config[main];
}
if ((strpos($page, ".")!==false)or(strpos($page, "?")!==false)or(strpos($page, "=")!==false)or(strpos($page, "#")!==false)
or(strpos($page, "%23")!==false)or(strpos($page, "%3D")!==false)or(strpos($page, "%3F")!==false)){
include "top.php";
print $lang[illegalpagename];
include "bottom.php";
exit;
}
$spaceonlyprevent=str_replace(" ","",$page);
$spaceonlyprevent=str_replace("%20","",$spaceonlyprevent);
if ($spaceonlyprevent==""){
include "top.php";
print $lang[illegalpagename];
include "bottom.php";
exit;
}
$page=urldecode($page);
$page=utf8_decode($page);
$enpage=base64_encode($page);
if (strlen($page)>60){
include "top.php";
print strlen($page);
print $lang[nametoolong];
include "bottom.php";
exit;
}
if ($HTTP_GET_VARS[source]=="1"){
$handle = @fopen("./data/$enpage", "r");
$contents = @fread($handle, filesize("./data/$enpage"));
@fclose($handle);
list ($lasteditor,$lastedited,$contents) = split ("|\:|", $contents,3);
include "top.php";
print "<h2>$lang[sourcecode] - <a href=\"index.php?page=".rawurlencode(utf8_encode($page))."\">$page</a></h2>";
print "<tr><td>\n<textarea cols=\"80\" rows=\"25\">$contents</textarea>\n";
$mtime=gmdate("$config[time]",$lastedited+$config[timezone]*3600);
print "<br><font color=\"#AAAAAA\"><small>$lang[lasteditby] $lasteditor $lang[at] $mtime $config[timezonetxt] <a href=\"index.php?page=".rawurlencode(utf8_encode($page))."\">$page</a></small></font>\n";
include "bottom.php";
}else{
if ((($config[permission]==1)or
(($config[permission]==2)and($cookie[exist]==TRUE))or
(($config[permission]==3)and($cookie[exist]==TRUE)and($cookie[admin]==TRUE)))
and
((($config[protect][$page]==TRUE)and($cookie[exist]==TRUE)and($cookie[admin]==TRUE))or
($config[protect][$page]!=TRUE))){
if ($HTTP_POST_VARS[contents]==""){
$handle = @fopen("./data/$enpage", "r");
$contents = @fread($handle, filesize("./data/$enpage"));
@fclose($handle);
list ($lasteditor,$lastedited,$contents) = split ("|\:|", $contents,3);
include "top.php";
print "<h2>$lang[edit] $page</h2>\n";
print "<table><form action=\"edit.php\" method=\"POST\">\n";
print "<textarea name=\"contents\" cols=\"80\" rows=\"25\">$contents</textarea><br>\n";
print "<input name=\"page\" value=\"".rawurlencode(utf8_encode($page))."\" type=\"hidden\">\n";
print "<input name=\"time\" value=\"".time()."\" type=\"hidden\">\n";
print "<input name=\"submit\" type=\"submit\" value=\"$lang[save]\">\n";
print "<input name=\"preview\" type=\"submit\" value=\"$lang[preview]\">\n";
print "</form></table>\n";
include "bottom.php";
}elseif($HTTP_POST_VARS[preview]!=""){
$contents=stripslashes($HTTP_POST_VARS[contents]);
include "top.php";
print "<h2>$lang[edit] $page</h2>\n";
print "<table><form action=\"edit.php\" method=\"POST\">\n";
print "<textarea name=\"contents\" cols=\"80\" rows=\"25\">$contents</textarea><br>\n";
print "<input name=\"page\" value=\"".rawurlencode(utf8_encode($page))."\" type=\"hidden\">\n";
print "<input name=\"time\" value=\"$HTTP_POST_VARS[time]\" type=\"hidden\">\n";
print "<input name=\"submit\" type=\"submit\" value=\"$lang[save]\">\n";
print "<input name=\"preview\" type=\"submit\" value=\"$lang[preview]\">\n";
print "</form></table>\n";
$contents=process($contents);
print "<h2><u>$lang[preview]</u></h2>\n<table width=\"100%\" border=\"0\" bgcolor=\"$config[tablecolor]\">";
print "<tr><td>\n$contents\n";
print "</td></tr></table>";
include "bottom.php";
}else{
if ($config[backup]>0){
$backuplist=list_backup($enpage);
for ($i = 0; $i < count($backuplist); $i++) {
$filename = explode(".", $backuplist[$i]);
if($filename[1]<(time()-$config[backup])){
if (!unlink("./backup/$backuplist[$i]")) {
include "top.php";
print $lang[failtodelbackup];
include "bottom.php";
exit;
}
}
}}
if (file_exists("./data/$enpage")){
$handle = @fopen("./data/$enpage", "r");
$contents = @fread($handle, filesize("./data/$enpage"));
@fclose($handle);
list ($lasteditor,$lastedited,$contents) = split ("|\:|", $contents,3);
if (!copy("./data/$enpage", "./backup/$enpage.$lastedited")) {
include "top.php";
print $lang[failtobackup];
include "bottom.php";
exit;
}
@chmod("./backup/$enpage.$lastedited", 0777);
}
$handle = @fopen("./data/$enpage", "r");
$oldcontents = @fread($handle, filesize("./data/$enpage"));
@fclose($handle);
list ($oldlasteditor,$oldlastedited,$oldcontents) = split ("|\:|", $oldcontents);
$contents=stripslashes($HTTP_POST_VARS[contents]);
if ($oldcontents==$contents){
include "top.php";
print "$lang[editfailnochange]<br>\n";
print "<a href=\"edit.php?page=".rawurlencode(utf8_encode($page))."\">$lang[edit] $page</a>";
include "bottom.php";
exit;
}
if ($HTTP_POST_VARS[time]<=$oldlastedited){
include "top.php";
print "$lang[editfailhaschange]<br>\n";
print "<a href=\"edit.php?page=".rawurlencode(utf8_encode($page))."\">$lang[edit] $page</a>";
include "bottom.php";
exit;
}
$handle = @fopen ("./data/$enpage", "w") or die($lang[editfail]);
if ($cookie[id]==""){$editor=$HTTP_SERVER_VARS['REMOTE_ADDR'];}else{$editor=$cookie[id];}
fwrite($handle, $editor."|:|".time()."|:|".$contents);
fclose($handle);
@chmod("./data/$enpage", 0777);
header("Location: index.php?page=".rawurlencode(utf8_encode($page)));
include "top.php";
print "$lang[updatesuccess]<br>\n";
print "<a href=\"index.php?page=".rawurlencode(utf8_encode($page))."\">$page</a>";
include "bottom.php";
exit;
}
}else{
include "top.php";
print $lang[editnotallow];
print "\n<br><a href=\"index.php?page=".rawurlencode(utf8_encode($page))."\">$page</a>";
include "bottom.php";
exit;
}
}... read more
- bugs fixed in diff.php
- new functions in redirect.php (auto search similar page name)
- new content replacement (external links with different colours, links to wikipedia & right alignment)
- Sorted page list
Bugs are found in diff.php, in the next version, the bug-fixed verion will be included
please update diff.php as:
<?php
include "timer.php";
include "config.php";
include "lang.php";
include "cookie.php";
$page1=$HTTP_POST_VARS[page1];
if ($page1==""){$page1=$config[main];}
$page1=urldecode($page1);
$page1=utf8_decode($page1);
$pos1 = strpos($page1, ".");
$filename1 = explode(".", $page1);
$filename1[0]=base64_encode($filename1[0]);
if ($pos1==0){$loc1="data";}else{$loc1="backup";}... read more
WikiRootry 0.1 is released
It uses PHP, no DB is needed.
It outputs text as unicode
problems: safe mode, diff is not working very well