コード例 #1
0
ファイル: AdminForums.cs プロジェクト: terryxym/DiscuzNT
 /// <summary>
 /// 创建表情
 /// </summary>
 /// <param name="displayorder">显示顺序</param>
 /// <param name="type">分类</param>
 /// <param name="code">快捷编码</param>
 /// <param name="url">图片地址</param>
 /// <param name="adminUid">管理员Id</param>
 /// <param name="adminUserName">管理员用户名</param>
 /// <param name="adminUserGruopId">管理员用户组Id</param>
 /// <param name="adminUserGroupTitle">管理员用户组名称</param>
 /// <param name="adminIp">管理员IP</param>
 public static void CreateSmilies(int displayOrder, int type, string code, string url, int adminUid, string adminUserName, int adminUserGruopId,
                                  string adminUserGroupTitle, string adminIp)
 {
     Discuz.Data.Smilies.CreateSmilies(Smilies.GetMaxSmiliesId(), displayOrder, type, code, url);
     ResetCacheObjectAboutSmilies();
     AdminVistLogs.InsertLog(adminUid, adminUserName, adminUserGruopId, adminUserGroupTitle, adminIp, "表情文件添加", code);
 }
コード例 #2
0
ファイル: Smilies.cs プロジェクト: Williebwl/Discuz_vs08
        /// <summary>
        /// 初始化表情正则对象数组
        /// </summary>
        public static void InitRegexSmilies()
        {
            SmiliesInfo[] smiliesList = Smilies.GetSmiliesListWithInfo();
            //对表情进行排序,将标识符长的放到最开始,这样可以让长标识表情先解释,以防止:giggle :g 解释为[:g]iggle [:g]
            for (int Outer = smiliesList.Length - 1; Outer >= 1; Outer--)
            {
                //一次冒泡排序比较0~ourter-1个元素的大小
                for (int Inner = 0; Inner <= Outer - 1; Inner++)
                {
                    //排序过程
                    if (smiliesList[Inner].Code.Length < smiliesList[Inner + 1].Code.Length)
                    {
                        SmiliesInfo temp = smiliesList[Inner];
                        smiliesList[Inner]     = smiliesList[Inner + 1];
                        smiliesList[Inner + 1] = temp;
                    }
                }
            }
            regexSmile = new Regex[smiliesList.Length];

            for (int i = 0; i < smiliesList.Length; i++)
            {
                regexSmile[i] = new Regex(@Regex.Escape(smiliesList[i].Code), RegexOptions.None);
            }
        }
コード例 #3
0
ファイル: DiscuzCloud.cs プロジェクト: xiongeee/BBX
        public static bool PushFeedToDiscuzCloud(TopicInfo topic, PostInfo post, AttachmentInfo[] attachments, UserConnect connectInfo, string ip, string rootUrl)
        {
            DiscuzCloudConfigInfo       config = DiscuzCloudConfigInfo.Current;
            List <DiscuzOAuthParameter> list   = new List <DiscuzOAuthParameter>();

            list.Add(new DiscuzOAuthParameter("client_ip", ip));
            list.Add(new DiscuzOAuthParameter("thread_id", topic.Tid.ToString()));
            list.Add(new DiscuzOAuthParameter("author_id", topic.Posterid.ToString()));
            list.Add(new DiscuzOAuthParameter("author", topic.Poster));
            list.Add(new DiscuzOAuthParameter("forum_id", topic.Fid.ToString()));
            list.Add(new DiscuzOAuthParameter("p_id", post.Pid.ToString()));
            list.Add(new DiscuzOAuthParameter("subject", topic.Title));
            GeneralConfigInfo config2 = GeneralConfigInfo.Current;

            list.Add(new DiscuzOAuthParameter("html_content", UBB.UBBToHTML(new PostpramsInfo
            {
                Sdetail     = post.Message,
                Smiliesinfo = Smilies.GetSmiliesListWithInfo(),
                Bbcodemode  = config2.Bbcodemode,
                Parseurloff = post.Parseurloff,
                BBCode      = post.Bbcodeoff < 1,
                Signature   = 0,
                Allowhtml   = post.Htmlon,
                Pid         = post.Pid,
                Showimages  = 1 - post.Smileyoff,
                Smileyoff   = post.Smileyoff,
                Smiliesmax  = config2.Smiliesmax,
                Hide        = 0
            })));
            list.Add(new DiscuzOAuthParameter("bbcode_content", post.Message));
            list.Add(new DiscuzOAuthParameter("read_permission", "0"));
            list.Add(new DiscuzOAuthParameter("u_id", topic.Posterid.ToString()));
            list.Add(new DiscuzOAuthParameter("f_type", TypeConverter.BooleanToIntString(connectInfo.AllowPushFeed)));
            StringBuilder stringBuilder = new StringBuilder();
            int           num           = 0;

            if (attachments != null)
            {
                for (int i = 0; i < attachments.Length; i++)
                {
                    AttachmentInfo attachmentInfo = attachments[i];
                    if (num < 3 && attachmentInfo.Filetype.IndexOf("image") > -1 && attachmentInfo.Attachprice <= 0)
                    {
                        stringBuilder.AppendFormat("|{0}upload/{1}", rootUrl, attachmentInfo.Filename.Replace("\\", "/"));
                        num++;
                    }
                }
            }
            list.Add(new DiscuzOAuthParameter("attach_images", stringBuilder.ToString().TrimStart('|')));
            DiscuzOAuth discuzOAuth = new DiscuzOAuth();
            string      postData    = "";
            string      oAuthUrl    = discuzOAuth.GetOAuthUrl(API_CONNECT_URL + "connect/feed/new", "POST", config.Connectappid, config.Connectappkey, connectInfo.Token, connectInfo.Secret, "", "", list, out postData);

            Utils.GetHttpWebResponse(oAuthUrl, postData);
            return(true);
        }
コード例 #4
0
        /// <summary>
        /// 初始化表情正则对象数组
        /// </summary>
        public static void InitRegexSmilies()
        {
            SmiliesInfo[] smiliesList  = Smilies.GetSmiliesListWithInfo();
            int           smiliesCount = smiliesList.Length;

            regexSmile = new Regex[smiliesCount];

            for (int i = 0; i < smiliesCount; i++)
            {
                regexSmile[i] = new Regex(@Regex.Escape(smiliesList[i].Code), RegexOptions.None);
            }
        }
コード例 #5
0
ファイル: AdminUsers.cs プロジェクト: xkandj/proj-15-pks1.1
        /// <summary>
        /// 更新用户全部信息
        /// </summary>
        /// <param name="__userinfo"></param>
        /// <returns></returns>
        public static bool UpdateUserAllInfo(UserInfo userInfo)
        {
            Users.UpdateUser(userInfo);

            //当用户不是版主(超级版主)或管理员
            if ((userInfo.Adminid == 0) || (userInfo.Adminid > 3))
            {
                //删除用户在版主列表中相关数据
                Data.Moderators.DeleteModerator(userInfo.Uid);
                //同时更新版块相关的版主信息
                UpdateForumsFieldModerators(userInfo.Username);
            }
            else
            {
                DNTCache cache = DNTCache.GetCacheService();
                cache.RemoveObject("/Forum/AdminUsers");
            }

            #region 以下为更新该用户的扩展信息

            string signature = Utils.HtmlEncode(ForumUtils.BanWordFilter(userInfo.Signature));

            UserGroupInfo     usergroupinfo = AdminUserGroups.AdminGetUserGroupInfo(userInfo.Groupid);
            GeneralConfigInfo config        = GeneralConfigs.GetConfig();

            PostpramsInfo postPramsInfo = new PostpramsInfo();
            postPramsInfo.Usergroupid        = usergroupinfo.Groupid;
            postPramsInfo.Attachimgpost      = config.Attachimgpost;
            postPramsInfo.Showattachmentpath = config.Showattachmentpath;
            postPramsInfo.Hide                   = 0;
            postPramsInfo.Price                  = 0;
            postPramsInfo.Sdetail                = userInfo.Signature;
            postPramsInfo.Smileyoff              = 1;
            postPramsInfo.Bbcodeoff              = 1 - usergroupinfo.Allowsigbbcode;
            postPramsInfo.Parseurloff            = 1;
            postPramsInfo.Showimages             = usergroupinfo.Allowsigimgcode;
            postPramsInfo.Allowhtml              = 0;
            postPramsInfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
            postPramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
            postPramsInfo.Smiliesmax             = config.Smiliesmax;
            postPramsInfo.Signature              = 1;
            postPramsInfo.Onlinetimeout          = config.Onlinetimeout;

            userInfo.Signature = signature;
            userInfo.Authstr   = ForumUtils.CreateAuthStr(20);
            userInfo.Sightml   = UBB.UBBToHTML(postPramsInfo);
            Users.UpdateUser(userInfo);

            #endregion

            Users.UpdateUserForumSetting(userInfo);
            return(true);
        }
