ValidateCode/ImageCode.aspx.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Imaging;

public partial class ImageCode : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpContext context = HttpContext.Current;
        int charsNo = 4;
        int fontSize = 14;
        int bgWidth = 60;
        int bgHeight =20;
        float x = (bgWidth - (charsNo * (fontSize + 0.5F))) / 2; // TODO: optimize
        float y = (bgHeight - (fontSize * 1.7F)) / 2; // TODO: optimize
        
        // Load defaults if params are empty
        //
        if (fontSize == -1) fontSize = 14;
        if (bgWidth == -1) bgWidth = 100;
        if (bgHeight == -1) bgHeight = 22;

        // Generate the text
        //
        //string genText = Globals.CreateTemporaryPassword(charsNo).ToUpper();
        string genText = CreateTemporaryPassword(charsNo).ToUpper();

        // Add the generate text to a session variable 
        //
        Session.Add("CheckCode", genText);
        // Create the memory map 
        //
        Bitmap raster;
        //System.Drawing.Imaging.PixelFormat pixFormat = System.Drawing.Imaging.PixelFormat.Format32bppArgb;

        // Select an memory image from file of 290x80 px
        // in the current dir, NoSpamBgImgs folder named bg_X.jpg
        //
        Graphics graphicObj;
        string bgFilePath = context.Server.MapPath(@".\ValidateBgImgs\bg_" + new Random().Next(5) + ".jpg");
        System.Drawing.Image imgObj = System.Drawing.Image.FromFile(bgFilePath);

        // Creating the raster image & graphic objects
        //
        raster = new Bitmap(imgObj, bgWidth, bgHeight);
        graphicObj = Graphics.FromImage(raster);

        // Creating an array for most readable yet cryptic fonts for OCR's
        // This is entirely up to developer's discretion
        // CAPTCHA recomandation
        //
后面还有 62 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。