Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
Картинка с цифрами при регистрации
|
|||
|---|---|---|---|
|
#18+
Всем доброго времени суток, Подскажите пожалуйста какой-то компонент для ASP.NET 1.1, который позволяет генерировать кртинку с цифрами. Для защиты от спам, ботов и т. д. А также может кто-то знает компонентик, который генерирует картинку с email адресом для тех же целей? Заранее блягодарен, Дмитрий. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2006, 23:44 |
|
||
|
Картинка с цифрами при регистрации
|
|||
|---|---|---|---|
|
#18+
Здравствуйте, Аноним, Вы писали: А>Всем доброго времени суток, А>Подскажите пожалуйста какой-то компонент для ASP.NET 1.1, который позволяет генерировать кртинку с цифрами. А>Для защиты от спам, ботов и т. д. А>А также может кто-то знает компонентик, который генерирует картинку с email адресом для тех же целей? А>Заранее блягодарен, А>Дмитрий. Привет! Это не мое. где-то взял, мелочь какую-ту менял. Спасибо забытому мной автору! using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Drawing.Text; public class AntiRobotImage { private string[] Fonts = { "Verdana", "Tahoma", "Arial", "Small", "Courier", "Fixedsys", "Garamound" }; #region Text private string text; /// <summary> /// Gets or sets the text. /// </summary> /// <value>The text.</value> public string Text { get { return text; } set { text = value; } } #endregion #region Width private int width; /// <summary> /// Gets or sets the image width. /// </summary> /// <value>The width.</value> public int Width { get { return width; } set { width = value; } } #endregion #region Height private int height; /// <summary> /// Gets or sets the image height. /// </summary> /// <value>The height.</value> public int Height { get { return height; } set { height = value; } } #endregion #region Image private Bitmap image; /// <summary> /// Gets or sets the image. /// </summary> /// <value>The image.</value> public Bitmap Image { get { return image; } set { image = value; } } #endregion #region FontFamily private string fontFamily; public string FontFamily { get { return fontFamily; } set { fontFamily = value; } } #endregion #region Random // For generating random numbers. private Random random = new Random(~unchecked((int)DateTime.Now.Ticks)); #endregion #region GenerateImage() private void GenerateImage() { // Create a new 32-bit bitmap image. Bitmap bitmap = new Bitmap(Width, Height, PixelFormat.Format32bppArgb); // Create a graphics object for drawing. Graphics g = Graphics.FromImage(bitmap); g.SmoothingMode = SmoothingMode.AntiAlias; Rectangle rect = new Rectangle(0, 0, Width, Height); // Fill in the background. HatchBrush hatchBrush = new HatchBrush(HatchStyle.SmallConfetti, Color.LightGray, Color.White); g.FillRectangle(hatchBrush, rect); // Set up the text font. SizeF size; float fontSize = height; Font font; // Adjust the font size until the text fits within the image. do { fontSize--; font = new Font(FontFamily, fontSize, FontStyle.Bold); size = g.MeasureString(this.text, font); } while (size.Width > rect.Width); // Set up the text format. StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; // Create a path using the text and warp it randomly. GraphicsPath path = new GraphicsPath(); path.AddString(this.text, font.FontFamily, (int)font.Style, font.Size, rect, format); float v = 4F; PointF[] points = { new PointF(this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v), new PointF(rect.Width - this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v), new PointF(this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v), new PointF(rect.Width - this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v) }; Matrix matrix = new Matrix(); matrix.Translate(0F, 0F); path.Warp(points, rect, matrix, WarpMode.Perspective, 0F); // Draw the text. hatchBrush = new HatchBrush(HatchStyle.LargeConfetti, Color.LightGray, Color.DarkGray); g.FillPath(hatchBrush, path); // Add some random noise. int m = Math.Max(rect.Width, rect.Height); for (int i = 0; i < (int)(rect.Width * rect.Height / 30F); i++) { int x = this.random.Next(rect.Width); int y = this.random.Next(rect.Height); int w = this.random.Next(m / 50); int h = this.random.Next(m / 50); g.FillEllipse(hatchBrush, x, y, w, h); } // Clean up. font.Dispose(); hatchBrush.Dispose(); g.Dispose(); // Set the image. this.image = bitmap; } #endregion #region Constructors() /// <summary> /// Initializes a new instance of the <see cref="T:AntiRobotImage"/> class. /// </summary> /// <param name="Text">The text.</param> /// <param name="Width">The width.</param> /// <param name="Height">The height.</param> public AntiRobotImage(string Text, int Width, int Height) { this.Text = Text; this.Width = Width; this.Height = Height; this.FontFamily = Fonts[random.Next(0, Fonts.Length - 1)]; GenerateImage(); } #endregion } Использую так 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; public partial class AntiRobotImagePage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //if (Session["AntiRobotImageKeyword"] == null) //{ Random random = new Random(unchecked((int)DateTime.Now.Ticks)); Session["AntiRobotImageKeyword"] = random.Next(100000, 999999).ToString(); //} AntiRobotImage ari = new AntiRobotImage(Session["AntiRobotImageKeyword"].ToString(), 150, 50); Response.Clear(); Response.ContentType = "image/jpeg"; ari.Image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); } } Дальше все понятно, надеюсь. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2006, 23:54 |
|
||
|
Картинка с цифрами при регистрации
|
|||
|---|---|---|---|
|
#18+
Здравствуйте, roman-k, Вы писали: RK>где-то взял, мелочь какую-ту менял. RK>Спасибо забытому мной автору! Действительно спасибо! А вам благодарствия, добрый человек. :user: RK>Использую так RK> RK> ari.Image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); RK> RK>Дальше все понятно, надеюсь. Более чем. Только вот нужно будет это на .NET 1.1 попробовать. Спасибо, Дмитрий. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 07.11.2006, 02:31 |
|
||
|
Картинка с цифрами при регистрации
|
|||
|---|---|---|---|
|
#18+
Здравствуйте, <Аноним>, Вы писали: А>Подскажите пожалуйста какой-то компонент для ASP.NET 1.1, который позволяет генерировать кртинку с цифрами. А>Для защиты от спам, ботов и т. д. http://www.codeproject.com/info/search.asp -> captcha... << RSDN@Home 1.2.0 alpha rev. 662>> ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 07.11.2006, 07:34 |
|
||
|
|

start [/forum/topic.php?fid=18&tid=1387848]: |
0ms |
get settings: |
8ms |
get forum list: |
14ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
44ms |
get topic data: |
9ms |
get forum data: |
3ms |
get page messages: |
32ms |
get tp. blocked users: |
1ms |
| others: | 213ms |
| total: | 330ms |

| 0 / 0 |
