Unstoppable Domains

Passing Variables to Perl

Spacemail by SpaceshipSpacemail by Spaceship
Watch

buddybuddha

Established Member
Impact
2
Ok, wierd problem here.

I have a perlscript for my email which has been either written with such poor organization that I can't even read it, or has been encoded for one reason or another so that I can't edit. Either way, I have an interesting problem.

The program allows you to edit the templates for every section, including the login page. I want to make it so that if the javascript can read the cookie from the rest of the site, pass the variable to the perl script via the POST method automatically. That way it is nice and integrated to the rest of the site.

I know a little about cookies, but I have a tutorial which I will read. The question here deals with how I should go about redirecting to another page if it sees the user is logged in and then passing the user info into it. Thanks.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
buddybuddha said:
Ok, wierd problem here.
I want to make it so that if the javascript can read the cookie from the rest of the site, pass the variable to the perl script via the POST method automatically. That way it is nice and integrated to the rest of the site.

I know a little about cookies, but I have a tutorial which I will read. The question here deals with how I should go about redirecting to another page if it sees the user is logged in and then passing the user info into it. Thanks.
Where does the user login at? Is it from the perl script or another section on the site? It would probably be easiest just to have the perl script check the cookie credentials and such, I think.
 
0
•••
I'm going to show you a couple lines of the code from the perlscript to show you all that it would be virtually impossible for me to sort through this.

Code:
use Socket; use FileHandle; my($mma) = new FileHandle(); &ReadParse; {  my($mmb) = 0;
my($mmc); foreach $mmc (keys(%mailman::in)) { if($mmc =~ /^(.+)\.[xy]$/) {
my($mmd) = $1; if($mmc =~ /^([^\#]+)\#(.*)\.[xy]$/) { $mmd = $1;
$mailman::in{$mmd} = mmuc($2); } else {
$mailman::in{$mmd} = 'MAILMANSPECIALTRUE'; } delete($mailman::in{$mmc}); } else {
if($mmc =~ /^([^\#]+)\#(.*)$/) { $mailman::in{$1} = mmuc($2); } } } }
if($mailman::in{'INTERFACE'}) { my(@mme) = split(/\&/,$mailman::in{'INTERFACE'});
my($mmf) = ''; foreach $mmf (@mme) { if($mmf =~ /^([^\=]+)\=(.*)$/) {
$mailman::in{$1} = mmuc($2); } }
unless($mailman::in{'INTERFACE'} =~ /ALTERNATE_TEMPLATES/) {
$mailman::in{'ALTERNATE_TEMPLATES'} = ''; } } {
@mailman::mmg = split(/\;/,$ENV{'HTTP_COOKIE'}); my($mmh) = '';
foreach $mailman::mmh (@mailman::mmg) { $mailman::mmi = 1;
if($mailman::mmh =~ /MailManAuth\=(\S+)/) { my(@mmj) = split(/\&/,$1);
my($mmk) = ''; foreach $mmk (@mmj) { $mmk =~ /^(.+)\#(.+)$/;
unless($mailman::in{$1}) { $mailman::in{$1} = $2; } } }
if($mailman::mmh =~ /MailManDir\=(\S+)/) { $mailman::mml = mmuc($1); } } }
$mailman::mmm = mmug($mailman::in{'USERNAME'});
$mailman::mmm =~ s/^\s*([^\s]+)\s*$/$1/;  if($mailman::bCaseInsensitiveAccounts);

To me it looks like they simply ignored placing things on seperate lines or something, but regardless this will just go to show you that I am completely unable to edit the perl script itself.

I know that would be best, but I am wondering if anyone knows a way to pass variables through POST via javascript.
 
0
•••
It looks like they just squished all the lines together, probably to make the file smaller. Here's the same code a bit more readable.
Code:
use Socket;
use FileHandle;
my ($mma) = new FileHandle();
&ReadParse;
{
    my ($mmb) = 0;
    my ($mmc);
    foreach $mmc ( keys(%mailman::in) ) {
        if ( $mmc =~ /^(.+)\.[xy]$/ ) {
            my ($mmd) = $1;
            if ( $mmc =~ /^([^\#]+)\#(.*)\.[xy]$/ ) {
                $mmd = $1;
                $mailman::in{$mmd} = mmuc($2);
            }
            else {
                $mailman::in{$mmd} = 'MAILMANSPECIALTRUE';
            }
            delete( $mailman::in{$mmc} );
        }
        else {
            if ( $mmc =~ /^([^\#]+)\#(.*)$/ ) { $mailman::in{$1} = mmuc($2); }
        }
    }
}
if ( $mailman::in{'INTERFACE'} ) {
    my (@mme) = split( /\&/, $mailman::in{'INTERFACE'} );
    my ($mmf) = '';
    foreach $mmf (@mme) {
        if ( $mmf =~ /^([^\=]+)\=(.*)$/ ) {
            $mailman::in{$1} = mmuc($2);
        }
    }
    unless ( $mailman::in{'INTERFACE'} =~ /ALTERNATE_TEMPLATES/ ) {
        $mailman::in{'ALTERNATE_TEMPLATES'} = '';
    }
}
{
    @mailman::mmg = split( /\;/, $ENV{'HTTP_COOKIE'} );
    my ($mmh) = '';
    foreach $mailman::mmh (@mailman::mmg) {
        $mailman::mmi = 1;
        if ( $mailman::mmh =~ /MailManAuth\=(\S+)/ ) {
            my (@mmj) = split( /\&/, $1 );
            my ($mmk) = '';
            foreach $mmk (@mmj) {
                $mmk =~ /^(.+)\#(.+)$/;
                unless ( $mailman::in{$1} ) { $mailman::in{$1} = $2; }
            }
        }
        if ( $mailman::mmh =~ /MailManDir\=(\S+)/ ) {
            $mailman::mml = mmuc($1);
        }
    }
}
$mailman::mmm = mmug( $mailman::in{'USERNAME'} );
$mailman::mmm =~ s/^\s*([^\s]+)\s*$/$1/;
if ($mailman::bCaseInsensitiveAccounts);

I don't think that you would need to edit anything in the script to check for the cookies, just add to it, most likely right up top. But either way, even if you did pass a variable to it somehow, then you'd still need to have the script do something with the processed variable which I think would require adding/editing. I am not exactly sure what you're wanting to do, but you can grab the value from a regular html/javascript page by submitting directly to the cgi script. You could have the value in a hidden field or something, then post directly to the cgi script with the value. Do you have any idea of how you want to this? From a form, or automagically or ?
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back