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

📄 nsadmin.cgi

📁 支持全流程的Perl+MySQL电子商务系统。完全公开代码。
💻 CGI
📖 第 1 页 / 共 2 页
字号:
#顺序号
$sth=$LIB->MySQL_Query("select num from store order by num desc limit 1");
$row = $sth->fetchrow_arrayref();
my $next_num = $row->[0]+1;

#上载小图片
	$image_file = &iLcatlib::param("image");
	$image_fh	 = &iLcatlib::param("image");

	$image_file =~ s/^.*(\\|\/)//;
	if ($image_file =~ /\.([\W\w\d]+)$/) {
		$image_extname = $1;
	}

	if (-e "$CON{path}{proimgpath}/$next_num-s.$image_extname") {
			close ($image_fh);
			$LIB->Error("$CON{path}{proimgpath}/$next_num-s.$image_extname  这个文件名已经存在");
	}
	unless (open (OUTFILE,">$CON{path}{proimgpath}/$next_num-s.$image_extname")) {
			close ($image_fh);
			$LIB->Error("$CON{path}{proimgpath}/$next_num-s.$image_extname 不能写文件");
	}

	binmode $image_fh;
	binmode OUTFILE;
	while (read($image_fh, $buffer, 1024)) {
		print OUTFILE $buffer;
	}
	close (OUTFILE);
	close ($image_fh);

#上载大图片
	$photo_file = &iLcatlib::param("photo");
	$photo_fh	 = &iLcatlib::param("photo");

	$photo_file =~ s/^.*(\\|\/)//;
	if ($photo_file =~ /\.([\W\w\d]+)$/) {
		$photo_extname = $1;
	}

	if (-e "$CON{path}{proimgpath}/$next_num-b.$photo_extname") {
			close ($photo_fh);
			$LIB->Error("$CON{path}{proimgpath}/$next_num-b.$photo_extname  这个文件名已经存在");
	}
	unless (open (OUTFILE,">$CON{path}{proimgpath}/$next_num-b.$photo_extname")) {
			close ($photo_fh);
			$LIB->Error("$CON{path}{proimgpath}/$next_num-b.$photo_extname 不能写文件");
	}

	binmode $photo_fh;
	binmode OUTFILE;
	while (read($photo_fh, $buffer, 1024)) {
		print OUTFILE $buffer;
	}
	close (OUTFILE);
	close ($photo_fh);

#增加商品数据

$LIB->MySQL_Do("INSERT into store(num,pid,name,image,photo,des,spec_desc,spec,price,amount,choosed,sellout,cretime,inherit_cate,life_foot,statmsg)
				values('$next_num',$FORM{'pid'},$FORM{'name'},'$CON{path}{proimg}/$next_num-s.$photo_extname','$CON{path}{proimg}/$next_num-b.$photo_extname',$FORM{'des'},$FORM{'spec_desc'},$FORM{'spec'},
				$FORM{'price'},$FORM{'amount'},'0','0',sysdate(),$FORM{'inherit_cate'},$FORM{'life_foot'},$FORM{'statmsg'})");

$LIB->Location("$CON{path}{cgiurl}/nsadmin.cgi?act=pg_pro");

#MySQL Disconnect
$LIB->MySQL_Disconnect();
#The END
$LIB->exit();
}


sub up_pro
{
my ($text,@view);

##########
#数据
$sth=$LIB->MySQL_Query("select num,name,des,spec_desc,spec,price,amount from store where num='$FORM{'num'}'");
$row = $sth->fetchrow_arrayref();
if ($FORM{'num'} ne $row->[0]) {$LIB->Error("没有这个商品存在");}

$text = {
	num		=>	$row->[0],
	name	=>	$row->[1],
	des		=>	$row->[2],
	spec_desc	=>	$row->[3],
	spec		=>	$row->[4],
	price		=>	$row->[5],
	amount		=>	$row->[6],
	cgiurl	=>	$CON{path}{cgiurl},
	imgurl	=>	$CON{path}{webimg},
};

@view=$LIB->Parse("admin_up_pro.htm",$text);

print @view;

#MySQL Disconnect
$LIB->MySQL_Disconnect();
#The END
$LIB->exit();
}

