示例#1
0
        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易服务
            {
                AddErrLine("系统未开启交易服务, 当前页面暂时无法访问!");
                return;
            }

            headerad = "";
            footerad = "";

            // 如果商品交易日志不正确
            if (goodstradelogid <= 0)
            {
                AddErrLine("无效的交易日志信息.");
                return;
            }

            goodstradelog = TradeLogs.GetGoodsTradeLogInfo(goodstradelogid);
            int oldstatus = goodstradelog.Status;

            if (config.Enablemall == 1) //开启普通模式
            {
                forumid   = GoodsCategories.GetCategoriesFid(goodstradelog.Categoryid);
                forum     = Forums.GetForumInfo(forumid);
                forumname = forum.Name;
                forumnav  = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                forumid = 0;
            }

            ///得到广告列表
            ///头部
            headerad = Advertisements.GetOneHeaderAd("", forumid);
            footerad = Advertisements.GetOneFooterAd("", forumid);
            doublead = Advertisements.GetDoubleAd("", forumid);
            floatad  = Advertisements.GetFloatAd("", forumid);

            pagetitle   = goodstradelog.Subject;
            navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);

            if (useradminid != 0)
            {
                if (config.Enablemall == 1) //开启普通模式
                {
                    ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0;
                }

                //得到管理组信息
                admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            }
            //验证不通过则返回
            if (!IsConditionsValid())
            {
                return;
            }

            goodsleavewordlist = GoodsLeaveWords.GetLeaveWordList(goodstradelog.Id);

            if (goodstradelog.Status == 7 || goodstradelog.Status == 17)
            {
                israted = GoodsRates.CanRate(goodstradelog.Id, userid) ? false : true; //如果当前用户已评价过则不允许再评价
            }
            //如果是提交则更新商品交易日志
            if (ispost && goodstradelog.Status >= 0)
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                //当要验证密码时
                if (DNTRequest.GetInt("status", -1) > 0 && IsVerifyPassWord(goodstradelog.Status))
                {
                    if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("password")))
                    {
                        AddErrLine("密码不能为空, 请返回填写.");
                        return;
                    }

                    int uid = -1;
                    if (config.Passwordmode == 1)
                    {
                        uid = Users.CheckDvBbsPassword(base.username, DNTRequest.GetString("password"));
                    }
                    else
                    {
                        uid = Users.CheckPassword(username, DNTRequest.GetString("password"), true);
                    }

                    if (uid < 0)
                    {
                        AddErrLine("您输入的密码不正确, 不能修改订单状态, 请返回修改.");
                        return;
                    }

                    //当验证密码正确后,则发送相应留言
                    Goodsleavewordinfo goodsleavewordinfo = new Goodsleavewordinfo();
                    goodsleavewordinfo.Ip         = DNTRequest.GetIP();
                    goodsleavewordinfo.Goodsid    = goodstradelog.Goodsid;
                    goodsleavewordinfo.Tradelogid = goodstradelog.Id;
                    goodsleavewordinfo.Uid        = userid;
                    goodsleavewordinfo.Username   = username;
                    goodsleavewordinfo.Message    = DNTRequest.GetString("message");
                    goodsleavewordinfo.Isbuyer    = buyerleaveword;
                    GoodsLeaveWords.CreateLeaveWord(goodsleavewordinfo, goodsinfo.Selleruid);
                }

                goodstradelog.Status = DNTRequest.GetInt("status", -1);

                if (goodstradelog.Status == 0)
                {
                    //当为买家时
                    if (isbuyer)
                    {
                        goodstradelog.Quality       = goodsinfo.Quality;
                        goodstradelog.Categoryid    = goodsinfo.Categoryid;
                        goodstradelog.Tax           = 0;
                        goodstradelog.Locus         = goodsinfo.Locus;
                        goodstradelog.Seller        = goodsinfo.Seller;
                        goodstradelog.Sellerid      = goodsinfo.Selleruid;
                        goodstradelog.Selleraccount = goodsinfo.Account;
                        goodstradelog.Buyerid       = userid;
                        goodstradelog.Buyer         = username;
                        goodstradelog.Buyercontact  = DNTRequest.GetString("buyercontact");
                        goodstradelog.Buyercredit   = 0;
                        goodstradelog.Buyermsg      = DNTRequest.GetString("buyermsg");
                        goodstradelog.Lastupdate    = DateTime.Now;
                        goodstradelog.Buyername     = DNTRequest.GetString("buyername");
                        goodstradelog.Buyerzip      = DNTRequest.GetString("buyerzip");
                        goodstradelog.Buyerphone    = DNTRequest.GetString("buyerphone");
                        goodstradelog.Buyermobile   = DNTRequest.GetString("buyermobile");
                        goodstradelog.Transport     = goodsinfo.Transport;
                        goodstradelog.Baseprice     = goodsinfo.Costprice;
                        goodstradelog.Discount      = goodsinfo.Discount;
                        goodstradelog.Ratestatus    = 0;
                        goodstradelog.Message       = "";
                    }

                    if (isseller) //当为卖家时
                    {
                        goodstradelog.Transportfee = DNTRequest.GetInt("fee", 0);
                    }
                }

                if (TradeLogs.UpdateTradeLog(goodstradelog, oldstatus, true))
                {
                    SetUrl("offlinetrade.aspx?goodstradelogid=" + goodstradelogid);
                    SetMetaRefresh();
                    AddMsgLine("交易单已更新, 现在转入交易单页面<br />(<a href=\"" + "offlinetrade.aspx?goodstradelogid=" + goodstradelogid + "\">如果您的浏览器没有自动跳转, 请点击这里</a>)<br />");
                }
            }
        }
示例#2
0
        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易服务
            {
                AddErrLine("系统未开启交易服务, 当前页面暂时无法访问!");
                return;
            }

            headerad = "";
            footerad = "";
            floatad  = "";

            // 如果商品交易日志不正确
            if (goodstradelogid <= 0)
            {
                AddErrLine("无效的交易日志信息.");
                return;
            }

            goodstradelog = TradeLogs.GetGoodsTradeLogInfo(goodstradelogid);
            int oldstatus = goodstradelog.Status;

            if (config.Enablemall == 1) //开启普通模式
            {
                forumid   = GoodsCategories.GetCategoriesFid(goodstradelog.Categoryid);
                forum     = Forums.GetForumInfo(forumid);
                forumname = forum.Name;
                forumnav  = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                forumid = 0;
            }

            ///得到广告列表
            ///头部
            headerad = Advertisements.GetOneHeaderAd("", forumid);
            footerad = Advertisements.GetOneFooterAd("", forumid);
            doublead = Advertisements.GetDoubleAd("", forumid);
            floatad  = Advertisements.GetFloatAd("", forumid);

            pagetitle   = goodstradelog.Subject;
            navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);

            if (useradminid != 0)
            {
                if (config.Enablemall == 1) //开启普通模式
                {
                    ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0;
                }

                //得到管理组信息
                admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            }
            //验证不通过则返回
            if (!IsConditionsValid())
            {
                return;
            }

            if (goodstradelog.Status == 7 || goodstradelog.Status == 17)
            {
                israted = GoodsRates.CanRate(goodstradelog.Id, userid) ? false : true; //如果当前用户已评价过则不允许再评价
            }
            if (DNTRequest.GetString("pay") == "yes")
            {
                ispay = true;
                string alipayurl = GetAliPayUrl();
                SetUrl(alipayurl);
                SetMetaRefresh();
                AddMsgLine("正在提交编号为 " + goodstradelog.Tradeno + " 的订单<br />(<a href=\"" + alipayurl + "\">如果您的浏览器没有自动跳转, 请点击这里</a>)<br />");
                return;
            }


            //如果是提交则更新商品交易日志
            if (ispost)
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                //当为买家时
                if (isbuyer)
                {
                    goodstradelog.Quality       = goodsinfo.Quality;
                    goodstradelog.Categoryid    = goodsinfo.Categoryid;
                    goodstradelog.Tax           = 0;
                    goodstradelog.Locus         = goodsinfo.Locus;
                    goodstradelog.Seller        = goodsinfo.Seller;
                    goodstradelog.Sellerid      = goodsinfo.Selleruid;
                    goodstradelog.Selleraccount = goodsinfo.Account;
                    goodstradelog.Buyerid       = userid;
                    goodstradelog.Buyer         = username;
                    goodstradelog.Buyercontact  = DNTRequest.GetString("buyercontact");
                    goodstradelog.Buyercredit   = 0;
                    goodstradelog.Buyermsg      = DNTRequest.GetString("buyermsg");
                    goodstradelog.Status        = 0;
                    goodstradelog.Lastupdate    = DateTime.Now;
                    goodstradelog.Buyername     = DNTRequest.GetString("buyername");
                    goodstradelog.Buyerzip      = DNTRequest.GetString("buyerzip");
                    goodstradelog.Buyerphone    = DNTRequest.GetString("buyerphone");
                    goodstradelog.Buyermobile   = DNTRequest.GetString("buyermobile");
                    goodstradelog.Transport     = goodsinfo.Transport;
                    goodstradelog.Baseprice     = goodsinfo.Costprice;
                    goodstradelog.Discount      = goodsinfo.Discount;
                    goodstradelog.Ratestatus    = 0;
                    goodstradelog.Message       = "";
                }
                else //当为卖家时
                {
                    goodstradelog.Transportfee = DNTRequest.GetInt("fee", 0);
                }

                if (TradeLogs.UpdateTradeLog(goodstradelog, oldstatus))
                {
                    SetUrl("onlinetrade.aspx?goodstradelogid=" + goodstradelogid);
                    SetMetaRefresh();
                    AddMsgLine("交易单已更新, 现在转入交易单页面<br />(<a href=\"" + "onlinetrade.aspx?goodstradelogid=" + goodstradelogid + "\">如果您的浏览器没有自动跳转, 请点击这里</a>)<br />");
                }
            }
        }
