Example #1
0
        /// <summary>
        /// 得到内容
        /// </summary>
        /// <param name="_channeltype"></param>
        /// <param name="_contentid"></param>
        /// <returns></returns>
        public Normal_Digg GetDigg(string _channeltype, string _contentid)
        {
            using (DbOperHandler _doh = new Common().Doh())
            {
                Normal_Digg digg = new Normal_Digg();
                digg.ChannelType = _channeltype;
                digg.ContentId = Str2Int(_contentid);
                _doh.Reset();
                _doh.ConditionExpress = "channeltype=@channeltype and contentid=@contentid";
                _doh.AddConditionParameter("@channeltype", _channeltype);
                _doh.AddConditionParameter("@contentid", _contentid);
                if (!_doh.Exist("jcms_normal_digg"))
                {
                    _doh.Reset();
                    _doh.AddFieldItem("ChannelType", _channeltype);
                    _doh.AddFieldItem("ContentId", _contentid);

                    _doh.AddFieldItem("DiggNum", 0);
                    _doh.Insert("jcms_normal_digg");
                }
                _doh.Reset();
                _doh.ConditionExpress = "channeltype=@channeltype and contentid=@contentid";
                _doh.AddConditionParameter("@channeltype", _channeltype);
                _doh.AddConditionParameter("@contentid", _contentid);
                digg.DiggNum = Str2Int(_doh.GetField("jcms_normal_digg", "DiggNum").ToString());
                return digg;
            }
        }
Example #2
0
 /// <summary>
 /// 批量操作插件
 /// </summary>
 /// <param name="_act">行为</param>
 /// <param name="_ids">id,以,隔开</param>
 public bool BatchOper(string _act, string _ids)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         string[] idValue;
         idValue = _ids.Split(',');
         if (_act == "pass")
         {
             for (int i = 0; i < idValue.Length; i++)
             {
                 _doh.Reset();
                 _doh.ConditionExpress = "id=@id";
                 _doh.AddConditionParameter("@id", idValue[i]);
                 _doh.AddFieldItem("Enabled", 1);
                 _doh.Update("jcms_normal_user_oauth");
             }
         }
         else if (_act == "nopass")
         {
             for (int i = 0; i < idValue.Length; i++)
             {
                 _doh.Reset();
                 _doh.ConditionExpress = "id=@id";
                 _doh.AddConditionParameter("@id", idValue[i]);
                 _doh.AddFieldItem("Enabled", 0);
                 _doh.Update("jcms_normal_user_oauth");
             }
         }
     }
     return true;
 }
Example #3
0
 /// <summary>
 /// 批量操作插件
 /// </summary>
 /// <param name="_act">行为</param>
 /// <param name="_ids">id,以,隔开</param>
 public bool BatchOper(string _act, string _ids)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         string[] idValue;
         idValue = _ids.Split(',');
         if (_act == "pass")
         {
             for (int i = 0; i < idValue.Length; i++)
             {
                 _doh.Reset();
                 _doh.ConditionExpress = "id=@id";
                 _doh.AddConditionParameter("@id", idValue[i]);
                 _doh.AddFieldItem("Enabled", 1);
                 _doh.Update("jcms_normal_extends");
             }
         }
         else if (_act == "nopass")
         {
             for (int i = 0; i < idValue.Length; i++)
             {
                 _doh.Reset();
                 _doh.ConditionExpress = "id=@id";
                 _doh.AddConditionParameter("@id", idValue[i]);
                 _doh.AddFieldItem("Enabled", 0);
                 _doh.Update("jcms_normal_extends");
             }
         }
         string TempStr = "";
         _doh.Reset();
         _doh.SqlCmd = JumboTCMS.Utils.SqlHelp.GetSql("[Title],[Name],[Type],[Enabled]", "jcms_normal_extends", "pId", 100, 1, "desc", "");
         DataTable dt = _doh.GetDataTable();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             if(dt.Rows[i]["Enabled"].ToString() =="1")
                 TempStr += "\r\nvar Plugin" + dt.Rows[i]["Name"].ToString() + "	= true;//" + dt.Rows[i]["Title"].ToString() + "插件";
             else
                 TempStr += "\r\nvar Plugin" + dt.Rows[i]["Name"].ToString() + "	= false;//" + dt.Rows[i]["Title"].ToString() + "插件";
         }
         string _globalJS = JumboTCMS.Utils.DirFile.ReadFile("~/_data/jcmsV5.js");
         string _strBegin = "//<!--插件开关begin";
         string _strEnd = "//-->插件开关end";
         System.Collections.ArrayList TagArray = JumboTCMS.Utils.Strings.GetHtmls(_globalJS, _strBegin, _strEnd, true, true);
         if (TagArray.Count > 0)//标签存在
         {
             _globalJS = _globalJS.Replace(TagArray[0].ToString(), _strBegin + "\r\n\r\n" + TempStr + "\r\n\r\n" + _strEnd);
         }
         JumboTCMS.Utils.DirFile.SaveFile(_globalJS, "~/_data/jcmsV5.js");
     }
     return true;
 }
