Using PHP
Now the site is made with PHP.
It was done with the help of a few utilities and in spite of configuration problems with Windows and Linux.
I found many advantages: maintenance is easier because it is an excellent preprocessor and it is a good way to remove the Javascript functions which made the site difficult to copy and unfriendly to a few navigators.
PHP can manipulate files on the server and control MySQL databases.
PHP can also collect (from the HTTP protocol) public data about you:
- country: UNITED STATES, language,
- IP address: 216.73.216.19 and server, host or provider: forwarded (Private Address)
and is interesting for curious people:
- getting browser identities (all - 13107 UA - 1 769 KB -, recent - 3959 UA -),
- making browser statistics
- or spotting webbot activity...
A disadvantage, however, the pages are heavier for recent navigators and browsing is slower.
Sending compressed CSS and compressed pages with the function ob_start("ob_gzhandler"); can counterbalance this drawback.
Your navigator is identified as:
Thus it's useless to generate a message for the problems related to Javascript or CSS2.
The pages may also be loaded more rapidly if you accept javascript.
PHP as a preprocessor
All the pages of the site generated for recent navigators need the following lines:
<link rel="stylesheet" href="css/style_old_nn4.css" type="text/css">
<style type="text/css">
/*<![CDATA[*/
@import url(css/style2.css);
<?php
if (strstr($HTTP_USER_AGENT,"MSIE 5") && !strstr($HTTP_USER_AGENT,"Opera"))
{
echo "@import \"css/style2ie5.5.css\"";
}
?>
/*]]>*/
</style>
<?php
@include("commun.inc");
?>
You can insert any text (HTML or not) outside PHP tags, a PHP or Javascript script...
Maintenance is easier and the size of the site on the server is much smaller (for this site divided by more than 3).
PHP to replace Javascript
PHP and Javascript can sometimes carry out the same tasks.It was the case for the menus.
Javascript makes it possible to considerably reduce the weight of the pages, this is not the case of PHP.
In the French version of the site -or the other version of the site- intended to navigators that do not interpret Javascript, the following functions replaced those of the file fonctions.js.
PHP and javascript
PHP is on the server side and generates HTML pages. It isn't aware of the user settings unless from a form or by sending variables.Javascript is on the user side and thus can get almost any information about the user's current settings.
PHP -> javascript
A PHP variable can easily be used by javascript. The script to protect a website email can use both languages:<?php $text="Contact (with a fake address)"; ?> <script type="text/javascript"> <!-- var at="@"; var text="<?php echo $text;?>"; var name="my_name"; var hote="my_isp.xy"; document.write("<a hr"+"ef=mai"+"lto:"+name+at+hote+">"+text+"</a>"); --> </script>or
<?php $text="Contact (with a fake address)"; echo ' <script type="text/javascript"> <!-- var at="@"; var text="'.$text.'" var name="my_name"; var hote="my_isp.xy"; document.write("<a hr"+"ef=mai"+"lto:"+name+at+hote+">"+text+"</a>"); --> </script>'; ?>
A script can also generate a list of addresses from a file on the server.
javascript -> PHP
To send information to PHP such as the screen size, the window size with Mozilla, the mouse position or to know if javascript is enabled or to get any information on the user's side, you have to use a form.
This is a real problem as Opera, for example, asks the user whether he accepts to send uncrypted data, you must be sure that javascript is interpreted and write the scripts if it is not.
As an example, here is a html page with a PHP script from php faqts allowing you to know if javascript is enabled:
It works, but the page must be called twice, if you call another page you will have to assume that the visitor has kept the same settings... Use javascript and only test that the content is still displayed if it is not enabled.
The mirror of a website using this technique may not work.
Here is another method without a form but with the same problems
that you can test here.
PHP and mirrors
With a site made in php (asp, cfm) you must identify the navigator which will be used to browse the capture.As the code is on the server, it is difficult to interpret the source as PHP can calculate addresses, generate routines in Javascript, generate all kinds of documents, carry out calculations etc...
Moreover, PHP is often used to stop robots or to slow them down. It does it very easily even if it discourages some readers.
If there is no map of the site, the dynamically generated menus will be generally unusable. You can always note the addresses when you visit the site and add them in the addresses to be captured or the scan rules, but it is a lot of work.
You can also examine the Internet cache, but the obstacles are numerous.
PHP (as Javascript) makes it possible to build mono-page sites. In these extreme cases, no solution off-line.
As a simpler example, the page displaying the visitors' country log file uses a form which does not allow the copy of one of the sorted lists:
<?php echo " <form action=\"$PHP_SELF\" method=\"post\"> <input type=\"submit\" name=\"tri\" value=\""; /* if $tri is empty then it is the first time the page has been loaded, if not, value receives $message3 or $message4 for a possible button click */ if ($tri==$message3 || $tri=="") echo $message4; else echo $message3; echo "\"> </form> "; ?>
The page is generated according to the variable $tri, any form could have set other values (or send variables -even arrays- that can be tested): only the first (or last) loaded page can be copied (and linked).
Several examples can give you ideas, but although WinHttrack does a good job, a whole site in PHP is rarely functional off-line, seldom "well written" and without bugs.
As for this site, PHP made its capture easier before free.fr banned some offline browsers, but as Javascript remains for recent navigators, it may be necessary, in spite of the presence of the site map, to download the js files in MSIE cache and modify the extensions or identify your utility (HTTrack is sometimes filtered) as an old browser (MSIE 4 if you use MSIE) and untick accept cookies.