fsconfig.php

Stores data storage configuration.

Summary
fsconfig.phpStores data storage configuration.
File Writing OverviewCurrently, LnBlog only stores data by writing it to text files on the web server.
Technical DetailsWriting to the filesystem is carried out using an abstract interface class.
Standard Constants
Constants
DOCUMENT_ROOTThis is the full local path to the web server’s document root, i.e.
FS_PLUGINThis determines which filesystem writing method to use.
FTPFS-only Constants
Constants
FTPFS_USERThe username to use when establishing an FTP connection.
FTPFS_PASSWORDThe password used to log in with FTPFS_USER.
FTPFS_HOSTThe host and/or domain name of the FTP server to connect to.
FTP_ROOTThe full path on the server to the user’s FTP root.

File Writing Overview

Currently, LnBlog only stores data by writing it to text files on the web server.  However, it supports two methods for doing this.  One is to use standard file-writing functions and the other is to use FTP.  These are refferred to, respectively, as NativeFS and FTPFS.  Deciding between these is the first configuration step for LnBlog and is done by the fs_setup.php script.  This script creates the fsconfig.php file, which should not be present in an initial installation.

The reason for having two types of filesystem writing is that many web hosts use PHP’s safe_mode feature to provide added security.  One of the restrictions this imposes is that scripts can only read files from the disk if the owner of the file is the same as the owner of the script.  In some shared hosting environments (such as those using Mod_PHP), PHP runs and writes files as a system accout, whereas the scripts themselves would be owned by the user account of the site operator, so scripts would not be able to read any of the files they created.  This restriction can be bypassed by performing file writing via FTP, as this allows scripts to connect to the FTP server as the site owner, not a system user.  This also has the beneficial effect that the files created by the scripts will be owned by the user account, so that they can be more easily managed via an FTP client.

If you have the option, it is recommended that you use NativeFS.  It is by far the faster, more reliable, and easier to configure.  FTPFS only exists to work around security restrictions created by certain configurations.  Furthermore, note that safe_mode was deprecated in PHP 5.3 and removed from PHP 5.4, so unless you’re stuck on a very old version of PHP, it is unlikely that you will need FTPFS.

Technical Details

Writing to the filesystem is carried out using an abstract interface class.  This class defines the basic functions of the file-writing subsystem, such as creating directories, deleting files, and writing text data to a file.  There are NativeFS and FTPFS subclasses which implement this interface.  LnBlog writes files by using a wrapper function in the creators.php file to instantiate the correct class based on a constant defined in the fsconfig.php file.

The fsconfig.php file is a simple PHP source code file which contains only a series of constant definitions.  If necessary, these definitions can be changed by hand, although this is not recommended.  Note that which definitions are actually present depends on the type of file writing used.  If NativeFS is used, there is no extra configuration needed, but FTPFS requires various user authentication details.

Standard Constants

Summary
Constants
DOCUMENT_ROOTThis is the full local path to the web server’s document root, i.e.
FS_PLUGINThis determines which filesystem writing method to use.

Constants

DOCUMENT_ROOT

This is the full local path to the web server’s document root, i.e. the root directory from which files are served.  This is not to be confused with the doc_root setting in the php.ini file.

This setting is used to convert local paths into URLs.  Basically, this path is stripped from the full paths to files and directories to get the path component of the URL.

FS_PLUGIN

This determines which filesystem writing method to use.  Currently, there are only two options, “nativefs” and “ftpfs”.

FTPFS-only Constants

Summary
Constants
FTPFS_USERThe username to use when establishing an FTP connection.
FTPFS_PASSWORDThe password used to log in with FTPFS_USER.
FTPFS_HOSTThe host and/or domain name of the FTP server to connect to.
FTP_ROOTThe full path on the server to the user’s FTP root.

Constants

FTPFS_USER

The username to use when establishing an FTP connection.  Note that this username must have write access to the relevant directories on the server, or else this obviously will not work.

FTPFS_PASSWORD

The password used to log in with FTPFS_USER.  Note that this constant currently uses a plain-text password.

FTPFS_HOST

The host and/or domain name of the FTP server to connect to.  In the fairly common case where the FTP server and web server are both running on the same machine, then you can use “localhost” for this value.  In other cases, it will probably be something like “ftp.myserver.com”.

FTP_ROOT

The full path on the server to the user’s FTP root.  In other words, this is the highest directory the user can access through FTP.  In some cases, it will be the root directory, or “/”.  In other cases, it may be something like “/home/username/”.  If you are unsure, you can use the ftproot_test.php script to try different possibilities.

The purpose of this constant is to convert paths on the FTP server into path on the web server.  Because FTP servers often restrict users to a certain portion of the filesystem, these paths are not always the same, even when both servers are on the same physical machine.

The username to use when establishing an FTP connection.
This file configures LnBlog’s file writing and allows you to set the document root for your web server (it will try to auto-detect this).
These are a collection of functions that return an object of the appropriate type based on certain parameters.
This is a one-off script to test values of FTP_ROOT for FTPFS.
Close