⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getorder.pl

📁 CyberCart Pro Internet Commerce System 3.042 很好的商业购物程序.Good Shopping Cart, Can be used for Multipl
💻 PL
📖 第 1 页 / 共 2 页
字号:
print "HTTP/1.0 200 OK\n";
#
#
# CyberCart Pro Internet Commerce System, Version 3.04
# Copyright 1997, Richard Torzynski
# 1-25-98
# All rights reserved
# This is NOT a shareware script.
#
# support@cybercart.com
# http://www.cybercart.com/

# License Agreement
# You should carefully read the following terms and conditions
# before using this script.  Unless you have a different license
# agreement signed by Rick Torzynski your use of this software
# indicates your acceptance of this license agreement and warranty.
#
# Multi-merchant Version
# One copy of the CyberCart IP Pro scripts may either
# be used by a single person or business, located on a single web server.
# Copies of this script may not be resold, leased, or distributed without
# the expressed written consent and approval of RT Web Design &
# Consulting.
#
# Disclaimer of Warranty
# THESE SCRIPTS AND THE ACCOMPANYING FILES ARE SOLD "AS IS" AND
# WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY
# OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED.  The user must
# assume the entire risk of using the program.  ANY LIABILITY OF
# THE SELLER WILL BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR
# REFUND OF PURCHASE PRICE.

#Define File Locations and Directories
#-------------------------------------------------------

# Home directory for Merchant files
$home_dir = "c:\\Merchant\\";


# Script URL
$script_url = "http://www.name.com/cgi-bin/getorder.pl";

# File to store userid and password of Cybercart Users
# This file must be created using passwords encoded using the crypt function.
$user_file = $home_dir . "ccusers.dat";


# File used to verify users logged in properly
$current = $home_dir . "current.dat";

# Summary script for clients to check their order totals
$summary_url = "http://www.name.com/summary.pl";

# Number of cols for editing merchant files
$cols = 80;

# Number of rows for editing merchant files
$rows = 15;

$merchant_help = "http://www.cybercart.com/instruct.htm";

#--------------------------------------------------------


&decode2;

$action = $post_query{'action'};
%cookies = split('[;=] *',$ENV{'HTTP_COOKIE'});

#&header;
#&debug;
#exit;

if ($action eq "logon") {
  &logon;
  &header;
  %cookies = split('[;=] *',$ENV{'HTTP_COOKIE'});
} else {
  &header;
  &verify;
  %cookies = split('[;=] *',$ENV{'HTTP_COOKIE'});
}

$status_file = $home_dir . $userid . "\\status.dat";
$log_file = $home_dir . $userid . "\\Logs\\$userid.log";
$referrer_list = $home_dir . $userid . "\\referrer.dat";


$ENV{'PATH_INFO'} =~ s/\/scripts\/getordernt.pl//g;
if ($ENV{'PATH_INFO'}) {
  &show_order;
  exit;
}

if ($action eq "delete") {
  &delete;
} elsif ($action eq "list") {
  &list;
} elsif ($action eq "changestatus") {
  &changestatus;
} elsif ($action eq "summary") {
  &summary;
} elsif ($action eq "itemlog") {
  &itemlog;
} elsif ($action eq "add_ref_form") {
  &add_referrer_form;
} elsif ($action eq "add_referrer") {
  &add_referrer;
} else {
  &menu;
}

exit;
# end main



