Training, Open Source Programming Languages

This is page http://www.wellho.net/resources/ex.php4

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Information about the visitor avaialble to a web site provider
Further Web Page and Network Handling example from a Well House Consultants training course
More on Further Web Page and Network Handling [link]

This example is described in the following article(s):
   • PHP data sources - other web servers, large data flows, and the client (browser) - [link]

If you're searching for a page where you can try this code, select here

This example references the following resources:
http://www.wellho.net/mouth/1798_What-does-an-browser-understand-What-does-an-HTML-document-contain-.html
http://www.wellho.net/forum/Writing-PHP/Which-browser-is-being-used.html
http://www.wellho.net/mouth/2135_What-features-does-this-visitors-browser-support-PHP-.html
http://www.wellho.net/mouth/767_Finding-the-language-preference-of-a-web-site-visitor.html
http://www.wellho.net/mouth/2884_Hotlinked-images-onto-adult-material-sites.html
http://www.wellho.net/mouth/1976_Where-is-this-IP-address-IPv4-and-IPv6.html

Source code: about_you.php Module: H112
<?php

$report 
= array (
        
"HTTP_USER_AGENT" => "Your Browser (1)",
        
"HTTP_ACCEPT_LANGUAGE" => "Languages you prefer (2)",
        
"HTTP_REFERER" => "The page you came from (3)",
        
"REMOTE_ADDR" => "Your IP address (4)",
        
"REQUEST_URI" => "The page you asked for (5)",
        
"REQUEST_TIME" => "When you called up this page (6)");

function 
cell($contains) {
        if (
$contains) {
                
$rv "<td>".htmlspecialchars($contains)."</td>";
        } else {
                
$rv "<td>-</td>";
        }
        return 
$rv;
}

$html '<table cellpadding="3" border="1">';
foreach (
array_keys($report) as $item) {
        
$html .= "<tr>".
                
cell($report[$item]).
                
cell($_SERVER[$item]).
                
"</tr>";
        }
$html .= "</table>";

# ---------------------------------------------------
?>
<html>
<head>
<title>About Your visit to us!</title>
</head>
<body>
<h1>A bit about <i>you</i></h1>
The $_SERVER superglobal in PHP contains a number of useful pieces of information that give
<i>an indication</i> about the visitor; as much / most of this information is supplied by the
visitor, it may be missing, it can be misleading, and it's possible for it to be falsified.<br />
<br /><?= $html ?><br />
<hr />
<b><u>Now --- what does that mean?</u></b><br /><br />
<b>(1) - HTTP_USER_AGENT => Your Browser. </b><br />
This is a string of text passed from your browser to the server to tell it
what type of browser is in use.  As well as helping you identify the common
browser types, you can identify the robots that roam the web indexing pages
for search engines, and you can very often spot incursion attacks and other
automata of various types too. The value is useful within the "real person"
group to help you spot who is likely to have flash capabilities, who can
correcly format phone: URLs, etc, so that you can adapt the page for them.
See <a href=http://www.wellho.net/mouth/1798_What-does-an-browser-understand-What-does-an-HTML-document-contain-.html>[here]</a>
and <a href=http://www.wellho.net/forum/Writing-PHP/Which-browser-is-being-used.html>[here]</a> and i
<a href=http://www.wellho.net/mouth/2135_What-features-does-this-visitors-browser-support-PHP-.html>[here]</a>.
<br /><br />
<b>(2) - HTTP_ACCEPT_LANGUAGE => Languages you prefer.</b><br />
This will tell you the nationallity and preferred language of your visitor if (s)he
has set it ... so that you can send out your response in English ... or French, Spanish,
Polish or Chinese if your web site has the capability.
See <a href=http://www.wellho.net/mouth/767_Finding-the-language-preference-of-a-web-site-visitor.html>[here]</a>
<br /><br />
<b>(3) - HTTP_REFERER => The page you came from.</b><br />
This is the URL of the previous page that the user was on, or in the case of images
and other files included <i>within</i> a page the URL of that page that called the
resource up. If empty, the request is by someone typing in a URL themselves, following
a link from an emal, or an automata that's indexing your site.   The value is especially
useful in telling you where new arrivals have come from - with a search engine, you can
tell what search term the user entered that brought him to you, and with an image you
can tell if it's been hotlinked from someone else's site, stealing your bandwidth and perhaps
your copyright. See <a href=http://www.wellho.net/mouth/2884_Hotlinked-images-onto-adult-material-sites.html>[here]</a>
for an example of this in use.
<br /><br />
<b>(4) - REMOTE_ADDR => Your IP address.</b><br />
The IP address of the browser - but (be careful) this may sometimes be an intermediate
proxy if the visitor is taking trouble to hide who (s)he is.  More about this (and how to look it up)
<a href=http://www.wellho.net/mouth/1976_Where-is-this-IP-address-IPv4-and-IPv6.html>[here]</a>
<br /><br />
<b>(5) - REQUEST_URI => The page you asked for.</b><br />
The page you asked for.  AT first glance, this might look pretty obvious as you'll be able
to find the name of the script you're running ... but in practise it's not that starightforward.
Using page redirection through mod_rewrite, you'll find you often run a piece of code held
in a file who's name is different to the page name requested, and that lots of requests
all map to the same script.   This value lets you backtrack.
<br /><br />
<b>(6) - REQUEST_TIME => When you called up this page.</b><br />
The time, in seconds, from 1.1.1970 that the page was called up.
<br /><br />
</body>
</html>

Learn about this subject
This module and example are covered on the following public courses:
 * Learning to program in PHP
 * PHP Programming
 * PHP Programming
 * Learning to program in PHP
Also available on on site courses for larger groups

Books covering this topic
Yes. We have over 700 books in our library. Books covering PHP are listed here and when you've selected a relevant book we'll link you on to Amazon to order.

Other Examples
This example comes from our "Further Web Page and Network Handling" training module. You'll find a description of the topic and some other closely related examples on the "Further Web Page and Network Handling" module index page.

Full description of the source code
You can learn more about this example on the training courses listed on this page, on which you'll be given a full set of training notes.

Many other training modules are available for download (for limited use) from our download centre under an Open Training Notes License.

Other resources
• Our Solutions centre provides a number of longer technical articles.
• Our Opentalk forum archive provides a question and answer centre.
The Horse's mouth provides a daily tip or thought.
• Further resources are available via the resources centre.
• All of these resources can be searched through through our search engine
• And there's a global index here.

Web site author
This web site is written and maintained by Well House Consultants.

Purpose of this website
This is a sample program, class demonstration or answer from a training course. It's main purpose is to provide an after-course service to customers who have attended our public private or on site courses, but the examples are made generally available under conditions described below.

Conditions of use
Past attendees on our training courses are welcome to use individual examples in the course of their programming, but must check the examples they use to ensure that they are suitable for their job. Remember that some of our examples show you how not to do things - check in your notes. Well House Consultants take no responsibility for the suitability of these example programs to customer's needs.

This program is copyright Well House Consultants Ltd. You are forbidden from using it for running your own training courses without our prior written permission. See our page on courseware provision for more details.

Any of our images within this code may NOT be reused on a public URL without our prior permission. For Bona Fide personal use, we will often grant you permission provided that you provide a link back. Commercial use on a website will incur a license fee for each image used - details on request.

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/ex.php4 • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb