Sie sind auf Seite 1von 3

ITApps Assessment 2013/14 P1 TMA

01/10/13 Page 1 of 3
Web Programming using PHP (P1)
Tutor Marked Assignment (TMA)
Introduction
The TMA carries 25% of the total marks for this module. Its aim is to help confirm that you
understand the basics of PHP and can parse web server log files to extract information f rom
them. It also ensures that you have mastered the basic skills needed to complete the FMA
and provides your tutor with the opportunity to feedback comments on your work.
The completed TMA deliverables should be submitted electronically in the assignment
Dropbox in Moodle BEFORE the start of Session 5.
Completing the TMA
You should work on your TMA after class and during the self-study Session scheduled after
Session 4. Begin your work early, as the TMA is a substantial task that requires planning and
effort to complete satisfactorily. The TMA prepares you for the FMA so you greatly reduce
your risk of a poor overall mark by completing and submitting a TMA.
Getting support
Support for the TMA work will be available in class during Session 4.
TMA Specifications
Introduction
When a file (HTML page, image file, etc.) is requested from a web server it is common
practice for the web server to log the request to a text file. Such files can be used to
determine the number of visits a site receives, for which pages and so on. In this TMA you
will be using PHP to parse such log files to extract information from them. To extract
information, you first need to understand the format of such files.
Each request to the web server is logged by a single line in the log-file. Therefore if the log
file for a particular month contains 1000 lines of data, you know that there have been 1000
file requests from the server in that month. An example of a typical line is:
66.191.27.30 -- [2007-04-01 09:10:35] "GET articles/using_regex_with_php
HTTP/1.0" 200 12234 "Googlebot/2.1"
This line contains the following information:
1. IP Address: This is the address of the machine that requested the file from the web
server. It consists of 4 numbers between 0-255 separated by a dot.
2. Timestamp: This contains the date and time of the request in the format YYYY-MM-DD
HH:MM:SS.
3. Filename: The address of the requested file on the server.
4. HTTP Status Code: This HTTP code logs the status of the request. For example, the
files we will be looking at have a status code of either 200 or 404. Status 200 means the
file was supplied to the requester successfully. Status 404 means the file could not be
found on the server, and a "404 Page not Found" error was returned to the requester.
5. Bandwidth Used: The size of the file delivered to the user is also logged, and this is
also the bandwidth used by this request. The value is logged in bytes.
6. User Agent: The program which the file is being delivered to on the requester's
machine. In the log files we examine this is either "Mozilla/4.0" (a browser like FireFox),
"MSIE 7.0" (a browser like Internet Explorer 7), or "Googlebot/2.1" (a google search
engine spider).
ITApps Assessment 2013/14 P1 TMA
01/10/13 Page 2 of 3
The format of these pieces of data in each line is:
ip_address -- [timestamp] "GET filename HTTP/1.0" status_code bandwidth
"user_agent"
Thus in our previous example:
66.191.27.30 -- [2007-04-01 09:10:35] "GET articles/using_regex_with_php
HTTP/1.0" 200 12234 "Googlebot/2.1"
The IP address of this request was 66.191.27.30, which was made on the 1st April 2007 at
9.10am by a Google spider. It requested the page "articles/using_regex_with_php" which was
delivered successfully (status code 200), consuming 12234 bytes of bandwidth (11.9kB).
Your Task
A small site uses log file rotation to produce a separate web server log file for each month.
Your task is to write a PHP script that examines the data in the log files and produces a
single short summary html page containing the usage statistics for all months. Note that all
summaries should be displayed on the same page. You have been provided with two sample
web server log files for April and May 2007: Download a Zip file of the sample log files
The statistical summary should contain:
1. The total number of file requests in the month.
2. The number of file requests from the articles directory.
3. The TOTAL bandwidth consumed by the file requests over the month.
4. The number of requests that resulted in 404 status errors. Display a list of the filenames
that produced these 404 errors (try not to repeat filenames if the same wrong filename
was requested more than once)
There is no need to apply any styling or formatting to your html output, and such formatting is
discouraged. However, the HTML output should be semantically appropriate and should
validate correctly under the DOCTYPE specified. Statistical information is required for both
months April and May 2007, derived from the two provided sample files.
Any deviation from these instructions must be agreed with your tutor beforehand.
Working towards a Solution - Some Hints!
Download the sample log files and familiarise yourself with their data format.
Think about what data you will need to extract from each line of the log to calculate the
required statistics, and how you will do this using PHP. It may be helpful to review the
work we have undertaken in class about file manipulation and string manipulation.
It may be helpful to test your script against a single line of the log file to check it is
working as expected before trying to work with the entire file.
Once you are confident extracting the required data from each line, open the log files in
PHP and loop through each line extracting data and calculating statistics. Once this is
completed, you will need to echo the results to the browser.
Code should not be repeated - marks are awarded for the careful use of functions and
code re-use, Try not to repeat any code even though you are analysing two log files.
Deliverables to Submit for Assessment
TMA documentation
The following TMA deliverables must be submitted electronically in the Assignment Dropbox
in Moodle BEFORE the start of Session 5:
1. A copy of all PHP source files that are required to display the statistics for both
months saved in a zip file, username_p1tma.zip.
Note: your TMA will not be marked without these PHP source files!
ITApps Assessment 2013/14 P1 TMA
01/10/13 Page 3 of 3
2. A learning/development log, saved as username_p1tma.pdf. This should include a
brief log of any problems you encountered during your work and how you solved
them. In particular, include any outstanding problems or errors that you didn't manage
to solve or are unsure about - it helps the tutors to provide constructive feedback.
You are also required to make a copy of your files available on your student web area on the
School server. The URL of your page should be:
http://titan.dcs.bbk.ac.uk/~username/p1tma/index.php
You should also include the full address of this page in your learning/development log.
Please ensure that your documentation files include your Full Name, ITS Username,
Module Name and Tutor Name. If a required file is not submitted, the examiners will not
search for missing files and 0% will be awarded for any missing components.
Getting feedback
Feedback on the marked TMA can be downloaded from Moodle and will normally be returned
to you within 2 weeks of submission. The feedback on your TMA and any issues that arise
can be discussed with your tutor within 2 weeks of the return of the marked TMA.
Backing up files
Always keep a back-up copy of all work submitted for assessment in case of unforeseen
submission problems.
Plagiarism
Plagiarism, which is claiming the work of others as your own, is a serious offence and can
result in your exclusion from all colleges of the University of London. You should be aware
that we use a range of automated tools to spot potential plagiarism in spreadsheets,
databases, program code and text documents. Providing you clearly reference work done by
others that you have included in your TMA you will not be penalised.
Criteria for assessment
You will gain maximum credit for a solution that uses solely your own original code. If you
have used any code that is not your own in your solution, or have used others work as a
reference to develop your own code, the source should be fully referenced in code comments
(see note about plagiarism above).
The criteria below show the proportion of the marks (out of 100%) that will be awarded for
each component of the assignment:
1. PHP Coding Style (30%): clearly commented, use of functions to prevent code
repetition, consistent indentation style, "release-quality" code without unnecessary
debugging additions.
2. Log File Analysis Functionality (42%): for both sample months correctly evaluate the
total requests, number of article requests, total bandwidth, the number of 404 requests
and their filenames.
3. Learning/Development Log (10%): Concise and to-the-point log of any problems. The
log should not contain excessive source code extracts.
4. Publishing/HTML Presentation (18%): Published on correct URL. Valid HTML to
specified doctype, with no CSS or inline formatting.
Note, no marks will be awarded for:
- The use of functions marked as deprecated in the PHP manual.
- The use of Regular expressions in your solution
- Code which suppresses PHP error messages or attempts to alter PHP's configuration in
order to suppress error messages.

Das könnte Ihnen auch gefallen