sub up_pro_do
{
my ($num,$amount,$price,$des,$spec_desc,$spec,$image_file,$image_fh,$photo_file,$photo_fh,$buffer,$image_extname,$photo_extname);
##########
#数据
$sth=$LIB->MySQL_Query("select des,spec_desc,spec,price,amount,image,photo from store where num='$FORM{'num'}'");
$row = $sth->fetchrow_arrayref();
if ($row->[0] eq "") {$LIB->Error("没有这个商品存在");}

if ($FORM{'amount_type'} eq "0") {
	$LIB->Error("货量填写不正确") if ($FORM{'amount'} =~ /[^0-9]/);
	$amount=$row->[6]-$FORM{'amount'};
}
elsif ($FORM{'amount_type'} eq "2") {
	$amount=$row->[6]+$FORM{'amount'};
}
else {
	$amount=$row->[6];
}

$num=$FORM{'num'};

if ($FORM{'price'} ne $row->[5]) {$price=$FORM{'price'};}
else {$price=$row->[5];}
if ($FORM{'des'} ne $row->[0]) {$des=$FORM{'des'};}
else {$des=$row->[0];}
if ($FORM{'spec_desc'} ne $row->[1]) {$spec_desc=$FORM{'spec_desc'};}
else {$spec_desc=$row->[1];}
if ($FORM{'spec'} ne $row->[2]) {$spec=$FORM{'spec'};}
else {$spec=$row->[2];}

$amount		=	$LIB->MySQL_Quote("$amount");
$price		=	$LIB->MySQL_Quote("$price");
$des		=	$LIB->MySQL_Quote("$des");
$spec_desc	=	$LIB->MySQL_Quote("$spec_desc");
$spec		=	$LIB->MySQL_Quote("$spec");


#上载小图片

if ($FORM{'image'} ne "") {
	$image_file = &iLcatlib::param("image");
	$image_fh	 = &iLcatlib::upload("image");

	$image_file =~ s/^.*(\\|\/)//;
	if ($image_file =~ /\.([\W\w\d]+)$/) {
		$image_extname = $1;
	}

	unless (open (OUTFILE,">$CON{path}{proimgpath}/$num-s.$image_extname")) {
			close ($image_fh);
			$LIB->Error("$CON{path}{proimgpath}/$num-s.$image_extname 不能写文件");
	}

	binmode $image_fh;
	binmode OUTFILE;
	while (read($image_fh, $buffer, 1024)) {
		print OUTFILE $buffer;
	}
	close (OUTFILE);
	close ($image_fh);

}

#上载大图片
if ($FORM{'photo'} ne "") {
	$photo_file = &iLcatlib::param("photo");
	$photo_fh	 = &iLcatlib::upload("photo");

	$photo_file =~ s/^.*(\\|\/)//;
	if ($photo_file =~ /\.([\W\w\d]+)$/) {
		$photo_extname = $1;
	}

	unless (open (OUTFILE,">$CON{path}{proimgpath}/$num-b.$photo_extname")) {
			close ($photo_fh);
			$LIB->Error("$CON{path}{proimgpath}/$num-b.$photo_extname 不能写文件");
	}

	binmode $photo_fh;
	binmode OUTFILE;
	while (read($photo_fh, $buffer, 1024)) {
		print OUTFILE $buffer;
	}
	close (OUTFILE);
	close ($photo_fh);

}


$LIB->MySQL_Do("UPDATE store set amount=$amount,price=$price,des=$des,spec_desc=$spec_desc,spec=$spec where num = '$FORM{'num'}'");

$LIB->Location("$CON{path}{cgiurl}/nsadmin.cgi?act=pg_pro");

#MySQL Disconnect
$LIB->MySQL_Disconnect();
#The END
$LIB->exit();
}


