Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^10: RFC: Proposed tutorial - simple login script using CGI::Application

by Anonymous Monk
on Jan 22, 2016 at 07:29 UTC ( [id://1153352]=note: print w/replies, xml ) Need Help??


in reply to Re^9: RFC: Proposed tutorial - simple login script using CGI::Application
in thread RFC: Proposed tutorial - simple login script using CGI::Application

Hi, Unfortunately it doesn’t works and behaves same manner, it there any way to create the index.html page without HTML template (i'm looking for CGI) I have seen the some webpage like ‘http://localhost/cgi-bin/web/login’ and once success logged in the page moving to different page eg(http://localhost/cgi-bin/web/search/text) and once logged out the page automatically redirect to original login page, however after logout when trying to access to (http://localhost/cgi-bin/web/search/text) its forced to redirect to default login page - could you please suggest on this, Many Thanks.
  • Comment on Re^10: RFC: Proposed tutorial - simple login script using CGI::Application

Replies are listed 'Best First'.
Re^11: RFC: Proposed tutorial - simple login script using CGI::Application
by scorpio17 (Canon) on Jan 22, 2016 at 16:08 UTC

    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 Simple.pm, 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 Simple.pm file, but you might call this one VPage.pm - 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 VPage.pm 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.

      Hi, Thanks for your suggestion and time. I tried the method and Unfortunately it does not working. The browser getting “The server encountered an internal error or misconfiguration and was unable to complete your request” and apache log file show below error.
      syntax error at /var/www/cgi-bin/WebApp/libs/libs/MyLib/VPage.pm line +24, near "}" BEGIN not safe after errors--compilation aborted at /var/www/cgi-bin/W +ebApp/libs/libs/MyLib/VPage.pm line 24. Compilation failed in require at /var/www/cgi-bin/WebApp/libs/vpage.pl + line 4. BEGIN failed--compilation aborted at /var/www/cgi-bin/WebApp/libs/vpag +e.pl line 4. Premature end of script headers: vpage.pl
      And I’m not sure, what has to define in the “myrunmode.html” file as well.
      sub myrunmode: StartRunmode { my $self = shift; my $template = $self->load_tmpl("myrunmode.html"); ### guts of old vpage.cgi go in here my $output="<b> Testing page</br>"; $template->param({ OUPUT => $output; # your output goes in here... }); return $template->output; }
      Please let me know if you any suggestion on this, Thanks in advance! Struggling here for last couple of days.

        I've edited your node and formatted the error message and the Perl code by adding <code>...</code> tags around them. Please use these to properly format your posts.

        You don't show all of the relevant code, but it seems that you have a syntax error somewhere in VPage.pm on line 24 or before that. I suggest using an editor that can show matching braces to show where you forgot to add a brace or parenthesis.

        Finding and fixing syntax errors is a basic skill that is needed for various programming languages. I recommend that you learn it.

        If you cannot make any progress in finding the syntax error in VPage.pm, I suggest removing whole subroutines from it until VPage.pm compiles again. Use perl -wc /var/www/cgi-bin/WebApp/libs/libs/MyLib/VPage.pm to test for compilation errors without a web server. The last subroutine you removed is the one containing the syntax error.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1153352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-16 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found