示例#3
0
        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易服务
            {
                AddErrLine("系统未开启交易服务, 当前页面暂时无法访问!");
                return;
            }

            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }

            headerad = "";
            footerad = "";

            // 如果商品交易日志不正确
            if (goodstradelogid <= 0)
            {
                AddErrLine("无效的交易日志信息.");
                return;
            }

            goodstradelog = TradeLogs.GetGoodsTradeLogInfo(goodstradelogid);
            int oldstatus = goodstradelog.Status;

            if (config.Enablemall == 1) //开启普通模式
            {
                forumid = GoodsCategories.GetCategoriesFid(goodstradelog.Categoryid);
            }
            else
            {
                forumid = 0;
            }

            ///得到广告列表
            ///头部
            headerad = Advertisements.GetOneHeaderAd("", forumid);
            footerad = Advertisements.GetOneFooterAd("", forumid);
            doublead = Advertisements.GetDoubleAd("", forumid);
            floatad  = Advertisements.GetFloatAd("", forumid);

            if (goodstradelog.Sellerid != userid && goodstradelog.Buyerid != userid)
            {
                AddErrLine("您的身份不是买卖双方, 因为不能评价");
                return;
            }
            if (goodstradelog.Status != 7 && goodstradelog.Status != 17)
            {
                AddErrLine("交易尚未结束, 因为不能评价");
                return;
            }
            if (!GoodsRates.CanRate(goodstradelog.Id, userid)) //如果当前用户已评价过则不允许再评价
            {
                AddErrLine("不能重复评价");
                return;
            }


            //如果是提交...
            if (ispost)
            {
                Goodsrateinfo goodsrateinfo = new Goodsrateinfo();
                goodsrateinfo.Ip              = DNTRequest.GetIP();
                goodsrateinfo.Postdatetime    = DateTime.Now;
                goodsrateinfo.Price           = goodstradelog.Number * goodstradelog.Price + goodstradelog.Transportfee;
                goodsrateinfo.Ratetype        = DNTRequest.GetInt("ratetype", 0);
                goodsrateinfo.Uid             = userid;
                goodsrateinfo.Username        = username;
                goodsrateinfo.Message         = DNTRequest.GetString("message");
                goodsrateinfo.Goodstradelogid = goodstradelog.Id;
                goodsrateinfo.Goodstitle      = goodstradelog.Subject;
                goodsrateinfo.Goodsid         = goodstradelog.Goodsid;
                goodsrateinfo.Explain         = "";

                if (goodstradelog.Buyerid == userid)  //买家
                {
                    goodsrateinfo.Uidtype        = 2;
                    goodsrateinfo.Ratetouid      = goodstradelog.Sellerid;
                    goodsrateinfo.Ratetousername = goodstradelog.Seller;
                    goodstradelog.Ratestatus     = 2;
                }
                else //卖家
                {
                    goodsrateinfo.Uidtype        = 1;
                    goodsrateinfo.Ratetouid      = goodstradelog.Buyerid;
                    goodsrateinfo.Ratetousername = goodstradelog.Buyer;
                    goodstradelog.Ratestatus     = 1;
                }
                if (GoodsRates.CreateGoodsRate(goodsrateinfo) > 0) //如果评价成功
                {
                    if (GoodsRates.RateClosed(goodsrateinfo.Goodstradelogid, goodstradelog.Sellerid, goodstradelog.Buyerid))
                    {
                        goodstradelog.Ratestatus = 3;
                        TradeLogs.UpdateTradeLog(goodstradelog, oldstatus); //更新交易的评价状态
                    }

                    GoodsUserCredits.SetUserCredit(goodsrateinfo, goodsrateinfo.Uidtype == 1 ? goodstradelog.Buyerid : goodstradelog.Sellerid);

                    SetUrl(base.ShowGoodsAspxRewrite(goodsrateinfo.Goodsid));
                    SetMetaRefresh();
                    AddMsgLine("您的评价已经成功<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsrateinfo.Goodsid) + "\">点击这里返回商品页面</a>)<br />");
                }
            }
        }
示例#4
0
        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易服务
            {
                AddErrLine("系统未开启交易服务, 当前页面暂时无法访问!");
                return;
            }
            else
            {
                goodscategoryfid = Discuz.Mall.GoodsCategories.GetGoodsCategoryWithFid();
            }

            headerad = "";
            footerad = "";
            floatad  = "";

            disablepostctrl = 0;

            // 如果商品ID无效
            if (goodsid == -1)
            {
                AddErrLine("无效的商品ID");
                return;
            }

            goodsinfo = Goods.GetGoodsInfo(goodsid);
            if (goodsinfo == null || goodsinfo.Closed > 1)
            {
                AddErrLine("不存在的商品ID");
                headerad = Advertisements.GetOneHeaderAd("", 0);
                footerad = Advertisements.GetOneFooterAd("", 0);
                floatad  = Advertisements.GetFloatAd("", 0);
                return;
            }

            UserInfo userinfo = Users.GetUserInfo(goodsinfo.Selleruid);

            if (userinfo != null)
            {
                joindate = Convert.ToDateTime(userinfo.Joindate).ToString("yyyy-MM-dd");
            }

            sb_usercredit       = GoodsUserCredits.GetUserCreditJsonData(goodsinfo.Selleruid);
            creditrulesjsondata = GoodsUserCredits.GetCreditRulesJsonData().ToString();

            if (config.Enablemall == 1) //开启普通模式
            {
                forumid = GoodsCategories.GetCategoriesFid(goodsinfo.Categoryid);
                forum   = Forums.GetForumInfo(forumid);
                if (forum == null)
                {
                    AddErrLine("当前商品所属分类未绑定相应版块");
                    return;
                }

                forumname = forum.Name;
                forumnav  = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);

                ///得到广告列表
                ///头部
                headerad = Advertisements.GetOneHeaderAd("", forumid);
                footerad = Advertisements.GetOneFooterAd("", forumid);
                doublead = Advertisements.GetDoubleAd("", forumid);
                floatad  = Advertisements.GetFloatAd("", forumid);

                // 检查是否具有版主的身份
                if (useradminid != 0)
                {
                    ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0;
                    //得到管理组信息
                    admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
                    if (admininfo != null)
                    {
                        disablepostctrl = admininfo.Disablepostctrl;
                    }
                }
            }
            goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(goodsinfo.Categoryid);
            pagetitle         = goodsinfo.Title;
            navhomemenu       = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);

            //验证不通过则返回
            if (!IsConditionsValid())
            {
                return;
            }

            //编辑器状态
            StringBuilder sb = new StringBuilder("var Allowhtml=1;\r\n");

            parseurloff = 0;
            bbcodeoff   = 1;
            if (config.Enablemall == 1) //开启普通模式
            {
                smileyoff = 1 - forum.Allowsmilies;

                if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1)
                {
                    bbcodeoff = 0;
                }

                allowimg = forum.Allowimgcode;
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                if (usergroupinfo.Allowcusbbcode == 1)
                {
                    bbcodeoff = 0;
                }

                allowimg = 1;
            }

            sb.Append("var Allowsmilies=" + (1 - smileyoff) + ";\r\n");
            sb.Append("var Allowbbcode=" + (1 - bbcodeoff) + ";\r\n");
            usesig = ForumUtils.GetCookie("sigstatus") == "0" ? 0 : 1;
            sb.Append("var Allowimgcode=" + allowimg + ";\r\n");

            AddScript(sb.ToString());

            if (config.Enablemall == 2)
            {
                recommendgoodslist = Goods.GetGoodsRecommendList(goodsinfo.Selleruid, 6, 1,
                                                                 DbProvider.GetInstance().GetGoodsIdCondition((int)MallUtils.OperaCode.NoEuqal, goodsinfo.Goodsid));
            }

            smilietypes = Caches.GetSmilieTypesCache();

            if (newpmcount > 0)
            {
                pmlist     = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1);
                showpmhint = Convert.ToInt32(Users.GetShortUserInfo(userid).Newsletter) > 4;
            }


            // 得到pptradelog设置
            pptradelog = Utils.StrToInt(ForumUtils.GetCookie("ppp"), config.Ppp);
            if (pptradelog <= 0)
            {
                pptradelog = config.Ppp;
            }

            //快速发帖广告
            if (config.Enablemall == 1) //开启普通模式
            {
                quickeditorad = Advertisements.GetQuickEditorAD("", forumid);
            }

            //更新页面Meta中的Description项, 提高SEO友好性
            string metadescritpion = Utils.RemoveHtml(goodsinfo.Message);

            metadescritpion = metadescritpion.Length > 100 ? metadescritpion.Substring(0, 100) : metadescritpion;
            UpdateMetaInfo(config.Seokeywords, metadescritpion, config.Seohead);

            GoodspramsInfo goodspramsInfo = new GoodspramsInfo();

            goodspramsInfo.Goodsid = goodsinfo.Goodsid;

            if (config.Enablemall == 1) //开启普通模式
            {
                goodspramsInfo.Fid           = forum.Fid;
                goodspramsInfo.Jammer        = forum.Jammer;
                goodspramsInfo.Getattachperm = forum.Getattachperm;
                goodspramsInfo.Showimages    = forum.Allowimgcode;
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                goodspramsInfo.Jammer        = 0;
                goodspramsInfo.Getattachperm = "";
                goodspramsInfo.Showimages    = 1;
            }
            goodspramsInfo.Pageindex          = pageid;
            goodspramsInfo.Usergroupid        = usergroupid;
            goodspramsInfo.Attachimgpost      = config.Attachimgpost;
            goodspramsInfo.Showattachmentpath = config.Showattachmentpath;
            goodspramsInfo.Hide  = 0;
            goodspramsInfo.Price = 0;
            goodspramsInfo.Usergroupreadaccess = usergroupinfo.Readaccess;

            if (ismoder == 1)
            {
                goodspramsInfo.Usergroupreadaccess = int.MaxValue;
            }

            goodspramsInfo.CurrentUserid          = userid;
            goodspramsInfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
            goodspramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
            goodspramsInfo.Smiliesmax             = config.Smiliesmax;
            goodspramsInfo.Bbcodemode             = config.Bbcodemode;
            goodspramsInfo.CurrentUserGroup       = usergroupinfo;
            goodspramsInfo.Sdetail     = goodsinfo.Message;
            goodspramsInfo.Smileyoff   = goodsinfo.Smileyoff;
            goodspramsInfo.Bbcodeoff   = goodsinfo.Bbcodeoff;
            goodspramsInfo.Parseurloff = goodsinfo.Parseurloff;
            goodspramsInfo.Allowhtml   = 1;
            goodspramsInfo.Sdetail     = goodsinfo.Message;

            message = Goods.MessgeTranfer(goodspramsInfo, GoodsAttachments.GetGoodsAttachmentsByGoodsid(goodsinfo.Goodsid));

            forumlistboxoptions = Caches.GetForumListBoxOptionsCache();
            tradecount          = TradeLogs.GetGoodsTradeLogCount(goodsid);
            leavewordcount      = GoodsLeaveWords.GetGoodsLeaveWordCount(goodsid);
            pptradelog          = 16;

            ForumUtils.WriteCookie("referer", string.Format(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid)));

            if (config.Enablemall == 1) //开启普通模式
            {
                ForumUtils.UpdateVisitedForumsOptions(forumid);
            }

            visitedforumsoptions = ForumUtils.GetVisitedForumsOptions(config.Visitedforums);

            //删除留言
            if (DNTRequest.GetInt("deleteleaveword", 0) == 1)
            {
                isdeleteop = true;
                int leavewordid = DNTRequest.GetInt("leavewordid", 0);

                if (leavewordid <= 0)
                {
                    AddErrLine("您要删除的留言已被删除, 现在转入商品页面");
                    return;
                }
                if (GoodsLeaveWords.DeleteLeaveWordById(leavewordid, userid, goodsinfo.Selleruid, useradminid))
                {
                    SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid));
                    SetMetaRefresh();
                    AddMsgLine("该留言已被删除, 现在转入商品页面<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">如果您的浏览器没有自动跳转, 请点击这里</a>)<br />");
                    return;
                }
                else
                {
                    AddErrLine("您的用户身份无效删除该留言, 现在转入商品页面");
                    return;
                }
            }

            //删除商品
            if (DNTRequest.GetInt("deletegoods", 0) == 1)
            {
                isdeleteop = true;
                //是否为卖家或版主
                if (Goods.IsSeller(goodsinfo.Goodsid.ToString(), userid) || ismoder == 1)
                {
                    Goods.DeleteGoods(goodsinfo.Goodsid.ToString(), false);

                    SetUrl(this.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1));
                    SetMetaRefresh();
                    AddMsgLine("操作成功. <br />(<a href=\"" + this.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1) + "\">点击这里返回</a>)<br />");
                    return;
                }
                else
                {
                    AddErrLine("你不是当前商品的卖家或版主,因此无法删除该商品");
                    return;
                }
            }


            //如果是提交
            if (ispost)
            {
                //如果不是提交...
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                if (DNTRequest.GetString("postleaveword") == "add")
                {
                    //当验证密码正确后,则发送相应留言
                    Goodsleavewordinfo goodsleavewordinfo = new Goodsleavewordinfo();
                    goodsleavewordinfo.Ip         = DNTRequest.GetIP();
                    goodsleavewordinfo.Goodsid    = goodsinfo.Goodsid;
                    goodsleavewordinfo.Tradelogid = 0;
                    goodsleavewordinfo.Uid        = userid;
                    goodsleavewordinfo.Username   = username;
                    goodsleavewordinfo.Message    = DNTRequest.GetString("message");
                    goodsleavewordinfo.Isbuyer    = goodsinfo.Selleruid != userid ? 1 : 0;
                    if (GoodsLeaveWords.CreateLeaveWord(goodsleavewordinfo, goodsinfo.Selleruid, DNTRequest.GetString("sendnotice") == "on" ? true : false) > 0)
                    {
                        SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid));
                        SetMetaRefresh();
                        AddMsgLine("您的留言已发布, 现在转入商品页面<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">如果您的浏览器没有自动跳转, 请点击这里</a>)<br />");
                    }
                }
                else
                {
                    //当验证密码正确后,则发送相应留言
                    Goodsleavewordinfo goodsleavewordinfo = GoodsLeaveWords.GetGoodsLeaveWordById(DNTRequest.GetInt("leavewordid", 0));
                    if (goodsleavewordinfo != null && goodsleavewordinfo.Id > 0)
                    {
                        goodsleavewordinfo.Ip           = DNTRequest.GetIP();
                        goodsleavewordinfo.Uid          = userid;
                        goodsleavewordinfo.Username     = username;
                        goodsleavewordinfo.Message      = DNTRequest.GetString("message");
                        goodsleavewordinfo.Postdatetime = DateTime.Now;
                        if (GoodsLeaveWords.UpdateLeaveWord(goodsleavewordinfo))
                        {
                            SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid));
                            SetMetaRefresh();
                            AddMsgLine("留言更新成功, 现在转入商品页面<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">如果您的浏览器没有自动跳转, 请点击这里</a>)<br />");
                        }
                    }
                    else
                    {
                        AddErrLine("当前留言不存在或已被删除");
                        return;
                    }
                }
            }
            else
            {
                goodsinfo.Viewcount += 1; //浏览量加1
                Goods.UpdateGoods(goodsinfo);
            }
        }
示例#5
0
        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易模式
            {
                AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!");
                return;
            }

            #region 临时帐号发帖
            //int realuserid = -1;
            //string tempusername = DNTRequest.GetString("tempusername");
            //if (tempusername != "" && tempusername != username)
            //{
            //    string temppassword = DNTRequest.GetString("temppassword");
            //    int question = DNTRequest.GetInt("question", 0);
            //    string answer = DNTRequest.GetString("answer");
            //    realuserid = Users.CheckTempUserInfo(tempusername, temppassword, question, answer);
            //    if (realuserid == -1)
            //    {
            //        AddErrLine("临时帐号登录失败,无法继续发帖。");
            //        return;
            //    }
            //    else
            //    {
            //        userid = realuserid;
            //        username = tempusername;
            //        usergroupinfo = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(userid).Groupid);
            //        usergroupid = usergroupinfo.Groupid;
            //        useradminid = Users.GetShortUserInfo(userid).Adminid;
            //    }
            //}
            #endregion

            #region 获取分类对象信息
            int categoryid = DNTRequest.GetInt("categoryid", -1);

            //如果是提交...
            if (ispost)
            {
                categoryid = DNTRequest.GetInt("goodscategoryid", -1);
            }

            if (categoryid > 0)
            {
                goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(categoryid);
            }

            if (goodscategoryinfo == null)
            {
                goodscategoryinfo            = new Goodscategoryinfo();
                goodscategoryinfo.Categoryid = -1;
            }

            if (goodscategoryinfo.Fid <= 0)
            {
                allowpostgoods = false;
                forumnav       = "";
                AddErrLine("错误的商品分类ID");
                return;
            }
            #endregion

            canhtmltitle     = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup);
            firstpagesmilies = Caches.GetSmiliesFirstPageCache();

            //内容设置为空;
            message = "";

            if (config.Enablemall == 1) //开启普通模式
            {
                forumid  = GoodsCategories.GetCategoriesFid(categoryid);
                forumnav = "";
                if (forumid == -1)
                {
                    allowpostgoods = false;
                    AddErrLine("错误的商品分类ID");
                    return;
                }
                else
                {
                    forum = Forums.GetForumInfo(forumid);
                    if (forum == null || forum.Layer == 0)
                    {
                        allowpostgoods = false;
                        AddErrLine("错误的商品分类ID");
                        return;
                    }

                    if (forum.Istrade <= 0)
                    {
                        allowpostgoods = false;
                        AddErrLine("当前版块不允许发布商品");
                        return;
                    }

                    forumname = forum.Name;
                    pagetitle = Utils.RemoveHtml(forum.Name);
                    forumnav  = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
                    enabletag = (config.Enabletag & forum.Allowtag) == 1;
                }
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                pagetitle          = "发布商品";
                forumnav           = "";
                enabletag          = true;
                forum              = new ForumInfo();
                forum.Allowsmilies = 1;
                forum.Allowbbcode  = 1;
            }

            //得到用户可以上传的文件类型
            StringBuilder sbAttachmentTypeSelect = new StringBuilder();
            if (!usergroupinfo.Attachextensions.Trim().Equals(""))
            {
                sbAttachmentTypeSelect.Append("[id] in (");
                sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions);
                sbAttachmentTypeSelect.Append(")");
            }
            if (config.Enablemall == 1) //开启普通模式
            {
                if (!forum.Attachextensions.Equals(""))
                {
                    if (sbAttachmentTypeSelect.Length > 0)
                    {
                        sbAttachmentTypeSelect.Append(" AND ");
                    }
                    sbAttachmentTypeSelect.Append("[id] in (");
                    sbAttachmentTypeSelect.Append(forum.Attachextensions);
                    sbAttachmentTypeSelect.Append(")");
                }
            }
            attachextensions       = Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString());
            attachextensionsnosize = Attachments.GetAttachmentTypeString(sbAttachmentTypeSelect.ToString());

            //得到今天允许用户上传的附件总大小(字节)
            int MaxTodaySize = 0;
            if (userid > 0)
            {
                MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid); //今天已上传大小
            }
            attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;          //今天可上传得大小

            parseurloff = 0;
            bbcodeoff   = 1;

            if (config.Enablemall == 1) //开启普通模式
            {
                smileyoff = 1 - forum.Allowsmilies;
                allowimg  = forum.Allowimgcode;

                if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1)
                {
                    bbcodeoff = 0;
                }
            }


            // 如果当前用户非管理员并且论坛设定了禁止发布商品时间段,当前时间如果在其中的一个时间段内,不允许用户发布商品
            if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1)
            {
                string visittime = "";
                if (Scoresets.BetweenTime(config.Postbanperiods, out visittime))
                {
                    AddErrLine("在此时间段( " + visittime + " )内用户不可以发布商品");
                    return;
                }
            }

            if (config.Enablemall == 1) //开启普通模式
            {
                if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password"))
                {
                    AddErrLine("本版块被管理员设置了密码");
                    SetBackLink(base.ShowForumAspxRewrite(forumid, 0));
                    return;
                }

                if (!Forums.AllowViewByUserId(forum.Permuserlist, userid))        //判断当前用户在当前版块浏览权限
                {
                    if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限
                    {
                        if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1))
                        {
                            AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限");
                            return;
                        }
                    }
                    else//当板块权限不为空,按照板块权限
                    {
                        if (!Forums.AllowView(forum.Viewperm, usergroupid))
                        {
                            AddErrLine("您没有发布商品的权限");
                            return;
                        }
                    }
                }

                if (!Forums.AllowPostByUserID(forum.Permuserlist, userid))        //判断当前用户在当前版块发布商品权限
                {
                    if (forum.Postperm == null || forum.Postperm == string.Empty) //权限设置为空时,根据用户组权限判断
                    {
                        // 验证用户是否有发布商品的权限
                        if (useradminid != 1 && usergroupinfo.Allowtrade != 1)
                        {
                            AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限");
                            return;
                        }
                    }
                    else//权限设置不为空时,根据板块权限判断
                    {
                        if (!Forums.AllowPost(forum.Postperm, usergroupid))
                        {
                            AddErrLine("您没有发布商品的权限");
                            return;
                        }
                    }
                }

                //是否有上传附件的权限
                if (Forums.AllowPostAttachByUserID(forum.Permuserlist, userid))
                {
                    canpostattach = true;
                }
                else
                {
                    if (forum.Postattachperm == "")
                    {
                        if (usergroupinfo.Allowpostattach == 1)
                        {
                            canpostattach = true;
                        }
                    }
                    else
                    {
                        if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid))
                        {
                            canpostattach = true;
                        }
                    }
                }
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                canpostattach = true;
                allowimg      = 1;
                smileyoff     = 0;
            }


            ShortUserInfo user = Users.GetShortUserInfo(userid);
            if (canpostattach && user != null && apb != null && config.Enablealbum == 1 &&
                (UserGroups.GetUserGroupInfo(user.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0))
            {
                caninsertalbum = true;
                albumlist      = apb.GetSpaceAlbumByUserId(userid);
            }
            else
            {
                caninsertalbum = false;
            }

            // 如果是受灌水限制用户, 则判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            disablepost = 0;
            if (admininfo != null)
            {
                disablepost = admininfo.Disablepostctrl;
            }

            if (admininfo == null || admininfo.Disablepostctrl != 1)
            {
                int Interval = Utils.StrDateDiffSeconds(lastposttime, config.Postinterval);
                if (Interval < 0)
                {
                    AddErrLine("系统规定发布商品间隔为" + config.Postinterval.ToString() + "秒, 您还需要等待 " + (Interval * -1).ToString() + " 秒");
                    return;
                }
                else if (userid != -1)
                {
                    ShortUserInfo shortUserInfo = Discuz.Data.Users.GetShortUserInfo(userid);
                    string        joindate      = (shortUserInfo != null) ? shortUserInfo.Joindate : "";
                    if (joindate == "")
                    {
                        AddErrLine("您的用户资料出现错误");
                        return;
                    }

                    Interval = Utils.StrDateDiffMinutes(joindate, config.Newbiespan);
                    if (Interval < 0)
                    {
                        AddErrLine("系统规定新注册用户必须要在" + config.Newbiespan.ToString() + "分钟后才可以发布商品, 您还需要等待 " + (Interval * -1).ToString() + " 分");
                        return;
                    }
                }
            }

            creditstrans       = Scoresets.GetCreditsTrans();
            userextcreditsinfo = Scoresets.GetScoreSet(creditstrans);

            if (userid > 0)
            {
                spaceid = Users.GetShortUserInfo(userid).Spaceid;
            }

            //如果不是提交...
            if (!ispost)
            {
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
                smilies           = Caches.GetSmiliesCache();
                smilietypes       = Caches.GetSmilieTypesCache();
                customeditbuttons = Caches.GetCustomEditButtonList();
            }
            else
            {
                SetBackLink(string.Format("postgoods.aspx?categoryid={0}&restore=1", categoryid));

                string postmessage = DNTRequest.GetString("message");

                ForumUtils.WriteCookie("postmessage", postmessage);

                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                if (DNTRequest.GetString("title").Trim().Equals(""))
                {
                    AddErrLine("商品标题不能为空");
                }
                else if (DNTRequest.GetString("title").IndexOf(" ") != -1)
                {
                    AddErrLine("商品标题不能包含全角空格符");
                }
                else if (DNTRequest.GetString("title").Length > 60)
                {
                    AddErrLine("商品标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length + " 个字符");
                }

                if (postmessage.Equals("") || postmessage.Replace(" ", "").Equals(""))
                {
                    AddErrLine("商品内容不能为空");
                }

                if (admininfo != null && admininfo.Disablepostctrl != 1)
                {
                    if (postmessage.Length < config.Minpostsize)
                    {
                        AddErrLine("您发表的内容过少, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字");
                    }
                    else if (postmessage.Length > config.Maxpostsize)
                    {
                        AddErrLine("您发表的内容过多, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字");
                    }
                }

                //新用户广告强力屏蔽检查
                if (config.Disablepostad == 1 || userid == -1)  //如果开启新用户广告强力屏蔽检查或是游客
                {
                    if (userid == -1 || (config.Disablepostadpostcount != 0 && user.Posts <= config.Disablepostadpostcount) ||
                        (config.Disablepostadregminute != 0 && DateTime.Now.AddMinutes(-config.Disablepostadregminute) <= Convert.ToDateTime(user.Joindate)))
                    {
                        foreach (string regular in config.Disablepostadregular.Replace("\r", "").Split('\n'))
                        {
                            if (Posts.IsAD(regular, DNTRequest.GetString("title"), postmessage))
                            {
                                AddErrLine("发布商品失败,商品内容中似乎有广告信息,请检查标题和内容,如有疑问请与管理员联系");
                                return;
                            }
                        }
                    }
                }

                if (IsErr())
                {
                    return;
                }

                // 如果用户上传了附件,则检测用户是否有上传附件的权限
                if (ForumUtils.IsPostFile())
                {
                    if (Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()).Trim() == "")
                    {
                        AddErrLine("系统不允许上传附件");
                    }

                    if (config.Enablemall == 1) //开启普通模式
                    {
                        if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid))
                        {
                            if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid))
                            {
                                AddErrLine("您没有在该版块上传附件的权限");
                            }
                            else if (usergroupinfo.Allowpostattach != 1)
                            {
                                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle));
                            }
                        }
                    }
                }

                if (IsErr())
                {
                    return;
                }

                int iconid = DNTRequest.GetInt("iconid", 0);
                if (iconid > 15 || iconid < 0)
                {
                    iconid = 0;
                }

                string curdatetime = Utils.GetDateTime();

                Goodsinfo goodsinfo = new Goodsinfo();

                //当在高级模式下则绑定相应店铺信息
                if (config.Enablemall == 2)
                {
                    Shopinfo shopinfo = Shops.GetShopByUserId(user.Uid);
                    if (shopinfo != null)
                    {
                        goodsinfo.Shopid = shopinfo.Shopid;
                    }
                }
                goodsinfo.Categoryid         = goodscategoryinfo.Categoryid;
                goodsinfo.Parentcategorylist = goodscategoryinfo.Parentidlist;
                goodsinfo.Recommend          = DNTRequest.GetString("recommend") == "on" ? 1 : 0;
                goodsinfo.Discount           = DNTRequest.GetInt("discount", 0);
                goodsinfo.Selleruid          = userid;
                goodsinfo.Seller             = username;
                goodsinfo.Account            = DNTRequest.GetString("account");
                goodsinfo.Price     = Convert.ToDecimal(DNTRequest.GetFormFloat("price", 1).ToString());
                goodsinfo.Amount    = DNTRequest.GetInt("amount", 0);
                goodsinfo.Quality   = DNTRequest.GetInt("quality", 0);
                goodsinfo.Lid       = DNTRequest.GetInt("locus_2", 0);
                goodsinfo.Locus     = Locations.GetLocusByLID(goodsinfo.Lid);
                goodsinfo.Transport = DNTRequest.GetInt("transport", 0);
                if (goodsinfo.Transport != 0)
                {
                    goodsinfo.Ordinaryfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_mail", 0).ToString());
                    goodsinfo.Expressfee  = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_express", 0).ToString());
                    goodsinfo.Emsfee      = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_ems", 0).ToString());
                }
                goodsinfo.Itemtype = DNTRequest.GetInt("itemtype", 0);

                DateTime dateline;
                switch (DNTRequest.GetInt("_now", 0))
                {
                case 1: dateline = Convert.ToDateTime(string.Format("{0} {1}:{2}:00", DNTRequest.GetString("_date"), DNTRequest.GetInt("_hour", 0), DNTRequest.GetInt("_minute", 0))); break; //设定

                case 2: dateline = Convert.ToDateTime("1900-01-01 00:00:00"); break;                                                                                                          //返回100年之后的日期作为"暂不设置"

                default: dateline = DateTime.Now; break;                                                                                                                                      //立即
                }

                goodsinfo.Dateline   = dateline;
                goodsinfo.Expiration = Convert.ToDateTime(DNTRequest.GetString("expiration"));
                goodsinfo.Lastbuyer  = "";
                goodsinfo.Lasttrade  = Convert.ToDateTime("1900-01-01 00:00:00");
                goodsinfo.Lastupdate = Convert.ToDateTime(Utils.GetDateTime());
                goodsinfo.Totalitems = 0;
                goodsinfo.Tradesum   = 0;
                goodsinfo.Closed     = 0;
                goodsinfo.Aid        = 0;
                goodsinfo.Costprice  = Convert.ToDecimal(DNTRequest.GetFormFloat("costprice", 1).ToString());
                goodsinfo.Invoice    = DNTRequest.GetInt("invoice", 0);
                goodsinfo.Repair     = DNTRequest.GetInt("repair", 0);
                if (useradminid == 1)
                {
                    goodsinfo.Message = Utils.HtmlEncode(postmessage);
                }
                else
                {
                    goodsinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage));
                }

                goodsinfo.Otherlink = "";
                int readperm = DNTRequest.GetInt("readperm", 0);
                goodsinfo.Readperm  = readperm > 255 ? 255 : readperm;
                goodsinfo.Tradetype = DNTRequest.GetInt("tradetype", 0);

                if (goodsinfo.Tradetype == 1 && Utils.StrIsNullOrEmpty(goodsinfo.Account)) //当为支付宝在线支付方式下,如果"支付宝账户"为空时
                {
                    AddErrLine("请输入支付宝帐号信息。");
                    return;
                }

                goodsinfo.Viewcount    = 0;
                goodsinfo.Displayorder = DNTRequest.GetString("displayorder") == "on" ? 0 : -3;

                if (config.Enablemall == 1) //当为版块交易帖是时
                {
                    if (forum.Modnewposts == 1 && useradminid != 1)
                    {
                        if (useradminid > 1)
                        {
                            if (disablepost != 1)
                            {
                                goodsinfo.Displayorder = -2;
                                disablepost            = 0;
                            }
                        }
                        else
                        {
                            goodsinfo.Displayorder = -2;
                            disablepost            = 0;
                        }
                    }
                }

                goodsinfo.Smileyoff = smileyoff;
                if (smileyoff == 0 && forum.Allowsmilies == 1)
                {
                    goodsinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0);
                }

                goodsinfo.Bbcodeoff = 1;
                if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1)
                {
                    goodsinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0);
                }

                goodsinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0);

                if (useradminid == 1)
                {
                    goodsinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title"));
                }
                else
                {
                    goodsinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title")));
                }

                string htmltitle = DNTRequest.GetString("htmltitle").Trim();
                if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != goodsinfo.Title)
                {
                    goodsinfo.Magic = 11000;
                    //按照  附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储
                    //例: 11001
                }

                //标签(Tag)操作
                string   tags      = DNTRequest.GetString("tags").Trim();
                string[] tagsArray = null;
                if (enabletag && tags != string.Empty)
                {
                    tagsArray = Utils.SplitString(tags, " ", true, 2, 10);
                    if (tagsArray.Length > 0)
                    {
                        if (goodsinfo.Magic == 0)
                        {
                            goodsinfo.Magic = 10000;
                        }

                        goodsinfo.Magic = Utils.StrToInt(goodsinfo.Magic.ToString() + "1", 0);
                    }
                }

                goodsinfo.Goodsid = Goods.CreateGoods(goodsinfo);
                //保存htmltitle
                if (canhtmltitle && htmltitle != string.Empty && htmltitle != goodsinfo.Title)
                {
                    Goods.WriteHtmlSubjectFile(htmltitle, goodsinfo.Goodsid);
                }

                if (enabletag && tagsArray != null && tagsArray.Length > 0)
                {
                    DbProvider.GetInstance().CreateGoodsTags(string.Join(" ", tagsArray), goodsinfo.Goodsid, userid, curdatetime);
                    GoodsTags.WriteGoodsTagsCacheFile(goodsinfo.Goodsid);
                }

                StringBuilder sb = new StringBuilder();
                sb.Remove(0, sb.Length);

                int watermarkstatus = (forum.Disablewatermark == 1) ? 0 : config.Watermarkstatus;

                Goodsattachmentinfo[] attachmentinfo = Discuz.Mall.MallUtils.SaveRequestFiles(categoryid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile");
                if (attachmentinfo != null)
                {
                    if (attachmentinfo.Length > config.Maxattachments)
                    {
                        AddErrLine("系统设置为每个商品附件不得多于" + config.Maxattachments + "个");
                        return;
                    }
                    int    errorAttachment = GoodsAttachments.BindAttachment(attachmentinfo, goodsinfo.Goodsid, sb, goodsinfo.Categoryid, userid);
                    int[]  aid             = GoodsAttachments.CreateAttachments(attachmentinfo);
                    string tempMessage     = GoodsAttachments.FilterLocalTags(aid, attachmentinfo, goodsinfo.Message);

                    goodsinfo.Goodspic = (attachmentinfo.Length > 0) ? attachmentinfo[0].Filename : "";
                    if (!tempMessage.Equals(goodsinfo.Message))
                    {
                        goodsinfo.Message = tempMessage;
                        goodsinfo.Aid     = aid[0];
                    }
                    Goods.UpdateGoods(goodsinfo);

                    UserCredits.UpdateUserExtCreditsByUploadAttachment(userid, aid.Length - errorAttachment);
                }

                //加入相册
                #region 相册
                if (config.Enablealbum == 1 && apb != null)
                {
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));
                }
                #endregion
                if (config.Enablemall == 1) //开启普通模式
                {
                    OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, "");
                }

                if (sb.Length > 0)
                {
                    SetShowBackLink(true);

                    sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发布商品成功,但以下附件上传失败:</nobr></span><br /></td></tr>");
                    sb.Append("</table>");
                    SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid), sb.ToString());
                }
                else
                {
                    SetShowBackLink(false);

                    if (config.Enablemall == 1 && forum.Modnewposts == 1 && useradminid != 1)
                    {
                        if (useradminid != 1)
                        {
                            if (disablepost == 1)
                            {
                                if (goodsinfo.Displayorder == -3)
                                {
                                    SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!");
                                }
                                else
                                {
                                    SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid),
                                                     "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回 " + forumname + "</a>)<br />");
                                }
                            }
                            else
                            {
                                SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但需要经过审核才可以显示. 返回商品列表");
                            }
                        }
                        else
                        {
                            SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 返回商品列表");
                        }
                    }
                    else
                    {
                        if (goodsinfo.Displayorder == -3)
                        {
                            SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!");
                        }
                        else
                        {
                            SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid),
                                             "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回</a>)<br />");
                        }
                    }
                }

                ForumUtils.WriteCookie("postmessage", "");
            }

            topicattachscorefield = 0;
        }
