Gossamer Forum
Home : Products : DBMan : Customization :

Ordernary MOD code problem

Quote Reply
Ordernary MOD code problem
Hi there,

I am trying out O grain's Order Mod but ran across a problem with one of the subroutines. The subroutine is for the html.pl file and is called html_send_addressed_order. It causes the script to stop working and return a DBMan error of "The server has encountered an internal error. Please enable debugging to view". THe script is not running on Windows.

I am not all that great at Perl so if someone could give me a hand that would be great. Thank you so much!

Here is the sub:

sub html_send_addressed_order {
# --------------------------------------------------------
# send the order after adding and checking delivery address


my (%rec) = @_;
$rec{$db_key} =~ s/<?.B>//g;



$rec{$db_key} =~ s/<?.B>//g;

### Check input
$order_error = 0;

unless ($in{'order_name'}) {
$message .= "<LI>You must enter your name.";
$order_error += 1;
}
unless ($in{'order_address'}) {
$message .= "<LI>You must enter your address.";
$order_error += 1;
}
unless ($in{'order_city'}) {
$order_error += 1;
$message .= "<LI>You must enter your postal address.";
}


if (!$in{'order_zipcode'} {
$message .= "<LI>You must enter your zip code. (If not applicable just put '-')";
$order_error += 1;
}

if ($in{'order_zipcode'} eq '-' ) {
$in{'order_zipcode'} = '';
}

if ($order_error > 0) {
$page_title = "The address form has not been filled in correctly";

&html_page_top;

# < -- Start page text -- >
print qq|
<$font>Please correct the following $order_error error(s):<p>
<UL>
$message
</UL>
</font>
|;
# < -- End page text -->

&html_rectify_address_form;

&html_footer;
&html_page_bottom;
}
else {

# Check that the order file is still there ....

if (!open(FILE, "<$orders_dir$in{'order_mail'}.txt")){
$page_title = "Unfortunately the order could not be sent.";

&html_page_top;

print qq|
<$font>The prepared order seems to have disappeared.<br>
Maybe you have already sent or cancelled the order and by mistake used the
browsers back button?
</font>
<P>
|;

&html_order_cleared_footer;
&html_page_bottom;


}
else {

&create_order_header;
&sum_up_order;


open (FILE, ">>$orders_dir$in{'order_mail'}.txt") || &cgierr("Can't open $orders_dir$in{'order_mail'}.txt.");
print FILE "\n\n--------------------------------------------------------\n\n";

print FILE "Totally $total_items of $merchandise - Total sum $currency $total_sum.\n";
print FILE "Shipping: $currency $shipping.\n\n";
print FILE "Grand total: $currency $grand_total";
close (FILE);

&send_order;
$page_title = "The following order has been sent to $shop";

&html_page_top;


open (FILE, "<$orders_dir$in{'order_mail'}.txt") || &cgierr("Can't open $orders_dir$in{'order_mail'}.txt.");
@lines = <FILE>;

close (FILE);

foreach $line (@lines) {
if ($line =~ /^\*/) {
print $line;
print "<br>";
}
else {
print "<$font>";
print $line;
print "</font><br>";
}
}


&html_order_cleared_footer;
&html_page_bottom;

$order_file = "$in{'order_mail'}.txt";
$in{'order_mail'} = '';
if ($auto_delete) {

# NOTE! If you are on a Windows system you will need to find the method
# of deleting/renaming a file and replace rm (delete) and mv (rename)
# with other commands

system('rm',"$orders_dir$order_file");
}
else {
# First append tracing data to file
open (FILE, ">>$orders_dir$order_file") || &cgierr("Can't open $orders_dir$order_file.");
@this_order = <FILE>;
print FILE "\n\nRemote Host: $ENV{REMOTE_HOST}\n";
print FILE "Remote Addr: $ENV{'REMOTE_ADDR'}\n";
$server_time = localtime(time());
print FILE "Server time: $server_time";
close (FILE);

# Then rename the file with a random extension so the user can't use
# the back button in the browser to add more things...
srand;
$extension = rand;
$extension =~ s/0\.//;
$archive_file = "$order_file";
$archive_file =~ s/.txt/_$extension/;
system ('mv',"$orders_dir$order_file","$orders_dir$archive_file");

}
}
}

}
Cheers!

Richard

Last edited by:

pkzone: Oct 19, 2002, 5:28 PM
Quote Reply
Re: [pkzone] Ordernary MOD code problem In reply to
It might be best if you are not able to get any debugging from your server's error log to add a snippet of code to your files and see if you can narrow down the error.

In the FAQ under the section "Troubleshooting" there is a snippet of code called "Debugging - How To Obtain Useful Error Messages". If you add this to your html.pl, db.cgi, .cfg and also if you use format.pl.

This snippet of code has saved me hours of trying to track down errors.

Hope this helps

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] Ordernary MOD code problem In reply to
unfortunately, when I try to use the 'Begin...error.txt' method of trying to get an error message the web server returns a 500 Internal error. I set the paths and everything correctly. I take it out of the cgi and then the script runs normally....

I tried getting some bracket checking code from your FAQ but it doesn't work. the file was called brackets.zip and it would seem to be corrupt or somthing, I can't uncompress it.

thanks,

Richard
Cheers!

Richard
Quote Reply
Re: [pkzone] Ordernary MOD code problem In reply to
I sorted out the problem with the 'Begin...error.txt' thingy. If you cut and paste from your FAQ page you need to change the quotation marks from ' to ". worked for me....

Cheerios,

Richard
Cheers!

Richard
Quote Reply
Re: [pkzone] Ordernary MOD code problem In reply to
Well I fixed all the errors in the Ordernary script additions and can happily say I have this MOD running perfectly now. I still have some problems with the script not adding up item amounts and the formatting and page layouts really are not that great but I am changing all that. Would someone mind helping me with regular expressions? I am not a whiz at that and could use some help. I need to find out why the script is not totalling up orders and applying shipping charges and such. I'm slowly figuring this stuff out, hehe. ANyways, thanks for the insight guys/gals and I'll be talking to ya again soon I'm sure!



Cheers!

Richard
Cheers!

Richard
Quote Reply
Re: [pkzone] Ordernary MOD code problem In reply to
I'm glad you were able to find and fix the errors.

Your best bet would be to search for all related threads for that mod and see what changes may have been made or what previous problems people have had. I don't have acess to the computer with all my notes and list of related threads, but I'm sure if you search the forums you will locate them. Or you can search for posts by Ograin. Many of the additions to the mod were provided within previous posts.

Sorry I could not be of more help

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] Ordernary MOD code problem In reply to
Thanks LoisC,

I browsed through (I hope) all the posts and FAQ's I can find. These are the first places I look because I don't want to seem like a silly willy who's asking the same 10 millionth question as everyone before me and I'm sure it gets annoying to you helpful people as well. I know I get a little frustrated when people ask me the same question over and over even though the answer is in a FAQ I have posted. Oh well, goes with the territory I guess, LOL.
So now what the heck was I going to say?? Oh gosh darn I've forgotten now, hahaha, well that is just too darn funny!! Perhaps I will remember in a bit. I suppose I should get back to working on the script, so toodles for now and thanks for the help!

Cheers!
Richard
Cheers!

Richard

Last edited by:

pkzone: Oct 22, 2002, 1:51 PM