Ejemplo n.º 1
0
        public void Execute(object state)
        {
            SpacePluginBase spb = SpacePluginProvider.GetInstance();

            AlbumPluginBase apb = AlbumPluginProvider.GetInstance();

            ForumTags.WriteHotTagsListForForumCacheFile(60);
            ForumTags.WriteHotTagsListForForumJSONPCacheFile(60);
            if (spb != null)
            {
                spb.WriteHotTagsListForSpaceJSONPCacheFile(60);
            }
            if (apb != null)
            {
                apb.WriteHotTagsListForPhotoJSONPCacheFile(60);
            }

            MallPluginBase imp = MallPluginProvider.GetInstance();

            if (imp != null)
            {
                imp.WriteHotTagsListForGoodsJSONPCacheFile(60);
            }
        }
Ejemplo n.º 2
0
        private string StartUploadFile()
        {
            string sSavePath = "";

            if (ViewState["UploadDir"] != null)
            {
                sSavePath = ViewState["UploadDir"].ToString();
            }
            else
            {
                sSavePath = Server.MapPath(BaseConfigs.GetForumPath + "space/upload/");
            }

            if (filefield1.PostedFile != null)
            {
                HttpPostedFile myFile   = filefield1.PostedFile;
                int            nFileLen = myFile.ContentLength;
                if (nFileLen == 0)
                {
                    return("");
                }

                byte[] myData = new Byte[nFileLen];
                myFile.InputStream.Read(myData, 0, nFileLen);
                Random random    = new Random(unchecked ((int)DateTime.Now.Ticks));
                string sFilename = (Environment.TickCount & int.MaxValue).ToString() + random.Next(1000, 9999).ToString() + System.IO.Path.GetExtension(myFile.FileName).ToLower();

                //判断sFilename的文件名称是否已存在于服务器上. 如存在, 则添加文件递增标识
                int file_append = 0;
                while (File.Exists(sSavePath + sFilename))
                {
                    file_append++;
                    sFilename = Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + Path.GetExtension(myFile.FileName).ToLower();
                }

                string fileExtName      = Path.GetExtension(myFile.FileName).ToLower();
                string relativeFilePath = ViewState["RelativeFilePath"].ToString().Trim();

                fileExtName = fileExtName != "" ? fileExtName: ".invalidExtName";

                if ((attachextensions == null) || (attachextensions.ToLower().IndexOf(fileExtName.Remove(0, 1)) >= 0))
                {
                    //上传图片文件
                    if ((fileExtName == ".jpg") || (fileExtName == ".gif") || (fileExtName == ".png") || (fileExtName == ".jpeg"))
                    {
                        try
                        {
                            AlbumPluginBase apb = AlbumPluginProvider.GetInstance();
                            //上传附件同时加入相册
                            if (albums.SelectedValue != "" && apb != null)
                            {
                                int maxphotosize     = UserGroups.GetUserGroupInfo(_userinfo.Groupid).Maxspacephotosize;
                                int currentphotisize = apb.GetPhotoSizeByUserid(userid);
                                if ((maxphotosize - currentphotisize - nFileLen) <= 0)  //相册的存储空间不足
                                {
                                    HttpContext.Current.Response.Write("<script>alert('" + config.Albumname + "空间不足, 上传至相册失败!');</script>");
                                    HttpContext.Current.Response.End();
                                    return("");
                                }
                                else
                                {
                                    FileStream newFile = new FileStream(sSavePath + sFilename, FileMode.Create);
                                    newFile.Write(myData, 0, myData.Length);
                                    newFile.Close();

                                    string extension = Path.GetExtension(sSavePath + sFilename);
                                    Common.Thumbnail.MakeThumbnailImage(sSavePath + sFilename, (sSavePath + sFilename).Replace(extension, "_thumbnail" + extension), 150, 150);
                                    Common.Thumbnail.MakeSquareImage(sSavePath + sFilename, (sSavePath + sFilename).Replace(extension, "_square" + extension), 100);
                                    string sPath = relativeFilePath;
                                    if (sPath.StartsWith("/"))
                                    {
                                        sPath = sPath.Substring(1, sPath.Length - 1);
                                    }

                                    PhotoInfo photoinfo = new PhotoInfo();
                                    photoinfo.Filename      = sPath + sFilename;
                                    photoinfo.Attachment    = Path.GetFileName(filefield1.PostedFile.FileName);
                                    photoinfo.Filesize      = nFileLen;
                                    photoinfo.Title         = sFilename.Remove(sFilename.IndexOf("."), 1);
                                    photoinfo.Description   = "";
                                    photoinfo.Albumid       = Utils.StrToInt(albums.SelectedValue, 0);
                                    photoinfo.Userid        = userid;
                                    photoinfo.Username      = username;
                                    photoinfo.Views         = 0;
                                    photoinfo.Commentstatus = 0;
                                    photoinfo.Tagstatus     = 0;
                                    photoinfo.Comments      = 0;
                                    photoinfo.IsAttachment  = 1;
                                    Space.Data.DbProvider.GetInstance().AddSpacePhoto(photoinfo);
                                    AlbumInfo albumInfo = apb.GetAlbumInfo(Utils.StrToInt((albums.SelectedValue), 0));
                                    albumInfo.Imgcount = Space.Data.DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(Utils.StrToInt(albums.SelectedValue, 0));
                                    Space.Data.DbProvider.GetInstance().SaveSpaceAlbum(albumInfo);

                                    //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                                    if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                                    {
                                        FTPs ftps = new FTPs();
                                        relativeFilePath = relativeFilePath.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, "");
                                        ftps.UpLoadFile(relativeFilePath, sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                                        ftps = new FTPs();
                                        ftps.UpLoadFile(relativeFilePath, (sSavePath + sFilename).Replace(extension, "_thumbnail" + extension), FTPs.FTPUploadEnum.SpaceAttach);
                                        ftps = new FTPs();
                                        ftps.UpLoadFile(relativeFilePath, (sSavePath + sFilename).Replace(extension, "_square" + extension), FTPs.FTPUploadEnum.SpaceAttach);
                                    }
                                }
                            }
                            else
                            {
                                int maxspacesize = UserGroups.GetUserGroupInfo(_userinfo.Groupid).Maxspaceattachsize;
                                int currentspaceattachmentsize = Space.Data.DbProvider.GetInstance().GetSpaceAttachmentSizeByUserid(userid);
                                if ((maxspacesize - currentspaceattachmentsize - nFileLen) <= 0)  //个人空间的存储空间不足
                                {
                                    HttpContext.Current.Response.Write("<script>alert('" + config.Spacename + "存储空间不足, 上传失败!');</script>");
                                    HttpContext.Current.Response.End();
                                    return("");
                                }
                                else
                                {
                                    FileStream newFile = new FileStream(sSavePath + sFilename, FileMode.Create);
                                    newFile.Write(myData, 0, myData.Length);
                                    newFile.Close();
                                }

                                //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                                if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                                {
                                    FTPs ftps = new FTPs();
                                    ftps.UpLoadFile(relativeFilePath.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, ""), sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                                }
                            }

                            InsertSapceAttachment(relativeFilePath + sFilename, myFile.ContentType, myData.Length, Path.GetFileName(myFile.FileName).ToLower());

                            return(sFilename);
                        }
                        catch (ArgumentException errArgument)
                        {
                            File.Delete(sSavePath + sFilename);
                            HttpContext.Current.Response.Write("<script>alert('" + errArgument.Message + "!');</script>");
                            HttpContext.Current.Response.End();
                            return("");
                        }
                    }
                    else //其它类型文件
                    {
                        int maxspacesize = UserGroups.GetUserGroupInfo(_userinfo.Groupid).Maxspaceattachsize;
                        int currentspaceattachmentsize = Space.Data.DbProvider.GetInstance().GetSpaceAttachmentSizeByUserid(userid);
                        if ((maxspacesize - currentspaceattachmentsize - nFileLen) <= 0)  //个人空间的存储空间不足
                        {
                            HttpContext.Current.Response.Write("<script>alert('" + config.Spacename + "存储空间不足, 上传失败!');</script>");
                            HttpContext.Current.Response.End();
                            return("");
                        }
                        else
                        {
                            try
                            {
                                myFile.SaveAs(sSavePath + sFilename);
                                InsertSapceAttachment(relativeFilePath + sFilename, myFile.ContentType, myData.Length, Path.GetFileName(myFile.FileName).ToLower());

                                //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                                if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                                {
                                    FTPs ftps = new FTPs();
                                    ftps.UpLoadFile(relativeFilePath.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, ""), sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                                }
                                return(sFilename);
                            }
                            catch (ArgumentException errArgument)
                            {
                                File.Delete(sSavePath + sFilename);
                                HttpContext.Current.Response.Write("<script>alert('" + errArgument.Message + "!');</script>");
                                HttpContext.Current.Response.End();
                                return("");
                            }
                        }
                    }
                }
                else //当上传的附件类型无效时
                {
                    return("invalid_file");
                }
            }
            return("");
        }
