/// <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; } }
/// <summary> /// 是否存在记录 /// </summary> /// <param name="_wherestr">条件</param> /// <returns></returns> public bool Exists(string _wherestr) { using (DbOperHandler _doh = new Common().Doh()) { int _ext = 0; _doh.Reset(); _doh.ConditionExpress = _wherestr; if (_doh.Exist("jcms_normal_page")) _ext = 1; return (_ext == 1); } }
/// <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); } }
/// <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); }
/// <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; }
/// <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")); } }
/// <summary> /// 判断是否有下属栏目 /// </summary> /// <param name="_id"></param> /// <returns></returns> public bool HasChild(string _channelid, string _id) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.ConditionExpress = "channelid=" + _channelid + " AND parentid=" + _id; bool _haschild = (_doh.Exist("jcms_normal_class")); return _haschild; } }
/// <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")); } }
/// <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 + "}"; } }
/// <summary> /// 检测指定IP地址是否已受到屏蔽 /// </summary> /// <param name="IP地址">要检测的IP地址</param> /// <returns>是否属于已屏蔽的IP</returns> public bool IPIsForbiding(string _ip) { using (DbOperHandler _doh = new Common().Doh()) { long ip = JumboTCMS.Utils.IPHelp.IP2Long(System.Net.IPAddress.Parse(_ip)); _doh.Reset(); if (this.DBType == "0") _doh.ConditionExpress = "StartIP<=" + ip + " and EndIP>=" + ip + " AND datediff('d','" + DateTime.Now.ToShortDateString() + "',ExpireDate)>0"; else _doh.ConditionExpress = "StartIP<=" + ip + " and EndIP>=" + ip + " AND datediff(d,'" + DateTime.Now.ToShortDateString() + "',ExpireDate)>0"; bool _isforbiding = _doh.Exist("jcms_normal_forbidip"); return _isforbiding; } }
/// <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; } }