示例#6
0
        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易模式
            {
                AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!");
                return;
            }

            #region 临时帐号发帖
            //int realuserid = -1;
            //string tempusername = DNTRequest.GetString("tempusername");
            //if (tempusername != "" && tempusername != username)
            //{
            //    string temppassword = DNTRequest.GetString("temppassword");
            //    int question = DNTRequest.GetInt("question", 0);
            //    string answer = DNTRequest.GetString("answer");
            //    realuserid = Users.CheckTempUserInfo(tempusername, temppassword, question, answer);

            //    if (realuserid == -1)
            //    {
            //        AddErrLine("临时帐号登录失败,无法继续发帖。");
            //        return;
            //    }
            //    else
            //    {
            //        userid = realuserid;
            //        username = tempusername;
            //        usergroupinfo = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(userid).Groupid);
            //        usergroupid = usergroupinfo.Groupid;
            //        useradminid = Users.GetShortUserInfo(userid).Adminid;
            //    }
            //}
            #endregion

            canhtmltitle     = true;
            firstpagesmilies = Caches.GetSmiliesFirstPageCache();

            //内容设置为空;
            message = "";

            int goodsid = DNTRequest.GetInt("goodsid", 0);
            // 如果商品交易日志不正确
            if (goodsid <= 0)
            {
                AddErrLine("错误的商品ID.");
                return;
            }

            goodsinfo = Goods.GetGoodsInfo(goodsid);
            if (goodsinfo == null || goodsinfo.Goodsid <= 0)
            {
                AddErrLine("错误的商品ID.");
                return;
            }

            goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(goodsinfo.Categoryid);
            if (goodscategoryinfo == null && goodscategoryinfo.Fid <= 0)
            {
                goodscategoryinfo            = new Goodscategoryinfo();
                goodscategoryinfo.Categoryid = -1;
            }

            attachmentlist = GoodsAttachments.GetGoodsAttachmentsByGoodsid(goodsinfo.Goodsid);

            message = goodsinfo.Message;

            // 如果商品交易日志不正确
            if (goodsinfo.Selleruid != userid)
            {
                AddErrLine("您不是当前商品的卖家!");
                return;
            }
            allowpostgoods = true;

            if (config.Enablemall == 1) //开启普通模式
            {
                forumid        = GoodsCategories.GetCategoriesFid(goodsinfo.Categoryid);
                allowpostgoods = false;
                forumnav       = "";
                if (forumid == -1)
                {
                    if (userid == goodsinfo.Selleruid)
                    {
                        forum = new ForumInfo();
                        forum.Attachextensions = "";
                        forum.Password         = "";
                        forum.Permuserlist     = "";
                    }
                    else
                    {
                        AddErrLine("错误的商品分类ID");
                        return;
                    }
                }
                else
                {
                    forum = Forums.GetForumInfo(forumid);
                    if (forum == null || forum.Layer == 0)
                    {
                        AddErrLine("错误的商品分类ID");
                        return;
                    }
                    if (forum.Istrade <= 0)
                    {
                        AddErrLine("当前版块不允许编辑商品");
                        return;
                    }

                    forumname = forum.Name;
                    pagetitle = Utils.RemoveHtml(forum.Name);
                    forumnav  = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
                    enabletag = (config.Enabletag & forum.Allowtag) == 1;
                }
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                pagetitle          = "编辑商品";
                forumnav           = "";
                enabletag          = true;
                forum              = new ForumInfo();
                forum.Allowsmilies = 1;
                forum.Allowbbcode  = 1;
            }

            //得到用户可以上传的文件类型
            StringBuilder sbAttachmentTypeSelect = new StringBuilder();
            if (!usergroupinfo.Attachextensions.Trim().Equals(""))
            {
                sbAttachmentTypeSelect.Append("[id] in (");
                sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions);
                sbAttachmentTypeSelect.Append(")");
            }

            if (config.Enablemall == 1) //开启普通模式
            {
                if (!forum.Attachextensions.Equals(""))
                {
                    if (sbAttachmentTypeSelect.Length > 0)
                    {
                        sbAttachmentTypeSelect.Append(" AND ");
                    }
                    sbAttachmentTypeSelect.Append("[id] in (");
                    sbAttachmentTypeSelect.Append(forum.Attachextensions);
                    sbAttachmentTypeSelect.Append(")");
                }
            }
            attachextensions       = Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString());
            attachextensionsnosize = Attachments.GetAttachmentTypeString(sbAttachmentTypeSelect.ToString());

            //得到今天允许用户上传的附件总大小(字节)
            int MaxTodaySize = 0;
            if (userid > 0)
            {
                MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid); //今天已上传大小
            }
            attachsize  = usergroupinfo.Maxsizeperday - MaxTodaySize;         //今天可上传得大小
            parseurloff = 0;
            bbcodeoff   = 1;

            if (config.Enablemall == 1) //开启普通模式
            {
                smileyoff = 1 - forum.Allowsmilies;
                if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1)
                {
                    bbcodeoff = 0;
                }

                allowimg = forum.Allowimgcode;

                if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password"))
                {
                    AddErrLine("本版块被管理员设置了密码");
                    SetBackLink(base.ShowForumAspxRewrite(forumid, 0));
                    return;
                }

                if (!Forums.AllowViewByUserId(forum.Permuserlist, userid))        //判断当前用户在当前版块浏览权限
                {
                    if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限
                    {
                        if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1))
                        {
                            AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限");
                            return;
                        }
                    }
                    else//当板块权限不为空,按照板块权限
                    {
                        if (!Forums.AllowView(forum.Viewperm, usergroupid))
                        {
                            AddErrLine("您没有浏览该商品分类的权限");
                            return;
                        }
                    }
                }

                //当前用户是卖家时
                if (goodsinfo.Selleruid == userid)
                {
                    //当前用户是否有允许下载附件权限
                    if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userid))
                    {
                        allowviewattach = true;
                    }
                    else
                    {
                        if (forum.Getattachperm == null || forum.Getattachperm == string.Empty)//权限设置为空时,根据用户组权限判断
                        {
                            // 验证用户是否有有允许下载附件权限
                            if (usergroupinfo.Allowgetattach == 1)
                            {
                                allowviewattach = true;
                            }
                        }
                        else if (Forums.AllowGetAttach(forum.Getattachperm, usergroupid))
                        {
                            allowviewattach = true;
                        }
                    }

                    //是否有上传附件的权限
                    if (Forums.AllowPostAttachByUserID(forum.Permuserlist, userid))
                    {
                        canpostattach = true;
                    }
                    else
                    {
                        if (forum.Postattachperm == "")
                        {
                            if (usergroupinfo.Allowpostattach == 1)
                            {
                                canpostattach = true;
                            }
                        }
                        else
                        {
                            if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid))
                            {
                                canpostattach = true;
                            }
                        }
                    }
                }
            }
            else if (config.Enablemall == 2) //当为高级模式时
            {
                canpostattach = true;
                allowimg      = 1;
                smileyoff     = 0;
            }

            ShortUserInfo user = Users.GetShortUserInfo(userid);
            if (canpostattach && user != null && apb != null && config.Enablealbum == 1 &&
                (UserGroups.GetUserGroupInfo(user.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0))
            {
                caninsertalbum = true;
                albumlist      = apb.GetSpaceAlbumByUserId(userid);
            }
            else
            {
                caninsertalbum = false;
            }

            if (Topics.GetMagicValue(goodsinfo.Magic, MagicType.HtmlTitle) == 1)
            {
                htmltitle = Goods.GetHtmlTitle(goodsinfo.Goodsid).Replace("\"", "\\\"").Replace("'", "\\'");
            }


            if (enabletag && Topics.GetMagicValue(goodsinfo.Magic, MagicType.TopicTag) == 1)
            {
                foreach (TagInfo tag in GoodsTags.GetTagsListByGoods(goodsinfo.Goodsid))
                {
                    if (tag.Orderid > -1)
                    {
                        goodstags += string.Format(" {0}", tag.Tagname);
                    }
                }
                goodstags = goodstags.Trim();
            }


            // 如果是受灌水限制用户, 则判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            disablepost        = (admininfo != null) ? admininfo.Disablepostctrl : 0;
            creditstrans       = Scoresets.GetCreditsTrans();
            userextcreditsinfo = Scoresets.GetScoreSet(creditstrans);
            if (userid > 0)
            {
                spaceid = Users.GetShortUserInfo(userid).Spaceid;
            }

            //如果不是提交...
            if (!ispost)
            {
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
                smilies           = Caches.GetSmiliesCache();
                smilietypes       = Caches.GetSmilieTypesCache();
                customeditbuttons = Caches.GetCustomEditButtonList();
            }
            else
            {
                SetBackLink(string.Format("postgoods.aspx?forumid={0}&restore=1", forumid));

                string postmessage = DNTRequest.GetString("message");

                ForumUtils.WriteCookie("postmessage", postmessage);

                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                if (DNTRequest.GetString("title").Trim().Equals(""))
                {
                    AddErrLine("商品标题不能为空");
                }
                else if (DNTRequest.GetString("title").IndexOf(" ") != -1)
                {
                    AddErrLine("商品标题不能包含全角空格符");
                }
                else if (DNTRequest.GetString("title").Length > 60)
                {
                    AddErrLine("商品标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length.ToString() + " 个字符");
                }

                if (postmessage.Equals("") || postmessage.Replace(" ", "").Equals(""))
                {
                    AddErrLine("商品内容不能为空");
                }

                if (admininfo != null && admininfo.Disablepostctrl != 1)
                {
                    if (postmessage.Length < config.Minpostsize)
                    {
                        AddErrLine("您发表的内容过少, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字");
                    }
                    else if (postmessage.Length > config.Maxpostsize)
                    {
                        AddErrLine("您发表的内容过多, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字");
                    }
                }

                if (IsErr())
                {
                    return;
                }

                // 如果用户上传了附件,则检测用户是否有上传附件的权限
                if (ForumUtils.IsPostFile())
                {
                    if (Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()).Trim() == "")
                    {
                        AddErrLine("系统不允许上传附件");
                    }

                    if (config.Enablemall == 1) //开启普通模式
                    {
                        if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid))
                        {
                            if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid))
                            {
                                AddErrLine("您没有在该版块上传附件的权限");
                            }
                            else if (usergroupinfo.Allowpostattach != 1)
                            {
                                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle));
                            }
                        }
                    }
                }

                if (IsErr())
                {
                    return;
                }

                int iconid = DNTRequest.GetInt("iconid", 0);
                if (iconid > 15 || iconid < 0)
                {
                    iconid = 0;
                }

                string curdatetime = Utils.GetDateTime();

                goodsinfo.Shopid = 0;
                //商品分类原值
                int oldgoodscategoryid = goodsinfo.Categoryid;
                //商品父分类原值
                string oldparentcategorylist = goodsinfo.Parentcategorylist;

                //当商品分类发生变化时
                if (DNTRequest.GetInt("goodscategoryid", 0) != 0 && goodsinfo.Categoryid != DNTRequest.GetInt("goodscategoryid", 0))
                {
                    goodsinfo.Categoryid         = DNTRequest.GetInt("goodscategoryid", 0);
                    goodsinfo.Parentcategorylist = GoodsCategories.GetParentCategoryList(goodsinfo.Categoryid);
                }

                goodsinfo.Recommend = DNTRequest.GetString("recommend") == "on" ? 1 : 0;
                goodsinfo.Discount  = DNTRequest.GetInt("discount", 0);
                goodsinfo.Selleruid = userid;
                goodsinfo.Seller    = username;
                goodsinfo.Account   = DNTRequest.GetString("account");
                goodsinfo.Price     = Convert.ToDecimal(DNTRequest.GetFormFloat("price", 1).ToString());
                goodsinfo.Amount    = DNTRequest.GetInt("amount", 0);
                goodsinfo.Quality   = DNTRequest.GetInt("quality", 0);
                if (DNTRequest.GetInt("locus_2", 0) != 0)
                {
                    goodsinfo.Lid   = DNTRequest.GetInt("locus_2", 0);
                    goodsinfo.Locus = Locations.GetLocusByLID(goodsinfo.Lid);
                }
                goodsinfo.Transport = DNTRequest.GetInt("transport", 0);
                if (goodsinfo.Transport != 0)
                {
                    goodsinfo.Ordinaryfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_mail", 0).ToString());
                    goodsinfo.Expressfee  = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_express", 0).ToString());
                    goodsinfo.Emsfee      = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_ems", 0).ToString());
                }

                goodsinfo.Itemtype = DNTRequest.GetInt("itemtype", 0);

                DateTime dateline;
                switch (DNTRequest.GetInt("_now", 0))
                {
                case 1: dateline = Convert.ToDateTime(string.Format("{0} {1}:{2}:00", DNTRequest.GetString("_date"), DNTRequest.GetInt("_hour", 0), DNTRequest.GetInt("_minute", 0))); break; //设定

                case 2: dateline = Convert.ToDateTime("1900-01-01 00:00:00"); break;                                                                                                          //返回100年之后的日期作为"暂不设置"

                default: dateline = DateTime.Now; break;                                                                                                                                      //立即
                }

                goodsinfo.Dateline   = dateline;
                goodsinfo.Expiration = Convert.ToDateTime(DNTRequest.GetString("expiration"));
                goodsinfo.Lastbuyer  = "";
                goodsinfo.Lastupdate = DateTime.Now;
                goodsinfo.Totalitems = 0;
                goodsinfo.Tradesum   = 0;
                goodsinfo.Closed     = 0;
                goodsinfo.Aid        = 0;

                int displayorder = goodsinfo.Displayorder;
                goodsinfo.Displayorder = DNTRequest.GetString("displayorder") == "on" ? 0 : -3;

                if (config.Enablemall == 1) //当为版块交易帖是时
                {
                    if (forum.Modnewposts == 1 && useradminid != 1)
                    {
                        if (useradminid > 1)
                        {
                            if (disablepost != 1)
                            {
                                goodsinfo.Displayorder = -2;
                            }
                        }
                        else
                        {
                            goodsinfo.Displayorder = -2;
                        }
                    }
                }

                goodsinfo.Costprice = Convert.ToDecimal(DNTRequest.GetFormFloat("costprice", 1).ToString());
                goodsinfo.Invoice   = DNTRequest.GetInt("invoice", 0);
                goodsinfo.Repair    = DNTRequest.GetInt("repair", 0);
                if (useradminid == 1)
                {
                    goodsinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage));
                }
                else
                {
                    goodsinfo.Message = Utils.HtmlEncode(postmessage);
                }

                goodsinfo.Otherlink = "";
                int readperm = DNTRequest.GetInt("readperm", 0);
                goodsinfo.Readperm  = readperm > 255 ? 255 : readperm;
                goodsinfo.Tradetype = DNTRequest.GetInt("tradetype", 0);

                if (goodsinfo.Tradetype == 1 && Utils.StrIsNullOrEmpty(goodsinfo.Account)) //当为支付宝在线支付方式下,如果"支付宝账户"为空时
                {
                    AddErrLine("请输入支付宝帐号信息。");
                    return;
                }

                goodsinfo.Smileyoff = smileyoff;
                if (smileyoff == 0 && forum.Allowsmilies == 1)
                {
                    goodsinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0);
                }

                goodsinfo.Bbcodeoff = 1;
                if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1)
                {
                    goodsinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0);
                }

                goodsinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0);

                if (useradminid == 1)
                {
                    goodsinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title"));
                }
                else
                {
                    goodsinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title")));
                }

                string htmltitle = DNTRequest.GetString("htmltitle").Trim();
                if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != goodsinfo.Title)
                {
                    goodsinfo.Magic = 11000;
                    //按照  附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储
                    //例: 11001
                }

                //标签(Tag)操作
                string   tags      = DNTRequest.GetString("tags").Trim();
                string[] tagsArray = null;
                if (enabletag && tags != string.Empty)
                {
                    tagsArray = Utils.SplitString(tags, " ", true, 2, 10);
                    if (tagsArray.Length > 0)
                    {
                        if (goodsinfo.Magic == 0)
                        {
                            goodsinfo.Magic = 10000;
                        }

                        goodsinfo.Magic = Utils.StrToInt(goodsinfo.Magic.ToString() + "1", 0);
                    }
                }

                Goods.UpdateGoods(goodsinfo, oldgoodscategoryid, oldparentcategorylist);

                if (displayorder != goodsinfo.Displayorder)             //当发生变化时
                {
                    if (displayorder < 0 && goodsinfo.Displayorder > 0) //该商品转为上架
                    {
                        DbProvider.GetInstance().UpdateCategoryGoodsCounts(goodsinfo.Categoryid, goodsinfo.Parentcategorylist, 1);
                    }
                    else if (displayorder >= 0 && goodsinfo.Displayorder < 0) //该商品转为下架(或进入回收站/待审核状态)
                    {
                        DbProvider.GetInstance().UpdateCategoryGoodsCounts(goodsinfo.Categoryid, goodsinfo.Parentcategorylist, -1);
                    }
                }

                //保存htmltitle
                if (canhtmltitle && htmltitle != string.Empty && htmltitle != goodsinfo.Title)
                {
                    Goods.WriteHtmlSubjectFile(htmltitle, goodsinfo.Goodsid);
                }

                if (enabletag && tagsArray != null && tagsArray.Length > 0)
                {
                    DbProvider.GetInstance().CreateGoodsTags(string.Join(" ", tagsArray), goodsinfo.Goodsid, userid, curdatetime);
                    GoodsTags.WriteGoodsTagsCacheFile(goodsinfo.Goodsid);
                }

                StringBuilder sb = new StringBuilder();
                sb.Remove(0, sb.Length);

                //编辑帖子时如果进行了批量删除附件
                string delAttId = DNTRequest.GetFormString("deleteaid");
                if (delAttId != string.Empty)
                {
                    if (Utils.IsNumericList(delAttId))//如果要删除的附件ID列表为数字数组
                    {
                        GoodsAttachments.DeleteGoodsAttachment(delAttId);
                    }
                }
                //编辑帖子时如果进行了更新附件操作
                string   updatedAttId     = DNTRequest.GetFormString("attachupdatedid");                 //被更新的附件Id列表
                string   updateAttId      = DNTRequest.GetFormString("attachupdateid");                  //所有已上传的附件Id列表
                string[] descriptionArray = DNTRequest.GetFormString("attachupdatedesc").Split(',');     //所有已上传的附件的描述
                string[] readpermArray    = DNTRequest.GetFormString("attachupdatereadperm").Split(','); //所有已上传得附件的阅读权限

                ArrayList updateAttArrayList = new ArrayList();
                if (updateAttId != string.Empty)
                {
                    foreach (string s in updateAttId.Split(','))
                    {
                        if (!Utils.InArray(s, delAttId, ","))//已上传的附件Id不在被删除的附件Id列表中时
                        {
                            updateAttArrayList.Add(s);
                        }
                    }
                }

                string[] updateAttArray = (string[])updateAttArrayList.ToArray(typeof(string));

                if (updateAttId != string.Empty)//原来有附件
                {
                    int watermarkstate = config.Watermarkstatus;

                    if (forum.Disablewatermark == 1)
                    {
                        watermarkstate = 0;
                    }

                    string[] updatedAttArray = updatedAttId.Split(',');

                    string filekey = "attachupdated";

                    //保存新的文件
                    Goodsattachmentinfo[] attArray = Discuz.Mall.MallUtils.SaveRequestFiles(
                        goodsinfo.Categoryid, config.Maxattachments + updateAttArray.Length,
                        usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize,
                        attachextensions, watermarkstate, config, filekey);

                    if (Utils.IsNumericArray(updateAttArray))
                    {
                        for (int i = 0; i < updateAttArray.Length; i++) //遍历原来所有附件
                        {
                            string attachmentId = updateAttArray[i];
                            if (Utils.InArray(attachmentId, updatedAttArray))   //附件文件被更新
                            {
                                if (Utils.InArray(attachmentId, delAttId, ",")) //附件进行了删除操作, 则不操作此附件,即使其也被更新
                                {
                                    continue;
                                }
                                //更新附件
                                int attachmentUpdatedIndex = GetAttachmentUpdatedIndex(attachmentId, updatedAttArray); //获取此次上传的被更新附件在数组中的索引
                                if (attachmentUpdatedIndex > -1)                                                       //附件索引存在
                                {
                                    if (attArray[attachmentUpdatedIndex].Sys_noupload.Equals(string.Empty))            //由此属性为空可以判断上传成功
                                    {
                                        //获取将被更新的附件信息
                                        Goodsattachmentinfo attachmentInfo =
                                            GoodsAttachments.GetGoodsAttachmentsByAid(Utils.StrToInt(updatedAttArray[attachmentUpdatedIndex], 0));
                                        if (attachmentInfo != null)
                                        {
                                            if (attachmentInfo.Filename.Trim().ToLower().IndexOf("http") < 0)
                                            {
                                                //删除原来的文件
                                                File.Delete(Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/" +
                                                                             attachmentInfo.Filename));
                                            }

                                            //记住Aid以便稍后更新
                                            attArray[attachmentUpdatedIndex].Aid         = attachmentInfo.Aid;
                                            attArray[attachmentUpdatedIndex].Description = descriptionArray[i];
                                            int att_readperm = Utils.StrToInt(readpermArray[i], 0);
                                            att_readperm = att_readperm > 255 ? 255 : att_readperm;
                                            attArray[attachmentUpdatedIndex].Readperm   = att_readperm;
                                            attArray[attachmentUpdatedIndex].Categoryid = attachmentInfo.Categoryid;
                                            attArray[attachmentUpdatedIndex].Goodscount = attachmentInfo.Goodscount;
                                            attArray[attachmentUpdatedIndex].Goodsid    = attachmentInfo.Goodsid;

                                            GoodsAttachments.SaveGoodsAttachment(attArray[attachmentUpdatedIndex]);
                                        }
                                    }
                                    else //上传失败的附件,稍后提示
                                    {
                                        sb.Append("<tr><td align=\"left\">");
                                        sb.Append(attArray[attachmentUpdatedIndex].Attachment);
                                        sb.Append("</td>");
                                        sb.Append("<td align=\"left\">");
                                        sb.Append(attArray[attachmentUpdatedIndex].Sys_noupload);
                                        sb.Append("</td></tr>");
                                    }
                                }
                            }
                            else //仅修改了阅读权限和描述等
                            {
                                if (Utils.InArray(updateAttArray[i], delAttId, ","))
                                {
                                    continue;
                                }
                                if ((attachmentlist[i].Readperm.ToString() != readpermArray[i]) ||
                                    (attachmentlist[i].Description.Trim() != descriptionArray[i]))
                                {
                                    int att_readperm = Utils.StrToInt(readpermArray[i], 0);
                                    att_readperm = att_readperm > 255 ? 255 : att_readperm;
                                    GoodsAttachments.SaveGoodsAttachment(Utils.StrToInt(updateAttArray[i], 0), att_readperm,
                                                                         descriptionArray[i]);
                                }
                            }
                        }
                    }
                }

                int watermarkstatus = config.Watermarkstatus;
                if (forum.Disablewatermark == 1)
                {
                    watermarkstatus = 0;
                }
                Goodsattachmentinfo[] attachmentinfo = Discuz.Mall.MallUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile");
                if (attachmentinfo != null)
                {
                    if (attachmentinfo.Length > config.Maxattachments)
                    {
                        AddErrLine("系统设置为每个商品附件不得多于" + config.Maxattachments + "个");
                        return;
                    }
                    int    errorAttachment = GoodsAttachments.BindAttachment(attachmentinfo, goodsinfo.Goodsid, sb, goodsinfo.Categoryid, userid);
                    int[]  aid             = GoodsAttachments.CreateAttachments(attachmentinfo);
                    string tempMessage     = GoodsAttachments.FilterLocalTags(aid, attachmentinfo, goodsinfo.Message);
                    if (attachmentinfo.Length == (System.Web.HttpContext.Current.Request.Files.Count - 2))
                    {
                        goodsinfo.Goodspic = attachmentinfo[0].Filename;
                        goodsinfo.Aid      = aid[0];
                    }
                    if (!tempMessage.Equals(goodsinfo.Message))
                    {
                        goodsinfo.Message = tempMessage;
                    }

                    Goods.UpdateGoods(goodsinfo);

                    UserCredits.UpdateUserExtCreditsByUploadAttachment(userid, aid.Length - errorAttachment);
                }

                //加入相册
                if (config.Enablealbum == 1 && apb != null)
                {
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));
                }

                if (config.Enablemall == 1) //开启普通模式
                {
                    OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, "");
                }

                if (sb.Length > 0)
                {
                    SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid));
                    SetMetaRefresh(5);
                    SetShowBackLink(true);
                    sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发布商品成功,但以下附件上传失败:</nobr></span><br /></td></tr>");
                    sb.Append("</table>");
                    AddMsgLine(sb.ToString());
                }
                else
                {
                    SetShowBackLink(false);
                    if (config.Enablemall == 1 && forum.Modnewposts == 1 && useradminid != 1)
                    {
                        if (useradminid != 1)
                        {
                            if (disablepost == 1)
                            {
                                if (goodsinfo.Displayorder == -3)
                                {
                                    SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1));
                                    SetMetaRefresh(5);
                                    AddMsgLine("编辑商品成功, 但未上架. 您可到用户中心进行上架操作!");
                                }
                                else
                                {
                                    SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid));
                                    SetMetaRefresh();
                                    AddMsgLine("编辑商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回 " + forumname + "</a>)<br />");
                                }
                            }
                            else
                            {
                                SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1));
                                SetMetaRefresh();
                                AddMsgLine("编辑商品成功, 但需要经过审核才可以显示. 返回商品列表");
                            }
                        }
                        else
                        {
                            SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1));
                            SetMetaRefresh();
                            AddMsgLine("发布商品成功, 返回商品列表");
                        }
                    }
                    else
                    {
                        if (goodsinfo.Displayorder == -3)
                        {
                            SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1));
                            SetMetaRefresh(5);
                            AddMsgLine("编辑商品成功, 但未上架. 您可到用户中心进行上架操作!");
                        }
                        else
                        {
                            SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid));
                            SetMetaRefresh();
                            AddMsgLine("编辑商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回</a>)<br />");
                        }
                    }
                }
                ForumUtils.WriteCookie("postmessage", "");
            }

            topicattachscorefield = 0;
        }
