PHP scripts
(September 2004)

PHP is a web server scripting language (it is executed on the server side). It is mainly used for dynamic web sites.
Table of contents


Script 1 : making a tar archive


The PHP variable $HTTP_REFERER gives information about where a visitor is coming from. Example :
REF= ... 
This works only when the user has clicked on a href link (not entered the address in the address bar of his/her browser).

There is now a real use in this IFRAME :

Script 1 : making a tar archive

tar is a file format initially used for tape archives, which is now commonly used and can be read by most archive programs (Winzip, PKzip,...).
Creating tar files is useful when proposing many files in a single download.

Here is a set of PHP functions which enable you to create tar files: tar.php.
Example of usage:
include("tar.php"); // the script provided on this site

$file_list = array("myfile.html", "pic01.jpg", "pic02.jpg"); // sample files

// call to the tar_c function which returns a string
// in the tar format
$contents = tar_c($file_list);

// header part which will tell the browser of which type the file is
header("Content-type: application/tar");
header("Content-Disposition: attachment; filename=\"myfile.tar\"");
header("Content-Length: ".strlen($contents));

// sending the contents to the browser
echo $contents;

This script enables the downloading of an HTML file and its pictures.
tar_c is defined in the tar.php part and creates a tar archive.

The used format is the one of the POSIX header (here on the GNU site) except that:
Others useful functions included in tar.php