7
KRDS technical test These exercises are limited in time. Only write the necessary lines of code to solve the problems. Indications of the number of expected single line of code (SLOC) and time are given for each exercise. DO NOT REINVENT THE WHEEL. These are offline test. Only the PHP doc and MySQL document in offline format are given. We are waiting for the most clever and efficient way to solve the exercise. Maximum allowed time is 2 hours 1. JSON & XML 1.1. JSON (~ 3 minutes, ~ 5 SLOC) Input: An object describing a person. The object has the following properties : First name Last name Address (door number, street and city) A list (array) of phone number (mobile, landline and skype number). Output: Please write the textual representation of the JSON object above. Guidelines: Write a plain text response, no PHP is asked here! 1.2. XML (~ 5 minutes, ~ 15 SLOC) Input: Your previous JSON object Output: Please write the exact XML representation of the JSON object you write. Guidelines: Write a plain text response, no PHP is asked here!

PHP Practical Test

Embed Size (px)

Citation preview

Page 1: PHP Practical Test

KRDS technical test

These exercises are limited in time.

Only write the necessary lines of code to solve the problems. Indications of the number of expected single

line of code (SLOC) and time are given for each exercise. DO NOT REINVENT THE WHEEL.

These are offline test. Only the PHP doc and MySQL document in offline format are given.

We are waiting for the most clever and efficient way to solve the exercise.

Maximum allowed time is 2 hours

1. JSON & XML

1.1. JSON (~ 3 minutes, ~ 5 SLOC)

Input:

An object describing a person. The object has the following properties :

First name

Last name

Address (door number, street and city)

A list (array) of phone number (mobile, landline and skype number).

Output:

Please write the textual representation of the JSON object above.

Guidelines:

Write a plain text response, no PHP is asked here!

1.2. XML (~ 5 minutes, ~ 15 SLOC)

Input:

Your previous JSON object

Output:

Please write the exact XML representation of the JSON object you write.

Guidelines:

Write a plain text response, no PHP is asked here!

Page 2: PHP Practical Test

1.3. PHP (~ 15 minutes, 4 < SLOC < 20)

Input:

Your previous JSON object and XML representation of this object

Output:

Please write the PHP code to echo the Skype phone number

o Of your JSON-described object

o Of your XML-described object

Please write the JAVASCRIPT code to access the Skype hone number of your JSON object

Guidelines:

No Ajax code waited at all!

Page 3: PHP Practical Test

2. Web services (read, ~ 15 minutes, ~ 10 SLOC)

2.1. JSON

Input:

The following URL output details for employee #18 using JSON format:

http://demo.tools.krds.com/dispatch_ws.php?action=get&id=18&format=json

This URL is slow to respond (~15 sec), it’s normal and must be handle accordingly in your code

Output:

Output to the browser the name property of the employee #18

Guidelines

Use CURL only

Use correct timeouts and correct encoding

2.2. XML (~ 7 minutes, ~10 SLOC)

Input:

The following URL output details for employee #18 using XML format:

http://demo.tools.krds.com/dispatch_ws.php?action=get&id=18&format=xml

This URL is slow to respond (~15 sec), it’s normal and must be handle accordingly in your code

Output:

Output to the screen the name property of the employee

Output to the screen the type attribute of the employee

Guidelines:

Use CURL only

Use SimpleXML

Use correct timeouts and correct encoding

Page 4: PHP Practical Test

3. Web services (Write)

3.1. Create a new employee record (~ 15 minutes, ~ 15 SLOC)

Input:

The following URL creates a new employee

http://demo.tools.krds.com/dispatch_ws.php?action=create

Expected POST data to create a new employee is name and type

Web service returns HTTP 201 CREATED response code if employee creation is successful

Output:

Create a new employee and output “OK” to the browser if and only if creation is successful

Guidelines

Use PHP & CURL only

Page 5: PHP Practical Test

4. Regular expressions

4.1. Data extracting (~ 5 minutes, ~ 5 SLOC)

Input:

An example text:

On February 13, 2009, at exactly 23:31:30 (UTC) the decimal representation of Unix time was equal to 1234567890.

Parties and other celebrations were held around the world, among various technical subcultures, to celebrate this day.

Output:

Output to the browser all numbers greater than 4 digits contained in the given input text using PHP.

Guidelines

Use regular expressions

Of course, the output must work whatever is the text given as input

4.2. Data replacing (~ 4 minutes, ~ 2 SLOC)

Input:

The following text:

During the day, Damien is working.

Output:

From the given input, output the following text to the browser:

Damien is happy to work.

Guidelines

Use regular expressions functions only

No more than 2 lines of code expected. Bigger code will be rejected

Page 6: PHP Practical Test

5. Common problems

5.1. Bad output in PHP (~ 7 minutes)

Input:

The 4.1.php file that can be found along with this document

Currently, this file renders like this:

Output:

Fix the file to get the correct output in the browser (“Hello Loréane !”) and Explain how you proceeded

DO NOT remove or alter existing lines in the given file

5.2. Bad output in HTML (~ 3 minutes)

Input:

The 4.2.html file

Currently, this file renders like this:

Output:

Describe 2 solutions to fix the problem and get the correct output in the browser: “¿Hola cómo está?”

DO NOT remove or alter existing lines in the given file

Page 7: PHP Practical Test

5.3. Security issue (~ 15 minutes)

Input:

Go to http://wargame2k10.nuitduhack.com:8086/

Output:

Hack this login form. Hacking is successful when the following screen will be displayed:

Please provide the full code that will appear once cracking is successful (end of the code is masked in black

in the image above – this is the code you must get)