01.12.2012 Views

7 Components: the Function Pages - Developers

7 Components: the Function Pages - Developers

7 Components: the Function Pages - Developers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Logout<br />

214<br />

��<br />

��<br />

��<br />

protected script. The easiest way is to add it to <strong>the</strong> menu sidebar, that<br />

is <strong>the</strong> WebLeftBar:<br />

[[%SCRIPTURL%/viewauth%SCRIPTSUFFIX%/ ↵<br />

%BASEWEB%/%BASETOPIC%][Login]]<br />

This link causes <strong>the</strong> page currently being viewed to always be<br />

loaded with <strong>the</strong> au<strong>the</strong>nticated script.<br />

The second problem: Once you are registered as a user with an IP<br />

address, you will remain registered for life. This is not only insecure,<br />

but also not very practical, since – especially as an administrator –<br />

you have to switch users from time to time. A relatively short script<br />

can bring relief: To log out, <strong>the</strong> only thing that needs to be deleted<br />

from <strong>the</strong> corresponding file is <strong>the</strong> entry of <strong>the</strong> logged-in user. The<br />

script looks like this:<br />

1 #!/usr/bin/perl -w<br />

2<br />

3 # set path for libraries<br />

4 BEGIN {<br />

5 if( $ENV{"SCRIPT_FILENAME"} &&<br />

6 $ENV{"SCRIPT_FILENAME"} =~<br />

7 /^(.+)\/[^\/]+$/ )<br />

8 {<br />

9 chdir $1;<br />

10 }<br />

11 unshift @INC, '.';<br />

12 require 'setlib.cfg';<br />

13 }<br />

14<br />

15 # integrate necessary modules<br />

16 use strict;<br />

17 use CGI::Carp qw(fatalsToBrowser);<br />

18 use CGI;<br />

19 use TWiki;<br />

20<br />

21 my $query = new CGI;<br />

22<br />

23 # determine current user<br />

24 my $<strong>the</strong>RemoteUser =<br />

25 TWiki::initializeRemoteUser();<br />

26<br />

27 # load user file<br />

28 my $text =<br />

14 User Permissions in TWiki

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!