
In this second part, i will show how to make an ASP.NET Validation control that uses the reCaptcha framework.
I named this control ReCaptchaValidator. This validator extends the abstract class BaseValidator. And so soon we arrived to the first point.
ReCaptchaValidator could implement the interface IValidator, but he would lose a functionality that is very useful. the property ValidationGroup. This property allows you to tell the validator that he will only make the validation when an input with the same validation group makes a post back.
Example
<asp:Button ValidationGroup="test" runat="server"/>
When the above control makes a post back to the server, only the controls in the validation group named “test” will be called.
So, the ReCaptchaValidater extends BaseValidator. Starting explanation, all the action will occur in the EvaluateIsValid, a method inherited from BaseValidator:
protected override bool EvaluateIsValid() {
string parameters = ReCaptchaParameters();
string result = ValidateCaptcha(parameters);
bool isValid = result.Equals("true\nsuccess");
if( !isValid ) {
ErrorMessage = "Your are not a human!";
Controls.Add( new LiteralControl(ErrorMessage));
}
return isValid;
}
This method will call the private method ReCaptchaParameters that will return all the parameters needed to make the Web Request to the reCaptcha url. This Web Request will be made by the method ValidateCaptcha to which the parameters are passed. (ReCaptchaParameters and ValidateCaptcha are defined below)
Then the result of the Web Request is validated. If the result is different from the string “true\nsuccess”, then the user didn’t inserted the captcha correctly (or a BOT is trying to register in your site).
/// <summary>
/// Gathers the parameters for reCaptchaValidator
/// </summary>
/// <returns></returns>
private static string ReCaptchaParameters() {
string response = GetFormValue("recaptcha_response_field");
string challenge = GetFormValue("recaptcha_challenge_field");
string IP = HttpContext.Current.Request.UserHostName;
StringBuilder builder = new StringBuilder();
builder.AppendFormat( "privatekey={0}&", PrivateKey );
builder.AppendFormat( "remoteip={0}&", IP );
builder.AppendFormat( "challenge={0}&", challenge );
builder.AppendFormat( "response={0}", response );
return builder.ToString();
}
/// <summary>
/// Validates the capcha inserted by the user
/// </summary>
/// <param name="parameters">parameters to verify</param>
/// <returns>response of the capcth</returns>
private static string ValidateCaptcha( string parameters ) {
try {
WebRequest request =
WebRequest.Create( "http://api-verify.recaptcha.net/verify" );
request.ContentType = "application/x-www-form-urlenpred";
request.Method = "POST";
StreamWriter writer =
new StreamWriter( request.GetRequestStream() );
writer.Write( parameters );
writer.Close();
//Response
HttpWebResponse webResponse =
(HttpWebResponse)request.GetResponse();
StreamReader myReader =
new StreamReader( webResponse.GetResponseStream() );
string response = myReader.ReadToEnd();
myReader.Close();
webResponse.Close();
return response;
}catch( WebException ) {
//Do Some Exception threatment
return string.Empty;
}
}
In the Render method we will render all the code necessary to show the reCaptcha validator:
/// <summary>
/// Writes the javascript to show the validation Captcha
/// </summary>
/// <param name="writer"></param>
protected override void Render(HtmlTextWriter writer) {
writer.Write(
@"
<script>
var RecaptchaOptions = {{theme : 'blackglass', tabindex : 2}};
</script>
<script type='text/javascript'
src='http://api.recaptcha.net/challenge?k={0}'&
gt;</script>
<noscript>
<iframe src='http://api.recaptcha.net/noscript?k={0}'
height='300' width='500'
frameborder='0'></iframe><br/>
<textarea name='recaptcha_challenge_field' rows='3'
cols='40'></textarea>
<input type='hidden' name='recaptcha_response_field'
value='manual_challenge'>
</noscript>", PublicKey );
dummy.Visible = false;
base.Render(writer);
}
Noticed the dummy.Visible = false in the render? This is the second point i wanted to talk about. The validators that inherit from BaseValidator were made to validate other controls. In this case, we don’t want to validate any asp.net control. The control we want to validate is provided by a third party code (all the javascript in the render method).
Because of this fact, the validator has an hack. A TextBox with the name “dummy” is created and it’s ID is passed to the property of BaseValidator, ControlToValidate. This way we can surpass the limitation of BaseValidator. Notice that, if this validator didn’t extend BaseValidator, but implemented IValidator, this hack would not be needed.
I made this hack on the event OnInit:
protected override void OnInit(EventArgs e) {
dummy.ID = "aaa";
Controls.Add(dummy);
ControlToValidate = "aaa";
base.OnInit(e);
}
An that’s it. A free captcha control that you can use in all yout web applications.
For your commodity, the ReCaptchaValidator code is available here (in C#) and here (in VB) (Note: the VB code was created using a converter so it might not be exactly like the C# original file).

It’s up to each and everyone of us to protect it! It’s our home!
Five ways to protect it:
source: Ecofriend

reCaptcha is a Captcha program that can tell the difference between a human and a machine. And Plus, it helps to digitalize books. And how does it do it?
Recapcha uses a 2 word challenge. A first word, that is an already known word, and a second word that comes from a digitalized book. If the user inserts the known word correctly, then the second word is assumed as correct and you helped to translate a digitalize one word.
A more complete explanation can be found here, at reCaptcha official page.
<script type="text/javascript" src="http://api.recaptcha.net/challenge?k=your_public_key"> </script> <noscript> <iframe src="http://api.recaptcha.net/noscript?k=your_public_key" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> </noscript>
And a box, similar to the one below, will appear.

Then, for this process to work, a request must be made to http://api-verify.recaptcha.net/verify with the right parameters in order to validate the captcha.
The steps to do this are:
The Web request you make to the above url will retrieve a response separated by a \n. In the first part of the response, the possible values are true or false. If the first part has the value false, then the second part is the error code. You can find the list of error codes here in the section “Error Code Reference”. This page also has all the information you need make your implementation.
In Part 2 of this article i will show how to implement an ASP.NET Validator control that uses this API.
I finally got rid of Microsoft Office 2007. Working with office 2007 was like having a deja vu of Office XP. Although all the updates were installed, power point didn’t like my toshiba and refused to work correctly (entering in a not responding state after 2 minutes, every single time!!!).
But one thing change in this new version of office. Not only Power Point refused to work, bu also Word!!! When a document was saved, 80% of the times Word also entered in a not responding state and i lost everything that i have wrote until that moment.
So i said “enough”! I unistalled Office 2007 and installed OpenOffice.
One thing i noticed. OpenOffice programs are not so visually attractive as Office 2007 ones. But at least they WORK!!!
I hope i finally can write a document until the end without any errors or without losing my work…
Last Friday, at lunch, someone asked me the following question:
“What type of board games do you play?”
and i responded: “none”
And then he replied: “So, how do you want to be a game designer?”
Let me first say before comment the phrase above that i’m not a professional in game design. In fact, i only made one game, Orion’s Belt, a game that is not a blockbuster. Let’s just say that i am a project of a game designer with some good ideas.
But, returning to the phrase above, i really don’t agree with it.
We are not better of worse game designers if we play board games. Game design is about getting good ideas and develop them to make a game that everyone will enjoy. it’s like lego. With the right idea and the right pieces, you can produce the right result, a result that can have success.
Of course, if you play a board game, you will have several good ideas about the structure and functioning of a board game, but that can be or may not be enough. You can develop those ideas, and gather them into a new kind of game, a game that people enjoy to play. Or you can mess everything up and make a game that only you and a few selected persons will enjoy, but the rest of the world (the players world) will not like.
I don’t play board games. But i try to play every new online game i can find (my area is multiplayer online games), to study the structure and new concepts. I consider this a good strategy because you not only get new ideas, ideas that you know that work (some of them at least), but you also study the market: Positive and Negative aspects of each game.
You can be a board gamer, simply a game fanatic or a person with a very good idea and a passion for games. Everyone can be a game designer, but only a few of us will have success.
I hope me and my team (Pedro and Tiago) are among those lucky guys (and your good friends of Vortix Games to. They deserve!)
How many of you, developers, once though: I really liked to develop a game.
The answer is simple: Most of you.
But beginning a game requires a lot of work. It requires a good idea that must be worked until exhaustion in order to develop a good starting base. This is the begging of the Game design.
Game design is the most important part of making a game. Is the Design that will define the success of a game. The game can be programmed by the best programmer in the world. That doesn’t mean the game will have success.
So what is game Design? Is a process that defines all the concept, rules, way of work of a game.
So, in the beggining of this phase, a lot of things must be done. The original idea must be polished by all the elements of the team. All the ideas must be putted above the table and discussed. Another thing that also helps a lot is to study similar games. And similar games are not necessarily games of the same type. Means games of the same market:
Example: You want to create a game for the Web, so one of the things you must do is explore all the games you can find (wikipedia is a wonderful starting point) of the same market (Web games in general).
And why? Because the type of game is not what matters. What matters are the concepts.
A good example are the GameForge games. Correct me if i’m wrong but games like Bitefight and DarkPirates aren’t exactly the same? User interface apart , the engine looks exactly the same: a place to shop, things you can buy to upgrade you character(Bitefight)/Ship(DarkPirates), find enemies to attack,etc. These two games are a good examples of similar concepts with different background stories.
If a good study of the market is a essential to start the design of a game, a brainstorm also is.
Only imaging new ideas, discussing them in several different perspectives, sometimes with people outside of the game development area (friends, family) can make your game unique, or at least different enough to attract different kind people to play it.
For example, in the current version of Orion’s Belt, the concept that separates Orion’s Belt for the other web games in the market is the Board game. It’s the “thing” that separates Orion’s Belt from all the other Massive multi Player web games in the web.
Of Course, because all members of team the have grew and news ideas have appeared and, in the last 4 years, we managed to build a good community that is always getting new idea. So, in Orion’s Belt 2 we will have concepts that are new in MMPOG (Browser based) and will make the game even more attractive to new players.
So, the ideas that you need to retain of this post are:
UPDATE: there was a problem with my wordpress and comments were shut down. I already took care of the problem. you can now comment this post
…from place. As simple as 1,2,3.
1. Detach it
Make the following query in Management Studio:
use master go sp_detach_db 'DatabaseName' go
2. Copy the files
Go to the SQL server directory where the databases are saved, usually C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data and copy the .mdf and the .ldf file of the database that you want to change to a new location.
3. Attach the Database From the new location
Run the following query:
go sp_attach_db 'DatabaseName','$LocationFileMdf$','$LocationFileLdf$' go
where DatabaseName is the name of the database in the Sql Management Studio, $LocationFileMdf$ is the new full path of the mdf file and $LocationFileLdf$ the new full path of the ldf file.
Just to guaranty that the operation was successfull, run the query:
use $DatabaseName$ sp_helpfile
and see if the location of the .ldf and .mdf files is correct.
This operation is particularly useful when you have 2 disks and you need to free some space in the one where you have the database stored.
The Elysion Saga of Saint Seiya Airs sometime in 2008 (I don’t understand Japanese, but according to this site it airs 3/7/2008 ). Must have this!
By the way, very cool cloths!
