-
Notifications
You must be signed in to change notification settings - Fork 19
MoniWiki System Overview en
This page describes the current MoniWiki runtime from source code. It is not a proposal.
-
wiki.phpis the primary web entry point. It loads config, createsWikiDB, initializes request/user state, handles session cookies, sets cache headers, and callswiki_main($options). -
wikilib.phpcontains shared request actions and user helpers. Important examples areWikiUser,do_goto(),do_post_savepage(),ajax_savepage(), anddo_post_DeleteFile(). -
plugin/*.phpfiles provide action, macro, and processor extensions.wiki.phpdiscovers plugin names withgetPlugin(),getProcessor(), andgetFilter(). -
lib/cache.text.phpstores cached settings, page HTML, PI metadata, and dynamic macro metadata.
flowchart TD
Request["HTTP request"] --> Bootstrap["wiki.php bootstrap"]
Bootstrap --> Config["config.php + site config cache"]
Config --> DBInfo["WikiDB"]
DBInfo --> UserInit["init_requests(options)"]
UserInit --> Session["session cookie check"]
Session --> Headers["early cache/CORS headers"]
Headers --> Main["wiki_main(options)"]
Main --> Security["DBInfo->security"]
Main --> Formatter["Formatter"]
Formatter --> Page["WikiPage"]
Main --> Plugins["plugin action/macro/processor"]
The central mutable context is $options. It starts as a small array in wiki.php, is populated by init_requests(), and then moves through wiki_main(), security checks, formatter rendering, and action handlers.
getPlugin(), getProcessor(), and getFilter() scan configured include paths and cache the discovered basename map. Action dispatch does not include arbitrary request paths directly; it resolves an action to a known plugin basename before include_once("plugin/$pn.php").
This means dynamic include risk should usually be reviewed at the resolver boundary and at configuration-controlled include paths, not only at individual action calls.
The current request boundary is split across several places:
-
init_requests()createsWikiUserfromMONI_IDand populates$options['id']. -
_session_start()validates the additionalMONIWIKIsession cookie when PHP sessions are enabled. -
wiki_main()performs request parsing, blocklist checks, robot handling, read checks, and action authorization. - Action handlers in
wikilib.phpand plugins perform action-specific checks such aswritable(), protected admin password checks, upload validation, and save hash checks.
For future fixes, keep normalizing identity and request state before action authorization. Fixing individual plugins is still necessary for file or output sinks, but it should not be the first layer of defense.