sub pg_account
{
my ($text,$where,$tag_value,$sth2,$row2,%dbs);


#格式化显示内容
if ($FORM{'orderby'} eq 'nopay') {$where = 'where gather = \'0\'';}
elsif ($FORM{'orderby'} eq 'payed') {$where = 'where gather = \'1\'';}
elsif ($FORM{'orderby'} eq 'nofull') {$where = 'where gather = \'2\'';}
else {$where = '';}

#==========================================================#
#多页显示
my ($countpag,$page_start,$pag,$page_list,$i);
$sth=$LIB->MySQL_Query("select count(num) from choosed $where");
$row = $sth->fetchrow_arrayref();
my $countpag = $row->[0];

$FORM{'page'}=1 if ($FORM{'page'} < '1');
$page_start=($FORM{'page'}*$CON{parameter}{admin_account_limit});
$page_start=$page_start-$CON{parameter}{admin_account_limit};

#######
#设置多页显示
$pag = int($countpag/$CON{parameter}{admin_account_limit});
$pag++ if ($countpag/$CON{parameter}{admin_account_limit} > $pag);

#多页显示代码
for ($i=1;$i<=$pag ;$i++) {
	$page_list .= qq~<a href="$CON{path}{cgiurl}/nsadmin.cgi?act=pg_account&orderby=$FORM{'orderby'}&page=$i">$i</a>&nbsp;~;
}

#新定单列表
my $dm_orderlist=0;
$sth=$LIB->MySQL_Query("select num,cretime,choosed_name,all_price,gather,pay_type,rec_type from choosed $where order by cretime,gather limit $page_start,$CON{parameter}{admin_account_limit}");
while (($row = $sth->fetchrow_arrayref)){

##########
#数据
$sth2=$LIB->MySQL_Query("select count(*) from choosed_pro where come_chose = '$row->[0]'");
$row2 = $sth2->fetchrow_arrayref();

	$tag_value .= "$row->[0],";

	$dbs{'orderlist'}{"$dm_orderlist"}={
			pro_count	=>	$row2->[0],
			num			=>	$row->[0],
			cretime		=>	$row->[1],
			choosed_name=>	$row->[2],
			all_price	=>	$row->[3],
			gather		=>	$CON{parameter}{"gather$row->[4]"},
			pay_type	=>	$CON{parameter}{"pay_type$row->[5]"},
			rec_type	=>	$CON{parameter}{"rec_type$row->[6]"},
	};
	$dm_orderlist++;
}

$text = {
	cgiurl	=>	$CON{path}{cgiurl},
	page_list	=>	$page_list,
	tag_value	=>	$tag_value,
	this_page	=>	$FORM{'page'},
	loop_orderlist	=>	$dm_orderlist-1,
};


print $LIB->Parse("admin_pg_account.htm",$text,%dbs);

#MySQL Disconnect#The END
$LIB->MySQL_Disconnect();$LIB->exit();
}

sub do_account
{
my (@value,@print_view,$text,%dbs);

#格式化所需要更新数据格式
@value=$LIB->Str_spec($FORM{'tag_value'});

#如果是全部处理模式
if ($FORM{'submode'} eq 'all') {
	foreach  (@value) {

		if ($FORM{"c$_"} eq 'nopay') {
			$LIB->MySQL_Do("UPDATE choosed set gather='0' where num = '$_'");
		}
		elsif ($FORM{"c$_"} eq 'payed') {
			push(@print_view,$_);
			$LIB->MySQL_Do("UPDATE choosed set gather='1' where num = '$_'");
		}
		elsif ($FORM{"c$_"} eq 'nofull') {
			$LIB->MySQL_Do("UPDATE choosed set gather='2' where num = '$_'");
		}
		elsif ($FORM{"c$_"} eq 'rm') {
		$LIB->MySQL_Do("DELETE FROM choosed WHERE num='$_'");
		$LIB->MySQL_Do("DELETE FROM choosed_pro WHERE come_chose='$_'");
		}
	}
}
else{
	@print_view=@value;
}


###############
#处理定单打印格式输出
my ($line,$pro_list,$sth2,$row2);
my $dm_list=0;
foreach $line (@print_view) {

	$pro_list='';

	$sth=$LIB->MySQL_Query("select gather,choosed_name,rec_type,rec_name,rec_address,rec_postcode,rec_contact from choosed where num = $line");
	$row = $sth->fetchrow_arrayref();

	$sth2=$LIB->MySQL_Query("select pro_id,pro_name,pro_count,spec from choosed_pro where come_chose = '$line'");
	while (($row2 = $sth2->fetchrow_arrayref)){
		$pro_list	.=	"[$row2->[0]]$row2->[1](规格:$row2->[3]):$row2->[2]件、";
	}

	$dbs{'list'}{"$dm_list"}={
					num=>	$line,
					gather	=>	$CON{parameter}{"gather$row->[0]"},
					choosed_name	=>	$row->[1],
					rec_type	=>	$CON{parameter}{"rec_type$row->[2]"},
					rec_name	=>	$row->[3],
					rec_address	=>	$row->[4],
					rec_postcode	=>	$row->[5],
					rec_contact	=>	$row->[6],
					pro_list	=>	$pro_list,
					
	};

	$dm_list++;
}

$text = {
	cgiurl	=>	$CON{path}{cgiurl},
	loop_list=>	$dm_list-1,
	webname	=>	$CON{syscon}{webname},
	datetime	=>	$LIB->ReadTime(),
	support_mail	=>	$CON{syscon}{support_replayto},
};


print $LIB->Parse("print_view.htm",$text,%dbs);

#MySQL Disconnect#The END
$LIB->MySQL_Disconnect();$LIB->exit();
}