Example #4
0
        /// <summary>
        /// 通过对方ID删除好友,如果不存在返回false
        /// </summary>
        /// <param name="_userid">发起方id</param>
        /// <param name="_username">发起方name</param>
        /// <param name="_friendid">自增长id</param>
        /// <returns></returns>
        public bool DeleteByFriendID(string _userid, string _username, string _friendid)
        {
            _username = _username == "" ? "user(id:" + _userid + ")" : _username;
            using (DbOperHandler _doh = new Common().Doh())
            {
                _doh.Reset();
                _doh.ConditionExpress = "friendid=@friendid and userid=@userid";
                _doh.AddConditionParameter("@friendid", _friendid);
                _doh.AddConditionParameter("@userid", _userid);
                int _del = _doh.Delete("jcms_normal_user_friends");
                if (_del == 1)
                    new JumboTCMS.DAL.Normal_UserNoticeDAL().SendNotite("解除好友", "<a href=\"javascript:void(0);\" onclick=\"ShowUserPage(" + _userid + ");\">" + _username + "</a> 和你解除了好友关系", _friendid, "friend");

                return (_del == 1);
            }
        }
Example #5
0
 /// <summary>
 /// 增加标签点击数
 /// </summary>
 /// <param name="_channelid"></param>
 /// <param name="_tagname"></param>
 public void AddClickTimes(string _channelid, string _tagname)
 {
     if (_tagname.Length == 0) return;
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "Title=@Title and ChannelId=" + _channelid;
         _doh.AddConditionParameter("@Title", _tagname);
         _doh.Add("jcms_normal_tag", "ClickTimes");
     }
 }
Example #6
0
 /// <summary>
 /// 删除一条数据
 /// </summary>
 public bool DeleteByID(string _id)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "id=@id";
         _doh.AddConditionParameter("@id", _id);
         int _del = _doh.Delete("jcms_normal_page");
         return (_del == 1);
     }
 }
Example #7
0
 /// <summary>
 /// 判断是否已经为好友
 /// </summary>
 /// <param name="_userid"></param>
 /// <param name="_friendid"></param>
 /// <returns></returns>
 public bool Exists(string _userid, string _friendid)
 {
     int _ext = 0;
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "friendid=@friendid and userid=@userid";
         _doh.AddConditionParameter("@friendid", _friendid);
         _doh.AddConditionParameter("@userid", _userid);
         if (_doh.Exist("jcms_normal_user_friends"))
             _ext = 1;
     }
     return (_ext == 1);
 }
Example #8
0
 /// <summary>
 /// 是否正在运行
 /// </summary>
 /// <param name="_oauthcode">接口代码</param>
 /// <returns></returns>
 public bool Running(string _oauthcode)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "code=@code and Enabled=1";
         _doh.AddConditionParameter("@code", _oauthcode);
         return (_doh.Exist("jcms_normal_user_oauth"));
     }
 }
Example #9
0
        /// <summary>
        /// 会员登录
        /// </summary>
        /// <param name="_username"></param>
        /// <param name="_userpass"></param>
        /// <param name="iExpires"></param>
        /// <param name="isMD5Passwd"></param>
        /// <returns></returns>
        public string ChkUserLogin(string _username, string _userpass, int iExpires, bool isMD5Passwd)
        {
            if (!isMD5Passwd)
                _userpass = JumboTCMS.Utils.MD5.Lower32(_userpass);
            using (DbOperHandler _doh = new Common().Doh())
            {
                _username = _username.Replace("\'", "");
                _doh.Reset();
                _doh.ConditionExpress = "username=@username";
                _doh.AddConditionParameter("@username", _username);
                string _userid = _doh.GetField("jcms_normal_user", "id").ToString();
                if (_userid != "")
                {
                    JumboTCMS.Entity.Normal_User _User = new JumboTCMS.DAL.Normal_UserDAL().GetEntity(_userid);
                    if (_User.UserPass != _userpass)
                    {
                        return "密码错误";
                    }
                    if (_User.State != 1)
                    {
                        return "帐号被锁定";
                    }
                    _doh.Reset();
                    _doh.SqlCmd = "SELECT [id],[GroupName],[IsLogin],[Setting] FROM [jcms_normal_usergroup] WHERE [Id]=" + _User.Group;
                    DataTable dtUserGroup = _doh.GetDataTable();
                    if (dtUserGroup.Rows.Count == 0)
                    {
                        return "用户组有误";
                    }
                    if (dtUserGroup.Rows[0]["IsLogin"].ToString() != "1")
                    {
                        return "帐号禁止登录";
                    }
                    string _userGroupid = dtUserGroup.Rows[0]["Id"].ToString();
                    string _userGroupname = dtUserGroup.Rows[0]["GroupName"].ToString();
                    string _userSetting = dtUserGroup.Rows[0]["Setting"].ToString();
                    dtUserGroup.Clear();
                    dtUserGroup.Dispose();
                    string _userCookies = "c" + (new Random().Next(10000000, 99999999)).ToString();
                    //设置Cookies
                    System.Collections.Specialized.NameValueCollection myCol = new System.Collections.Specialized.NameValueCollection();
                    myCol.Add("id", _userid);
                    myCol.Add("name", _User.UserName);
                    myCol.Add("nickname", _User.NickName);
                    myCol.Add("password", _User.UserPass);
                    myCol.Add("email", _User.Email);
                    myCol.Add("groupid", _userGroupid);
                    myCol.Add("groupname", _userGroupname);
                    myCol.Add("setting", _userSetting);
                    myCol.Add("cookies", _userCookies);
                    JumboTCMS.Utils.Cookie.SetObj(site.CookiePrev + "user", 60 * 60 * 24 * iExpires, myCol, site.CookieDomain, site.CookiePath);

                    //更新User登陆信息
                    _doh.Reset();
                    _doh.ConditionExpress = "id=@id and state=1";
                    _doh.AddConditionParameter("@id", _userid);
                    _doh.AddFieldItem("Cookies", _userCookies);
                    _doh.AddFieldItem("LastTime", DateTime.Now.ToString());
                    _doh.AddFieldItem("LastIP", IPHelp.ClientIP);
                    _doh.AddFieldItem("UserSign", "");
                    _doh.Update("jcms_normal_user");
                    if (site.ForumAPIKey != "")
                    {
                        bool _AutoLogining = false;
                        string _ForumAutoRegister = JumboTCMS.Utils.XmlCOM.ReadConfig("~/_data/config/site", "ForumAutoRegister");
                        if (_ForumAutoRegister == "true")//表示自动注册论坛用户
                            _AutoLogining = true;
                        if (_AutoLogining == true)
                        {
                            //登陆社区
                            _doh.Reset();
                            _doh.ConditionExpress = "id=@id and state=1";
                            _doh.AddConditionParameter("@id", _userid);
                            object[] _forumInfo = _doh.GetFields("jcms_normal_user", "ForumName,ForumPass");
                            if (_forumInfo[0].ToString().Length > 0 && _forumInfo[1].ToString().Length > 0)
                            {
                                JumboTCMS.API.Discuz.Toolkit.DiscuzSession ds = JumboTCMS.API.Discuz.DiscuzSessionHelper.GetSession();
                                ds.Login(ds.GetUserID(_forumInfo[0].ToString()), _forumInfo[1].ToString(), true, iExpires, site.CookieDomain);
                            }
                        }
                    }
                    return "ok";
                }
                else
                {
                    return "帐号不存在";
                }

            }
        }
Example #10
0
 /// <summary>
 /// 内容加入专题
 /// </summary>
 /// <param name="_specialid">专题ID</param>
 /// <param name="_channelid">频道ID</param>
 /// <param name="_channeltype">频道类型,也就是内容的模型</param>
 /// <param name="_contentids">内容ID,以,隔开</param>
 public bool Move2Special(int _specialid, string _channelid, string _channeltype, string _contentids)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         string _contentid = string.Empty;
         string _title = string.Empty;
         _doh.Reset();
         _doh.SqlCmd = "SELECT [Id],[Title] FROM [jcms_module_" + _channeltype + "] WHERE [ChannelId]=" + _channelid + " AND [Id] In (" + _contentids + ")";
         DataTable dt = _doh.GetDataTable();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             _contentid = dt.Rows[i]["Id"].ToString();
             _title = dt.Rows[i]["Title"].ToString();
             _doh.Reset();
             _doh.ConditionExpress = "sid=@sid and contentid=@contentid and channelid=@channelid";
             _doh.AddConditionParameter("@sid", _specialid);
             _doh.AddConditionParameter("@contentid", _contentid);
             _doh.AddConditionParameter("@channelid", _channelid);
             if (!_doh.Exist("jcms_normal_specialcontent"))
             {
                 _doh.Reset();
                 _doh.AddFieldItem("Title", _title);
                 _doh.AddFieldItem("sId", _specialid);
                 _doh.AddFieldItem("ChannelId", _channelid);
                 _doh.AddFieldItem("ContentId", _contentid);
                 _doh.Insert("jcms_normal_specialcontent");
             }
         }
     }
     return true;
 }
Example #11
0
 /// <summary>
 /// 是否正在运行
 /// </summary>
 /// <param name="_extendname">插件名称</param>
 /// <returns></returns>
 public bool Running(string _extendname)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "name=@name and Enabled=1";
         _doh.AddConditionParameter("@name", _extendname);
         return (_doh.Exist("jcms_normal_extends"));
     }
 }
Example #12
0
        /// <summary>
        /// 获得新插件列表JSON
        /// </summary>
        /// <param name="_jsonstr"></param>
        public void GetNewJSON(ref string _jsonstr)
        {
            using (DbOperHandler _doh = new Common().Doh())
            {
                DirectoryInfo di = new DirectoryInfo(HttpContext.Current.Server.MapPath(site.Dir + "extends/"));
                DirectoryInfo[] directorylist = di.GetDirectories();
                string tempstr = "table:[";
                int extendcount = 0;
                string _title = "";
                string _name = "";
                string _author = "";
                string _type = "";
                foreach (DirectoryInfo dii in directorylist)
                {
                    if (!JumboTCMS.Utils.DirFile.FileExists(site.Dir + "extends/" + dii.Name + "/install.config"))
                        continue;
                    _title = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + dii.Name + "/install", "Title");
                    _name = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + dii.Name + "/install", "Name");
                    _author = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + dii.Name + "/install", "Author");
                    _type = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + dii.Name + "/install", "Type");

                    _doh.Reset();
                    _doh.ConditionExpress = "name=@name";
                    _doh.AddConditionParameter("@name", _name);
                    if (_doh.Exist("jcms_normal_extends"))
                        continue;
                    tempstr += ",{title: '" + _title + "'," +
                        "name: '" + _name + "'," +
                        "author: '" + _author + "'," +
                        "type: '" + _type + "'}";
                    extendcount++;
                }
                tempstr += "]";
                tempstr = tempstr.Replace("table:[,", "table:[");
                _jsonstr = "{result :\"1\",returnval :\"操作成功\",recordcount:" + extendcount + "," + tempstr + "}";

            }
        }
Example #13
0
        /// <summary>
        /// 删除一个插件
        /// </summary>
        /// <param name="_id"></param>
        /// <param name="_err">返回错误信息</param>
        /// <returns></returns>
        public bool DeleteByID(string _id, ref string _err)
        {
            using (DbOperHandler _doh = new Common().Doh())
            {
                if (_id != "" && _id != "0")
                {
                    _doh.Reset();
                    _doh.ConditionExpress = "id=@id";
                    _doh.AddConditionParameter("@id", _id);
                    object[] _values = _doh.GetFields("jcms_normal_extends", "Name,Locked,Enabled,BaseTable");
                    string eName = _values[0].ToString();
                    string eLocked = _values[1].ToString();
                    string eEnabled = _values[2].ToString();
                    string _delTables = _values[3].ToString();
                    if (eLocked == "1")
                    {
                        _err = "锁定的插件不可删";
                        return false;
                    }

                    if (eEnabled == "1")
                    {
                        _err = "先把插件禁用再卸载";
                        return false;
                    }

                    if (_delTables.Trim().Length > 0)//需要删除插件表
                    {
                        string[] _delTable = _delTables.Split(',');
                        for (int i = 0; i < _delTable.Length; i++)
                        {
                            _doh.Reset();
                            _doh.DropTable(_delTable[i]);
                        }
                    }
                    //删除插件整个目录
                    JumboTCMS.Utils.DirFile.DeleteDir(site.Dir + "extends/" + eName + "/");
                    _doh.Reset();
                    _doh.ConditionExpress = "id=@id";
                    _doh.AddConditionParameter("@id", _id);
                    _doh.Delete("jcms_normal_extends");
                }
                else
                {
                    _err = "参数错误";
                    return false;
                }
                return true;
            }
        }
Example #14
0
 /// <summary>
 /// 更新起/始IP整型值
 /// </summary>
 /// <param name="_id">编号</param>
 /// <param name="_startip">开始IP</param>
 /// <param name="_endip">结束IP</param>
 public bool UpdateIPData(string _id, string _startip, string _endip)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "id=@id";
         _doh.AddConditionParameter("@id", _id);
         _doh.AddFieldItem("StartIP", JumboTCMS.Utils.IPHelp.IP2Long(System.Net.IPAddress.Parse(_startip)));
         _doh.AddFieldItem("EndIP", JumboTCMS.Utils.IPHelp.IP2Long(System.Net.IPAddress.Parse(_endip)));
         _doh.AddFieldItem("Enabled", 1);
         int _update = _doh.Update("jcms_normal_forbidip");
         return (_update == 1);
     }
 }
Example #15
0
 /// <summary>
 /// 判断usersign是否正确
 /// </summary>
 /// <param name="_userid"></param>
 /// <param name="_usersign">长度一定是32位</param>
 /// <returns></returns>
 public bool ChkUserSign(string _userid, string _usersign)
 {
     if (_usersign.Length != 32 || _userid == "")
     {
         return false;
     }
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "id=@userid and usersign=@usersign and state=1";
         _doh.AddConditionParameter("@userid", Str2Int(_userid));
         _doh.AddConditionParameter("@usersign", _usersign);
         if (_doh.Exist("jcms_normal_user"))
             return true;
         else
             return false;
     }
 }
Example #16
0
        /// <summary>
        /// 移动
        /// </summary>
        /// <param name="_id"></param>
        /// <param name="_isup">true代表向上移动</param>
        /// <param name="_response"></param>
        /// <returns></returns>
        public bool Move(string _id, bool _isup, ref string _response)
        {
            using (DbOperHandler _doh = new Common().Doh())
            {
                if (_id == "0")
                {
                    _response = "ID错误";
                    return false;
                }
                _doh.Reset();
                _doh.ConditionExpress = "id=@id";
                _doh.AddConditionParameter("@id", _id);
                string pId = _doh.GetField("jcms_normal_user_oauth", "pId").ToString();

                string temp;
                _doh.Reset();
                if (_isup)
                {
                    _doh.ConditionExpress = "pId<@pId ORDER BY pId desc";
                    _doh.AddConditionParameter("@pId", pId);
                }
                else
                {
                    _doh.ConditionExpress = "pId>@pId ORDER BY pId";
                    _doh.AddConditionParameter("@pId", pId);
                }
                temp = _doh.GetField("jcms_normal_user_oauth", "pId").ToString();
                if (temp == "")
                {
                    _response = "无须移动";
                    return false;
                }
                else
                {
                    _doh.Reset();
                    _doh.ConditionExpress = "pId=@pId";
                    _doh.AddConditionParameter("@pId", temp);
                    _doh.AddFieldItem("pId", "-100000");
                    _doh.Update("jcms_normal_user_oauth");
                    _doh.Reset();
                    _doh.ConditionExpress = "id=@id";
                    _doh.AddConditionParameter("@id", _id);
                    _doh.AddFieldItem("pId", temp);
                    _doh.Update("jcms_normal_user_oauth");
                    _doh.Reset();
                    _doh.ConditionExpress = "pId=@pId";
                    _doh.AddConditionParameter("@pId", "-100000");
                    _doh.AddFieldItem("pId", pId);
                    _doh.Update("jcms_normal_user_oauth");

                }
                return true;
            }
        }
Example #17
0
 /// <summary>
 /// 判断重复性(标题是否存在)
 /// </summary>
 /// <param name="_title">需要检索的标题</param>
 /// <param name="_id">除外的ID</param>
 /// <param name="_wherestr">其他条件</param>
 /// <returns></returns>
 public bool ExistTitle(string _title, string _id, string _wherestr)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         int _ext = 0;
         _doh.Reset();
         _doh.ConditionExpress = "title=@title and id<>" + _id;
         if (_wherestr != "") _doh.ConditionExpress += " and " + _wherestr;
         _doh.AddConditionParameter("@title", _title);
         if (_doh.Exist("jcms_normal_page"))
             _ext = 1;
         return (_ext == 1);
     }
 }
Example #18
0
 /// <summary>
 /// 修改指定用户的密码
 /// </summary>
 /// <param name="_userid"></param>
 /// <param name="_originalPassword">原始密码</param>
 /// <param name="_newPassword">新密码</param>
 /// <returns></returns>
 public bool ChangeUserPassword(string _userid, string _originalPassword, string _newPassword)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "id=@id and state=1";
         _doh.AddConditionParameter("@id", _userid);
         object pass = _doh.GetField("jcms_normal_user", "UserPass");
         if (pass != null)//用户存在
         {
             if (pass.ToString().ToLower() == JumboTCMS.Utils.MD5.Lower32(_originalPassword) || pass.ToString().ToLower() == JumboTCMS.Utils.MD5.Lower16(_originalPassword)) //验证旧密码
             {
                 _doh.Reset();
                 _doh.ConditionExpress = "id=@id and state=1";
                 _doh.AddConditionParameter("@id", _userid);
                 _doh.AddFieldItem("UserPass", JumboTCMS.Utils.MD5.Lower32(_newPassword));
                 _doh.Update("jcms_normal_user");
                 return true;
             }
             else
                 return false;
         }
         else
             return false;
     }
 }