示例#1
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;
 }
示例#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_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;
 }
示例#3
0
 /// <summary>
 /// 更新购物车商品信息
 /// </summary>
 /// <param name="_productid">根据产品查询</param>
 /// <param name="_buycount"></param>
 /// <param name="_state">1表示状态发生了变化</param>
 /// <returns></returns>
 public bool UpdateGoods(string _uid, string _productid, int _buycount, int _state)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         int _num = 0;
         if (_state == 0)
         {
             _doh.Reset();
             _doh.ConditionExpress = "ProductId=" + _productid + " and state=0 and userid=" + _uid;
             _doh.AddFieldItem("BuyCount", _buycount);
             _doh.AddFieldItem("CartTime", DateTime.Now.ToString());
             _num = _doh.Update("jcms_normal_user_cart");
         }
         else if (_state == 1)
         {
             _doh.Reset();
             _doh.ConditionExpress = "ProductId=" + _productid + " and state=1 and userid=" + _uid;
             _doh.AddFieldItem("State", 1);
             _num = _doh.Update("jcms_normal_user_cart");
         }
         return (_num == 1);
     }
 }
示例#4
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;
            }
        }
示例#5
0
 /// <summary>
 /// 更新购物信息
 /// </summary>
 /// <param name="_uid"></param>
 /// <param name="_ids"></param>
 /// <param name="_ordernum"></param>
 /// <param name="_state"></param>
 /// <returns></returns>
 public int UpdateGoods(string _uid, string _ids, int _state)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         int _num = 0;
         if (_state == 1)
         {
             _doh.Reset();
             _doh.ConditionExpress = "Id in (" + _ids + ") and state=0 and userid=" + _uid;
             _doh.AddFieldItem("State", 1);
             _num = _doh.Update("jcms_normal_user_goods");
         }
         else if (_state == 2)
         {
             _doh.Reset();
             _doh.ConditionExpress = "Id in (" + _ids + ") and state=1 and userid=" + _uid;
             _doh.AddFieldItem("State", 2);
             _num = _doh.Update("jcms_normal_user_goods");
         }
         return _num;
     }
 }
示例#6
0
 /// <summary>
 /// 在线支付成功,给会员充博币
 /// </summary>
 /// <param name="_uid"></param>
 /// <param name="_ordernum"></param>
 /// <param name="_payway">如:支付宝、财付通等</param>
 /// <returns></returns>
 public bool UpdateOrder(string _uid, string _ordernum, string _payway)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "OrderNum='" + _ordernum + "' and state=0 and userid=" + _uid;
         int _points = Str2Int(_doh.GetField("jcms_normal_recharge", "Points").ToString());
         if (_points > 0)//充值的博币
         {
             new Normal_UserDAL().AddPoints(_uid, _points);
             _doh.Reset();
             _doh.ConditionExpress = "OrderNum='" + _ordernum + "' and state=0 and userid=" + _uid;
             _doh.AddFieldItem("State", 1);
             _doh.AddFieldItem("PaymentWay", _payway);
             _doh.Update("jcms_normal_recharge");
             return true;
         }
         else
         {
             return false;
         }
     }
 }
示例#7
0
 /// <summary>
 /// 更新订单
 /// </summary>
 /// <param name="_uid"></param>
 /// <param name="_ordernum">通过订单号棋查询</param>
 /// <param name="_state">1表示付款;2表示交易完成(货收到了)</param>
 /// <param name="_payway">如:alipay、tenpay等</param>
 /// <returns></returns>
 public int UpdateOrder(string _uid, string _ordernum, int _state, string _payway)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         int _num = 0;
         if (_state == 1)
         {
             _doh.Reset();
             _doh.ConditionExpress = "OrderNum='" + _ordernum + "' and state=0 and userid=" + _uid;
             _doh.AddFieldItem("State", 1);
             _doh.AddFieldItem("PaymentWay", _payway);
             _num = _doh.Update("jcms_normal_user_order");
         }
         else if (_state == 2)
         {
             _doh.Reset();
             _doh.ConditionExpress = "OrderNum='" + _ordernum + "' and state=1 and userid=" + _uid;
             _doh.AddFieldItem("State", 2);
             _num = _doh.Update("jcms_normal_user_order");
         }
         return _num;
     }
 }
示例#8
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="_id">用户ID</param>
 /// <param name="_pass">修改后的密码</param>
 public void ChangePsd(string _id, string _pass)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "id=" + _id;
         _doh.AddFieldItem("UserPass", _pass);
         _doh.Update("jcms_normal_user");
     }
 }
示例#9
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);
     }
 }
示例#10
0
 /// <summary>
 /// 续费VIP
 /// </summary>
 /// <param name="_id">用户ID</param>
 /// <param name="_vipyears">续的年数</param>
 public void AddVIPYears(string _id, int _vipyears)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         DateTime LimitDate = DateTime.Now;
         _doh.Reset();
         _doh.ConditionExpress = "id=" + _id;
         object[] values = _doh.GetFields("jcms_normal_user", "IsVIP,VIPTime");
         bool _isvip = (JumboTCMS.Utils.Validator.StrToInt(values[0].ToString(), 0) == 1);
         if (!_isvip)//如果还不是VIP
             LimitDate = DateTime.Now.AddYears(_vipyears);
         else
         {
             if (JumboTCMS.Utils.Validator.ValidDate(values[1].ToString()))//如果已经过期
                 LimitDate = DateTime.Now.AddYears(_vipyears);
             else
                 LimitDate = DateTime.Parse(values[1].ToString()).AddYears(_vipyears);
         }
         _doh.Reset();
         _doh.ConditionExpress = "id=" + _id;
         _doh.AddFieldItem("IsVIP", 1);
         _doh.AddFieldItem("VIPTime", LimitDate);
         _doh.Update("jcms_normal_user");
     }
 }
示例#11
0
 public int Register(string _username, string _nickname, string _userpass, bool isMD5Passwd, int _sex, string _email, string _birthday, string _usersign, string _adminname, string _adminpass, string _oauth_code, string _oauth_token)
 {
     if (_oauth_code == "") _oauth_code = "tencent";
     if (Exists(string.Format("username='******'", _username)))
         return 0;
     using (DbOperHandler _doh = new Common().Doh())
     {
         string _md5pass = isMD5Passwd ? _userpass : JumboTCMS.Utils.MD5.Lower32(_userpass);
         string _md5pass2 = isMD5Passwd ? _adminpass : JumboTCMS.Utils.MD5.Lower32(_adminpass);
         int dPoints = Str2Int(JumboTCMS.Utils.XmlCOM.ReadConfig("~/_data/config/site", "DefaultPoints"), 0);
         int uState = site.CheckReg ? 0 : 1;
         object[,] addFields = new object[2, 19] {
                 {
                     "UserName", "NickName", "UserPass", "Sex", "Email", "Birthday",
                     "Group", "Points", "Login", "State", "AdminId", "Setting", "UserSign",
                     "AdminState", "IsVIP", "Integral","RegTime", "RegIp","Token_"+_oauth_code},
                 {
                     _username, _nickname, _md5pass, _sex,_email, _birthday,
                     1, dPoints, 0, uState,0, ",,", _usersign,
                     0,0, 0, DateTime.Now.ToString(),IPHelp.ClientIP,_oauth_token}
                 };
         _doh.Reset();
         _doh.AddFieldItems(addFields);
         int _uID = _doh.Insert("jcms_normal_user");
         #region 复制头像
         JumboTCMS.Utils.DirFile.CopyFile("~/_data/avatar/0_l.jpg", "~/_data/avatar/" + _uID + "_l.jpg", true);
         JumboTCMS.Utils.DirFile.CopyFile("~/_data/avatar/0_m.jpg", "~/_data/avatar/" + _uID + "_m.jpg", true);
         JumboTCMS.Utils.DirFile.CopyFile("~/_data/avatar/0_s.jpg", "~/_data/avatar/" + _uID + "_s.jpg", true);
         #endregion
         #region 同步升级为管理员
         if (_adminname.Length > 0 && _adminpass.Length > 0)
         {
             _doh.Reset();
             _doh.ConditionExpress = "id=" + _uID;
             _doh.AddFieldItem("State", 1);
             _doh.AddFieldItem("AdminState", 1);
             _doh.AddFieldItem("AdminId", _uID);
             _doh.AddFieldItem("AdminName", _adminname);
             _doh.AddFieldItem("AdminPass", _md5pass2);
             _doh.AddFieldItem("Group", site.AdminGroupId);
             _doh.Update("jcms_normal_user");
             _doh.Reset();
             _doh.ConditionExpress = "id=" + site.AdminGroupId;
             _doh.Add("jcms_normal_usergroup", "UserTotal");
         }
         else
         {
             _doh.Reset();
             _doh.ConditionExpress = "id=1";
             _doh.Add("jcms_normal_usergroup", "UserTotal");
         }
         #endregion
         #region 论坛同步注册
         if (site.ForumAPIKey != "")
         {
             string _ForumAutoRegister = JumboTCMS.Utils.XmlCOM.ReadConfig("~/_data/config/site", "ForumAutoRegister");
             if (_ForumAutoRegister == "true")//表示自动注册论坛用户
             {
                 JumboTCMS.API.Discuz.Toolkit.DiscuzSession ds = JumboTCMS.API.Discuz.DiscuzSessionHelper.GetSession();
                 int _userid = ds.Register(_username, _userpass, _email, isMD5Passwd);
                 if (_userid > 0)
                 {
                     //注册成功
                     _doh.Reset();
                     _doh.ConditionExpress = "id=" + _uID;
                     _doh.AddFieldItem("ForumName", _username);
                     _doh.AddFieldItem("ForumPass", _md5pass);
                     _doh.Update("jcms_normal_user");
                     return _uID;
                 }
                 return 0;
             }
             return _uID;
         }
         #endregion
         return _uID;
     }
 }
示例#12
0
 /// <summary>
 /// 插入GUID
 /// </summary>
 /// <param name="_id"></param>
 public string InsertGUID(string _id, DbOperHandler doh)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         string _guid = "";
         _doh.Reset();
         _doh.SqlCmd = "SELECT [GUID] FROM [jcms_normal_user] WHERE [Id]=" + _id;
         DataTable dt = _doh.GetDataTable();
         if (dt.Rows.Count > 0)
         {
             _guid = dt.Rows[0][0].ToString();
         }
         if (_guid.Length != 36)
         {
             _guid = Guid.NewGuid().ToString();
             _doh.ConditionExpress = "id=" + _id;
             _doh.AddFieldItem("guid", _guid);
             _doh.Update("jcms_normal_user");
         }
         return _guid;
     }
 }
示例#13
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 "帐号不存在";
                }

            }
        }
示例#14
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;
     }
 }