sub pg_goods
{
my ($text,$where,$tag_value,$sth2,$row2,%dbs);


#格式化显示内容
if ($FORM{'orderby'} eq '0') {$where = 'where gather=\'1\' and send = \'0\'';}
elsif ($FORM{'orderby'} eq '1') {$where = 'where gather=\'1\' and send = \'1\'';}
elsif ($FORM{'orderby'} eq '2') {$where = 'where gather=\'1\' and send = \'2\'';}
elsif ($FORM{'orderby'} eq '3') {$where = 'where gather=\'1\' and send = \'3\'';}
elsif ($FORM{'orderby'} eq 'all') {$where = 'where gather=\'1\'';}
else {$where = 'where gather=\'1\' and send = \'0\'';}

#==========================================================#
#多页显示
my ($countpag,$page_start,$pag,$page_list,$i);
$sth=$LIB->MySQL_Query("select count(num) from choosed $where");
$row = $sth->fetchrow_arrayref();
my $countpag = $row->[0];

$FORM{'page'}=1 if ($FORM{'page'} < '1');
$page_start=($FORM{'page'}*$CON{parameter}{admin_goods_limit});
$page_start=$page_start-$CON{parameter}{admin_goods_limit};

#######
#设置多页显示
$pag = int($countpag/$CON{parameter}{admin_goods_limit});
$pag++ if ($countpag/$CON{parameter}{admin_goods_limit} > $pag);

#多页显示代码
for ($i=1;$i<=$pag ;$i++) {
	$page_list .= qq~<a href="$CON{path}{cgiurl}/nsadmin.cgi?act=pg_goods&orderby=$FORM{'orderby'}&page=$i">$i</a>&nbsp;~;
}

#新定单列表
my $dm_orderlist=0;
my ($any_pro_list);
$sth=$LIB->MySQL_Query("select num,cretime,choosed_name,send from choosed $where order by cretime limit $page_start,$CON{parameter}{admin_goods_limit}");
while (($row = $sth->fetchrow_arrayref)){
	$any_pro_list='';
	$tag_value .= "$row->[0],";

##########
#数据
	$sth2=$LIB->MySQL_Query("select pro_name,spec_desc,pro_count from choosed_pro where come_chose = '$row->[0]'");
	while (($row2 = $sth2->fetchrow_arrayref)){
		$any_pro_list .=qq~<option>=$row2->[0]=$row2->[1]=$row2->[2]=$row2->[3]=</option>~;
	}

	$dbs{'orderlist'}{"$dm_orderlist"}={
			num			=>	$row->[0],
			any_pro_list	=>	$any_pro_list,
			cretime		=>	$row->[1],
			choosed_name=>	$row->[2],
			send		=>	$CON{parameter}{"send$row->[3]"},
	};
	$dm_orderlist++;
}

$text = {
	cgiurl	=>	$CON{path}{cgiurl},
	page_list	=>	$page_list,
	tag_value	=>	$tag_value,
	this_page	=>	$FORM{'page'},
	loop_orderlist	=>	$dm_orderlist-1,
};


print $LIB->Parse("admin_pg_goods.htm",$text,%dbs);

#MySQL Disconnect#The END
$LIB->MySQL_Disconnect();$LIB->exit();
}

