NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Passing Variables to Perl

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 07-08-2005, 08:03 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
buddybuddha's Avatar
Join Date: May 2005
Location: PA
Posts: 216
buddybuddha is an unknown quantity at this point
 



Passing Variables to Perl


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.
????: NamePros.com http://www.namepros.com/programming/105136-passing-variables-to-perl.html

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.
buddybuddha is offline  
Old 07-08-2005, 09:32 PM   #2 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



Originally Posted by buddybuddha
Ok, wierd problem here.
????: NamePros.com http://www.namepros.com/showthread.php?t=105136
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.
deadserious is offline  
Old 07-08-2005, 10:36 PM THREAD STARTER               #3 (permalink)
NamePros Regular
 
buddybuddha's Avatar
Join Date: May 2005
Location: PA
Posts: 216
buddybuddha is an unknown quantity at this point
 



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.
????: NamePros.com http://www.namepros.com/showthread.php?t=105136

I know that would be best, but I am wondering if anyone knows a way to pass variables through POST via javascript.
buddybuddha is offline  
Old 07-08-2005, 10:47 PM   #4 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



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 ?
deadserious is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows deadserious Webmaster Tutorials 96 05-27-2007 02:24 PM
String and variables lovelinuxlove Programming 2 10-31-2004 05:26 AM
Tutorial: Creating a simple cgi hit counter for your site using Perl deadserious Webmaster Tutorials 3 05-29-2004 02:31 AM
How I fill javascript array with php variables? wiedzim CODE 0 03-31-2004 03:45 AM
A simple cgi hit counter for your site using Perl deadserious CODE 2 11-07-2003 09:23 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 07:51 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger