There was a little nice test on that site back in 2006. I did not need the job back then but I wanted to prove my net worth for the sake of coding.
I spent few hours on this test but the result was really good. The guy emailed me back for an interview and mentioned in the email that this was one of the neatest code that they have got out of few thousands.
I did not continue to the interview as I did not need the job back then and I was moving from programming into Finance.
It is another nice memory and I would like to share my code with those old PHP nerds who would like to read some // 2cents.
//***********************************************************
//***********************************************************
// Script name: prove_your_worth_code.php *
// Version: 1.0 *
// Coder: Bilal Abdul Kader *
// Date: October 29th, 2006 *
// *
// This script automate the submission of a mixed form *
// (strings + files) to the ProveYourWorth website. *
// *
// It emulates the browser using CURL library for PHP, the *
// same task can be done using fsockopen and Snoopy. *
// *
// The first task is to open the form in order to get the *
// PHPSESSID and any other cookies. Then the code emulates *
// the form submission and send it to the server again. *
// *
// I kept the code to a minimum as it is a PROOF OF CONCEPT *
// only. *
//***********************************************************
//***********************************************************
//
// Get the cookie of the site first
// The script should fetch the index page
// in order to get the cookie(s)
// Apparently the site sets the PHPSESSID cookie only
//
//
// Define the curl handler
//
$my_curl_handler = curl_init();
//
// The web site to fetch
//
$url = "http://www.proveyourworth.net/index.php?p=begin&mistake=little";
//
// Add the URL operator
//
curl_setopt($my_curl_handler, CURLOPT_URL, $url);
//
// Handle the cookies of the site in order to send it later on
// the tmp folder is used on Nix machines or temp on Windows
// Add an agent header line
// Add a referer header line
//
curl_setopt($my_curl_handler, CURLOPT_COOKIEFILE, "c:\\temp\\cookie.txt");
curl_setopt($my_curl_handler, CURLOPT_COOKIEJAR, "c:\\temp\\cookie.txt");
curl_setopt($my_curl_handler, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-AU; rv:1.8.1) Gecko/20061010 Firefox/2.0");
//
// Follow any location HTTP command if any
// It seems that redirection is not used on this page
// However, this is kept for portability
//
curl_setopt($my_curl_handler, CURLOPT_FOLLOWLOCATION, 1);
//
// Return the trasnfer as part of the return value in curl_exec()
//
curl_setopt($my_curl_handler, CURLOPT_RETURNTRANSFER, 1);
//
// Execute the command and get the html page that has the forum
//
$htmlPage=curl_exec ($my_curl_handler);
//
// Parse the page in order to get the new hash key
//
preg_match("/\bhash\b\" value=\"(.*)\"/i",$htmlPage, $matches);
$myHashKey = $matches[1];
// echo "Hash Key is: $myHashKey
";
//
// Other action can be added here to check if the curl has
// got the correct page. This can be done using the
// $headers variable (For example $headers['url'])
//
//*******************************************************
//
// Now start the actual work to automate the form
// submission and to send the fields and the files
// fsock or Snoopy is not that hard to implement
// However, I prefered to use curl this time
// The other two implementations are as hard.
//
//*******************************************************
//
// Change the URL that the form should be submitted to
//
$url="http://www.proveyourworth.net/?p=auto_submit";
curl_setopt($my_curl_handler, CURLOPT_URL, $url);
//
// Now change the CURL operating model to POST (not GET)
// Regular HTTP POST (application/x-www-form-urlencoded)
// Add the new URL to send the form to
//
curl_setopt($my_curl_handler, CURLOPT_POST, 1);
//
// In case the form action need a valid referer to work
//
curl_setopt($my_curl_handler, CURLOPT_REFERER, "http://www.proveyourworth.net/index.php?p=begin&mistake=little");
//
// Build the data for the form
// I am using hard coded data in here for simplicity
// However, dynamic data can be easily incorporated
//
// Select the files to attach
//
$cvFile = "cv";
$sourceFile="prove_your_worth_code.php";
$myFormData = array(
"form_id"=>"job",
"name"=>"Bilal Abdul Kader",
"email"=>"bilal@brightvision.net",
"about"=>"Simple, I have a love affair with PHP and Programming in general. The puzzle was nice and tricky. I have emulated other more complex forms in real time.",
"incoming_file"=>"@$cvFile.doc",
"incoming_source"=>"@$sourceFile.txt",
"hash"=>"$myHashKey",
"Submit"=>"Submit"
);
//
// Build the form data now
//
curl_setopt ($my_curl_handler, CURLOPT_POSTFIELDS, $myFormData);
//
// Send the POST request and store the resuts in myResults
//
$myResult=curl_exec($my_curl_handler);
//
// In case of error during the submission
// Show the error.
//
echo curl_error($my_curl_handler);
//
// Otherwise, show the return of the form
//
echo $myResult;
//
//
//
?>
3 comments:
Prove.It
Finished following the little yellow brick road...
Looks good.
Congrats, you have passed the test.
You should be contacted soon.
THE END
:)
If you apply and go to the interview ask for the contract you will be signing and look the environment of work and ask about ex employees... thank me later. Oh and ask what will you be doing... legal aspects and the sort ;)... These tests are talent phishing. Whoever has this skills-set will be very well compensated in a well established and registered company.
I do not know anything about their work environment. I did this test for fun and when they called me I told them I am not interested in the job.
It is very important for anyone applying for the job to check the contract and the pay package. Otherwise, one might regret it.
Post a Comment