WEBPUB.NET subsystems - accessing using PHP code

Often when you install PHP based applications, or are writing your own PHP code - you will need to place paths in various configuration variables.

If your application writes to files in such a path, then the path should not be located under your standard 'www' area. This is especially true if the file is a configuration file or a database file.
It is important not to hardcode physical directory paths in your code, because they may change over time, and may be different on different servers.

To assist in determining the paths to your files, as described in Subsystem structure; we have provided a PHP include file.
To use this file, place the following two lines somewhere at the beginning of your PHP code:


You could then for example specify an upload folder with a line something like:
$upload_folder = $WEBPUB['READWRITEDEL'] . '/myuploads'; 

This assumes you have already created the 'myuploads' folder
e.g by going to the /readwritedel/live/ folder in ftp and using a command such as 'mkdir myuploads'.

Here is an example of how to specify a connection string for an MSAccess database db1.mdb stored in your 'mdb' subsystem:


    $dbfile = $WEBPUB['MDB'] . "/db1.mdb";

    if (!$conn = new COM("ADODB.Connection"))
        exit("Unable to create an ADODB connection");

    $strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . $dbfile; 

Below is an example of the contents of the $WEBPUB array.
Note that these paths are subject to change. Do not hardcode the full paths into your code.
Always use an element of the array to build up a path as in the examples above.

    [ACCOUNTID] => pcm
    [CELL] => E:\webpub
    [WWW] => E:\webpub\www\pcm
    [PUBLIC_HTML] => E:\webpub\www\pcm
    [WWWPVT] => E:\webpub\wwwpvt\pcm
    [READWRITEDEL] => E:\webpub\readwritedel\pcm
    [READWRITE] => E:\webpub\readwrite\pcm
    [READ] => E:\webpub\read\pcm
    [WRITE] => E:\webpub\write\pcm
    [PVT] => E:\webpub\pvt\pcm
    [MDB] => E:\webpub\mdb\pcm
    [DOCROOT] => E:\webpub\www\pcm