コード例 #6
0
        /// <summary>
        /// 获得表情分类列表
        /// </summary>
        /// <returns>表情分类列表</returns>
        public static DataTable GetSmilieTypesCache()
        {
            Discuz.Cache.DNTCache cache       = Discuz.Cache.DNTCache.GetCacheService();
            DataTable             smilietypes = cache.RetrieveObject("/UI/SmiliesTypeList") as DataTable;

            if (smilietypes == null || smilietypes.Rows.Count == 0)
            {
                smilietypes = Smilies.GetSmilieTypes();
                cache.AddObject("/UI/SmiliesTypeList", smilietypes);
            }

            return(smilietypes);
        }
コード例 #7
0
ファイル: AdminUsers.cs プロジェクト: object8421/ichari
        /// <summary>
        /// 更新用户全部信息
        /// </summary>
        /// <param name="__userinfo"></param>
        /// <returns></returns>
        public static bool UpdateUserAllInfo(UserInfo __userinfo)
        {
            DatabaseProvider.GetInstance().UpdateUserAllInfo(__userinfo);

            //当用户不是版主(超级版主)或管理员
            if ((__userinfo.Adminid == 0) || (__userinfo.Adminid > 3))
            {
                //删除用户在版主列表中相关数据
                DatabaseProvider.GetInstance().DeleteModerator(__userinfo.Uid);

                //同时更新版块相关的版主信息
                UpdateForumsFieldModerators(__userinfo.Username);
            }

            #region 以下为更新该用户的扩展信息

            string signature = Utils.HtmlEncode(ForumUtils.BanWordFilter(__userinfo.Signature));

            UserGroupInfo     usergroupinfo = AdminUserGroups.AdminGetUserGroupInfo(__userinfo.Groupid);
            GeneralConfigInfo config        = GeneralConfigs.GetConfig();

            PostpramsInfo _postpramsinfo = new PostpramsInfo();
            _postpramsinfo.Usergroupid        = usergroupinfo.Groupid;
            _postpramsinfo.Attachimgpost      = config.Attachimgpost;
            _postpramsinfo.Showattachmentpath = config.Showattachmentpath;
            _postpramsinfo.Hide                   = 0;
            _postpramsinfo.Price                  = 0;
            _postpramsinfo.Sdetail                = __userinfo.Signature;
            _postpramsinfo.Smileyoff              = 1;
            _postpramsinfo.Bbcodeoff              = 1 - usergroupinfo.Allowsigbbcode;
            _postpramsinfo.Parseurloff            = 1;
            _postpramsinfo.Showimages             = usergroupinfo.Allowsigimgcode;
            _postpramsinfo.Allowhtml              = 0;
            _postpramsinfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
            _postpramsinfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
            _postpramsinfo.Smiliesmax             = config.Smiliesmax;
            _postpramsinfo.Signature              = 1;
            _postpramsinfo.Onlinetimeout          = config.Onlinetimeout;

            DatabaseProvider.GetInstance().UpdateUserField(__userinfo, signature, ForumUtils.CreateAuthStr(20), UBB.UBBToHTML(_postpramsinfo));

            #endregion

            Users.UpdateUserForumSetting(__userinfo);

            return(true);
        }
コード例 #8
0
        /// <summary>
        /// 获取第一页的表情
        /// </summary>
        /// <returns>获取第一页的表情</returns>
        public static string GetSmiliesFirstPageCache()
        {
            DNTCache cache = DNTCache.GetCacheService();
            string   str   = cache.RetrieveObject("/UI/SmiliesListFirstPage") as string;

            if (str != null)
            {
                return(str);
            }
            StringBuilder builder = new StringBuilder();
            DataTable     dt      = Smilies.GetSmiliesListDataTable();

            foreach (DataRow drCate in dt.Copy().Rows)
            {
                if (drCate["type"].ToString() == "0")
                {
                    builder.AppendFormat("'{0}': [\r\n", drCate["code"].ToString().Trim().Replace("'", "\\'"));
                    bool flag = false;

                    int smiliescount = 0;
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr["type"].ToString() == drCate["id"].ToString() && smiliescount < 16)
                        {
                            builder.Append("{'code' : '");
                            builder.Append(dr["code"].ToString().Trim().Replace("'", "\\'"));
                            builder.Append("', 'url' : '");
                            builder.Append(dr["url"].ToString().Trim().Replace("'", "\\'"));
                            builder.Append("'},\r\n");
                            flag = true;
                            smiliescount++;
                        }
                    }
                    if (builder.Length > 0 && flag)
                    {
                        builder.Remove(builder.Length - 3, 3);
                    }
                    builder.Append("\r\n],\r\n");

                    break;
                }
            }
            builder.Remove(builder.Length - 3, 3);

            cache.AddObject("/UI/SmiliesListFirstPage", builder.ToString());
            return(builder.ToString());
        }
