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

📄 shop.php

📁 FTB安装版 v1.3(虚拟形象)FTB安装版 v1.3(虚拟形象)
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?
$forumid=122;
require("userdata/style.php");
require("global.php");
require("header.php");echo"$headertp";
if($login_status==0) print_err("出错啦~你还没有登陆");
if (empty($action)) $action="show";
if($action=="show") headguide('你现在正在'.$bbs_title.'<br>商店','<a href=shop.php>商店</a> >> 选购商品','','no');
elseif($action=="view") headguide('你现在正在'.$bbs_title.'<br>查看自己的物品','<a href=shop.php>商店</a> >> 查看自己的物品','','no');
elseif($action=="send") headguide('你现在正在'.$bbs_title.'<br>赠送礼物','<a href=shop.php>商店</a> >> 赠送礼物','','no');
elseif($action=="buy") headguide('你现在正在'.$bbs_title.'<br>购买商品','<a href=shop.php>商店</a> >> 购买商品','','no');
elseif($action=="sell") headguide('你现在正在'.$bbs_title.'<br>出售商品','<a href=shop.php>商店</a> >> 出售商品','','no');
elseif($action=="add") headguide('你现在正在'.$bbs_title.'<br>新增商品','<a href=shop.php>商店</a> >> 新增商品','','no');
elseif($action=="modify") headguide('你现在正在'.$bbs_title.'<br>修改商品','<a href=shop.php>商店</a> >> 修改商品','','no');
elseif($action=="del") headguide('你现在正在<br>'.$bbs_title.'<br>清除商品','<a href=shop.php>商店</a> >> 清除商品','','no');
elseif($action=="use") headguide('你现在正在<br>'.$bbs_title.'<br>使用商品','<a href=shop.php>商店</a> >> 使用商品','','no');
else headguide('你现在正在'.$bbs_title.'<br>商品','<a href=shop.php>商店</a> >> 出错啦~','','no');

if ($action=="show") show();
elseif ($action=="view") mygoods();
elseif ($action=="buy") buy($sth);
elseif ($action=="sell") sell($sth);
elseif ($action=="send") send($sth);
elseif ($action=="add") add($sth);
elseif ($action=="del") del($sth);
elseif ($action=="modify") modify($sth);
elseif ($action=="use") useit($sth);
else print_err("出错啦~我不知道你想做什么");

function print_err($status) {
$title="发生错误";
$content="管理程式发生了错误,情况:<br>
<br>$status<br><ul>
<li><a href='javascript:history.back(1)'>返回前一页</a></li>
</ul>";
msg_box($title,$content);
require("footer.php");echo"$footertp";
exit;
}