sub do_goods
{
my (@value,%dbs);
my ($username,$rec_type,$rec_address,$rec_postcode,$rec_name,$sender_mailto,$pro_list,$mail_user);

#格式化所需要更新数据格式
@value=$LIB->Str_spec($FORM{'tag_value'});

foreach  (@value) {

	if ($FORM{"c$_"} eq '0') {#更改为新定单
		$LIB->MySQL_Do("UPDATE choosed set send='0' where num = '$_'");
	}
	elsif ($FORM{"c$_"} eq '1') {#更改为已发货定单,并且发邮件给用户

	
	$LIB->MySQL_Do("UPDATE choosed set send='1' where num = '$_'");

	##邮件发送-读出需要发送的内容
	$sth=$LIB->MySQL_Query("select choosed_name,rec_type,rec_address,rec_postcode,rec_name from choosed where num = '$_'");
	$row = $sth->fetchrow_arrayref();
	$username=$row->[0];
	$rec_type=$row->[1];
	$rec_address=$row->[2];
	$rec_postcode=$row->[3];
	$rec_name=$row->[4];

	#读出用户的电子信箱地址
	$sth=$LIB->MySQL_Query("select email from userdata where id = '$username'");
	$row = $sth->fetchrow_arrayref();
	$sender_mailto = $row->[0];

	$pro_list='';
	#读出所有被订购的商品
	$sth=$LIB->MySQL_Query("select pro_pid,pro_name,pro_count,spec_desc from choosed_pro where come_chose = '$_'");
	while ($row = $sth->fetchrow_arrayref()) {
		$pro_list .="[$row->[0]]:$row->[1]		规格:$row->[3]	数量:$row->[2]\n";
	};

	#####格式化发给用户的邮件
	$mail_user = $LIB->Parse("sendword.mlt",{
									username	=>	$username,
									pro_list	=>	$pro_list,
									rec_type	=>	$CON{parameter}{"rec_type$rec_type"},
									rec_address	=>	$rec_address,
									rec_postcode	=>	$rec_postcode,
									rec_name	=>	$rec_name,
									webname	=>	$CON{syscon}{webname},
									weburl	=>	$CON{syscon}{weburl},
								});

&_sendmail($CON{syscon}{support_from},$CON{syscon}{support_replayto},$sender_mailto,"$CON{syscon}{webname} 发货通知",$mail_user);
	}
	elsif ($FORM{"c$_"} eq '2') {#更改为缺货定单
		$LIB->MySQL_Do("UPDATE choosed set send='2' where num = '$_'");
	}
	elsif ($FORM{"c$_"} eq '3') {#更改为无法发送定单
		$LIB->MySQL_Do("UPDATE choosed set send='3' where num = '$_'");
	}
	elsif ($FORM{"c$_"} eq 'rm') {
		$LIB->MySQL_Do("DELETE FROM choosed WHERE num='$_'");
		$LIB->MySQL_Do("DELETE FROM choosed_pro WHERE come_chose='$_'");
	}
}

$LIB->Location("$CON{path}{cgiurl}/nsadmin.cgi?act=pg_goods");

#MySQL Disconnect#The END
$LIB->MySQL_Disconnect();$LIB->exit();
}

sub _sendmail
{
my ($from,$replay,$to,$subject,$text)=@_;

#SendMail System
 open( MAIL, "| $CON{path}{sendmail} -t" ) || $LIB->Lost("无法发送邮件");
 print MAIL "To: $to\n";
 print MAIL "From: $from\n";
 print MAIL "Reply-to: $replay\n";
 print MAIL "Subject: $subject\n\n";
 print MAIL "$text","\n\n";
 close MAIL;

return();
}

⌨️ 快捷键说明

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