Exemple #1
0
        public static byte Auto_Login_User()
        {
            String admin_User_Value = Tool.NTool.GetCookieValue(User_login_ck_name);

            string[] arr = admin_User_Value.Split('_');

            if (Tool.NStr.hasSessionValue(NModel.EnObject.CurrentLoginUserSessionName))
            {
                return(1);
            }
            else if (Tool.NTool.IsArrEqualLen <string>(arr, 2))
            {
                BLL.DB_Session bll_Session = new BLL.DB_Session();
                long           User_ID     = 0;
                long.TryParse(arr[1], out User_ID);
                bool has = bll_Session.Exists_CID_UserID(arr[0], User_ID);
                if (has)
                {
                    BLL.DB_User bll = new BLL.DB_User();
                    HttpContext.Current.Session[NModel.EnObject.CurrentLoginUserSessionName] = bll.GetModel((long?)User_ID);
                    bll.Close();
                    return(2);
                }
            }

            return(0);
        }
Exemple #2
0
        public ActionResult Login()
        {
            NModel.NewsPager model_pager      = LoadConfig("/nlcq/login");
            string           loginCaptcha     = this.Request.Form["loginCaptcha"];
            string           User_ID          = this.Request.Form["User_ID"];
            string           User_Pw          = this.Request.Form["User_Pw"];
            string           isCutLoginStatus = this.Request.Form["isCutLoginStatus"];

            bool UserNotEmpty = !string.IsNullOrEmpty(User_ID) && !string.IsNullOrEmpty(User_Pw);
            bool isNotEmpty   = !string.IsNullOrEmpty(loginCaptcha) && !string.IsNullOrEmpty(NModel.EnObject.GetCodeValue);

            if (isNotEmpty && UserNotEmpty)
            {
                if (loginCaptcha.Trim().ToLower().Equals(NModel.EnObject.GetCodeValue.Trim().ToLower()))
                {
                    byte isBool = 0;
                    byte.TryParse(isCutLoginStatus, out isBool);
                    bool isCue = isBool == 1 ? true : false;

                    BLL.DB_User bll_User = new BLL.DB_User();
                    bool        isLogin  = bll_User.CheckLogin(User_ID, User_Pw, "", isCue);
                    bll_User.Close();
                    if (isLogin)
                    {
                        return(this.RedirectToAction("index", "nlcq"));
                    }
                }
            }

            return(View(model_pager));
        }
Exemple #3
0
        //
        // GET: /NLCQ/
        public ActionResult Reg()
        {
            NModel.NewsPager model_pager = LoadConfig("/nlcq/reg");

            string _Captcha         = this.Request.Form["Captcha"];
            string password         = this.Request.Form["password"];
            string isCueLoginStatus = this.Request["isCueLoginStatus"];

            //验证码
            if (!string.IsNullOrEmpty(_Captcha) && !string.IsNullOrEmpty(NModel.EnObject.GetCodeValue + ""))
            {
                if (_Captcha.Equals(NModel.EnObject.GetCodeValue + ""))
                {
                    String JsonStr = "";

                    NModel.DB_User model    = new NModel.DB_User();
                    BLL.DB_User    bll_User = new BLL.DB_User();

                    bool isGet = Tool.NStr.PostForSetVal <NModel.DB_User>(ref model, ref JsonStr, "");

                    bool isUserNameExists = !String.IsNullOrEmpty(model.User_Name) && bll_User.ExistsName(model.User_Name);

                    if (isGet && !isUserNameExists)
                    {
                        bool isUserEmailExists = !String.IsNullOrEmpty(model.User_Email) && bll_User.ExistsEmail(model.User_Email);
                        if (!isUserEmailExists)
                        {
                            if (!string.IsNullOrEmpty(model.User_PW) && !string.IsNullOrEmpty(password))
                            {
                                //密码是否相同
                                if (model.User_PW.Trim().Equals(password.Trim()))
                                {
                                    model.User_PW = NMd5.GetMd5Hash(model.User_PW);
                                    //增加数据
                                    if (bll_User.AddFree(model) > 0)
                                    {
                                        bll_User.CheckLogin(model.User_Name, model.User_PW, _Captcha, true);
                                        Tool.NMsg.AlertAndRedirect("注册成功", "/nlcq/index");
                                    }

                                    //登录

                                    //刷新验证码
                                    NCaptcha.Generate(NModel.EnObject.UserCodeSessionName);
                                }
                            }
                        }
                    }
                    bll_User.Close();
                }
            }

            // if(isGet&&model.)

            return(View(model_pager));
        }
Exemple #4
0
        public ActionResult UserExistName()
        {
            string name = this.Request.Form["param"];

            BLL.DB_User bll_user = new BLL.DB_User();

            bool isHasName = bll_user.ExistsName(name);

            if (isHasName)
            {
                this.Response.Write("{ \"info\":\"用户已存在\", \"status\":\"n\" }");
            }
            else
            {
                this.Response.Write("{ \"info\":\"用户名已通验证\", \"status\":\"y\" }");
            }

            bll_user.Close();

            return(View());
        }
Exemple #5
0
        public ActionResult UploadHeadCut()
        {
            BLL.DB_Img_Category  dal = new BLL.DB_Img_Category();
            System.Drawing.Image img = null;
            //进行裁剪
            System.Drawing.Bitmap bmpCrop = null;

            BLL.DB_Image           dal_di = new BLL.DB_Image();
            NModel.DB_Img_Category c_dic  = new NModel.DB_Img_Category();
            try
            {
                Response.ContentType = "text/plain";
                String _img = Request.Form["img"];

                string oldPath = Server.MapPath(uploadPath) + "\\" + _img.Trim();
                //新图片路径
                string newimg = "small_" + DateTime.Now.ToString("hhmmssfff") + _img;
                ;
                String newPath = Server.MapPath(uploadPath) + "\\" + newimg;

                //设置截取的坐标和大小
                int x = 0, y = 20, width = 200, height = 2400;

                string _x = Request.Form["x"];
                string _y = Request.Form["y"];
                string _w = Request.Form["w"];
                string _h = Request.Form["h"];

                int.TryParse(_x, out x);
                int.TryParse(_y, out y);
                int.TryParse(_w, out width);
                int.TryParse(_h, out height);
                //计算新的文件名,在旧文件名后加_new

                //定义截取矩形
                System.Drawing.Rectangle cropArea = new System.Drawing.Rectangle(x, y, width, height);                 //要截取的区域大小

                //加载图片
                img = System.Drawing.Image.FromStream(new System.IO.MemoryStream(System.IO.File.ReadAllBytes(oldPath)));

                //判断超出的位置否
                if ((img.Width < x + width) || img.Height < y + height)
                {
                    Response.Write("截取的区域超过了图片本身的高度、宽度.");
                    img.Dispose();
                    return(View());
                }
                //定义Bitmap对象
                System.Drawing.Bitmap bmpImage = new System.Drawing.Bitmap(img);

                //进行裁剪
                bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);

                //保存成新文件

                string dffpath = this.Server.MapPath(UFPath);
                bool   Has     = System.IO.Directory.Exists(dffpath);
                if (!Has)
                {
                    System.IO.Directory.CreateDirectory(dffpath);
                }

                string thumbnail_id = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                string file_id      = DateTime.Now.ToString("yyyyMMdd");

                string AllFilePath = dffpath;

                string allPath   = this.Server.MapPath(DictFilePath);
                string ALLDFPath = this.Server.MapPath(DFPath);
                string cid       = this.Request.QueryString["cid"];
                int    count     = Request.Files.Count;

                long _cid = 0;
                long.TryParse(cid, out _cid);
                string size = "0x0";

                {
                    if (_cid > 0)
                    {
                        c_dic = dal.GetModel(_cid);
                        if (c_dic != null && !string.IsNullOrEmpty(c_dic.Img_category_Folder))
                        {
                            file_id = c_dic.Img_category_Folder;
                        }

                        if (c_dic != null && !string.IsNullOrEmpty(c_dic.Img_category_Size))
                        {
                            size = c_dic.Img_category_Size;
                        }
                    }

                    // original_image = System.Drawing.Image.FromStream(jpeg_image_upload.InputStream);
                    //system.Drawing.Image.FromFile(ph)
                    string[] sz = size.Split(';');
                    string[] fr = file_id.Split(';');

                    if (fr != null && fr.Length <= 10 && sz != null && sz.Length <= 10)
                    {
                        for (int i = 0; i < fr.Length; i++)
                        {
                            bool _Has = System.IO.Directory.Exists(ALLDFPath + "/" + fr[i]);
                            if (!_Has)
                            {
                                System.IO.Directory.CreateDirectory(ALLDFPath + "/" + fr[i]);
                            }

                            string[] xy = sz[i].Split('x');

                            int.TryParse(xy[0], out x);
                            int.TryParse(xy[1], out y);

                            string savepath = "/" + fr[i] + "/" + newimg;

                            string ap = ALLDFPath + savepath;

                            dal_di.DelByBelongsID(BLL.Fun.Current_Login_DB_User().User_ID);
                            string          delImagepath = "";
                            NModel.DB_Image cdi          = dal_di.GetModelByBelongsID(BLL.Fun.Current_Login_DB_User().User_ID);
                            if (cdi != null && !string.IsNullOrEmpty(cdi.Image_Url))
                            {
                                delImagepath = UploadFileController.DFPath + cdi.Image_Url;
                                bool isdelOk = Tool.NImage.DelImage(delImagepath);
                            }

                            bmpCrop.Save(ap.Trim());

                            var             user = BLL.Fun.Current_Login_DB_User();
                            NModel.DB_Image c_di = new NModel.DB_Image();

                            c_di.Image_AddTime     = DateTime.Parse(DateTime.Now.ToString("s"));
                            c_di.Image_EditTime    = DateTime.Parse(DateTime.Now.ToString("s"));
                            c_di.Image_Category_ID = _cid;
                            c_di.Image_SortNo      = 1;
                            c_di.Image_Status      = 1;
                            c_di.Image_Size        = sz[i];
                            c_di.Image_Operate     = 1;
                            c_di.Image_Url         = savepath;
                            c_di.Image_Belongs_ID  = long.Parse(user.User_ID + "");

                            c_di.Image_Name = user.User_Name;
                            bool isadd = dal_di.Add(c_di) > 0 ? true : false;

                            if (isadd)
                            {
                                BLL.DB_User    bll        = new BLL.DB_User();
                                NModel.DB_User user_model = new NModel.DB_User();
                                user_model.User_HeadImg = "/upload/" + imgPath + "" + savepath;
                                bll.EditFree(user_model, (long)user.User_ID);

                                bll.Close();
                                Response.Write("/upload/" + imgPath + "" + savepath);
                            }
                            else
                            {
                                Response.Write("/content/web/img/noerr.png");
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { }
            finally
            {
                if (dal != null)
                {
                    dal.Close();
                }

                if (dal_di != null)
                {
                    dal_di.Close();
                }
                //释放对象

                if (img != null)
                {
                    img.Dispose();
                }
                if (bmpCrop != null)
                {
                    bmpCrop.Dispose();
                }
            }

            return(View());
        }