function show() {
global $bbs_title,$bordercolor,$forumcolorone,$titlecolor,$tablewidth,$style_path,$username,$manager,$bbs_money;
$useri=get_user_info($username);
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$content="| 你有现金 $useri[24] $bbs_money | <a href=shop.php?action=view>我的物品</a> | <a href=shop.php?action=send>我要送礼</a> | <a href=shop.php?action=sell>出售商品</a> | ";
if($username==$manager) $content.="<a href=shop.php?action=add>添加商品</a> | <a href=shop.php?action=modify>修改商品</a> | <a href=shop.php?action=del>清空商品</a> |";
$content.="<form method=POST action=shop.php><input type=hidden name=action value=buy>
         <table border=0 bgcolor=$titlecolor width=100% cellspacing=1 cellpadding=0 height=20>
            <tr bgcolor=$titlecolor> 
<td width=25 bgcolor=$titlecolor class=title>选择</td>
<td width=80 bgcolor=$titlecolor class=title>图片</td>
<td width=100 bgcolor=$titlecolor class=title>物件</td>
<td width=80 bgcolor=$titlecolor class=title>数量</td>
<td width=80 bgcolor=$titlecolor class=title>单价</td>
<td bgcolor=$titlecolor class=title>说明</td> 
<td width=80 bgcolor=$titlecolor class=title>购买数量</td>
</tr>
</table>
";
	if (file_exists("userdata/shop/good.php")) 
	$goodlist=explode("\n",readfromfile("userdata/shop/good.php"));
	else $goodlist[0]="";
	$count=count($goodlist);
	for($i=0;$i<$count;$i++){
		$detail=explode("|",$goodlist[$i]);
		$content.="
            <table border=0 bgcolor=$forumcolorone width=100%h cellspacing=1 cellpadding=0 height=20>
            <tr> 
<td width=25><input type=radio name='sth' value=$i></td>
<td width=80><input type=hidden name=pic[$i] value=$detail[1]><img src=images/shop/$detail[1] alt=$detail[0]></div></td>
<td width=100><input type=hidden name=good[$i] value=$detail[0]>$detail[0]</td>
<td width=80><input type=hidden name=num[$i] value=$detail[2]>$detail[2]</td>
<td width=80><input type=hidden name=value[$i] value=$detail[3]>$detail[3]</td> 
<td><input type=hidden name=des[$i] value=$detail[4]>$detail[4]</td> 
<td width=80><input type=text  size=3 name=buynum[$i] value=1 maxlength=3></td>
</tr>
</table>
";
}
$content.="<center>
<input type=submit value=确定购买> 
<input type=reset value=重新选择> </center>
</form>
";
msg_box($title,$content);
}
function buy($sth) {
global $bbs_title,$bordercolor,$forumcolorone,$titlecolor,$tablewidth,$style_path,$username,$manager,$bbs_money,$step,$good,$pic,$num,$buynum,$des,$sth,$value,$timestamp;
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$useri=get_user_info($username);
if(empty($step)) {
$content="你有现金 $useri[24] $bbs_money ,你选购了以下商品:";
$content.="<form method=POST action=shop.php>
<input type=hidden name=action value=buy>
<input type=hidden name=step value=2>
         <table border=0 bgcolor=$titlecolor width=100% cellspacing=1 cellpadding=0 height=20>
            <tr bgcolor=$titlecolor> 
<td width=25 bgcolor=$titlecolor class=title>选择</td>
<td width=80 bgcolor=$titlecolor class=title>图片</td>
<td width=100 bgcolor=$titlecolor class=title>物件</td>
<td width=80 bgcolor=$titlecolor class=title>数量</td>
<td width=80 bgcolor=$titlecolor class=title>单价</td>
<td bgcolor=$titlecolor class=title>说明</td> 
<td width=80 bgcolor=$titlecolor class=title>购买数量</td>
<td width=80 bgcolor=$titlecolor class=title>价格($bbs_money)</td>
</tr>
</table>
";
$moneyall=0;
	if (file_exists("userdata/shop/good.php")) 
	$goodlist=explode("\n",readfromfile("userdata/shop/good.php"));
	else $goodlist[0]="";
	$count=count($goodlist);
	for($i=0;$i<$count;$i++){
		if($sth!=$i || $buynum[$i]<1 || $buynum[$i]>999) continue;
		$money[$i]= $buynum[$i]*$value[$i];
		$moneyall+=$money[$i];
		$content.="
            <table border=0 bgcolor=$forumcolorone width=100% cellspacing=1 cellpadding=0 height=20>
            <tr> 
<td width=25><input type=radio name=sth value='$i' checked></td>
<td width=80><input type=hidden name=pic[$i] value=$pic[$i]><img src=images/shop/$pic[$i] alt=$good[$i]></td>
<td width=100><input type=hidden name=good[$i] value=$good[$i]>$good[$i]</td>
<td width=80><input type=hidden name=num[$i] value=$num[$i]>$num[$i]</td>
<td width=80><input type=hidden name=value[$i] value=$value[$i]>$value[$i]</td> 
<td><input type=hidden name=des[$i] value=$des[$i]>$des[$i]</td> 
<td width=80><input type=hidden name=buynum[$i] value=$buynum[$i]><font color=green>$buynum[$i]</font></td>
<td width=80><font color=blue>$money[$i]</font></td> 
</tr>
</table>
";
}
if($useri[24]>=$moneyall) 
$content.="
<table border=0 bgcolor=$forumcolorone width=100% cellspacing=1 cellpadding=0 height=20>
<tr> 
<td colspan=7 align=center>真得要购买吗?</td>
<td width=80><font color=red><b>总价:$moneyall</b></red></td>
</tr>
</table>
<center>
<input type=submit value=确定购买> 
<input type=button value=重新选购 onclick=history.go(-1)> 
</center>
</form>
";
else $content.="
<table border=0 bgcolor=$forumcolorone width=100% cellspacing=1 cellpadding=0 height=20>
<tr> 
<td colspan=7 align=center>有没有搞错,你哪来那么多钱?</td>
<td width=80><font color=red><b>总价:$moneyall</b></red></td>
</tr>
</table>
<center>
<input type=button value=返回重新选购 onclick=history.go(-1)> 
</center>
</form>
";
msg_box($title,$content);
}else {
$moneyall=0;
	if (file_exists("userdata/shop/good.php")) 
	$goodlist=explode("\n",readfromfile("userdata/shop/good.php"));
	else $goodlist[0]="";
	if (file_exists("userdata/shop/$username.php")) 
	$shoplist=explode("\n",readfromfile("userdata/shop/$username.php"));
	else $shoplist[0]="";
	$count=count($goodlist);
	$scount=count($shoplist);

	for($ii=0;$ii<$count;$ii++){		
		$detail=explode("|",$goodlist[$ii]);
		if($good[$sth]==$detail[0] && $buynum[$sth]>=1 && $buynum[$sth]<=999) {
		$detail[2]-=$buynum[$sth];
		$goodlist[$ii]=implode("|",$detail); 
		break;
		}
	}
	$newgoodlist=implode("\n",$goodlist); 
	writetofile("userdata/shop/good.php",$newgoodlist);

	$shoplist[$scount]="$good[$sth]|$pic[$sth]|$buynum[$sth]|$value[$sth]|$des[$sth]|$timestamp||||";
	for($j=0;$j<$scount;$j++){
		$sdetail=explode("|",$shoplist[$j]);
		if($sdetail[0]==$good[$sth]) {
			$sdetail[2]+=$buynum[$sth];
			$shoplist[$j]=implode("|",$sdetail);
			unset($shoplist[$scount]);
			break;
		}
		if($shoplist[0]=="") unset($shoplist[0]);
	}
	$newshoplist=implode("\n",$shoplist); 
	writetofile("userdata/shop/$username.php",$newshoplist);
	$money[$sth]= $buynum[$sth]*$value[$sth];
	$moneyall+=$money[$sth];
	dtchange($username,0,0,-$moneyall);

$content="购买成功";
msg_box($title,$content);
}
}
function sell($sth) {
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$content="不好意思,程式尚未成完!";
msg_box($title,$content);
}

function send($sth) {
global $bbs_title,$userpath,$say,$timestamp,$msgpath,$buynum,$num,$bordercolor,$forumcolorone,$sth,$titlecolor,$tablewidth,$style_path,$username,$manager,$bbs_money,$step,$sendjob,$sendto;
$useri=get_user_info($username);
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";

⌨️ 快捷键说明

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