Ejemplo n.º 3
0
        protected override void ShowPage()
        {
            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }

            //收藏的是主题
            if (topicid != -1)
            {
                // 获取该主题的信息
                TopicInfo topic = Topics.GetTopicInfo(topicid);
                // 如果该主题不存在
                if (topic == null)
                {
                    AddErrLine("不存在的主题ID");
                    return;
                }

                topictitle = topic.Title;
                forumid    = topic.Fid;
                forum      = Forums.GetForumInfo(forumid);
                forumname  = forum.Name;
                pagetitle  = Utils.RemoveHtml(forum.Name);
                forumnav   = forum.Pathlist;

                CheckFavorite(FavoriteType.ForumTopic, topicid, "主题");
            }

            //收藏的是相册
            if (albumid != -1)
            {
                AlbumPluginBase apb = AlbumPluginProvider.GetInstance();
                if (apb == null)
                {
                    AddErrLine("未安装相册插件");
                    return;
                }
                if (apb.GetAlbumInfo(albumid) == null)
                {
                    AddErrLine("不存在的相册ID");
                    return;
                }

                CheckFavorite(FavoriteType.Album, albumid, "相册");
            }

            //收藏的是空间文章
            if (blogid != -1)
            {
                SpacePluginBase spb = SpacePluginProvider.GetInstance();
                if (spb == null)
                {
                    AddErrLine("未安装空间插件");
                    return;
                }
                if (spb.GetSpacepostsInfo(blogid) == null)
                {
                    AddErrLine("不存在的文章ID");
                    return;
                }

                CheckFavorite(FavoriteType.SpacePost, blogid, "文章");
            }

            //收藏的是商品
            if (goodsid != -1)
            {
                MallPluginBase mpb = MallPluginProvider.GetInstance();
                if (mpb == null)
                {
                    AddErrLine("未安装交易插件");
                    return;
                }
                if (mpb.GetGoodsInfo(goodsid) == null)
                {
                    AddErrLine("不存在的商品ID");
                    return;
                }

                CheckFavorite(FavoriteType.Goods, goodsid, "商品");
            }
        }
