Not logged in. · Lost password · Register
Forum: General Help and Support Installation and Configuration RSS
dokuwiki on awardspace.com free web hosting
Avatar
hladky #1
Member since Sep 2006 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: dokuwiki on awardspace.com free web hosting
Hello!

I have tried to install dokuwiki on awardspace but it's not working because realpath function is not supported :#:

Warning: realpath() has been disabled for security reasons

So I have decided to define this function myself:

<?php

function cleanPath($path) {
   $result = array();
   // $pathA = preg_split('/[\/\\\]/', $path);
   $pathA = explode('/', $path);
   if (!$pathA[0])
       $result[] = '';
   foreach ($pathA AS $key => $dir) {
       if ($dir == '..') {
           if (end($result) == '..') {
               $result[] = '..';
           } elseif (!array_pop($result)) {
               $result[] = '..';
           }
       } elseif ($dir && $dir != '.') {
           $result[] = $dir;
       }
   }
   if (!end($pathA))
       $result[] = '';
/*       echo implode('/', $result); */
   return implode('/', $result);
}

?>

I have then wrote a Perl script to modify all dokuwiki php source files. It will
- replace realpath function through cleanPath
-add @require_once('cleanpath.php'); when needed

I'm not really php expert, the only option how to get @require_once('cleanpath.php') working was to link file "cleanpath.php" to every directory with php files. Any idea how to get this fix working with cleanpath.php stored only at ONE location is very welcome!

Please read more on my dokuwiki:
http://lnx-hladky2/~hladky/dokuwiki/doku.…?id=dokuwiki:a…

Jiri
This post was edited on 2006-09-25, 18:48 by hladky.
Avatar
andi (Administrator) #2
User title: splitbrain
Member since May 2006 · 3522 posts · Location: Berlin Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Put your file into the inc directory. Then add the the require to inc/init.php right after the include path define like this:

  1.  // define the include path
  2.  if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
  3.  require_once(DOKU_INC.'cleanpath.php');

Andi
Read this if you don't get any useful answers.
Lies dies wenn du keine hilfreichen Antworten bekommst.
Avatar
hladky #3
Member since Sep 2006 · 5 posts
Group memberships: Members
Show profile · Link to this post
Hi Andi,

the trouble is that I cannot use realpath function - I define "my" realpath function (cleanPath) in cleanpath.php. In you example, I have to use function cleanPath before I define it. Can PHP handle this situation?

Or will following code work?


require_once('./cleanpath.php');
if(!defined('DOKU_INC')) define('DOKU_INC',cleanPath(dirname(__FILE__).'/../').'/');


Please notice - on first line, I define function cleanPath and I rely on the fact that  init.php and cleanpath.php are in the same directory.
On line 2, I'm using cleanPath instead of realpath.

Thanks a lot!
Jiri
Avatar
andi (Administrator) #4
User title: splitbrain
Member since May 2006 · 3522 posts · Location: Berlin Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Ahh sorry. I hadn't thought of that. Your code should work but better use the following include line:

  1. require_once(dirname(__FILE__).'cleanpath.php');

Andi
Read this if you don't get any useful answers.
Lies dies wenn du keine hilfreichen Antworten bekommst.
Avatar
hladky #5
Member since Sep 2006 · 5 posts
Group memberships: Members
Show profile · Link to this post
Hi Andi,

I'm still struggling. Is inc/init.php loaded everytime before the execution of whatever script starts? I don't think so.

All PHP scripts begin with

if(!defined('DOKU_INC')) define('DOKU_INC',cleanPath(dirname(__FILE__).'/../../').'/');

so I have to define function "cleanPath" first. I have tried to omit

require_once('./cleanpath.php');

in some scripts but it was not working. Basically, if I understand it right, your idea was to have
require_once(DOKU_INC.'cleanpath.php');

in each script. But each script relys on cleanpath in order to define DOKU_INC. Well, any idea?

Thanks a lot!
Jiri
Avatar
andi (Administrator) #6
User title: splitbrain
Member since May 2006 · 3522 posts · Location: Berlin Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I should stop responding late in the evenings :-/

Okay, since basically all scripts use realpath before including init.php you need to adjust them all. But it should be enough to simply remove the realpath call in the define calls as it is not strictly needed there. So changing something like

  1. if(!defined('DOKU_INC')) define('DOKU_INC',realPath(dirname(__FILE__).'/../../').'/');

to

  1. if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../);

should work. You then need to include your little fix in init.php only, for the remaining calls to realPath (or cleanPath in your patched version).

Andi
Read this if you don't get any useful answers.
Lies dies wenn du keine hilfreichen Antworten bekommst.
Avatar
hladky #7
Member since Sep 2006 · 5 posts
Group memberships: Members
Show profile · Link to this post
Hi Andi,

actually it was my first approach to completely remove realPath function. However, it's not working. I have also tried to reference cleanpath.php like this: (bin/dwpage.php, file cleanpath.php is in dokuwiki directory)

@require_once(dirname(__FILE__).'/../cleanpath.php');

This works fine on my home linux server (which is not connected to the internet) but fails on awardspace - basicaly all formatting is away: [Image: http://hladky.awardspace.com/Temp/dokuwiki.png]

The advanced functions like "Admin" do not work anymore. Any idea?

For the time, I have reverted back to
@require_once('cleanpath.php');

and copying cleanpath.php everywhere - it seems to work reliably.

Thanks a lot!
Jiri
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2020-02-17, 22:13:44 (UTC +01:00)