2Jennifer has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone, The below to lines of code were deleted from a cgi script that replicates members html pages. The script worked well until the 2 lines of code were deleted. I don't know where they go back in the script. I was wondering if anyone knew where it belongs? Thank you, Jennifer Deleted code:
&MLMP::OpenCompanyDB; &MLMP::CompanyLinks($fields{'userid'},$fields{'parent'});
The script:
#!/usr/bin/perl ########################################################### # MLM Manager 2.0 Pro # Mage Software, Inc. # http://www.magesoft.com # member_page.cgi # Version 1.2.1 #---------------------------------------------------------- # DESCRIPTION # This script generates the top level html for an # individual member page. It generates the title by # querying the member database, then generates a top # frame and a bottom frame, including header.cgi and # page_body.cgi respectively. # #---------------------------------------------------------- # Copyright 1996,2000 # Mage Software, Inc. # http://www.magesoft.com # All Rights Reserved ############################################################### use strict; use lib '/home/independence/.mgcfg/mlm_pro/lib'; use MLMP; my $title; my $header_text; my $email; my $tbody; my $thing; my @page; if ($MLMP::disable) { &MLHTM::HTML_Header( "$MLMP::MLMWEB_NAME Member Pages" ); &MLHTM::HTML_Section( "Down for Maintenance", "The $MLMP::MLMWEB_NAME automatic web page system is temporarily d +own\n". "for maintenance. We apologize for any inconvenience.\n" ); exit; } # # Get the member key from the URL name # my ($userid,$page_name)=&Grab_Info; my $key=$userid; &MLMP::OpenMemberDB(); if ($key eq "MAINSITE") { $key=&MLMP::Rotate_Index; print "Content-type: tex/html\n\n"; print qq!<html><head><meta http-equiv="refresh" content=0;url="/mem +bers/$key/$page_name"></head></html>!; &MLHTM::HTML_FOOTER; exit; } my %fields=&MLMP::LoadMember($key); if (scalar keys %fields <= 0) { $key=$MLMP::default_key; $title=$MLMP::default_title; $header_text=$MLMP::default_header_text; $email=$MLMP::default_email; } else { $title=$fields{'htmltitle'}; $email=$fields{'email'}; $header_text=$MLMP::default_header_text; } $header_text =~ s/\W/+/g; &MLMP::OpenCompanyDB; &MLMP::CompanyLinks($fields{'userid'},$fields{'parent'}); if ($MLMP::frames_mode eq "off") { open TEMPLATE,"<$MLMP::web_template_dir/$page_name"; @page=<TEMPLATE>; close TEMPLATE; $tbody=join('',@page); foreach $thing (keys %MLMP::psubs) { $tbody =~ s/\_\_$MLMP::psubs{$thing}\_\_/$fields{$thing}/g; } $tbody =~ s/\<\/body\>//i; $tbody =~ s/\<\/html\>//i; print "Content-type: text/html\n\n"; print $tbody; if ($MLMP::cfg{$page_name}) print "</body></html>"; &MLMP::CloseMemberDB(); exit; } #---------------------------------------------------------- print <<PAGE_TEMPLATE; Content-type:text/html <HTML> <HEAD> <TITLE>$title</TITLE> </HEAD> <!-- This first section is for frames-capable browsers --> <FRAMESET ROWS=$MLMP::header_frame_pixels,* FRAMESPACING=0 BORDER=0 FRAMEBORDER="NO"> <FRAME SRC="$MLMP::member_script_url/header.cgi?key=$key&header=$h +eader_text&email=$email" NAME="header" SCROLLING="NO"> <FRAME SRC="$MLMP::member_script_url/page_body.cgi?userid=$key" NA +ME="daddy"> </FRAMESET> <NOFRAMES> PAGE_TEMPLATE #---------------------------------------------------------- # Generate a non-frames member page if (open FRONTPAGE, "$MLMP::html_dir/$MLMP::frontpage_url") { while (<FRONTPAGE>) { print; } close FRONTPAGE; } else { print <<NOFRONTPAGE; The main informational page is being updated. NOFRONTPAGE } print <<PAGE_TEMPLATE; </NOFRAMES> </HTML> PAGE_TEMPLATE #---------------------------------------------------------- &MLMP::CloseMemberDB(); sub Grab_Info { my $thing; if ( $ENV{'DOCUMENT_URI'} =~ /^\/members\/(\w+)\/(\w+\.\w+)$/ ) { return ($1,$2); } $ENV{'DOCUMENT_URI'} =~ /\/(\w+\.\w+)$/; return ("MAINSITE",$1); }

Replies are listed 'Best First'.
Re: Missing code in replicating cgi script
by grep (Monsignor) on Jan 24, 2002 at 06:06 UTC
    &MLMP::OpenCompanyDB; &MLMP::CompanyLinks($fields{'userid'},$fields{'parent'});


    Looks like a custom module specific to your company. I would guess by looking at them that they initialize a DB connection and then pull some fields relating to the Links in yout documents.

    I would guess the &MLMP::OpenCompanyDB; statement belongs at the top.

    If you want to get this right, I would either find an older version, or look over MLMB module. The MLMB module should be located under 'site/lib'. (In Windows most likely 'C:\perl\site\lib' in *nix '/usr/lib/perl5/site/lib')

    If there were ever an argument to use Versioning Control this would be it.

    grep
    grep> cd pub
    grep> more beer
Re: Missing code in replicating cgi script
by pjf (Curate) on Jan 24, 2002 at 07:56 UTC

    Is it worth pointing out that the two "missing" lines are already in your script, about half-way down, at the line immediately after the $header_text substitution?

    Given that the script uses strict, the lines you've provided (assuming they go together) would have to appear somewhere after the my %fields=&MLMP::LoadMember($key); line, since %fields isn't defined until that point. Given they probably do some initialisation for other MLMP functions, immediately after defining %fields is probably a reasonable spot.

    As grep mentioned previously, since we don't actually know what those functions do, it's difficult to give more specific advice.

    Paul Fenwick
    Perl Training Australia