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

📄 productlist.cgi

📁 支持全流程的Perl+MySQL电子商务系统。完全公开代码。
💻 CGI
字号:
#!/usr/bin/perl
#
#
##########################################################
#					网络小厨房 商店系统
#					Net Kitchen SHOP
##########################################################
#首页代码
##########################################################

####################################################################################
#前端预处理
####################################################################################
use FindBin qw($Bin);
use lib "$Bin/library";
use iLcatlib;
use strict;
use vars qw(%FORM %CON %COOKIE $LIB $sth $row @userdata);

#获得系统参数
tie %CON, 'IniFiles', ( -file => "$Bin/nkshop.ini" );

#构造新对象
$LIB=iLcatlib->new(ttmlpath=>"$CON{path}{ttmlpath}");

#获得COOKIE
%COOKIE=$LIB->ReadCookie();

#获得提交内容
%FORM=$LIB->ReadParse();


#连接数据库
$LIB->MySQL_Connect(
	database=>"$CON{database}{database}",
	dbhost=>"$CON{database}{dbhost}",
	dbuser=>"$CON{database}{dbuser}",
	dbpwd=>"$CON{database}{dbpwd}"
);


##########################################################################
########			程序正文系统
my (%dbs,@view,$text,$current_name,$des,$current_image);
my $dm_lists=0;
my $dm_product=0;
my $dm_lifefoot=0;

#########
#购物车处理
my (@user_order,@user_count,$all_orders,$i);

@user_order=$LIB->Shopping("$COOKIE{'order'}");
@user_count=$LIB->Shopping("$COOKIE{'count'}");
$all_orders=0;
for ($i=0;$i<=$#user_order ;$i++) {

	#########
	#取得已订购商品
	$sth=$LIB->MySQL_Query("select name from store where num = '$user_order[$all_orders]'");
	$row = $sth->fetchrow_arrayref();
	if ($row->[0] ne "") {
		$dbs{'all_orders'}{"$all_orders"}={
				count		=>	$all_orders+1,
				order_count	=>	$user_count[$all_orders],
				name		=>	$row->[0],
		};
		$all_orders++;
	}
}

if ($FORM{'act'} eq "bylife") {
	
	##########所有分类列表
	$sth=$LIB->MySQL_Query("select cate_num,cate_name from pro_cate where cate_type = '0'");
	while (($row = $sth->fetchrow_arrayref)){

		$dbs{'lists'}{"$dm_lists"}={
				list_name	=>	$row->[1],
				list_num	=>	$row->[0],
				cgiurl		=>	$CON{path}{cgiurl},
		};
		$dm_lists++;
	}

	#获得生存关系信息

	$sth=$LIB->MySQL_Query("select cate_num,cate_name,cate_image from pro_cate where cate_type = '1'");
	while (($row = $sth->fetchrow_arrayref)){
	
		$dbs{'lifefoot'}{"$dm_lifefoot"}={
				num	=>	$row->[0],
				name	=>	$row->[1],
		};
		$dm_lifefoot++;
	}

	#当前关系名称
	$sth=$LIB->MySQL_Query("select cate_num,cate_name,cate_image from pro_cate where cate_num = '$FORM{'num'}'");
	$row = $sth->fetchrow_arrayref();
	if ($row eq "") {$LIB->Error("没有这个关系系列产品");}
	$current_name = $row->[1];
	$current_image = $row->[2];

	###########产品信息

	$sth=$LIB->MySQL_Query("select num,name,image,des,price from store where life_foot = '$FORM{'num'}'");
	while (($row = $sth->fetchrow_arrayref)){

		$des=$LIB->Str_dual($row->[3],$CON{parameter}{main_demo_word});
	
		$dbs{'product'}{"$dm_product"}={
				num		=>	$row->[0],
				name	=>	$row->[1],
				image	=>	$row->[2],
				des		=>	$des,
				price	=>	$row->[4],
				cgiurl	=>	$CON{path}{cgiurl},
				imgurl	=>	$CON{path}{webimg},
		};
		$dm_product++;
	}



	$text={
	cgiurl	=>	$CON{path}{cgiurl},
	imgurl	=>	$CON{path}{webimg},
	current_image => $current_image,	
	current_name => $current_name,
	htmurl  =>	$CON{path}{htmurl},
	loop_lists  => $dm_lists-1,
	loop_product => $dm_product-1,
	loop_lifefoot	=>	$dm_lifefoot-1,
	loop_all_orders	=>	$all_orders-1,
	};

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

	print @view;
}
else {
	
	##########所有分类列表
	$sth=$LIB->MySQL_Query("select cate_num,cate_name from pro_cate where cate_type = '0'");
	while (($row = $sth->fetchrow_arrayref)){

		$dbs{'lists'}{"$dm_lists"}={
				list_name	=>	$row->[1],
				list_num	=>	$row->[0],
				cgiurl		=>	$CON{path}{cgiurl},
		};
		$dm_lists++;
	}

	#获得生存关系信息

	$sth=$LIB->MySQL_Query("select cate_num,cate_name,cate_image from pro_cate where cate_type = '1'");
	while (($row = $sth->fetchrow_arrayref)){
	
		$dbs{'lifefoot'}{"$dm_lifefoot"}={
				num	=>	$row->[0],
				name	=>	$row->[1],
		};
		$dm_lifefoot++;
	}

	#当前分类名称
	$sth=$LIB->MySQL_Query("select cate_num,cate_name from pro_cate where cate_num = '$FORM{'num'}'");
	$row = $sth->fetchrow_arrayref();
	if ($row eq "") {$LIB->Error("没有这个分类");}
	$current_name = $row->[1];
	
	###########Rand 产品信息

	$sth=$LIB->MySQL_Query("select num,name,image,des,price from store where inherit_cate = '$FORM{'num'}'");
	while (($row = $sth->fetchrow_arrayref)){

		$des=$LIB->Str_dual($row->[3],$CON{parameter}{main_demo_word});
	
		$dbs{'product'}{"$dm_product"}={
				num		=>	$row->[0],
				name	=>	$row->[1],
				image	=>	$row->[2],
				des		=>	$des,
				price	=>	$row->[4],
				cgiurl	=>	$CON{path}{cgiurl},
				imgurl	=>	$CON{path}{webimg},
		};
		$dm_product++;
	}

	$text={
	cgiurl	=>	$CON{path}{cgiurl},
	imgurl	=>	$CON{path}{webimg},
	current_name => $current_name,
	htmurl  =>	$CON{path}{htmurl},
	loop_lists  => $dm_lists-1,
	loop_product => $dm_product-1,
	loop_lifefoot	=>	$dm_lifefoot-1,
	loop_all_orders	=>	$all_orders-1,
	};

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

	print @view;
}

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

⌨️ 快捷键说明

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