📄 shop.php
字号:
if(empty($sendjob)) {
$content="你有现金 $useri[24] $bbs_money | <a href=shop.php>我要购物</a> | <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?sendjob=1><input type=hidden name=action value=send>
<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/$username.php")) {
$goodlist=explode("\n",readfromfile("userdata/shop/$username.php"));
$count=count($goodlist);
for($i=0;$i<$count;$i++){
if($goodlist[$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=checkbox name='sth[$i]' value='$detail[0]'></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>
";
}}
if(!$sendjob){
$content.="
你要送给谁?<input type=text name=sendto size=10>
<input type=hidden name=sendjob value=2>
<input type=submit value=确定送出>
<input type=reset value=重新选择>你想对他(她)说:<input type=text name=say size=40>
</form>";
}}else $content.="你还没有购买任何物品,请先购买。";
msg_box($title,$content);
exit;}
$count=count($sth);
if($count==0)
{msg_box('发生错误','你没有选择所要送的商品<br><ul><li><a href="javascript:history.back(1)">返回前页</a><br></li></ul>');require("footer.php");echo"$footertp";exit;}
if($count>1)
{msg_box('发生错误','每次只能赠送一样礼品<br><ul><li><a href="javascript:history.back(1)">返回前页</a><br></li></ul>');require("footer.php");echo"$footertp";exit;}
if(!$sendto ||!file_exists("$userpath/$sendto.php"))
{msg_box('发生错误','无此用户<br><ul><li><a href="javascript:history.back(1)">返回前页</a><br></li></ul>');require("footer.php");echo"$footertp";exit;}
$key=key($sth);
if($buynum[$key]>$num[$key])
{msg_box('发生错误','你没那么多数量吧?<br><ul><li><a href="javascript:history.back(1)">返回前页</a><br></li></ul>');require("footer.php");echo"$footertp";exit;}
if ($buynum[$key]==$num[$key]||$buynum[$key]==0) {
$goodlist=file("userdata/shop/$username.php");
unset($goodlist[$key]);
$goodlists=implode("",$goodlist);
$f=fopen("userdata/shop/$username.php","w");
fputs($f,$goodlists);
}
else
{$goodlist=file("userdata/shop/$username.php");
$list=explode("|",$goodlist[$key]);
$list[2]-=$buynum[$key];
$goodlist[$key]=implode("|",$list);
$goodlists=implode("",$goodlist);
$f=fopen("userdata/shop/$username.php","w");
fputs($f,$goodlists);
}
if($buynum[$key]==0)
{msg_box('发生错误','此商品数量为0<br><ul><li><a href="javascript:history.back(1)">返回前页</a><br></li></ul>');require("footer.php");echo"$footertp";exit;}
if(file_exists("userdata/shop/$sendto.php"))$tttt=file("userdata/shop/$sendto.php");
if (file_exists("userdata/shop/good.php"))
if (file_exists("userdata/shop/$username.php") && file_exists("userdata/shop/$sendto.php"))
$shoplist=explode("\n",readfromfile("userdata/shop/$sendto.php"));
else $shoplist[0]="";
$scount=count($shoplist);
list($good[$key],$pic[$key],$num[$key],$value[$key],$des[$key],$timestamp,$bei1,$bei2,$bei3,$bei4)=explode("|",$goodlist[$key]);
$shoplist[$scount]="$good[$key]|$pic[$key]|$buynum[$key]|$value[$key]|$des[$key]|$timestamp||||";
for($j=0;$j<$scount;$j++){
$sdetail=explode("|",$shoplist[$j]);
if($sdetail[0]==$good[$key]) {
$sdetail[2]+=$buynum[$key];
$shoplist[$j]=implode("|",$sdetail);
unset($shoplist[$scount]);
break;
}
if($shoplist[0]=="") unset($shoplist[0]);
}
$newshoplist=implode("\n",$shoplist);
writetofile("userdata/shop/$sendto.php",$newshoplist);
if (file_exists("userdata/$msgpath/{$sendto}1.php"))
{$msg=file("userdata/$msgpath/{$sendto}1.php");}
else
{$msg[0]="";}
$old=implode("",$msg);
$content="$username 将 $good[$key],赠送给你,并对你说:$say";
$new="<?die;?>|系统信息|有人给你送礼物啦~|$timestamp|$content|\n";
writetofile("userdata/$msgpath/{$sendto}1.php",$new.$old);
$content="赠送成功 <a href=shop.php?action=send>继续赠送</a>";
msg_box($title,$content);
}
function add($sth) {
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$content="不好意思,程式尚未成完!";
msg_box($title,$content);
}
function del($sth) {
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$content="不好意思,程式尚未成完!";
msg_box($title,$content);
}
function modify($sth) {
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$content="不好意思,程式尚未成完!";
msg_box($title,$content);
}
function useit($sth) {
global $username,$userpath;
if($sth=="火狐狸"||$sth=="NBA篮球"){
if (file_exists("userdata/shop/$username.php")) {
$goodlist=explode("\n",readfromfile("userdata/shop/$username.php"));
$count=count($goodlist);
$youhave=0;
for($i=0;$i<$count;$i++){
$detail=explode("|",$goodlist[$i]);
if($detail[0]==$sth) {$detail[2]--;$youhave=1;}
if($detail[2]>0) $goodlist[$i]=implode("|",$detail);
else unset($goodlist[$i]);
}
if(!$youhave) {
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$content="你并没有此物品,使用失败!";
msg_box($title,$content);
require("footer.php");echo"$footertp";
exit;
}
$newshoplist=implode("\n",$goodlist);
writetofile("userdata/shop/$username.php",$newshoplist);
if($newshoplist=="") unlink("userdata/shop/$username.php");
}
}
if($sth=="火狐狸") {
$useri=get_user_info($username);
$useri[19]=1;
$uu=implode("|",$useri);
writetofile("$userpath/$username.php",$uu);
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$content="成功使用该物品,你现在可以查看用户IP地址了!";
msg_box($title,$content);
}
elseif($sth=="NBA篮球") {
$useri=get_user_info($username);
$useri[16]+=10;
$uu=implode("|",$useri);
writetofile("$userpath/$username.php",$uu);
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$content="成功使用该物品,你的威望增加了一点!";
msg_box($title,$content);
}
else {
$title="<b>欢迎光临 $bbs_title 商店,本店商品物美价廉,请选择你喜欢的物品,我们将真诚为你服务!</b>";
$content="不好意思,此物品暂时无法使用!";
msg_box($title,$content);
}
}
function mygoods() {
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.="<table border=0 bgcolor=$titlecolor width=100% cellspacing=1 cellpadding=0 height=20>
<tr bgcolor=$titlecolor>
<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/$username.php")) {
$goodlist=explode("\n",readfromfile("userdata/shop/$username.php"));
$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=80><img src=images/shop/$detail[1] alt=$detail[0]></div></td>
<td width=100>$detail[0]</td>
<td width=80>$detail[2]</td>
<td width=80>$detail[3]</td>
<td>$detail[4]</td>
<td width=80><a href=shop.php?action=use&sth=$detail[0]>使用</a></td>
</tr>
</table>
";
}
}else $content.="你还没有购买任何物品,请先购买。";
msg_box($title,$content);
}
require("footer.php");echo"$footertp";
exit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -