Ejemplo n.º 1
0
        protected override void OnInit(EventArgs e)
        {
            if (bsites.GetList().Count > 0)
            {
                msite = bsites.GetList()[0];
                muser = (Model.users)Session[userKey];
            }

            if (!Page.IsPostBack)
            {
                var inm = Request.Url.ToString().ToLower().IndexOf("/manager/");
                if (inm > -1)
                {
                    //权限验证
                    if (Session[userKey] == null)
                    {
                        if (Request.Url.ToString().ToLower().IndexOf("/manager/login") == -1)
                        {
                            Response.Write("<script>if(window.opener){window.opener.document.location='/manager/login';}else{document.location='/manager/login';};</script>");
                        }
                    }
                }
                else
                {
                    //前台页面
                }
            }

            base.OnInit(e);
            this.Load  += new System.EventHandler(PageBase_Load);
            this.Error += new System.EventHandler(PageBase_Error);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.sites GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.sites model = new Model.sites();
            //利用反射获得属性的所有公共属性
            Type modelType = model.GetType();

            PropertyInfo[] pros = modelType.GetProperties();
            foreach (PropertyInfo p in pros)
            {
                str1.Append(p.Name + ",");//拼接字段
            }
            strSql.Append("select " + str1.ToString().Trim(','));
            strSql.Append(" from " + databaseprefix + "sites");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32, 4)
            };
            parameters[0].Value = id;
            DataTable dt = DbHelperMySql.Query(strSql.ToString(), parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                return(DataRowToModel(dt.Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.sites GetModel(string build_path)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.sites model = new Model.sites();
            //利用反射获得属性的所有公共属性
            PropertyInfo[] pros = model.GetType().GetProperties();
            foreach (PropertyInfo p in pros)
            {
                str1.Append(p.Name + ",");//拼接字段
            }
            strSql.Append("select " + str1.ToString().Trim(','));
            strSql.Append(" from " + databaseprefix + "sites");
            strSql.Append(" where build_path=@build_path");
            SqlParameter[] parameters =
            {
                new SqlParameter("@build_path", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = build_path;
            DataTable dt = DbHelperSQL.Query(strSql.ToString(), parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                return(DataRowToModel(dt.Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            JC.Model.sites msite  = new Model.sites();
            JC.Model.posts mpost  = new Model.posts();
            JC.BLL.sites   bsites = new BLL.sites();
            JC.BLL.posts   bposts = new BLL.posts();

            var tbs = "msgs";

            key = obj["siteKey"].ToString();

            context.Response.ContentType = "text/plain";
            var name   = context.Request.Form["name"];
            var mobile = context.Request.Form["mobile"];
            var info   = context.Request.Form["info"];
            var ua     = context.Request.Form["ua"];
            var date   = DateTime.Now.ToString();
            var res    = "";

            msite = bsites.GetList()[0];

            try
            {
                var mailFrom   = msite.mail;
                var mailPwd    = JC.Common.DESEncrypt.Decrypt(msite.mailpwd, key);//破解密码
                var smtpServer = msite.mailsmtp;
                var smtpPort   = msite.mailport;
                var mailToList = new List <string>();
                var tit        = "客户" + name + ",手机" + mobile + ",发过来的咨询邮件--" + msite.title;
                var bod        = @"<p>用户名称:<b>" + name + "</b></p>";
                bod += "<p>用户手机:<b>" + mobile + ":</b></p>";
                bod += "<p>UA:<b>" + ua + ":</b></p>";
                bod += @"<hr />";
                bod += @"<p>咨询内容:<b>" + info + "</b></p>";
                bod += @"<p style='text-align:right'>" + date + "</p>";

                JC.Common.Common.MultiSendEmail(smtpServer, smtpPort, mailFrom, mailPwd, mailToList, null, null, tit, bod, null, true);

                //插入数据库
                mpost.postby     = name;
                mpost.postdate   = DateTime.Now;
                mpost.modifydate = DateTime.Now;
                mpost.content    = info;
                mpost.ext1       = mobile;
                mpost.enable     = 0;
                mpost.read       = 0;
                mpost.ext        = tbs;//VIP code

                bposts.Add(mpost);

                res = "{status:\"1\",msg:\"邮件发送成功!\"}";
            }
            catch (Exception)
            {
                res = "{status:\"0\",msg:\"邮件发送失败!\"}";
                throw;
            }
            context.Response.Write(res);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 返回站点信息
        /// </summary>
        public Model.sites GetSiteModel()
        {
            string requestDomain = System.Web.HttpContext.Current.Request.Url.Authority.ToLower(); //获得来源域名含端口号
            string requestPath   = System.Web.HttpContext.Current.Request.RawUrl.ToLower();        //当前的URL地址
            string sitePath      = GetSitePath(requestPath, requestDomain);

            Model.sites modelt = SiteDomains.GetSiteDomains().SiteList.Find(p => p.build_path == sitePath);
            return(modelt);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.sites model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        StringBuilder str1   = new StringBuilder(); //数据字段
                        StringBuilder str2   = new StringBuilder(); //数据参数

                        //利用反射获得属性的所有公共属性
                        PropertyInfo[]      pros  = model.GetType().GetProperties();
                        List <SqlParameter> paras = new List <SqlParameter>();
                        strSql.Append("insert into " + databaseprefix + "sites(");
                        foreach (PropertyInfo pi in pros)
                        {
                            //如果不是主键则追加sql字符串
                            if (!pi.Name.Equals("id"))
                            {
                                //判断属性值是否为空
                                if (pi.GetValue(model, null) != null)
                                {
                                    str1.Append(pi.Name + ",");                                           //拼接字段
                                    str2.Append("@" + pi.Name + ",");                                     //声明参数
                                    paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                                }
                            }
                        }
                        strSql.Append(str1.ToString().Trim(','));
                        strSql.Append(") values (");
                        strSql.Append(str2.ToString().Trim(','));
                        strSql.Append(") ");
                        strSql.Append(";select @@IDENTITY;");
                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), paras.ToArray());//带事务
                        model.id = Convert.ToInt32(obj);
                        //如果不是基于其它站点数据则添加导航菜单
                        if (model.parent_id == 0)
                        {
                            new DAL.navigation(databaseprefix).Add(conn, trans, "sys_contents", "channel_" + model.build_path, model.title, "", model.sort_id, 0, "Show");
                        }
                        trans.Commit();//提交事务
                    }
                    catch
                    {
                        trans.Rollback();//回滚事务
                        return(0);
                    }
                }
            }
            return(model.id);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 父类的构造函数
 /// </summary>
 public BasePage()
 {
     //是否关闭网站
     if (config.webstatus == 0)
     {
         HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode(config.webclosereason)));
         return;
     }
     //取得站点信息
     site = GetSiteModel();
     //抛出一个虚方法给继承重写
     ShowPage();
 }
Ejemplo n.º 8
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.sites   bll   = new BLL.sites();
            Model.sites model = bll.GetModel(_id);

            model.parent_id  = int.Parse(ddlParentId.SelectedValue);
            model.title      = txtTitle.Text.Trim();
            model.build_path = txtBuildPath.Text.Trim();
            model.domain     = txtDomain.Text.Trim();
            model.sort_id    = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            if (cbIsDefault.Checked == true)
            {
                model.is_default = 1;
            }
            else
            {
                model.is_default = 0;
            }
            if (cbIsLock.Checked == true)
            {
                model.is_lock = 0;
            }
            else
            {
                model.is_lock = 0;
            }
            model.site_type       = int.Parse(rblSiteType.SelectedValue);
            model.name            = txtName.Text.Trim();
            model.logo            = txtLogo.Text.Trim();
            model.company         = txtCompany.Text.Trim();
            model.address         = txtAddress.Text.Trim();
            model.tel             = txtTel.Text.Trim();
            model.fax             = txtFax.Text.Trim();
            model.email           = txtEmail.Text.Trim();
            model.crod            = txtCrod.Text.Trim();
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keyword     = txtSeoKeyword.Text.Trim();
            model.seo_description = Utils.DropHTML(txtSeoDescription.Text);
            model.copyright       = txtCopyright.Text.Trim();

            if (bll.Update(model))
            {
                CacheHelper.Remove(DTKeys.CACHE_SITE_HTTP_DOMAIN);                      //更新一下域名缓存
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改站点:" + model.title); //记录日志
                result = true;
            }

            return(result);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.sites model, string old_build_path)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.ConnectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        StringBuilder str1   = new StringBuilder();
                        //利用反射获得属性的所有公共属性
                        PropertyInfo[]      pros  = model.GetType().GetProperties();
                        List <SqlParameter> paras = new List <SqlParameter>();
                        strSql.Append("update  " + databaseprefix + "sites set ");
                        foreach (PropertyInfo pi in pros)
                        {
                            //如果不是主键则追加sql字符串
                            if (!pi.Name.Equals("id"))
                            {
                                //判断属性值是否为空
                                if (pi.GetValue(model, null) != null)
                                {
                                    str1.Append(pi.Name + "=@" + pi.Name + ",");                          //声明参数
                                    paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                                }
                            }
                        }
                        strSql.Append(str1.ToString().Trim(','));
                        strSql.Append(" where id=@id ");
                        paras.Add(new SqlParameter("@id", model.id));
                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), paras.ToArray());

                        //检查旧导航是否存在
                        if (new DAL.navigation(databaseprefix).GetModel(conn, trans, "channel_" + old_build_path) != null)
                        {
                            //修改导航菜单
                            new DAL.navigation(databaseprefix).Update(conn, trans, "channel_" + old_build_path, "channel_" + model.build_path, model.title, model.sort_id);
                        }
                        trans.Commit();//提交事务
                    }
                    catch
                    {
                        trans.Rollback();//回滚事务
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 10
0
        private bool DoAdd()
        {
            Model.sites model = new Model.sites();
            BLL.sites   bll   = new BLL.sites();

            model.title      = txtTitle.Text.Trim();
            model.build_path = txtBuildPath.Text.Trim();
            model.domain     = txtDomain.Text.Trim();
            model.sort_id    = ConvertTool.ToInt(txtSortId.Text.Trim(), 99);
            if (cbIsDefault.Checked == true)
            {
                model.is_default = 1;
            }
            else
            {
                model.is_default = 0;
            }
            if (cbIsLock.Checked == true)
            {
                model.is_lock = 0;
            }
            else
            {
                model.is_lock = 0;
            }
            model.name            = txtName.Text.Trim();
            model.logo            = txtLogo.Text.Trim();
            model.company         = txtCompany.Text.Trim();
            model.address         = txtAddress.Text.Trim();
            model.tel             = txtTel.Text.Trim();
            model.fax             = txtFax.Text.Trim();
            model.email           = txtEmail.Text.Trim();
            model.crod            = txtCrod.Text.Trim();
            model.seo_title       = txtSeoTitle.Text.Trim();
            model.seo_keyword     = txtSeoKeyword.Text.Trim();
            model.seo_description = Utils.DropHTML(txtSeoDescription.Text);
            model.copyright       = txtCopyright.Text.Trim();

            if (bll.Add(model) > 0)
            {
                //更新一下域名缓存
                CacheHelper.Remove(DTKeys.CACHE_SITE_HTTP_DOMAIN);
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加站点:" + model.title); //记录日志
                return(true);
            }

            return(false);
        }
Ejemplo n.º 11
0
        //private string appkey = "dingzreafyvgzklylomj";
        //private string appsecret = "e-PldpQ915MdEYJlL-s3P3kp8Z9HBi1GcaQOHfr39PfgY6AG2lPn16KqgYaMyr3J";

        /// <summary>
        /// 获取access_token
        /// </summary>
        //private string gettoken_url = @"https://oapi.dingtalk.com/gettoken";

        /// <summary>
        /// 获取用户userid
        /// </summary>
        //private string getuserinfo_url = @"https://oapi.dingtalk.com/user/getuserinfo?access_token=access_token&code=code";


        /// <summary>
        /// 父类的构造函数
        /// </summary>
        public BasePage()
        {
            //是否关闭网站
            if (config.webstatus == 0)
            {
                HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode(config.webclosereason)));
                return;
            }
            //取得站点信息
            site = GetSiteModel();
            //抛出一个虚方法给继承重写
            ShowPage();

            //OapiGettokenResponse response = getDingTalkAccessToken();
            //HttpContext.Current.Response.Write(response.AccessToken);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 将对象转换实体
 /// </summary>
 public Model.sites DataRowToModel(DataRow row)
 {
     Model.sites model = new Model.sites();
     if (row != null)
     {
         //利用反射获得属性的所有公共属性
         Type modelType = model.GetType();
         for (int i = 0; i < row.Table.Columns.Count; i++)
         {
             PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName);
             if (proInfo != null && row[i] != DBNull.Value)
             {
                 proInfo.SetValue(model, row[i], null);//用索引值设置属性值
             }
         }
     }
     return(model);
 }
Ejemplo n.º 13
0
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     base.OnActionExecuting(filterContext);
     //this.CheckRoot();
     //是否关闭网站
     if (config.webstatus == 0)
     {
         filterContext.Result = Redirect(linkurl("error", "?msg=" + Utils.UrlEncode(config.webclosereason)));
         return;
     }
     //取得站点信息
     site                 = GetSiteModel();
     web_view             = string.Format(web_view, site.build_path, this.GetType().Name.Replace("Controller", ""));
     ViewBag.site         = site;
     ViewBag.config       = config;
     ViewBag.uconfig      = uconfig;
     ViewBag.TemplateSkin = site.build_path;
     ViewBag.BasePage     = this;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JC.Model.sites Get(int id)
        {
            object objModel = JC.Common.DataCache.Get(cacName);

            JC.Model.sites md = new Model.sites();
            if (objModel != null)
            {
                List <JC.Model.sites> modelList = (List <JC.Model.sites>)objModel;
                if (modelList != null && modelList.Count > 0)
                {
                    md = modelList.Find(c => c.id == id);
                }
            }
            else
            {
                md = dal.GetModel(id);
            }
            return(md);
        }
Ejemplo n.º 15
0
        private void ShowInfo(int _id)
        {
            BLL.sites   bll   = new BLL.sites();
            Model.sites model = bll.GetModel(_id);

            txtTitle.Text     = model.title;
            txtBuildPath.Text = model.build_path;
            txtBuildPath.Attributes.Add("ajaxurl", "../../tools/admin_ajax.ashx?action=site_path_validate&old_build_path=" + Utils.UrlEncode(model.build_path));
            txtBuildPath.Focus(); //设置焦点,防止JS无法提交
            txtDomain.Text = model.domain;
            txtSortId.Text = model.sort_id.ToString();
            if (model.is_default == 1)
            {
                cbIsDefault.Checked = true;
            }
            else
            {
                cbIsDefault.Checked = false;
            }
            if (model.is_lock == 0)
            {
                cbIsLock.Checked = true;
            }
            else
            {
                cbIsLock.Checked = false;
            }
            ddlParentId.SelectedValue = model.parent_id.ToString();
            rblSiteType.SelectedValue = model.site_type.ToString();
            txtName.Text           = model.name;
            txtLogo.Text           = model.logo;
            txtCompany.Text        = model.company;
            txtAddress.Text        = model.address;
            txtTel.Text            = model.tel;
            txtFax.Text            = model.fax;
            txtEmail.Text          = model.email;
            txtCrod.Text           = model.crod;
            txtSeoTitle.Text       = model.seo_title;
            txtSeoKeyword.Text     = model.seo_keyword;
            txtSeoDescription.Text = model.seo_description;
            txtCopyright.Text      = model.copyright;
        }
Ejemplo n.º 16
0
        private string CreateIndexHtml(string lang, string aspx_filename, string catalogue)
        {
            if (File.Exists(Utils.GetMapPath(config.webpath + aspx_filename.Substring(0, aspx_filename.IndexOf(".aspx") + 5))))
            {
                string urlPath  = config.webpath + aspx_filename.Replace("^", "&"); //文件相对路径
                string htmlPath = config.webpath + catalogue;                       //保存相对路径
                if (htmlPath.IndexOf(".") < 0)
                {
                    htmlPath = htmlPath + "index." + config.staticextension;
                }
                //检查目录是否存在
                string directorystr = HttpContext.Current.Server.MapPath(htmlPath.Substring(0, htmlPath.LastIndexOf("/")));
                if (!Directory.Exists(directorystr))
                {
                    Directory.CreateDirectory(directorystr);
                }
                string linkwebsite = HttpContext.Current.Request.Url.Authority;

                Model.sites modelchannelsite = objchannel_site.GetModel("build_path='" + lang + "'", string.Empty, string.Empty);
                if (modelchannelsite != null && !string.IsNullOrEmpty(modelchannelsite.domain))
                {
                    linkwebsite = modelchannelsite.domain;
                }
                System.Net.WebRequest  request      = System.Net.WebRequest.Create("http://" + linkwebsite + urlPath);
                System.Net.WebResponse response     = request.GetResponse();
                System.IO.Stream       stream       = response.GetResponseStream();
                System.IO.StreamReader streamreader = new System.IO.StreamReader(stream, System.Text.Encoding.GetEncoding("utf-8"));
                string content = streamreader.ReadToEnd();
                using (StreamWriter sw = new StreamWriter(Utils.GetMapPath(htmlPath), false, Encoding.UTF8))
                {
                    sw.WriteLine(content);
                    sw.Flush();
                    sw.Close();
                }
                return("0");
            }
            else
            {
                return("1");
                //HttpContext.Current.Response.Write("1");//找不到生成的模版!
            }
        }
