Mu Wiki

(Restored - please check)


MuWiki is a 9 line PHP WikiClone, it has been written for the ShortestWikiContest and isn't used anywhere.

The first version, 15 lines, produces a cleaner html and is quasi readable.

The second version, 10 lines, have a really bad html but is someway smaller and the logic is a bit more complicated.

The third version in 9 lines also have the support for BackLinks, an insane logic and doesn't fclose() files..

then i changed my mind (see note) on that and wrote a 15 lines version that is xHTML compliant..

        * Working code: http://jaramir.slack.it/MuWiki/
        * Source code: http://jaramir.slack.it/MuWiki/wiki.phps

For the syntax see mainly TextFormattingRules, but the lists are made with "{", "@" and "}"

Acknowledgements: sen (#php@irc.freenode.net) s/file_get_contents()/join(file())/


PHP, Perl and ShortestWikiContest

Perl have won! PHP isn't (yet) that good for short programming (or maybe: i'm not that good coder) so i've changed MuWiki to do something useful: produce xHTML clean pages (that was on my todo list) and restarted shortening this version (that's huge: 15 lines!!)

Even if PHP have lost it was fun to try this contest :o)


Hmm, I tried the 15-line "xHTML Compliant" version and got the error "Warning: Wrong parameter count for join() in /test/index.php on line 8" -- is this a PHP version problem?

php.net/implode: (join is an alias of implode) As of PHP 4.3.0, the glue parameter of implode() is optional and defaults to the empty string(''). It's a versioning problem: i've sacrified compattibility with PHP 4.2.* for 4 chars: ",' '" -- Jaramir


I too had the following errors while running it locally with PHP 4.3.3 :

well, "clean" and "short" aren't that much friends in programming, if the files dosn't exists it will show an empty form so it's not needed to create the page. these are just Warnings and Notices, you'll have to write one or two lines more to take em out.. -- Jaramir


Here is a copy of the source:

 <?echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/'.
 '/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w'.
 '3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; '.
 'charset=UTF-8"/><title>MuWiki</title></head><body>';$r=$_REQUEST;$w=($r[0])?$r
 [0]:"HomePage";$l='<a href="';$e='<br/><a href="http://validator.w3.org/check/'
 .'referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="ValidxHTML" b'
 .'order="0"/></a></body></html>';if($r[2]){$f=fopen("_$w",'w');fwrite($f,$r[2])
 ;$r[1]='';}if(!$t=join(file("_$w"),"")or$r[1])die ('<form method="post" action="">
 <textarea name="2" cols="80" rows="24">'.$t.'</textarea><input type="submit" />
 </form>'.$e);foreach(glob("_*")as$g)if(ereg($w,join(file("$g"))))$b.=" $g";echo
 "<h1>$w</h1>".preg_replace(array("/\n( +.*)\n/","/([^']*)/","/''([^']*)'"
 ."'/","/\n{/","/\n@(.*)/","/\n}/","/\n+/","/(http:[^ \n]*)/","/[_']?(([A-Z][a".
 "-z]+){2,})/","/-{4}/","/'{6}/"),array('<pre>\1</pre>','<b>\1</b>','<i>\1</i>',
 '<ul>','<li>\1</li>','</ul>','<br/>',$l. '\1">\1</a>'," $l".'?0=\1">\1</a>',"<"
 ."hr/>","",),$t."<hr/>".$b);echo" $l?0=$w&amp;1=1\">ed $w</a>".$e;/* xHTML */?>

-- Jaramir


Original 9 line version:

 <title>MuWiki</title><?$r=$_REQUEST; $w=($r[0])?$r[0]:"HomePage";$l='<a href=';
 if($r[2]){$f=fopen("_$w",'w');fwrite($f,$r[2]);$r[1]='';}if(!$t=join(file("_$w"
 ))or$r[1])die("<form method=POST><textarea name=2 cols=80 rows=24>$t</textarea>
 <input type=submit>");foreach(glob("_*")as$g)if(ereg($w,join(file("$g")) ))$b.=
 " $g";echo"<h1>$w</h1>".preg_replace(array("/\n( +.*)\n/","/([^']*)/","".
 "/([^']*)/","/\n\*\*(.*)/","/\n\*/","/\n+/","/(http:[^ \n]*)/","/[ _']?((["
 ."A-Z][a-z]+){2,})/","/-{4}/","/'{6}/"),array('<pre>\1</pre>','<b>\1</b>','<i'.
 ">\\1</i>",'<ul><li>\1</ul>','<li>',"<p></p>",$l.'\1>\1</a>',$l.'?0=\1>\1</a>',
 "<hr>","",),$t."<hr>".$b);echo" $l?0=".$w."&1=1>edit $w";?><!-- &Syntax+++; -->
-- Jaramir


CategoryWikiImplementation


EditText of this page (last edited December 13, 2013) or FindPage with title or text search