Hi, everyone,
I have made dokuwiki as a transparent module on my webpage. Though there is one problem - logging in - cookies don't seem to work (?)
How my embedding of dokuwiki was done:
1. I created dokuwiki installation at dir '/dw'
2. I turned on url rewriting in dokuwiki configuration
3. I used this apache rewrite configuration:
RewriteEngine on
#
## Not all installations will require the following line. If you do,
## change "/dokuwiki" to the path to your dokuwiki directory relative
## to your document root.
RewriteBase /
#
RewriteRule ^_media/(.*) /dw/lib/exe/fetch.php?media=$1 [QSA,L]
RewriteRule ^_detail/(.*) /dw/lib/exe/detail.php?media=$1 [QSA,L]
RewriteRule ^_export/([^/]+)/(.*) index.php?src=doku&srctype=0&do=export_$1&id=$2 [QSA,L]
RewriteRule ^$ index.php?src=doku&srctype=1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?src=doku&srctype=0&id=$1 [QSA,L]
RewriteRule ^index.php$ index.php?src=doku
4. Notice 2 options for url rewriting: srctype=0 and 1. This is for page handling of "id=???" and empty requests.
5. I changed string 'doku.php' in init.php and common.php to 'index.php'. This doesn't break dokuwiki,
but allows my code to work further with rewriting, since doku.php is the only script which rewriting is not touching.
NOTICE to DEVELOPERS!
5. I use this php code to read from dokuwiki engine:
$isdoku = true; //should be false, but is true for the start page
$dokurequest = "";
$dokucontents = "";
$srctype = 0;
if (isset ( $HTTP_GET_VARS['src'] ))
{
$isdoku = $HTTP_GET_VARS['src'] == "doku";
if( $isdoku )
if( isset( $HTTP_GET_VARS['srctype'] ))
$srctype = $HTTP_GET_VARS['srctype'];
}
else
if (isset ( $HTTP_POST_VARS['src'] ))
{
$isdoku = $HTTP_POST_VARS['src'] == "doku";
if( $isdoku )
if( isset( $HTTP_POST_VARS['srctype'] ))
$srctype = $HTTP_POST_VARS['srctype'];
}
if( $isdoku )
if( $srctype == 0 )
$dokurequest = substr( $HTTP_SERVER_VARS['QUERY_STRING'], 19 );
else
if( $srctype == 1 )
$dokurequest = substr( $HTTP_SERVER_VARS['REQUEST_URI'], 5 );
if( $isdoku )
{
$url2decode = "http://".$CURR_HOST."/dw/doku.php?".$dokurequest;
if( $auth )
{
$urlfile=fopen($url2decode, "rb");
if( $urlfile )
{
while (!feof($urlfile)) {
$dokucontents .= fread($urlfile, 1024);
}
fclose( $urlfile );
}
else die( 'error while reading dokuwiki engine!' );
//here we have dokuwiki content, now extract links and print them in the <head>
//collect links
$matches = array();
$regex = '/(?i)(<link(.|[\r\n])+?\/>)/';
preg_match_all($regex, $dokucontents, $matches);
if( count($matches[0]) > 0 ) {
foreach( $matches[0] as $link ) {
echo $link."\r\n" ;
}
}
unset( $matches );
}
}
//in this stage, print body tag, and embed dokuwiki body:
if( $isdoku )
{
$startbpos = strpos( $dokucontents, "<body>" );
$endbpos = strpos( $dokucontents, "</body>" );
$body = substr( $dokucontents, $startbpos+6, $endbpos - $startbpos - 6 );
echo $body;
}
This allows me to work with dokuwiki as a module and stay in my webpage.
Now there is only one problem:
If I run from document root and dokuwiki is in /dw directory, I can't login. I am not strong with cookies authentication (and I think it's related with paths), so maybe someone can pinpoint what could be wrong?
Rgrds, Ulterior