Ejemplo n.º 17
0
Archivo: sites.cs Proyecto: SuanR/ande
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.sites model)
        {
            string old_build_path = dal.GetBuildPath(model.id);

            if (string.IsNullOrEmpty(old_build_path))
            {
                return(false);
            }
            if (dal.Update(model, old_build_path))
            {
                if (old_build_path.ToLower() != model.build_path.ToLower())
                {
                    //更改频道分类对应的目录名称
                    FileHelper.MoveDirectory(sysConfig.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/" + old_build_path,
                                             sysConfig.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/" + model.build_path);
                    FileHelper.MoveDirectory(sysConfig.webpath + DTKeys.DIRECTORY_REWRITE_HTML + "/" + old_build_path,
                                             sysConfig.webpath + DTKeys.DIRECTORY_REWRITE_HTML + "/" + model.build_path);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 18
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("sys_site_manage", DTEnums.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.sites bll = new BLL.sites();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    //检查该分类下是否还有频道
                    int channelCount = new BLL.site_channel().GetCount("site_id=" + id);
                    if (channelCount > 0)
                    {
                        errorCount += 1;
                        continue;
                    }
                    Model.sites model = bll.GetModel(id);
                    //删除成功后对应的目录及文件
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                        FileHelp.DeleteDirectory(sysConfig.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/" + model.build_path);
                        FileHelp.DeleteDirectory(sysConfig.webpath + DTKeys.DIRECTORY_REWRITE_HTML + "/" + model.build_path);
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除站点成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("site_list.aspx", "keywords={0}", this.keywords), "parent.loadMenuTree");
        }
Ejemplo n.º 19
0
Archivo: sites.cs Proyecto: SuanR/ande
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.sites model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 20
0
 // GET: api/Sites/5
 public string Get(int id)
 {
     model = bll.Get(id);
     return(JsonConvert.SerializeObject(model));
 }