[Pmwiki-users] Create a Wiki page through a script

Patrick R. Michaud pmichaud
Thu Aug 26 07:47:29 CDT 2004


On Thu, Aug 26, 2004 at 03:38:25PM +0200, Thomas Weibel wrote:
> > Try:
> >
> >    if (!PageExists('Main.Login')) {
> >       $page['text'] = '[[authform]]';
> >       WritePage('Main.Login',$page);
> >    }
> 
> Thank you, this code works.
> 
> But now I have some kind of a chicken/egg problem: If editing is secured
> through a password, I need a login page which can only be written 
> with editing rights.
> 
> This doesn't really matter for me, because the login page is generated 
> quickly, but to for another user who wants to deploy my script, it is 
> easier to just copy it into local/ and add it to config.php.
> 
> Is there a way to "surpass" the authentication system within a PHP script? 
> E.g. by writing directly into wiki.d/wikilib.d?

Ummmm, I'm not sure I understand entirely.  You want the Main.Login
page to be created with a password already in place?  No problem:

    if (!PageExists('Main.Login')) {
       $page['text'] = '[[authform]]';
       $page['passwdedit'] = crypt('editpass');
       WritePage('Main.Login',$page);
    }

Or, if you just want the page to be completely locked against editing
except by the admin password,  use $page['passwdedit'] = '*'; instead.

You can also disable editing of Main.Login entirely by just doing
something like:

   if ($pagename=='Main.Login') $action='browse';

Pm



More information about the pmwiki-users mailing list