University of Newcastle · FACULTY OF COMPUTER SCIENCE

SENG1050 Chap.6 The Client-Server Model, Apache and PHP

- one subject, every graph, every model, every mark
8 Chapters5-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 6 of 12 · SENG1050

The Client-Server Model, Apache and PHP

This chapter follows the Week 6 lecture and the Apache and PHP lab. It explains services and the client-server model, the challenges of distributed applications, two-tier and three-tier designs and the trade-offs against peer-to-peer.

It then configures Apache's document root, virtual hosts and two hardening settings, and teaches the PHP needed for the exam: variables, strings, decisions, loops and reading form data from the GET and POST arrays. Lab 6 installs XAMPP, configures a virtual host, hardens Apache and writes first PHP scripts that count, loop and read form input sent by POST.

In this chapter

What this chapter covers

  • 01

    Services, clients and servers

  • 02

    Four challenges of distribution

  • 03

    Two-tier and three-tier designs

  • 04

    Client-server versus peer-to-peer

  • 05

    Web servers, ports and stacks

  • 06

    Apache document root and virtual hosts

  • 07

    Hiding versions and directory listings

  • 08

    PHP syntax, loops and form input

Worked example · free

Map a booking application onto three tiers

Q [3 marks]. A cinema booking app lets customers choose seats in a browser, checks seat availability and price rules, and stores bookings. Assign each job to a tier of the three-tier model and give one reason the design helps. The mark allocation here is AskSia's own and is not a University marking scheme.
A three-tier web application from left to right: the client handles presentation, the application server processes requests, and the database server stores dataA three-tier web application from left to right: the client handles presentation, the application server processes requests, and the database server stores data, with every exchange crossing the network. ClientApplication serverDatabase server presentationprocessingstorage requestresponsequerydata
A three-tier web application from left to right: the client handles presentation, the application server processes requests, and the database server stores data, with every exchange crossing the network.
  • 1Presentation, showing the seat map and taking the customer's choices, belongs on the client tier in the browser.
  • 1Processing, checking availability and applying price rules, belongs on the application server; storage of bookings belongs on the database server.
  • 1Separating the tiers lets each be scaled and secured on its own, and keeps one trusted source of booking data on the server side.
The client handles presentation, the application server handles processing such as availability and pricing, and the database server stores bookings. Splitting them lets each tier scale and be secured separately while the server side remains the single trusted source of the data.
Sia tip — Sort every job in a client-server question into input and output, processing, or storage first; the tier then follows almost automatically.
Glossary

Key terms

Service
A service is a bundle of functions offered to other devices over a network, such as file storage or a website.
Three-tier architecture
Three-tier architecture separates presentation on the client, processing on an application server and storage on a database server.
Peer-to-peer
Peer-to-peer is an architecture in which every device acts as both client and server and contributes resources.
Document root
The document root is the folder whose files a web server publishes, htdocs by default in XAMPP.
Virtual host
A virtual host is one of several sites served by a single Apache installation, each with its own document root.
Superglobal array
A superglobal array such as $_POST holds submitted form values keyed by each control's name.
Ternary operator
The ternary operator chooses between two values in one expression: condition ? value if true : value if false.
FAQ

The Client-Server Model, Apache and PHP FAQ

How does a PHP script read what a form sent?

Each control's name attribute becomes a key in a built-in array: $_GET when the form used method get and $_POST when it used post. A field named price is read as $_POST["price"]; cast it with (float) or (int) before comparing or calculating.

Why does the lab hide the Apache version?

By default Apache can announce its exact product and version in error pages and response headers. An attacker can use that to look up known weaknesses for that version, so ServerSignature Off and ServerTokens Prod reduce the information given away.

What is the main weakness of the client-server model?

The server is a single point of failure, a single target for attackers and a performance bottleneck, which makes denial-of-service attacks possible. Those costs come with its strengths: central storage, one trusted source of truth and one place to enforce rules.

What is the difference between a while loop and a do-while loop in PHP?

A while loop tests its condition before each pass, so its body may never run. A do-while loop runs its body first and tests afterwards, so the body always runs at least once. In both, update the loop variable or the loop never ends.

What does PHP send to the browser?

Only its output. The script runs on the server, and whatever it prints, usually HTML, becomes the body of the HTTP response. The browser never receives the PHP source code, which is why the generated HTML should be validated separately.

Study strategy

Exam move

Write three short PHP scripts on paper each week: one that reads form values and prints a calculated result, one with a loop using continue or break, and one with an if and else chain. Trace each by hand with a small set of inputs before checking it on a server. Learn the three-tier diagram and the pros and cons of each architecture as matched pairs.

Check every script for matching braces, semicolons and the correct superglobal before you consider it finished.

Working through The Client-Server Model, Apache and PHP in SENG1050? Sia is AskSia’s AI Computer Science tutor — ask any SENG1050 The Client-Server Model, Apache and PHP question and get a clear, step-by-step explanation grounded in how SENG1050 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 14 of your University of Newcastle subjects - and 1,000+ Bibles across every Australian university.
Sia - your SENG1050 tutor, unlimited, worked the way the exam marks it
The full 5-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works