sub summary {

$numorders = 0;


print qq[
<center>
<h1>Orders For $userid</h1>
</center>
];

open(LOG, "<$log_file") || &error("Can't open $log_file.  Check to
make sure logging features in CyberCart script are properly set.");
while (<LOG>) {
chop;
  (@order) = split(/:/,$_);

  if (exists($orderexist{$order[1]})) {
      # do nothing
  } else {
    
    $orderexist{$order[1]} = 1; 
    $count += 1;
      
    if ($count < 10) { 
      $count = "000" . $count;
    } elsif ($count < 100) {
      $count = "00" . $count;
    } elsif ($count < 1000) {
      $count = "000" . $count;
    }  
    

    $orderlist{$count} ="<td align=left>$order[0]</td><td align=left><a href=$script_url/$order[1]\.order>$order[1]</a></td><td>$order[2]</td>";

    $orderdate{$count} = $order[2];


    $orderamount{$count} = $order[3];
    $orderclient{$order[0]} += $order[3];

    # Add order to total
    $order_total{$count} = $order[3];
    $order_grand{$count} = $order[4];
    $order_total_client{$order[0]} += $order[3];
    $order_grand_client{$order[0]} += $order[4];

    $total_amount += $order[3];
    $grand_total += $order[4];
  }
}

if ($count == 0) {
  print qq[
There were no orders for merchant $userid.  If you think there is an
error, please contact <a href="mailto:$Admin">$Admin</a>.
];
} else {
 if (-s $referrer_list) {
  open(REF, "<$referrer_list") || &error("Cant open referrer_list at $referrer_list");
  while(<REF>) {
    chop;
    ($cn,$em,$pw) = split(/:/);
    $clientemail{$cn} = $em;
    $clientpass{$cn} = $pw;
  }
 }

foreach $client (sort keys %orderclient) {
if ($clientemail{$client}) {
  print qq[
  <font size=+2>Referrer $client</font>
  (<a href=mailto:$clientemail{$client}>$clientemail{$client}</a>)
  <p>
  ];
} else {
  print qq[
  <font size=+2>Referrer $client </font>
  ];
}
print qq[
<table width=450>
<tr align=right>
<th width=150><br></th>
<th align=left width=100>Order Number</th><th width=100>Date</th><th
width=100>Net</th><th width=100>Gross</th>
</tr>
<tr><td colspan=5><hr></td></tr>
];

@sorteddate = sort { $orderdate{$a} cmp $orderdate{$b} } keys(%orderdate);

# foreach $key (sort keys %orderlist) {
foreach $key (@sorteddate) {
  if ($orderlist{$key} =~ m/$client/) {
    print "<tr align=right>";
    printf "$orderlist{$key}<td align=right>\$%5.2f</td>\n",$order_total{$key};
    printf "<td align=right>\$%5.2f</td>\n", $order_grand{$key};
    print "</tr>";
  }
}
print "<tr><td colspan=5><hr></td></tr>";
if ($clientpass{$client}) {
  $sum_url = "$summary_url/$userid\+$client\+$clientpass{$client}";
} else {
  $sum_url = "$summary_url/$userid\+$client";
}
print "<tr><td colspan=3><a href=$sum_url>Show report for $client ONLY</a></td>";
printf "<th align=right>\$%5.2f</th>", $order_total_client{$client};
printf "<th align=right>\$%5.2f</th>", $order_grand_client{$client};
print "</table><p>";
}

}

printf "<font size=+2>Net for $userid: \$%5.2f</font><p>",
$total_amount;
printf "<font size=+2>Grand Total for $userid: \$%5.2f</font><p>",
$grand_total;

print "<p><a href=$script_url>Return to Main Menu</a><p>";

&footer;
exit;
}
# ------------------------------------------------------------------


sub changestatus {
$status_new = $status_file . "\.temp";

$order_num = $post_query{'order'};
open(OLDSTATUS, "<$status_file");
open(NEWSTATUS, ">$status_new");
while (<OLDSTATUS>) {
  if ($_ =~ m/$order_num/) {
    ($ordern,$name,$date_received,$order_status) = split(/::/);
    $newstat = $ordern . "::" . "$name" . "::" . "$date_received" . "::" .
"$post_query{'status'}\n";
    print (NEWSTATUS "$newstat");
  } else {
    print (NEWSTATUS "$_");
  }
}
close(OLDSTATUS);
close(NEWSTATUS);

open(OLD, ">$status_file");
open(NEW, "<$status_new");
while(<NEW>) {
  print OLD "$_";
}
close(NEW);
close(OLD);

if ($post_query{'last'} eq "list") {
  &list;
} else {
  &show_order;
}
}
# End sub changestatus
#--------------------------------------------------------------------

sub debug {
foreach $key (keys %cookies) {
  print "$key = $cookies{$key}<br>";
}
foreach $key (keys %post_query) {
  print "$key = $post_query{$key}<br>";
}
}
# End sub debug
#-----------------------------------------------------------

# New, more secure decoding routine from Matt's Script Archive Programs
sub decode2 {
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
  @pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
  read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  @pairs = split(/&/, $buffer);
}

foreach $pair (@pairs) {
  ($name, $value) = split(/=/, $pair);
  $name =~ tr/+/ /;
  $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

  # Take care of server side includes
  $value =~ s/<!--(.|\n)*-->//g;

  $post_query{$name} = $value;
}
}
# End sub decode2
#----------------------------------------------------#


sub delete {
$del_order = $home_dir . $userid . "\\Data\\" . "$post_query{'order'}\.order";
$del_items = $home_dir . $userid . "\\Data\\" . "$post_query{'order'}\.temp";

if (-s $del_order) {
  unlink($del_order) || &error("Couldn't delete $del_order");
}
if (-s $del_items) {
  unlink($del_items) || &error("Couldn't delete $del_items");
}
&list;
}
# End sub delete
#-----------------------------------------------------------

sub error {
local($error_message) = @_;
# Print message indicating that there is an error
if (!$header) {
  # print header if one hasn't been printed
  &header;
}
print "<h1>CyberCart Error</h1>\n";
print "$error_message<br>";
&footer;
exit;
}
# End sub error
#-----------------------------------------------------

sub footer {

print qq(
<p>
<h5>
<hr width=580 align=left>
CyberCart IP Pro, Copyright 1996 RT Web Design &amp Consulting<br>
</body>
</html>
);
}
# End sub footer
#-----------------------------------------------------------------


sub get_status {
$order_number = $_[0];

open(STATUS, "$status_file");
while (<STATUS>) {
  if ($_ =~ m/$order_number/i) {
    ($ordern,$name,$date_received,$order_status) = split(/::/);
    $of = 1;
    last;
  }
}
if (!$of) {
  $order_status = "Unknown";
}
$of = 0;
return ($order_status,$date_received,$name);
}
# sub get_status
#-------------------------------------------------------------

sub header {
print "Content-type: text/html\n\n";
print "<html>";
$header=1;
}
# End sub header
#------------------------------------------------------

sub list {
#list files
$user_dir = $home_dir . $userid . "\\Data";
opendir ORDERS, $user_dir;
@orders = readdir ORDERS;

foreach $filename (@orders) {
  my $tempname = $user_dir . "/$filename";
  $fileage = -M $tempname;
  $orderage{$filename} = $fileage;
}
@sortedage = sort {$orderage{$a} <=> $orderage{$b} } keys(%orderage);


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -