[pmwiki-users] creating a page and setting password in php
ilja.livenson at gmail.com
Mon Jul 16 07:13:31 CDT 2007
thank you for the quick reply!
UpdatePage is not really available in the stable version, only in beta (but
I have other problems with beta so would like to stick with the stable for
The code is a bit more complicated so I won't overwrite existing pages.
Anyway, if I'm sure I will be _creating_ the page, can I still use PostPage
On 16/07/07, Petko Yotov <5ko at free.fr> wrote:
> On Monday 16 July 2007, Ilja Livenson wrote:
> > I would like to achieve the following: have a user fill the form, create
> > page populated with data from the form, set a edit/upload password and
> > them to the user. But here's my problem - it seems pretty stupid, but I
> > cannot' set password and populate page at the same time (in one
> > transaction) - it's either one or another.
> > Basically, my code is like this:
> > $base = MakePageName($pagename, "Students.Invitation");
> > $basegroup = PageVar($base, '$Group');
> > $newpage = MakePageName($base, "$basegroup.$name");
> > $new['text'] = "smth template";
> > PostPage($newpage, $new, $new);
> > // --- setting password ---
> > Lock(2);
> > $auth = RetrieveAuthPage($newpage, 'attr', false);
> > $password = gen_password();
> > $auth['passwdedit'] = crypt($password);
> > $auth['passwdupload'] = crypt($password);
> > mail($email, 'password', "$password");
> > WritePage($page, $auth);
> > Lock(0);
> > // --- done setting password ----
> You should be able to do it at the same time:
> $new['text'] = "smth template";
> $password = gen_password();
> $new['passwdedit'] = crypt($password);
> $new['passwdupload'] = crypt($password);
> UpdatePage($newpage, $old, $new);
> All data (text, passwords) is in the $new array. Use the UpdatePage()
> function, not PostPage().
> Note that the code you posted, if it is that simple, it may allow someone
> overwrite existing pages (and by the occasion, change their passwords).
> should check to see if it is really a new page.
> See also:
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pmwiki-users