Example #1
0
        private void file_validate(HttpContext context)
        {
            string file_name = OSRequest.GetString("param");
            string skin      = OSRequest.GetString("skin");
            string type      = OSRequest.GetString("type");

            if (string.IsNullOrEmpty(file_name))
            {
                context.Response.Write("{ \"info\":\"文件名不可为空\", \"status\":\"n\" }");
                return;
            }
            string        sl = !string.IsNullOrEmpty(skin) ? "/" + skin : "";
            DirectoryInfo FatherDirectory = new DirectoryInfo(Utils.GetMapPath(@"../Template" + sl)); //当前目录

            FileInfo[] NewFileInfo = FatherDirectory.GetFiles();
            foreach (FileInfo DirFile in NewFileInfo)                    //获取此级目录下的所有文件
            {
                if (file_name + type == DirFile.Name.ToString())
                {
                    context.Response.Write("{ \"info\":\"该文件名已被占用,请更换!\", \"status\":\"n\" }");
                    return;
                }
            }
            context.Response.Write("{ \"info\":\"该文件名可使用\", \"status\":\"y\" }");
            return;
        }
Example #2
0
        private void UpLoadFile(HttpContext context)
        {
            string         _delfile     = OSRequest.GetString("DelFilePath");
            HttpPostedFile _upfile      = context.Request.Files["Filedata"];
            bool           _iswater     = false; //默认不打水印
            bool           _isthumbnail = false; //默认不生成缩略图

            if (OSRequest.GetQueryString("IsWater") == "1")
            {
                _iswater = true;
            }
            if (OSRequest.GetQueryString("IsThumbnail") == "1")
            {
                _isthumbnail = true;
            }
            if (_upfile == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}");
                return;
            }
            UpLoad upFiles = new UpLoad();
            string msg     = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater);

            //删除已存在的旧文件
            if (!string.IsNullOrEmpty(_delfile))
            {
                Utils.DeleteUpFile(_delfile);
            }
            //返回成功信息
            context.Response.Write(msg);
            context.Response.End();
        }
Example #3
0
        private void validate_username(HttpContext context)
        {
            string user_name = OSRequest.GetString("param");

            //如果为Null,退出
            if (string.IsNullOrEmpty(user_name))
            {
                context.Response.Write("{ \"info\":\"请输入用户名\", \"status\":\"n\" }");
                return;
            }
            Model.configs.userconfig userConfig = new BLL.configs.userconfig().loadConfig();
            //过滤注册用户名字符
            string[] strArray = userConfig.regkeywords.Split(',');
            foreach (string s in strArray)
            {
                if (s.ToLower() == user_name.ToLower())
                {
                    context.Response.Write("{ \"info\":\"用户名不可用\", \"status\":\"n\" }");
                    return;
                }
            }
            BLL.users.users bll = new BLL.users.users();
            //查询数据库
            if (bll.Exists(user_name.Trim()))
            {
                context.Response.Write("{ \"info\":\"用户名已重复\", \"status\":\"n\" }");
                return;
            }
            context.Response.Write("{ \"info\":\"用户名可用\", \"status\":\"y\" }");
            return;
        }
Example #4
0
        private void navigation_validate(HttpContext context)
        {
            string navname  = OSRequest.GetString("param");
            string old_name = OSRequest.GetString("old_name");

            if (string.IsNullOrEmpty(navname))
            {
                context.Response.Write("{ \"info\":\"该导航菜单ID不可为空!\", \"status\":\"n\" }");
                return;
            }
            if (navname.ToLower() == old_name.ToLower())
            {
                context.Response.Write("{ \"info\":\"该导航菜单ID可使用\", \"status\":\"y\" }");
                return;
            }
            //检查保留的名称开头
            if (navname.ToLower().StartsWith("channel_"))
            {
                context.Response.Write("{ \"info\":\"该导航菜单ID系统保留,请更换!\", \"status\":\"n\" }");
                return;
            }
            BLL.contents.article_category bll = new BLL.contents.article_category();
            if (bll.Exists(navname))
            {
                context.Response.Write("{ \"info\":\"该导航菜单ID已被占用,请更换!\", \"status\":\"n\" }");
                return;
            }
            context.Response.Write("{ \"info\":\"该导航菜单ID可使用\", \"status\":\"y\" }");
            return;
        }
Example #5
0
        private void attribute_field_validate(HttpContext context)
        {
            string column_name = OSRequest.GetString("param");

            if (string.IsNullOrEmpty(column_name))
            {
                context.Response.Write("{ \"info\":\"名称不可为空\", \"status\":\"n\" }");
                return;
            }
            BLL.contents.article_attribute_field bll = new BLL.contents.article_attribute_field();
            if (bll.Exists(column_name))
            {
                context.Response.Write("{ \"info\":\"该名称已被占用,请更换!\", \"status\":\"n\" }");
                return;
            }
            context.Response.Write("{ \"info\":\"该名称可使用\", \"status\":\"y\" }");
            return;
        }
Example #6
0
        private void manager_validate(HttpContext context)
        {
            string user_name = OSRequest.GetString("param");

            if (string.IsNullOrEmpty(user_name))
            {
                context.Response.Write("{ \"info\":\"请输入用户名\", \"status\":\"n\" }");
                return;
            }
            BLL.managers.manager bll = new BLL.managers.manager();
            if (bll.Exists(user_name))
            {
                context.Response.Write("{ \"info\":\"用户名已被占用,请更换!\", \"status\":\"n\" }");
                return;
            }
            context.Response.Write("{ \"info\":\"用户名可使用\", \"status\":\"y\" }");
            return;
        }
Example #7
0
        private void urlrewrite_name_validate(HttpContext context)
        {
            string new_name = OSRequest.GetString("param");
            string old_name = OSRequest.GetString("old_name");

            if (string.IsNullOrEmpty(new_name))
            {
                context.Response.Write("{ \"info\":\"名称不可为空!\", \"status\":\"n\" }");
                return;
            }
            if (new_name.ToLower() == old_name.ToLower())
            {
                context.Response.Write("{ \"info\":\"该名称可使用\", \"status\":\"y\" }");
                return;
            }
            BLL.configs.url_rewrite bll = new BLL.configs.url_rewrite();
            if (bll.Exists(new_name))
            {
                context.Response.Write("{ \"info\":\"该名称已被使用,请更换!\", \"status\":\"n\" }");
                return;
            }
            context.Response.Write("{ \"info\":\"该名称可使用\", \"status\":\"y\" }");
            return;
        }