示例#7
0
        private string condition = ""; //查询条件


        protected override void ShowPage()
        {
            if (config.Enablemall == 0) //未启用交易模式
            {
                AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!");
                return;
            }
            else
            {
                goodscategoryfid = Discuz.Mall.GoodsCategories.GetGoodsCategoryWithFid();
            }

            forumnav      = "";
            forumallowrss = 0;
            if (categoryid <= 0)
            {
                AddErrLine("无效的商品分类ID");
                return;
            }

            if (config.Enablemall == 2) //开启高级模式
            {
                AddLinkRss("mallgoodslist.aspx?categoryid=" + categoryid, "商品列表");
                AddErrLine("当前页面在开启商城(高级)模式下无法访问, 系统将会重定向到商品列表页面!");
                return;
            }

            goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(categoryid);
            if (goodscategoryinfo != null && goodscategoryinfo.Categoryid > 0)
            {
                forumid = GoodsCategories.GetCategoriesFid(goodscategoryinfo.Categoryid);
            }
            else
            {
                AddErrLine("无效的商品分类ID");
                return;
            }

            ///得到广告列表
            ///头部
            headerad   = Advertisements.GetOneHeaderAd("", forumid);
            footerad   = Advertisements.GetOneFooterAd("", forumid);
            pagewordad = Advertisements.GetPageWordAd("", forumid);
            doublead   = Advertisements.GetDoubleAd("", forumid);
            floatad    = Advertisements.GetFloatAd("", forumid);
            mediaad    = Advertisements.GetMediaAd(templatepath, "", forumid);

            disablepostctrl = 0;
            if (userid > 0 && useradminid > 0)
            {
                admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            }

            if (admingroupinfo != null)
            {
                this.disablepostctrl = admingroupinfo.Disablepostctrl;
            }

            if (forumid == -1)
            {
                AddLinkRss("tools/rss.aspx", "最新商品");
                AddErrLine("无效的商品分类ID");
                return;
            }
            else
            {
                forum = Forums.GetForumInfo(forumid);
                // 检查是否具有版主的身份
                if (useradminid > 0)
                {
                    ismoder = Moderators.IsModer(useradminid, userid, forumid);
                }

                #region 对搜索条件进行检索

                string orderStr = "goodsid";

                if (DNTRequest.GetString("search").Trim() != "") //进行指定查询
                {
                    //所在城市信息
                    cond = DNTRequest.GetInt("locus_2", -1);
                    if (cond < 1)
                    {
                        condition = "";
                    }
                    else
                    {
                        locus     = Locations.GetLocusByLID(cond);
                        condition = "AND [lid] = " + cond;
                    }

                    //排序的字段
                    order = DNTRequest.GetInt("order", -1);
                    switch (order)
                    {
                    case 2:
                        orderStr = "expiration";     //到期日
                        break;

                    case 1:
                        orderStr = "price";     //商品价格
                        break;

                    default:
                        orderStr = "goodsid";
                        break;
                    }

                    if (DNTRequest.GetInt("direct", -1) == 0)
                    {
                        direct = 0;
                    }
                }

                #endregion

                if (forum == null)
                {
                    if (config.Rssstatus == 1)
                    {
                        AddLinkRss("tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新商品");
                    }

                    AddErrLine("不存在的商品分类ID");
                    return;
                }


                //当版块有外部链接时,则直接跳转
                if (forum.Redirect != null && forum.Redirect != string.Empty)
                {
                    System.Web.HttpContext.Current.Response.Redirect(forum.Redirect);
                    return;
                }

                if (forum.Istrade <= 0)
                {
                    AddErrLine("当前版块不允许商品交易");
                    forumnav = "";
                    return;
                }

                if (forum.Fid < 1)
                {
                    if (config.Rssstatus == 1 && forum.Allowrss == 1)
                    {
                        AddLinkRss("tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新商品");
                    }

                    AddErrLine("不存在的商品分类ID");
                    return;
                }
                if (config.Rssstatus == 1)
                {
                    AddLinkRss("tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新商品");
                }

                forumname     = forum.Name;
                pagetitle     = Utils.RemoveHtml(forum.Name);
                subforumcount = forum.Subforumcount;
                forumnav      = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
                navhomemenu   = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);

                //更新页面Meta中的Description项, 提高SEO友好性
                UpdateMetaInfo(config.Seokeywords, forum.Description, config.Seohead);

                // 是否显示版块密码提示 1为显示, 0不显示
                showforumlogin = 1;
                // 如果版块未设密码
                if (forum.Password == "")
                {
                    showforumlogin = 0;
                }
                else
                {
                    // 如果检测到相应的cookie正确
                    if (Utils.MD5(forum.Password) == ForumUtils.GetCookie("forum" + forumid.ToString() + "password"))
                    {
                        showforumlogin = 0;
                    }
                    else
                    {
                        // 如果用户提交的密码正确则保存cookie
                        if (forum.Password == DNTRequest.GetString("forumpassword"))
                        {
                            ForumUtils.WriteCookie("forum" + forumid.ToString() + "password", Utils.MD5(forum.Password));
                            showforumlogin = 0;
                        }
                    }
                }

                if (!Forums.AllowViewByUserId(forum.Permuserlist, userid))        //判断当前用户在当前版块浏览权限
                {
                    if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限
                    {
                        if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1))
                        {
                            AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该商品分类的权限");
                            if (userid == -1)
                            {
                                needlogin = true;
                            }
                            return;
                        }
                    }
                    else //当板块权限不为空,按照板块权限
                    {
                        if (!Forums.AllowView(forum.Viewperm, usergroupid))
                        {
                            AddErrLine("您没有浏览该商品分类的权限");
                            if (userid == -1)
                            {
                                needlogin = true;
                            }
                            return;
                        }
                    }
                }


                ////判断是否有发主题的权限
                if (userid > -1 && Forums.AllowPostByUserID(forum.Permuserlist, userid))
                {
                    canposttopic = true;
                }

                if (forum.Postperm == null || forum.Postperm == string.Empty) //权限设置为空时,根据用户组权限判断
                {
                    // 验证用户是否有发表交易的权限
                    if (usergroupinfo.Allowtrade == 1)
                    {
                        canposttopic = true;
                    }
                }
                else if (Forums.AllowPost(forum.Postperm, usergroupid))
                {
                    canposttopic = true;
                }

                // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖
                if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1)
                {
                    string visittime = "";
                    if (Scoresets.BetweenTime(config.Postbanperiods, out visittime))
                    {
                        canposttopic = false;
                    }
                }

                if (newpmcount > 0)
                {
                    pmlist     = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1);
                    showpmhint = Convert.ToInt32(Users.GetShortUserInfo(userid).Newsletter) > 4;
                }

                //得到子分类JSON格式
                subcategoriesjson = GoodsCategories.GetSubCategoriesJson(categoryid);
                //得到当前用户请求的页数
                pageid = DNTRequest.GetInt("page", 1);
                //获取主题总数
                goodscount = Goods.GetGoodsCount(categoryid, condition);

                // 得到gpp设置
                if (gpp <= 0)
                {
                    gpp = config.Gpp;
                }

                if (gpp <= 0)
                {
                    gpp = 16;
                }

                //修正请求页数中可能的错误
                if (pageid < 1)
                {
                    pageid = 1;
                }

                if (forum.Layer > 0)
                {
                    //获取总页数
                    pagecount = goodscount % gpp == 0 ? goodscount / gpp : goodscount / gpp + 1;
                    if (pagecount == 0)
                    {
                        pagecount = 1;
                    }

                    if (pageid > pagecount)
                    {
                        pageid = pagecount;
                    }

                    goodslist = Goods.GetGoodsInfoList(categoryid, gpp, pageid, condition, orderStr, direct);

                    ForumUtils.WriteCookie("referer", string.Format("showgoodslist.aspx?categoryid={0}&page={1}&order={2}&direct={3}&locus2={4}&search={5}", categoryid.ToString(), pageid.ToString(), orderStr, direct, cond, DNTRequest.GetString("search")));

                    //得到页码链接
                    if (DNTRequest.GetString("search") == "")
                    {
                        if (categoryid == 0)
                        {
                            if (config.Aspxrewrite == 1)
                            {
                                pagenumbers = Utils.GetStaticPageNumbers(pageid, pagecount, "showgoodslist-" + categoryid.ToString(), config.Extname, 8);
                            }
                            else
                            {
                                pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showgoodslist.aspx?categoryid=" + categoryid.ToString(), 8);
                            }
                        }
                        else //当有类型条件时
                        {
                            pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showgoodslist.aspx?categoryid=" + categoryid, 8);
                        }
                    }
                    else
                    {
                        pagenumbers = Utils.GetPageNumbers(pageid, pagecount,
                                                           "showgoodslist.aspx?search=" + DNTRequest.GetString("search") + "&order=" + 2 + "&direct=" + direct + "&categoryid=" + categoryid + "&locus_2=" + cond, 8);
                    }
                }
            }


            forumlistboxoptions = Caches.GetForumListBoxOptionsCache();

            OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forumname, -1, "");


            showforumonline = false;
            onlineiconlist  = Caches.GetOnlineGroupIconList();
            if (forumtotalonline < config.Maxonlinelist || DNTRequest.GetString("showonline") == "yes")
            {
                showforumonline = true;
                onlineuserlist  = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest,
                                                                           out forumtotalonlineuser, out forumtotalonlineinvisibleuser);
            }

            if (DNTRequest.GetString("showonline") == "no")
            {
                showforumonline = false;
            }

            ForumUtils.UpdateVisitedForumsOptions(forumid);
            visitedforumsoptions = ForumUtils.GetVisitedForumsOptions(config.Visitedforums);
            //因为目前还未提供RSS功能,所以下面两项为0
            forumallowrss = 0;
        }