コード例 #9
0
ファイル: DiscuzCloud.cs プロジェクト: Natsuwind/DeepInSummer
        /// <summary>
        /// 发送feed请求到云平台
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="post"></param>
        /// <param name="attachments"></param>
        /// <param name="connectInfo"></param>
        /// <returns></returns>
        public static bool PushFeedToDiscuzCloud(TopicInfo topic, PostInfo post, AttachmentInfo[] attachments, UserConnectInfo connectInfo, string ip, string rootUrl)
        {
            DiscuzCloudConfigInfo       config   = DiscuzCloudConfigs.GetConfig();
            List <DiscuzOAuthParameter> parmlist = new List <DiscuzOAuthParameter>();

            parmlist.Add(new DiscuzOAuthParameter("client_ip", ip));
            parmlist.Add(new DiscuzOAuthParameter("thread_id", topic.Tid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("author_id", topic.Posterid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("author", topic.Poster));
            parmlist.Add(new DiscuzOAuthParameter("forum_id", topic.Fid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("p_id", post.Pid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("subject", topic.Title));

            #region 构造postparmsinfo

            GeneralConfigInfo generalConfig = GeneralConfigs.GetConfig();
            PostpramsInfo     postpramsInfo = new PostpramsInfo();
            postpramsInfo.Sdetail     = post.Message;
            postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo();
            postpramsInfo.Bbcodemode  = generalConfig.Bbcodemode;
            postpramsInfo.Parseurloff = post.Parseurloff;
            postpramsInfo.Bbcodeoff   = post.Bbcodeoff;
            postpramsInfo.Signature   = 0;
            postpramsInfo.Allowhtml   = post.Htmlon;
            postpramsInfo.Pid         = post.Pid;
            postpramsInfo.Showimages  = 1 - post.Smileyoff;
            postpramsInfo.Smileyoff   = post.Smileyoff;
            postpramsInfo.Smiliesmax  = generalConfig.Smiliesmax;
            //判断是否为回复可见帖, hide=0为不解析[hide]标签, hide>0解析为回复可见字样, hide=-1解析为以下内容回复可见字样显示真实内容
            //将逻辑判断放入取列表的循环中处理,此处只做是否为回复人的判断,主题作者也该可见
            postpramsInfo.Hide = 0;

            #endregion
            parmlist.Add(new DiscuzOAuthParameter("html_content", UBB.UBBToHTML(postpramsInfo)));
            parmlist.Add(new DiscuzOAuthParameter("bbcode_content", post.Message));
            parmlist.Add(new DiscuzOAuthParameter("read_permission", "0"));
            parmlist.Add(new DiscuzOAuthParameter("u_id", topic.Posterid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("f_type", connectInfo.AllowPushFeed.ToString()));

            StringBuilder attachUrlList = new StringBuilder();
            int           attachCount   = 0;
            if (attachments != null)
            {
                foreach (AttachmentInfo info in attachments)
                {
                    if (attachCount < 3 && info.Filetype.IndexOf("image") > -1 && info.Attachprice <= 0)
                    {
                        attachUrlList.AppendFormat("|{0}upload/{1}", rootUrl, info.Filename.Replace("\\", "/"));
                        attachCount++;
                    }
                }
            }

            parmlist.Add(new DiscuzOAuthParameter("attach_images", attachUrlList.ToString().TrimStart('|')));

            DiscuzOAuth oAuth    = new DiscuzOAuth();
            string      queryStr = "";
            string      feedUrl  = oAuth.GetOAuthUrl(API_CONNECT_URL + "connect/feed/new", "POST",
                                                     config.Connectappid, config.Connectappkey, connectInfo.Token, connectInfo.Secret, "", "", parmlist, out queryStr);

            Utils.GetHttpWebResponse(feedUrl, queryStr);
            return(true);
        }