Exemplo n.º 1
0
        /// <summary>
        /// 登录验证码
        /// </summary>
        public void VerifyCode_GET()
        {
            if (Cms.RunAtMono)
            {
                return;                // mono下字体无法识别
            }
            string word           = null;
            VerifyCodeGenerator v = new VerifyCodeGenerator();

            try
            {
                FontFamily f    = VerifyCodeGenerator.GetFontFamily();
                Font       font = new Font(f, 16);
                v.AllowRepeat = false;
                Response.BinaryWrite(v.GraphicDrawImage(4,
                                                        VerifyWordOptions.Letter,
                                                        !true,
                                                        font,
                                                        50,
                                                        out word));
                VerifyCodeManager.AddWord(word);
                Response.ContentType = "Image/Jpeg";
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Exemplo n.º 2
0
        public void VerifyImg(string length, string opt, string useFor)
        {
            int _length;                  //验证码长度
            VerifyWordOptions _opt;       //验证码选项
            string            verifycode; //验证码

            if (String.IsNullOrEmpty(length) || !Regex.IsMatch(length, "^\\d+$"))
            {
                _length = 4;
            }
            else
            {
                _length = int.Parse(length);
            }

            if (String.IsNullOrEmpty(opt) || !Regex.IsMatch(opt, "^\\d$"))
            {
                _opt = VerifyWordOptions.Number;
            }
            else
            {
                _opt = (VerifyWordOptions)int.Parse(opt);
            }

            VerifyCodeGenerator v = new VerifyCodeGenerator();

            v.AllowRepeat = false;

            //显示验证码
            v.RenderGraphicImage(_length, _opt, true, out verifycode, "Image/Jpeg");

            //保存验证码
            Session[String.Format("$jr.site_{0}_verifycode", this.OutputCntext.CurrentSite.SiteId.ToString())] = verifycode;
        }
Exemplo n.º 3
0
        public ActionResult App_VerifyCode()
        {
            string verifyCode = VerifyCodeGenerator.GenVerifyCode();

            byte[] bytes = VerifyCodeHelper.GetVerifyCodeByteArray(verifyCode);

            WebHelper.SetSession(App_VerifyCodeKey, verifyCode);

            return(this.File(bytes, @"image/Gif"));
        }
Exemplo n.º 4
0
        public ActionResult VerifyCode()
        {
            string verifyCode = VerifyCodeGenerator.GenVerifyCode();

            byte[] bytes = VerifyCodeHelper.GetVerifyCodeByteArray(verifyCode);

            HttpContext.SetSession(VerifyCodeKey, verifyCode);

            return(File(bytes, @"image/Gif"));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 主链路登录请求消息
        /// </summary>
        /// <param name="request"></param>
        /// <returns>主链路登录应答消息</returns>
        public virtual JT809Response Msg0x1001(JT809Request request)
        {
            var verifyCode = VerifyCodeGenerator.Create();

            Logger.LogInformation($"主链路登录请求消息:VerifyCode-{verifyCode}");
            var package = JT809BusinessType.主链路登录应答消息.Create(new JT809_0x1002()
            {
                Result     = JT809_0x1002_Result.成功,
                VerifyCode = verifyCode
            });
            var jT809_0x1001 = request.Package.Bodies as JT809_0x1001;

            SubordinateLoginService.Login(jT809_0x1001.DownLinkIP, jT809_0x1001.DownLinkPort);
            return(new JT809Response(package, 256));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 登录验证码
        /// </summary>
        public void VerifyCode()
        {
            string word = null;
            var    v    = new VerifyCodeGenerator();

            Response.ContentType("Image/Jpeg");
            var f    = GetCodeFontFamily();
            var font = new Font(f, 16);

            v.AllowRepeat = false;
            var code = v.GenerateVerifyWords(4, VerifyWordOptions.Letter);

            Response.WriteAsync(v.GraphicDrawImage(code, !true, font, 50));
            VerifyCodeManager.AddWord(new string(code));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 设置应用程序,如在过程中发生异常则重启并提醒!
        /// </summary>
        public static void Init(BootFlag flag, String confPath)
        {
            BeforeInit();
            if (!IsInstalled())
            {
                return;
            }
            //初始化目录
            ChkCreate(CmsVariables.TEMP_PATH);
            // 加载配置
            Configuration.LoadCmsConfig(confPath);
            //设置数据库
            CmsDataBase.Initialize(String.Format("{0}://{1}", Settings.DB_TYPE.ToString(),
                                                 Settings.DB_CONN.ToString()), Settings.DB_PREFIX, Settings.SQL_PROFILE_TRACE);
            //清空临时文件
            //resetTempFiles();
            // 初始化键值存储
            InitKvDb();
            // 加载其他配置
            LoadOtherConfig();
            //获取静态服务器
            //UpdateServerInfo();

            // 正常模式启动
            if ((flag & BootFlag.Normal) != 0)
            {
                _buildSet = new CustomBuildSet();

                //
                //TODO:
                //
                //检查网站激活状态
                //SoftwareActivator.VerifyActivation();
                //如果不存在模板文件夹,则创建目录
                if (!Directory.Exists(Cms.PyhicPath + "templates/"))
                {
                    Directory.CreateDirectory(Cms.PyhicPath + "templates/").Create();
                    //暂时网络安装默认模板(后可使用资源代替)
                    Updater.InstallTemplate("default", "tpl_default.zip");
                }
                _templateManager = new TemplateManager(Cms.PyhicPath + CmsVariables.TEMPLATE_PATH);

                // 注册模板
                Template.Register("/" + CmsVariables.TEMPLATE_PATH, true);
                // 注册插件
                //PluginConfig.PLUGIN_FILE_PARTTERN = "*.dll,*.so";
                PluginConfig.PLUGIN_DIRECTORY         = CmsVariables.PLUGIN_PATH;
                PluginConfig.PLUGIN_TMP_DIRECTORY     = CmsVariables.TEMP_PATH + "plugin/";
                PluginConfig.PLUGIN_LOG_OPENED        = true;
                PluginConfig.PLUGIN_LOG_EXCEPT_FORMAT = "** {time} **:{message}\r\nSource:{source}\r\nAddress:{addr}\r\nStack:{stack}\r\n\r\n";
                string pluginPhysicPath = Cms.PyhicPath + PluginConfig.PLUGIN_TMP_DIRECTORY;
                if (!Directory.Exists(pluginPhysicPath))
                {
                    Directory.CreateDirectory(pluginPhysicPath).Create();
                }
                // 连接插件
                CmsPluginContext.Connect();

                // 设置验证码字体
                VerifyCodeGenerator.SetFontFamily(Cms.PyhicPath + CmsVariables.FRAMEWORK_ASSETS_PATH + "fonts/comic.ttf");
            }
            if (OnInit != null)
            {
                Cms.OnInit();
            }

            IsInitFinish = true;
        }