Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

require function in perl for .lib files

Status
Not open for further replies.

alanamr

Programmer
Jul 25, 2012
1
US
Hi All,

I am having trouble using the "require" function on perl when the file is a .lib file. Every time I am getting a 500 Internal Server Error.

This is the script that has the require function in it:

#!/usr/bin/perl

### created 12/14/10 - adapted from notes_upload_file.pl
### modified: 2/24/2012 - added alivechurch special case.
### modified: 5/4/2012 - added new jslsolutions4 server
### modified: 5/31/2012 - converted to read on-demand URL
### modified: 6/19/2012 - added jslsolutions13 server to list
### modified: 7/12/2012 - added new server locations to the list

require "sub_admin_sub_problem.lib";
require "sub_cookie_prob_admin.lib"; ### thisstuff

require "subparseform.lib";
&Parse_Form;



$temp_id = $formdata{'churchid'}; ### thisstuff
##### read the churchid from the cookie
if ($ENV{'HTTP_COOKIE'}) {
@cookies = split (/; /, $ENV{'HTTP_COOKIE'});
foreach $cookie (@cookies) {
($name, $value) = split (/=/,$cookie);
$crumbs{$name} = $value;
}
}
$churchid = $crumbs{'adminchurchid'};
##### log them out if cookies aren't set properly
if ($churchid eq "") {
### pass temp_id to the subroutine... ### thisstuff
&Cookie_prob_admin("$temp_id");
exit;
}
## determine if they can update this function...
$admin_email_sub = $crumbs{'admin_email_sub'};
if ($admin_email_sub ne "") { ### they are a sub admin..
open(ADMIN_FILE,"< /mnt/stor14-wc2-dfw1/454462/ #read the file
@admin_file = <ADMIN_FILE>;
close(ADMIN_FILE);
foreach $line (@admin_file) { #read each line of the admin sub file
@field = split(/\|/, $line); #parse the line into fields
$attribute = @field[0];
if ($attribute eq "admin") { ### if its an admin line...
$admin_email_address = @field[1];
$sermons = @field[28];
if ( ($admin_email_address eq $admin_email_sub) && ($sermons ne "") ) { ### they don't have permissions
&admin_sub_problem("$temp_id");
exit;
}
}
}
}

### get referred info...
$artwork = $formdata{'artwork'};
$notes_id = $formdata{'notes_id'};

### connect to database...
require "db_connect.lib";
&db_connect;

######### look up their upload directory info...
my $sth = $dbh->prepare("SELECT on_demand_url
FROM streaming
WHERE org_id = '$churchid'");
$sth->execute;
while(my($on_demand_url) = $sth->fetchrow_array()) {
$the_on_demand_url = $on_demand_url;
}
#### parse the stream_url to get their directory
if ($the_on_demand_url =~ /edgesvr/) { ## valid streams contain edgesvr
@field = split(/\//, $the_on_demand_url); ## split the url at the slashes, typical values include...
## rtmp://jslsolutions.flashedgesvr.com/church3240edge/_definst_/&file=live.flv
## ## mms://church2457.streamedgesvr.com/church2457-live
## rtmp://jslsolutions2.flashedgesvr.com/streamingtv025live/_definst_/&file=live.flv
## rtmp://alivechurch.flashedgesvr.com/alivechurchedge/_definst_/&file=live1.flv
$root_name = @field[3];
$root_name =~ s/edge//g; ### remove the edge if it's there
$root_name =~ s/live//g; ### remove the live if it's there
$root_name =~ s/-//g; ### remove the live if it's there

$protocol = @field[0];

#### look for uploaded files...
$server_name = @field[2];
}

#look up ftp login info from the database
my $sth = $dbh->prepare("SELECT ftp_host, ftp_login, ftp_password
FROM streaming
WHERE org_id = '$churchid'");
$sth->execute;
while(my($ftp_host, $ftp_login, $ftp_password ) = $sth->fetchrow_array()) {
$ftphost = $ftp_host;
$ftplogin = $ftp_login;
$ftppassword = $ftp_password;
}


if (($ftphost eq "") || ($ftplogin eq "") || ($ftppassword eq "")) {
print "Content-type:text/html\n\n";
print <<"html_code4";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " <html xmlns=" <head>
<title>Streaming Admin - Choose Streaming File</title>
<link href="../styles/admin_style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<div align="center">
<span class="bold16">Select Streaming File</span>
<p>Please update your FTP settings on your streaming church admin panel<br>
</body>
html_code4
exit;
}




use Net::FTP;
$ftp = Net::FTP->new($ftphost, Debug => 0) || &connection_problem;
$ftp->login($ftplogin,$ftppassword) || &login_prob;
my @file_list = $ftp->ls("streaming/")
or die "get failed ", $ftp->message;
$ftp->quit;
### build out the drop down menu...

$filepath = $protocol . "//" . $server_name . "/" . $root_name . "/_definst_/%26file%3D";

foreach $file_name (@file_list) {
$file_menu .= "<option value=\"$filepath$file_name\">$file_name</option>\n";
}

print "Content-type:text/html\n\n";
##################################################################
##### format the html form...

print <<"html_code1";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<title>Streaming Admin - Choose Streaming File</title>
<link href="../styles/admin_style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
html_code1

print <<"html_code3";
<div align="center">
<span class="bold16">Select Streaming File</span>
<form id="form1" name="form1" method="post" action="notes_choose_streaming2.pl">
<P class="tenpoint_text">Streaming File
<select name="file_url" id="file_url">
$file_menu
</select>
<INPUT TYPE=hidden NAME="churchid" VALUE="$churchid">
<INPUT TYPE=hidden NAME="artwork" VALUE="$artwork">
<INPUT TYPE=hidden NAME="notes_id" VALUE="$notes_id">
<input type="submit" name="submit" id="submit" value="Select..." />
</p>
</form>
</div>
</body>
</html>
html_code3
###
sub login_prob {
print "Content-type:text/html\n\n";
print <<"html_codee";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " <html xmlns=" <head>
<title>Streaming Admin - Choose Streaming File</title>
<link href="../styles/admin_style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<div align="center">
<span class="bold16">Select Streaming File</span>
<p>Problem with the login<br>
</body>
html_codee
exit;
}
sub connection_problem {
print "Content-type:text/html\n\n";
print <<"html_coded";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " <html xmlns=" <head>
<title>Streaming Admin - Choose Streaming File</title>
<link href="../styles/admin_style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<div align="center">
<span class="bold16">Select Streaming File</span>
<p>Problem connecting with server<br>
</body>
html_coded
exit;
}

$dbh->disconnect;


And this is the .lib file I am trying to use with the perl file:
sub db_connect {
use DBI;
my $dsn = 'dbi:mysql:454462_myflock2_com:mysql50-20.wc2.dfw1.stabletransit.com:3306';
# set the user and password
my $user = '454462_slacy';
my $pass = 'Extexan1';
# now connect and get a database handle
my $dbh = DBI->connect($dsn, $user, $pass)
or die "Can’t connect to the DB: $DBI::errstr\n";
}
1;



Does anyone know what my problem is and how I can fix it because I have tried a lot of different things and nothing seems to work.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top