Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Probably the easiest way to make your vpage.cgi script password protected is to create a new runmode (to do this by modifying the demo, you would add a new sub in the file, use either 'private' or 'private2' as examples for this. Copy the guts of your original script into the body of this new run mode. You'll also need to create a template file to work with HTML template, for the output.

An alternative (maybe a bit more complicated), is to modify your original script so that it is a package (like my file, but you might call this one - name doesn't matter. It will look something like this:

package MyLib::VPage; use strict; use lib '/var/www/cgi-bin/WebApp/libs'; use base 'MyLib::Login'; sub cgiapp_init { my $self = shift; $self->SUPER::cgiapp_init; $self->authen->protected_runmodes( 'myrunmode', ); } sub myrunmode: StartRunmode { my $self = shift; my $template = $self->load_tmpl("myrunmode.html"); ### guts of old vpage.cgi go in here $template->param({ OUPUT => $output; # your output goes in here... }); return $template->output; } 1;
To invoke this, you'll need an app file like this:
#!/usr/bin/perl use strict; use lib '/var/www/cgi-bin/WebApp/libs'; use MyLib::VPage; my $webapp = MyLib::VPage->new( PARAMS => { cfg_file => ['simple.ini', 'vpage.ini'], format => 'equal', }, ); $webapp->run();
The "use base MyLib::Login" line in makes VPage inherit the login logic. The vpage.ini file is optional - use it if you need to define parameters for the new run mode (or else, lump them into simple.ini).

I hope that helps. Good luck.

In reply to Re^11: RFC: Proposed tutorial - simple login script using CGI::Application by scorpio17
in thread RFC: Proposed tutorial - simple login script using CGI::Application by scorpio17

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2023-03-21 13:50 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.