Sorry for the long delay, I've uploaded the new version and it's ready for download, you can change the font color in the uCaptcha config file using RGB values! :)
First of all, you need to make sure you have an image to use as your captcha bg located at '/images/captcha_bg.png' alternatively you can change the location and name of the background image using the configuration file stored in '/config/uCaptcha.config'.
Once set up and configured, you can call the captcha by visiting 'http://yourwebsiteaddress/uCaptcha.ashx' this will return an image, so to display it on a web page reference it like any other image '<img src="/uCaptcha.ashx" width="150" height="40" alt="Captcha" />'.
You can find out the value of the captcha programaticaly by loading the session variable named 'captchaString' you can access it using this: 'HttpContext.Current.Session["captchaString"]'
In terms of adding it into uBlogsy, I'm not sure as I didn't create uBlogsy but I'd guess you'd download the uBlogsy source code from here: http://our.umbraco.org/projects/starter-kits/ublogsy and then navigate to the class file for the uBlogsy usercontrol named 'Contact', I think you'd then need to add a captcha check in the 'btnSubmit_Click' function; to do this, you'd need to create a text input field in the ashx for the user to input what they think the captcha reads and load the captcha image there too.You can then compare the value of the text input field with the value of the session variable set up by the captcha in the 'btnSubmit_Click' function to decide if the comment should be posted or not.
Example of what should be added to the 'Contact.ashx' file:
Thanks for your fantastic work. It really helped me to implement captcha in my umbraco project. Just a friendly request to write your above instructions in the documentation pdf file. Like me many of us may be confused how to implement step by step.
Hello, I'm new on umbraco, and not a good developper. but this captcha is very interesting for us. I want to validate the captcha before submitting the page (and sending the e-mail) on the contact.ascx. I want that the validation will be like the e-mail textbox.
How to do it? How to insert the session, 'HttpContext.Current.Session["captchaString"]', in the parameter ValidationExpression
Hi,
I am facing this problem while running the .ashx file can you please tell me how to fix this
Error:
"A Graphics object cannot be created from an image that has an indexed pixel format."
[Exception: A Graphics object cannot be created from an image that has an indexed pixel format.]
System.Drawing.Graphics.FromImage(Image image) +1620124
uCaptcha.Web.Handler.GenerateCaptcha(HttpContext context) +777
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
configuration
Is it possible to configure font color?
Thanks for sharing!
Hi Jesper,
Not as yet, I will add that to the configuration for you later this evening.
Thanks,
Luke
Thx :-)
Sorry for the long delay, I've uploaded the new version and it's ready for download, you can change the font color in the uCaptcha config file using RGB values! :)
How can we call and validate uCaptcha in uBlogsy submit comments?
Thanks,
Hema
Hi Hema,
First of all, you need to make sure you have an image to use as your captcha bg located at '/images/captcha_bg.png' alternatively you can change the location and name of the background image using the configuration file stored in '/config/uCaptcha.config'.
Once set up and configured, you can call the captcha by visiting 'http://yourwebsiteaddress/uCaptcha.ashx' this will return an image, so to display it on a web page reference it like any other image '<img src="/uCaptcha.ashx" width="150" height="40" alt="Captcha" />'.
You can find out the value of the captcha programaticaly by loading the session variable named 'captchaString' you can access it using this: 'HttpContext.Current.Session["captchaString"]'
In terms of adding it into uBlogsy, I'm not sure as I didn't create uBlogsy but I'd guess you'd download the uBlogsy source code from here: http://our.umbraco.org/projects/starter-kits/ublogsy and then navigate to the class file for the uBlogsy usercontrol named 'Contact', I think you'd then need to add a captcha check in the 'btnSubmit_Click' function; to do this, you'd need to create a text input field in the ashx for the user to input what they think the captcha reads and load the captcha image there too.You can then compare the value of the text input field with the value of the session variable set up by the captcha in the 'btnSubmit_Click' function to decide if the comment should be posted or not.
Example of what should be added to the 'Contact.ashx' file:
<asp:TextBox ID="txtCaptcha" runat="server"></asp:TextBox>
<img src="/uCaptcha.ashx" width="150" height="40" alt="Captcha" />
Example of what should be added to the 'Contact.ascx.cs' file:
#region btnSubmit_Click
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (m_NodeTypeAlias == "uBlogsyPost")
{
if (HttpContext.Current.Session["captchaString"] == txtCaptcha.Text)
{
CreateComment();
}
}
else
{
SendEmail();
}
// redirect to current page to ensure razor macro is refreshed
Response.Redirect(Request.Url.AbsolutePath.ToString() + "?success=true");
}
#endregion
Again this is just a quick guess by looking at the source code myself.
Thanks Luke, Your response is very quickely and useful.
Hi Luke,
Thanks for your fantastic work. It really helped me to implement captcha in my umbraco project. Just a friendly request to write your above instructions in the documentation pdf file. Like me many of us may be confused how to implement step by step.
Thanks
Shafiq
Hello,
I'm new on umbraco, and not a good developper. but this captcha is very interesting for us.
I want to validate the captcha before submitting the page (and sending the e-mail) on the contact.ascx.
I want that the validation will be like the e-mail textbox.
How to do it? How to insert the session, 'HttpContext.Current.Session["captchaString"]', in the parameter ValidationExpression
Regards,
Antra
Hi, I am facing this problem while running the .ashx file can you please tell me how to fix this Error: "A Graphics object cannot be created from an image that has an indexed pixel format." [Exception: A Graphics object cannot be created from an image that has an indexed pixel format.] System.Drawing.Graphics.FromImage(Image image) +1620124 uCaptcha.Web.Handler.GenerateCaptcha(HttpContext context) +777 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
is working on a reply...