Ejemplo n.º 4
0
        private void BindItem()
        {
            switch (listtype)
            {
            case "spacepost":
                SpacePluginBase spb = SpacePluginProvider.GetInstance();
                if (spb == null)
                {
                    AddErrLine("未安装空间插件");
                    return;
                }
                spacepostcount = spb.GetSpacePostCountWithSameTag(tagid);
                SetPage(spacepostcount);
                if (spacepostcount > 0)
                {
                    spacepostlist = spb.GetSpacePostsWithSameTag(tagid, pageid, config.Tpp);
                    pagenumbers   = Utils.GetPageNumbers(pageid, pagecount, "tags.aspx?t=spacepost&tagid=" + tagid, 8);
                }
                else
                {
                    AddErrLine("该标签下暂无日志");
                }
                break;

            case "photo":
                AlbumPluginBase apb = AlbumPluginProvider.GetInstance();
                if (apb == null)
                {
                    AddErrLine("未安装相册插件");
                    return;
                }
                photocount = apb.GetPhotoCountWithSameTag(tagid);
                SetPage(photocount);
                if (photocount > 0)
                {
                    photolist = apb.GetPhotosWithSameTag(tagid, pageid, config.Tpp);
                    foreach (PhotoInfo photo in photolist)
                    {
                        if (photo.Filename.IndexOf("http") < 0)     //当是远程照片时
                        {
                            photo.Filename = forumpath + AlbumPluginProvider.GetInstance().GetThumbnailImage(photo.Filename);
                        }
                        else
                        {
                            photo.Filename = AlbumPluginProvider.GetInstance().GetThumbnailImage(photo.Filename);
                        }
                    }
                    pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "tags.aspx?t=photo&tagid=" + tagid, 8);
                }
                else
                {
                    AddErrLine("该标签下暂无图片");
                }
                break;

            case "mall":
                if (MallPluginProvider.GetInstance() == null)
                {
                    AddErrLine("未安装商城插件");
                    return;
                }
                goodscount = MallPluginProvider.GetInstance().GetGoodsCountWithSameTag(tagid);
                SetPage(goodscount);
                if (goodscount > 0)
                {
                    goodslist   = MallPluginProvider.GetInstance().GetGoodsWithSameTag(tagid, pageid, config.Tpp);
                    pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "tags.aspx?t=mall&tagid=" + tagid, 8);
                }
                else
                {
                    AddErrLine("该标签下暂无商品");
                }
                break;

            case "topic":
                topiccount = Topics.GetTopicCountByTagId(tagid);
                SetPage(topiccount);
                if (topiccount > 0)
                {
                    topiclist   = Topics.GetTopicListByTagId(tagid, pageid, config.Tpp);
                    pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "tags.aspx?t=topic&tagid=" + tagid, 8);
                }
                else
                {
                    AddErrLine("该标签下暂无主题");
                }
                break;
            }
        }