![]() |
![]() |
||
| HOME | WEB DESIGN | COMPUTING | GRAPHICS/PHOTOS | MUSIC | |||
|
Web Sites
Web Design
Web Technology
Panoramic Earth
School Web Sites
Summer Web Sites
DLib PHP Library
Introduction
Download
Installation
Database Examples 1
Database Examples 2
HTML Examples
HtmlPage Examples
DLib PHP Library API
|
![]() |
InstallationDLib PHP LibraryNote that the instructions on this and subsequent pages assume that you are fully conversant with normal PHP programming methods. If this is not the case then pick up one of the many PHP books that are currently available (a new one seems to come out every week!). Unzip the downloaded file into an area of your site that is OUTSIDE of the normal publicly accessible area. For example, you may have the following directories on a Unix/Linux server running Apache: /var/www/htdocs <-- where the document root points /var/www/cgi-bin <-- where CGI programs live You could put the library at the same level: /var/www/dlib5 <-- library files For the PHP pages inside htdocs you will need to add a single include file that will allow those pages access to the library. Create a file include.php with the following code and put it in htdocs:
<?php
if (strpos ($_SERVER ['SCRIPT_NAME'], "include.php") !== false)
die ("Illegal access");
ini_set ("include_path", ".:/var/www/dlib5");
include_once "lib.php";
?>
The file is doing three things:
Notes:
Here's an example include.php to illustrate some of the above. This time it's for Windows and assumes that you have installed the library within the normal Apache 2 location and have added some extra code in commonphp, and the main include file for your code is called mystuff.php:
<?php
if (strpos ($_SERVER ['SCRIPT_NAME'], "include.php") !== false)
die ("Illegal access");
ini_set ("include_path", ".;C:\Program Files\Apache Group\Apache2\dlib5;C:\Program Files\Apache Group\Apache2\commonphp");
include_once "lib.php";
include_once "mystuff.php";
?>
The final example shows how you can use the same include.php file to handle a local development server on Windows and a live server that uses Unix/Linux. This interrogates the host it is running on to figure out which type of format it should be using which means that separate files need not be created for running the same code on different operating systems. Note that we also set a variable $live which may come in useful in other parts of the system for allowing separate functions or code to run on the local development and live servers, and we set a value in $dbTablePrefix which prefixes all the tables used with, in this case, xyz_. This is useful when you are running several sites on one physical database - a common restriction with some hosting services - so that you can easily separate each group of tables from each other.
<?php
if (strpos ($_SERVER ['SCRIPT_NAME'], "include.php") !== false)
die ("Illegal access");
$host = $_SERVER ['HTTP_HOST'];
switch ($host)
{
case "www.somewhere.com" :
ini_set ("include_path", ".:/var/www/dlib5:/var/www/commonphp");
$live = true;
break;
default :
ini_set ("include_path", ".;C:\Program Files\Apache Group\Apache2\dlib5;C:\Program Files\Apache Group\Apache2\commonphp");
$live = false;
}
$dbTablePrefix = "xyz_";
include_once "lib.php";
include_once "mystuff.php";
?>
|
|
| Copyright ©2003-2010 davidviner.com Terms and Conditions | |||
![]() | |||