Public Data:

Popular Project Sites: Project Sites:

Luke Cole

Donate to Luke Cole
Locations of visitors to this page


No longer recommended - too much overhead. New version comming soon.

phpSite provides a framework for real webmasters to seriously create/edit/manage powerful, flexiable and modulated web sites extremely easy using their preferred text/html editor (or a browser soon, like a wiki). Webmasters generate web pages content using HTML/CSS and define page layouts via writting a web page avatar and skin using HTML/CSS, and can create/update backbone php modules with ease. phpSite can support any databases that php supports, such as PostgreSQL, however currently only a MySQL interface is implemented. phpSite can support any coding language within HTML, such as C/C++, however currently only supports php and python. phpSite has many modules already included in the package, such as: authorisation, file management and shop tools.

Why use phpSite?

  • Installed/Updated via a Makefile.
  • All page content is defined by a tree structure, using one, or multiple XML/HTML/CSS files.
  • Web page style and layout (i.e. skins, avatars) can be designed (HTML/CSS) for particular or many pages.
  • Code (e.g. php, python) is supported in imported HTML pages. The code output is displayed wherever the the code is written in the HTML pages.
  • phpSite variables can be used within the HTML pages and any code that resides within those HTML pages.
  • There are many modules (see below) available to create authentication systems, file managers, shops, etc
  • All page files are a copy of a skeleton index file and is created when you first visit your home page.
  • Command line scripts to update site html or database. Great for scheduling regular site updates via, for example, crontab.
  • geoip, ip2location supported.
  • exchange rate facilities.
  • supported.
  • Hits, sessions, IP and user tracking facilities.
  • Web site statistics interpreting facilities.
  • Shopping cart and ordering facilities.
  • Shop products star ratings.
  • A shop home page can be determined via calculating the most viewed products and what are new products.
  • Apache .htpasswd supported and integrated within user module
  • High Security:
    1. Auth module uses MD5 encryption for user passwords.
    2. Protection against web bots using CAPTCHA's in forms, and soon a better system.
    3. UNIX style read/write file access for the Filesystem module.
    4. Tested against website exploits such as Remote File Inclusion (RFI), Local File Inclusion (LFI) and SQL Injection.

Some Web Sites Using phpSite

Current Release (Free Software, Open Source)


Dependencies: make, rsync, [mysql-server], php5, php5-mysql, php5-cli, [python]
Filesystem Module Dependencies: convert (i.e. ImageMagick), ffmpeg
Supported Databases: mysql
Supported Lanagauage within included HTML files (steming from phpSite/site/data.xml): php, python
Modules Included: Mail Module, DB Module, Stats Module, Filesystem Module, Authentication Module, Shop Module (incomplete)

Lines Of Code (LOC)

True Code

Please note sloccount does not include white space.

localhost:~>sloccount phpSite/*

SLOC    Directory       SLOC-by-Language (Sorted)
12842   src             php=12798,ansic=44
2159    scripts         php=2152,sh=7
156     contrib         php=156
0       CVS             (none)
0       avatars         (none)
0       conf            (none)
0       images          (none)
0       site            (none)
0       skins           (none)
0       top_dir         (none)

Totals grouped by language (dominant language first):
php:          15106 (99.66%)
ansic:           44 (0.29%)
sh:               7 (0.05%)

Total Physical Source Lines of Code (SLOC)                = 15,157
Development Effort Estimate, Person-Years (Person-Months) = 3.47
 (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
Schedule Estimate, Years (Months)                         = 0.86
 (Basic COCOMO model, Months = 2.5 * (person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule)  = 4.04
Total Estimated Cost to Develop                           = $ 469,122
 (average salary = $56,286/year, overhead = 2.40).
SLOCCount, Copyright (C) 2001-2004 David A. Wheeler
SLOCCount is Open Source Software/Free Software, licensed under the
SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to
redistribute it under certain conditions as specified by the GNU GPL
see the documentation for details.
Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."


Please note wc -l counts the white space.

localhost:~>wc -l phpSite/site/*
    275 data.xml
    763 data.xml.auth.body.html
     88 data.xml.auth.menu_right.html
    144 data.xml.db.body.html
     31 data.xml.db.menu_right.html
     75 data.xml.default.avatar.html
     59 data.xml.default.footer.html
      1 data.xml.default.header.html
    109 data.xml.default.menu_left.html
      0 data.xml.default.menu_right.html
    323 data.xml.fs.body.html
     71 data.xml.fs.menu_right.html
     15 data.xml.index.body.html
    351 data.xml.mail.body.html
     47 data.xml.mail.menu_right.html
    110 data.xml.stats.body.html
     75 data.xml.stats.menu_right.html
      6 mail-body-confirm_new_email.txt
      6 mail-body-confirm_registration.txt
      6 mail-body-new_products.txt
      9 mail-body-order_status.txt
     21 mail-body-supplier_order.txt
      2 robots.txt
   6242 total

SQL Code

Please note wc -l counts the white space.

localhost:~>wc -l phpSite/scripts/db/*.sql phpSite/scripts/stats/*.sql \
 phpSite/scripts/auth/*.sql phpSite/scripts/shop/*.sql
   19 db/create_tables.sql
   14 db/drop_tables.sql
   62 stats/create_tables.sql
   17 stats/drop_tables.sql
   18 stats/export_table_data.sql
   18 stats/import_table_data.sql
  197 auth/create_tables.sql
   22 auth/drop_tables.sql
   23 auth/export_table_data.sql
   24 auth/import_table_data.sql
  312 shop/create_tables.sql
   33 shop/drop_tables.sql
   38 shop/export_table_data.sql
   32 shop/import_table_data.sql
  829 total


Installing / Updating

  1. Config your site as required (see below):
    emacs phpSite/conf/phpSite.conf
    emacs phpSite/site/data.xml
  2. Point your web server to the httpdocs. Example:
    ln -s phpSite/httpdocs /var/www
  3. Go to source directory:
    cd phpSite/src
  4. Install/Update phpSite libraries (requires root/sudo access). If database disabled OR just updating phpSite libraries:
    sudo make install
    If database enabled and installing phpSite libraries and database for the first time then:
    sudo make installdb
  5. Create/Update httpdocs:
    make httpdocs
  6. Add the path '/usr/lib/phpSite' to your php include_path variable in php.ini (in Ubuntu that is /etc/php5/cli/php.ini and /etc/php5/apache2/php.ini)
  7. Open a internet browser and go to:
    If the Auth module is enabled. The default administrator login is:
    Username: admin
    Password: admin

How to Configure

Step 1 (Mandatory)

Step 2 (Mandatory)

Add/edit pages within xml file SITE_TREE_FILE, between the <xml></xml> tags. Each page can have a number of elements.

  <filename>       index.php                    </filename>

  <module>         auth                         </module>

  <modules>        stats:auth                   </modules>

  <subjects>       home_page:about:spam         </subjects>

     <meta name="description" content="$description">
     <meta name="author" content="$conf:webmaster">
     <link rel="SHORTCUT ICON" href="$icon_filename" type="image/x-icon">
     <link rel="stylesheet" href="$skin" type="text/css">

  <skin>           skin0.css                    </skin>

  <icon_filename>  $conf:site_images_diricon.png </icon_filename>

  <title>          $conf:org_name - Home Page   </title>

  <description>    $conf:org_name's site ...    </description>

  <header>         <h1>$conf:org_name</h1>      </header>

    Created by <a href="$conf:webmaster_email">$conf:webmaster_name</a>

    <a href="index.php">Home Page</a>
    <a href="index.php?subject=about">About</a>
    <a href="index.php?subject=spam">Spam</a>
    <a href="mail.php">Contact</a>

  <menu_right>      <!-- empty :( -->            </menu_right>


   <form action="$current_url" enctype="multipart/form-data" method="POST">
    <input type="hidden" name="validate" value="1">
    <input type="hidden" name="subject" value="$_REQUEST[subject]">

    <!-- subject == home_page START -->
      echo "hello $stats:session_id ($stats:log_id), "
       . "this website is called $org:org_name";

      <!-- login == 0 START -->
        Your not logged on!
      <!-- login == 0 END -->
      <!-- login == 1 START -->
        Thankyou for logging on
        Table of all your users (processed from auth module):
      <!-- login == 1 END -->

      <!-- group == webmaster START -->
        You must be in the webmaster group, some of your details:<br>
        Name: $auth:user:name<br>
        Username: $auth:user:username (ID: $user:id)<br>
        Password (MD5): $auth:user:password<br>
        Group(s): $auth:user:groups_format<br>
        $path = "$conf:user_images_dir$";
        if (file_exists($path)) {
          echo "<img alt=\"$auth:user:name\" src=\"$path\">";
      <!-- group == webmaster END -->

    <!-- subject == home_page END -->

    <!-- subject == about START -->
      about me!!
    <!-- subject == about END -->

    <!-- subject == spam START -->

      <!-- error == 0 START -->
      <!-- error == 0 END -->
      <!-- error == 1 START -->
        Invalid Fields:
        <? echo implode(", ", explode("::", "$page:errors")); ?>
      <!-- error == 1 END -->
      Enter some spam:
      <input type="text" name="spam" value="$_REQUEST[spam]">
      <input type="submit" name="submit_button" value="Submit">

      Did you submit $_REQEUST?
      (the form input value has also been updated with your spam)

    <!-- subject == spam END -->



  1. If any page element is not given, the default file 'data.xml.default.element.html' will be imported.
  2. Use comments to remove other page subjects and user groups.

Step 3

Design a html web site avatar and css skin for the page elements avatar and skin.

  1. Any of the following variables may be used, which are mostly defined in the SITE_TREE_FILE (see step 2): $title, $description, $header, $footer, $menu_left, $menu_right, $body

Modules Summary / Step 2 Options

Mail Module

  • Description: A set of email forms. [ DONATE ]
  • Pages (Subjects): home_page, send_mail, webmaster, org

DB Module - Incomplete

  • Description: Database web interface. [ DONATE ]

Stats Module

  • Description: Statistics inferface. Log data such as session, IP, current page, from page and get listings on popular pages, downloads, IP's, etc. geoip, ip2location Supported. [ DONATE ]
  • Pages (Subjects): home_page, online, pages, ips, downloads, user_agents, page, ip, session, user
  • Cookies: session

Auth Module

  • Description: Authentication for users (membership system) login, logoff, registering, modify users. Follows unix user and group standards. Also file permissions are available, which follows the unix file system standards. Table columns access and Table action access is also available. All passwords are MD5 encrypted. [ DONATE ]
  • Prerequisites: Database enabled
  • Pages (Subjects): home_page, users (actions: edit, add, view), login, logoff, register
  • Cookies: login
  • Log Types surfing, db, auth
  • Online Example:
    1. coleTEK:

File System Module

Shop Module - Incompletes

  • Description: Sell products via a database of items using a shopping cart (great for business). It is built as is a complete ordering and product database system to supply all needs with some minor changes. Handles multiple suppliers and currencies. An orders weight, logistics and bank costs can be calculated. Product star rating available. Exchange rate facilities via [ DONATE ]
  • Prerequisites: Database enabled, user module
  • Pages (Subjects): home_page, items (actions: search, new, popular, add, edit, view), organisations (actions: search, new, popular, add, edit, view), orders (catalogue, search, edit, add, view), custom_system, cart, terms_and_conditions
  • Cookies: currency
  • Online Example:
    1. LowZo:
    2. coleTEK:

Content Management Module - Not converted from older version as yet

  • Description: View/Edit/Download files, similar to CVS, but web based and easier to use. [ DONATE ]
  • Prerequisites: Database enabled, user module
  • Pages (Subjects): files, new, update

Frequently Asked Questions

Question: How do I call other db modules functions in a db module function?
Answer: Easy, if the module is called 'auth' and the function you wish to call is 'spam' then you call:
Question: How do I handle _REQUEST data?
Answer: For POST forms use an str_replace() within insert_data(), GET forms are handled automatically.

Development Documentation

Global Coding Standards

  • Keep all lines correctly indented. Best to use the following modes in emacs via alt-x:
    tex-mode for [la]tex files
    html-helper-mode for html files php-mode for php files
    shell-script-mode for bash/tcsh/csh files
    c++-mode for c++ files
    c-mode for c files
  • NO line should extend 80 characters.
  • REMEMBER: white space is your friend.
  • All functions should be seperated by one or more of the following comments of the style. Where the equal signs extend to the last character of an 80 character wide buffer.
  • All functions comments should have a comment explaining it self (if needed) in the following form. Place under the function seperater comment, with space new line between the comments.
     * commment here
  • long functions should have have its code seperated by one of the following comments of the style. Where the dashes signs extend to the last character of an 80 character wide buffer.
  • All comments in functions should have the the following form. Place under the long function seperater comment, with no between the long function seperater comment and your comment.
    // comment here
  • All function must be of the following form. i.e. a space between ')' and '{' and a newline for '}':

    PHP style:

    function function_name($var1, $var2) {
      return 0;

    C style:

    int function_name(type1 var1, type2 var2) {
      return 0;
  • All if/for/while, etc statements must be of the following form i.e. a space between ')' and '{' and a newline for '}':

    If statement:

    if (condition) {
    } else if (condition) {
    } else {

    While statement:

    while (condition) {

    For statement:

    for (init; condition; increment) {
  • All expressions should have space to the left and right of the next expression. Examples:
    i >= 3
    3 + 4 * 2
    (3 + 4) * (4 * 14 - (23 + 2))
  • All 'for' loops should be of the form. i.e. starts at '0' and up to 'i_max - 1', if your loop needs to go backwards (or anything else) offset 'i'. e.g. new_i = (i_max - 1) - i
    for (i = 0; i < i_max; i++)
  • All matrices should be scaned from left to right, top to bottom. i.e:
    for (j = 0; j < height; j++) {
      for (i = 0; i < width; i++) {
        // do something to array[j][i];
  • All functions should return '< 0' if the function fails, '>= 0' otherwise.

An Example of Poor Coding Standard

for (i=0;i<=height;i++)
  /*some comment
  if (something==spam)
  echo "cool";

HTML Coding Standards

Image Standards

  • Valid HTML image types: jpeg, gif, png
  • PNG Images: IE 6.0 or less only supports an 8-bit alpha channel, so png images need to been used in index mode if transparency is required. Otherwise replace the transparency with your website background colour.
  • Thumbnails widths are recommend to be less then 100 pixels.
  • The following image types are recommend for HTML:
    • gif: if animation required
    • png indexed: if transparency required
    • jpeg: if hardware outputed this type
    • png: otherwise
  • Website downloadable images are recommend to have a width less then 1200 pixels.
  • Website viewable images are recommend to have a width less then 550 pixels.

phpSite Site Coding Standard

  • At no time should you edit any files in the 'httpdocs' directory, as this is updated from the 'src' and 'site' directory.
  • Copy 'phpSite/src/modules/skeleton/' to create a new phpSite module.
  • Copy 'phpSite/script/skeleton.php' to create a new phpSite script.
  • Any site variables must be located in 'phpSite/phpSite.conf' and parsed by 'phpSite/src/parser/config_file_parser.php::parse_site_config_file()'
  • All files should contain the following LINCENSE at the head of the file:
     * <file_name> - <description>
     * Copyright (C) <year> <author>
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of version 2 of the GNU General Public
     * License as published by the Free Software Foundation
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * GNU General Public License for more details.
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
     * 02111-1307, USA.
     * @author  <author> <<email>>
     * @version
     *   $Id$
  • All calls to a function should check for any errors and if there are any call the debug::error function (shown below) and return -1, so the current function will exit.
    function example_function($var1, $var2, $var3) {
      if (function_name($var1, $var2) < 0) {
        debug::error(__FILE__, __FUNCTION__, __LINE__,
                     "function_name($var1, $var2) failed");
        return -1;
      return 0;

How the current page is the created (for developers)

Well all page files (e.g. index.php) contain the perso-do code:

$module = "page";

if (_REQUEST[m]) {
  require_once "modules/_REQUEST[m]/_REQUEST[m]_page.php";
  $module = strtolower(_REQUEST[m]) . "_page";

page::set_conf($conf_path, $module);

$page = new $module();


printf("%s", $page->get_html());

Where the perso-do code of page.create() is:

# Init

$data = array();
$html = "";

# connect to db


   $this->setup_tables();      # create and import empty or non existing tables

foreach (CONF_MODULES as $module_name) {

foreach (CONF_MODULES as $module_name) {
  $this->module[$module_name]->data = $this->data;

# Perform tasks for page currently being viewed


if (!$this->is_allowed()) {      
   $this->replace_body(&$html, CONF_COMMENT_UNAUTHORIZED_ACCESS);
} else {

$this->insert_data($data, &$html);      

# Perform tasks for any page

foreach (CONF_MODULES as $module_name) {
   $this->module[$module_name]->insert_data($data, &$html);


$this->common_insert_data($data, &$html);


# insert page data again for any code created variables
$this->insert_data($data, &$html); 



HIGH Priority (Bugs)

  • Print user error if now able to read file, when should be. Where this??
  • Fix invitation code usage.
  • Improve error emailing
  • User errors for db max connections or can't connect! and when mysql "Server shutdown in progress"
  • Version Handling when using actions
  • Shop module: fix adding org types from forms

MEDIUM Priority (Enhance Features)

  • fs module: change "Upload File" feature in fs to upload to current directory only, and have write permissions to files; Option to see full file names
  • Shop module: add/update muliple items, cart, custom_system
  • Auth module: comm's between users, public page | allow users option

LOW Priority (New Features)

  • File permissions options on each page.
  • Sorting table columns.
  • Shop module: companys and users relationships, countries product search
  • Shop module pages: new_organisations, popular_organisations
  • Split DB for Intranet version: users data and shop data

Design Issues

  • when inserting variable into html, must use a hack for character ".
  • correct action for sub tables when viewing a item/org - get_html_table_db_access needs subject, however only table_name given?? when using actions should subject == table_name?? - TMP FIX IN page::get_html_table_action_access
  • Ideally when a table has a _id it should display the appropriate name instead (e.g. merchant_id = 10 so display "Spam World")
  • Shop module:
    • Search Products/Services: How are these handled now..
    • Getting rather large: can we split up the module?? or maybe just replace routine with more generic style routines, as they are becoming are very simpliar.
    • cart and cart_saved
    • how is the price in the tables setup?
    • should add items_merchant update the merchant item if merchant_id used? - Currently the case...
    • adding items_merchant gives error when merchant_id exists.
    • add item condition and qty in add_item OR remove merchant data in add_item? - TMP FIX the first option

New Design Notes

  • update_* replaced set_*_data, udpdate_* handles adding and update'ing - ideally a new generic routine should be written.
  • Image not viewable when adding, only editing.
  • grab name from name id's for top form select option
  • late update, and added to cat not on item info page. Plus items_status needs to be updated to the new sub-table format.
  • Windows setup: Makefile not ideal
  • All tables have two extra columns: Thumbnail Image and Action:
    • A Thumbnail Image will link to:
    • The Action column has an array of icons which are defined by the table action_access and will link to:
      where page_name is defined in data.xml, enabling subjects (and hence also tables) to be viewed are also defined in data.xml
  • All tables must have the following columns: id, name and modules/*_db.php require the following routies to update table:
     get_<table_name>_data($id) - generally used in *_page::get_data
     get_<table_name>($id) - generally used in *_page::get_data
     add_<table_name>($data) - required for update
     update_<table_name>($data) - generally used in *_page::run_page
     <table_name>_exists($id, $keys...) - required for update
    where $id is the table row ID, $data is an array with a row for the table. Here $data[id] is always assumed to be the table row ID, $data[name] is always assumed to be the table row name. ID and its Name should always be unique.
  • All sub table must have following columns are used: id, <table_name>_id, <sub_table_name>_name and modules/*_db.php require the following routies to update table:
     get_<table_name>_data($id) - generally used in *_page::get_data - R u sure???
     get_<table_name>($id) - gennerally used in *_page::get_data - R u sure??
     get_<table_name>_id($id, $<sub_table_name>_name) - required for update
     add_<table_name>($data) - required for update
     update_<table_name>($data) - generally used in *_page::run_page
     <table_name>_exists($id, $<sub_table_name>_id, $key...) - required for update
    where $id is the table row ID, $data is an array with a row for the table. Here $data[id] is always assumed to be the table row ID, $data[$<sub_table_name>_id] is always assumed to be the root table row ID. $data[name] is always assumed to be the table row name. ID and its Name should always be unique.

Release Notes

phpSite-1.10 - November 19, 2007

Fixed some simple, but frustrating first time installation bugs. Fixed and finished shop features for items and organisations (only cart requires fixing). Fixed some bugs. [ 15157 LOC ]

phpSite-1.9 - November 11, 2007

More shop features added. Add reCAPTCHA support to forms. Fixed some bugs.

phpSite-1.8 - August 28, 2007

Included modules (i.e. auth, fs, shop) that where previously temporary on sale to improve phpSite features. Enabled multiple site setup and debug url. Fixed some bugs. [ 13171 LOC ]

phpSite-1.6 - August 21, 2006

Added geoip support to initialize site data for the country the surfer is visiting from. Added more online views of statistics. Added some scripts for file name manipulation and old phpSite database version importing. Added video functions within filesystem module to view downloadable movies as gif animations online. Updated and added some built-in images. Fixed many bugs.

phpSite-1.5 - June 27, 2006

More re-implementation of backbone to allow for a different avatar and skin for each page (if needed) and reduced the required execution time. Removed config options modules and module subjects. Added page items: module, modules, subjects, avatar, skin, icon_filename. Any page item can now be imported. Pages and module definitions separated.

phpSite-1.1 - June 13, 2006

Added script to update popular products for shop module: most viewed products from stats module and new products added. Finally added subjects for statistics module: top pages, top downloads, page logs, session logs, ip logs, online logs, user logs. Fixed some bugs such as page title and some scripts, added alt comments for fs images for web bots.

phpSite-1.0 - May 26, 2006

Renamed modules contact, user, store to mail, auth, shop. Replaced image_browser module with file_manager module, which includes image_browser functions. Replaced conf module with base module and added db_admin module. Major changes to backbone function page.php::create(). See the section "How the current page is the created" in the development documentation.

phpSite-0.7 - January 20, 2006

Added image_browser module.

phpSite-0.6 - January 10, 2006

Added store module.

phpSite-0.5 - December 1, 2005

Added user module.

phpSite-0.4 - June 20, 2005

Added contact, conf modules.

phpSite-0.3 - December 5, 2004

Module interface added.

phpSite-0.2 - May 20, 2004

Added database interface with web-based config.

phpSite-0.1 - January 20, 2004

Initial code release. This release contains provides a way to view pages with different body content but with a common menu, header, footer all defined in html files, but viewed as run as php files (i.e. provides an avatar system for the page data layout).


© 2000-2024 Luke Cole
All rights reserved