Nailblog-2.x by Martin Wikström
http://www.waxjism.org/nail/

Content ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

User documentation
 * About
 * Installation
 * Changelog

API documentation
 * Core PHP functions
 * Core PHP variables
 * Core CSS classes
 * Core JavaScript functions
 * Core JavaScript variables
 * Design guidelines

About ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The Nailblog is a simple modular content management system which
only depends on php to function. It is suitable for small sites
with no access to a database.

Installation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 * Extract the files in public_html or document root or any
   place reachable through the web server.
 * Create a folder for generated data files anywhere and grant
   the web server write access to it.
 * Edit the file nailblog/sets.php and set the variable
   $nailblog_data to point to the created folder.
 * Browse to nailblog.php and log in using username="admin" and
   password="admin".

Notes:
 * Readme's for modules are found in the module directory.
 * In case of a module conflict the system will be rendered
   unusable and you can't login unless it is in safe mode.
   To enable safe mode goto the page "?safemode=1". In safe mode
   you can disable the conflicting module on page
   "?act=admin&open=system".

Changelog ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

100828-nailblog-2.0.3
 * Added viewmode selector to File manager.
 * Added File manager to Menu quick list.
 * Replaced some Owner-Ids with Owners names.
 * Moved Blog and Menu data to php files so they can't be read
   directly.

100325-nailblog-2.0.2
 * Added a file manager module.
 * Renamed index.php to nailblog.php so it can be installed next
   to an existing system.
 * Added nailblog_delete for removing files by GLOB.
 * Added translations to Nailblog core and fixed translation
   related bug.
 * Added anti-bot measurements to the blog module.
 * Clicking blog entry titles switches between single entry and
   multi-entry view.

100203-nailblog-2.0.1
 * Added a new template.
 * Added blog module.
 * Added "Remember me" checkbox to the login form.
 * Added cross site scripting prevention to the user module.
 * Changed the format for menu items to unordered lists.
 * Made the menu_href quicklist also populate the title field.
 * Added help text to the rules fields in menu_edit and
   data_edit.
 * Added user_getlist which returns an associated array with
   user Id's as keys and user names as values.
 * Added design guidelines to the readme.txt file.

091112-nailblog-2.0.0
 * Switched to Git for source control. The changelog will look
   differently from now on.

090806-nailblog-2.0.0-beta2
 * nailblog/nailblog.php
   Changed $nailblog_version to "2.0.0-beta2".
 * nailblog/modules/data.php
   Added translations to the data module.
   Created function data_getrow($entryid) which returns parsed
   rowdata.
   Added support for translated content.
 * nailblog/modules/data.en.lang
   Added english translations for the data module.
 * nailblog/modules/data.sv.lang
   Added swedish translations for the data module.
 * nailblog/modules/menu.php
   Added support for translated content.
 * nailblog/modules/data.txt
   Updated the documentation.
 * nailblog/modules/system.php
   Created function system_main() for replacing the site title,
   header and footer with translated content when available.
   Added support for translated content.
 * nailblog/modules/system.txt
   Updated the documentation.
 * nailblog/templates/default/template.php
   Added the <title> tag which displays $nailblog_title in the
   page title.

090716-nailblog-2.0.0-beta1
 * nailblog/modules/user.php
   Continued work on the translations.
 * nailblog/modules/user.en.lang
   Continued work on the translations.
 * nailblog/modules/user.sv.lang
   Added swedish translations for the user module.
 * nailblog/modules/menu.php
   Added translation support to the menu module.
 * nailblog/modules/menu.en.lang
   Added english translations for the menu module.
 * nailblog/modules/menu.sv.lang
   Added swedish translations for the menu module.

090712-nailblog-2.0.0-beta1
 * nailblog/core.php
   Added variable $nailblog_lang which tells the system which
   language is in use.
   Added a row for default language (row 8) to system.txt.
   Added function nailblog_trans($id) which returns text in the
   selected language.
   Added function nailblog_setlang() which sets the sessions
   language to $_GET['lang'].
   Added variable $nailblog_curlang, which is the sessions
   current language.
 * nailblog/core.en.lang
   Created core.en.php which contains the english translation
   data for core.php and nailblog.php.
 * nailblog/core.sv.lang
   Created core.sv.lang which contains the swedish translation
   data for core.php and nailblog.php.
 * nailblog/nailblog.php
   Moved all non-debug messages to core.en.php.
   The system will now load a language specific version of the
   template when available.
 * nailblog/modules/system.en.lang
   Created system.en.lang which contains the english translation
   data for system.php.
 * nailblog/modules/system.php
   Added support for the language row in system.txt.
   Moved all text to system.en.lang.
 * nailblog/modules/menu.php
   Added available languages to the quick links list.
 * nailblog/modules/user.en.lang
   Created user.en.lang which contains the english translation
   data for user.php.
 * nailblog/modules/user.php
   Moved text to user.en.lang (not finished).

090608-nailblog-2.0.0-beta1
 * nailblog/core.php
   Added variable $nailblog_forcemodules which contains the same
   values $nailblog_modules contains before the system is
   inited. This array is used in safe mode.
   Added variable $nailblog_safemode which tells the system
   whether it should load the predefined modules or the modules
   specified on disk.
   Added function nailblog_safemode() which reads or sets
   the value for safe mode in a session variable. Visit the page
   "?safemode=1" and "?safemode=0" to turn safe mode on and off.
   Added a safe mode message that is displayed while in safe
   mode.
   Added nailblog_getrow($filepath,$defaultvalue,$headersiz,$id)
   for getting one row of tab separated data identified by first
   row.
 * nailblog/nailblog.php
   Made the module loader honor $nailblog_safemode.
   Changed $nailblog_version to "2.0.0-beta1".
 * nailblog/modules/menu.php
   Updated menu_getentry($entryid) to use
   nailblog_getrow($filepath,$defaultvalue,$headersize,$id).
 * nailblog/modules/data.php
   Created a module for displaying static HTML on the site.
 * nailblog/modules/data.txt
   Created a readme file for the data module.
 * nailblog/modules/user.php
   Added function user_nailtags() which is called during post
   processing. It replaces the following tags (nailtags) with
   active content:
    * <nailblog>user_id</nailblog>
    * <nailblog>user_login</nailblog>
    * <nailblog>user_name</nailblog>
    * <nailblog>user_groups</nailblog>
    * <nailblog>user_ip</nailblog>
 * nailblog/modules/user.txt
   Added documentation about the nailtags.
 * nailblog/modules/system.php
   Added function user_nailtags() which is called during post
   processing. It replaces the following tags (nailtags) with
   active content:
    * <nailblog>system_version</nailblog>
    * <nailblog>system_template</nailblog>
 * nailblog/modules/system.txt
   Added documentation about the nailtags.

090607-nailblog-2.0.0-alpha3
 * nailblog/nailblog.php
   Changed $nailblog_version to nailblog-2.0.0-alpha3.
 * nailblog/modules/user.txt
   Continued work on the user authentication module
   documentation.
 * nailblog/modules/user.php
   Fixed a minor cosmetic detail in the user_admin() function.
   Added a link to user.txt from the user admin page.
   Added a page for users to change their password and name.
 * nailblog/modules/user.js
   Added function user_validatesets() for validating and
   encrypting new passwords (checking if two passwords are the
   same)
 * nailblog/modules/menu.php
   Added a link to menu.txt from the menu admin page.

090605-nailblog-2.0.0-alpha2
 * nailblog/modules/menu.txt
   Continued work on the menu module documentation.

090604-nailblog-2.0.0-alpha2
 * nailblog/core.php
   Added read-only mode.
   Added function nailblog_deleterecursive($startpath) for
   deleting all data from a given directory.
   Added function nailblog_deleteall($startpath,$deletethis) for
   deleting files and directories from the data directory.
 * nailblog/modules/system.php
   Removed function system_deleteall($startpath) and made it use
   nailblog_deletall instead.
   Added links to module documentation when available.
   Added link to the main readme file.
 * nailblog/modules/menu.txt
   Added a documentation file for the menu module.
 * nailblog/modules/user.txt
   Added a documentation file for the user module.
 * nailblog/modules/system.txt
   Added a documentation file for the system module.

090601-nailblog-2.0.0-alpha2
 * index.php
   Redefined index.php's functionality to also contain the
   default overrides previously found in sets.php.
 * nailblog/sets.php
   Removed the file sets.php and moved its functionality to
   index.php.
 * nailblog/nailblog.php
   Moved the main file to nailblog.php. It must now be included
   into a host file (index.php) in order to work.
 * nailblog/templates/default/style.css
   Fixed some minor cosmetic issues.
 * nailblog/templates/default/template.php
   Fixed some minor cosmetic issues.
 * nailblog/core.php
   Fixed the rule parser in nailblog_getprivs(...).

090531-nailblog-2.0.0-alpha2
 * nailblog.php
   Updated $nailblog_version to "2.0.0-alpha2".
 * nailblog/core.php
   Added nailblog_quicklist($trg,$vals,$titl,$ind,$repl) for
   creating dropdown lists.
   Fixed one bug in the rule parser in
   nailblog_getprivs($access,$rules,$groups,$owner).
 * nailblog/core.js
   Added function nailblog_appendinput(from,to) for appending
   values from one input box to another. This is mainly used by
   the PHP function nailblog_quicklist(...).
 * nailblog/modules/menu.php
   Added a quicklist for menu entry positions to menu_edit().
   Added a quicklist for menu entry href to menu_edit().
   Added move functionality to the menu entry list.
 * nailblog/modules/user.php
   Added a quicklist for group values to user_edit().
 * nailblog/modules/system.php
   Added move functionality to the module list.
 * nailblog/templates/default/style.css
   Added styles for left and right column.

090530-nailblog-2.0.0-alpha1
 * nailblog/modules/menu.php
   Continued work on the menu module.
 * nailblog/modules/system.php
   All relevant functions check if user authentication is
   enabled before validating access now.
 * nailblog/core.php
   Added nailblog_getprivs($access,$rules,$groups,$owner) for
   validating access privileges.
   Added variables $nailblog_top, $nailblog_left,
   $nailblog_right and $nailblog_bottom for output control.

090529-nailblog-2.0.0-alpha1
 * nailblog.php
   The system now checks if a user authentication module and
   a system administration module is activated. If not it
   provides a method for activating the default versions of
   these modules. This way the admin will not get locked out by
   mistake.
 * nailblog/core.php
   Added variables $nailblog_header, $nailblog_footer,
   $nailblog_systemversion and $nailblog_template.
   Added function nailblog_readsystem() for loading system
   settings from disk.
   Updated nailblog_redir($target) to send a message to
   nailblog_error($message) if $nailblog_errors is true.
 * nailblog/modules/system.php
   Created a module for administering then core system.
 * nailblog/templates/default/template.php
   Added output for $nailblog_header and $nailblog_footer.
 * nailblog/templates/default/style.css
   Added styles for header and footer.
 * nailblog/modules/menu.php
   Started working on a menu module.
 * nailblog/modules/user.php
   Fixed user_class method ingroups($groups). You now don't have
   to be in every group to pass. Just one.

090528-nailblog-2.0.0-alpha1
 * nailblog.php
   Made common JavaScript files load before module loaded ones.
 * nailblog/modules/user.php
   Continued work on the user authentication module.
 * nailblog/modules/user.js
   Added function user_md5(fieldid) for encrypting passwords.
 * nailblog/core.php
   Added function nailblog_getnextid($idpath,$startid) for
   getting a new, unused id.
   Added function nailblog_tabsafe($data) for prepairing data
   for storage in tab-separated-data files.
   Added function nailblog_savedata($filepath,$data) for
   writing data to disk.

090527-nailblog-2.0.0-alpha1
 * nailblog/modules/user.php
   Continued work on the user authentication module.
 * nailblog/modules/user.js
   Fixed an error in function user_md5salt where the password
   was encrypted incorrectly.
 * nailblog/core.php
   Added function nailblog_redir($target) for redirecting to
   other pages.
   Added variable $nailblog_title for specifying the document
   title.
 * nailblog/templates/default/template.php
   Created a default template.
 * nailblog/templates/default/style.css
   Created a stylesheet for the default template.

090526-nailblog-2.0.0-alpha1
 * index.php
   Renamed index.php to nailblog.php and made index.php include
   nailblog.php instead. This adds support for multiple Nailblog
   versions in the same installation directory.
 * nailblog.php
   Renamed from index.php, added support for variable $nailblog
   which is the system path.
 * nailblog/core.php
   Added function nailblog_tosession($varname,$value).
 * nailblog/modules/user.php
   Continued work on the user authentication module.
 * nailblog/modules/user.js
   Created a JavaScript file for the user module.

090518-nailblog-2.0.0-alpha1
 * index.php
   Created the index.php file.
 * nailblog/readme.txt
   Created this readme file.
 * nailblog/sets.php
   Created a file for default overrides.
 * nailblog/core.php
   Created a file for core functions and variables.
 * nailblog/modules/user.php
   Created a module for user authentication.

Core PHP functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 * function nailblog_error($message)
   Outputs an error message if $nailblog_errors==true

 * function nailblog_commonjs($filename)
   Loads common JavaScript files

 * function nailblog_tosession($varname,$value)
   Store a value in a session variable

 * function nailblog_fromsession($varname,$default)
   Restores a value from a session variable

 * function nailblog_alert($message)
   Outputs an alert message

 * function nailblog_unmagic($data)
   Fix magic quotes if they are enabled

 * function nailblog_readdata($filepath,$default)
   Reads data from disk

 * function nailblog_parsedata($data)
   Converts tab separated data into an array unless the data is an array

 * function nailblog_redir($target)
   Redirects to another page

 * function nailblog_adminbox($module,$groups,$title)
   Header for an toolbox on the admin page

 * function nailblog_getnextid($idpath,$startid)
   Increments a specified id, stores it on disk, a returns it

 * function nailblog_tabsafe($data)
   Converts posted data to tab-separated-data

 * function nailblog_appenddata($filepath,$data,$header)
   Appends data to a file or create one with specified header if not exists

 * function nailblog_savedata($filepath,$data)
   Writes a data string to disk

 * function nailblog_readsystem()
   Reads the system settings from disk

 * function nailblog_getprivs($access,$rules,$groups,$owner)
   Validates user access privileges

 * function nailblog_trans($id)
   Returns a text translated to whatever language $nailblog_lang is set to

 * nailblog_quicklist($target,$values,$titles,$indent,$replace,$titletarget="")
   Returns a dropdown select list

 * function nailblog_deleterecursive($startpath)
   Deletes everything within a directory (use with caution!!!)
   This function should only be called by other core functions
   such as nailblog_deleteall, which checks for security threats

 * function nailblog_deleteall($startpath,$deletethis)
   Deletes files and directories in the data folder
 
 * function nailblog_delete($glob)
   Deletes files in the data folder

 * function nailblog_safemode()
   Sets or gets safe mode

 * function nailblog_getrow($filepath,$defaultvalue,$headersize,$entryid)
   Returns a single row of tab separated data identified by first column

 * function nailblog_setlang()
   Sets the sessions active language

 * function nailblog_checkreferer($validrefs,$exit)
   This function is used to prevent cross site scripting attacks
   
 * function nailblog_antibot()
   This function asks for a small password in order to prevent bots from spamming

Core PHP variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 * $nailblog_systemversion

 * $nailblog_data
   Default: "data/"
   Path to generated data

 * $nailblog_modules
   Default: array("system","user","menu")
   Default modules

 * $nailblog_forcemodules
   Default: $nailblog_modules
   Used in safe mode

 * $nailblog_safemode
   Default: false
   Safe mode

 * $nailblog_errors
   Default: false
   Debugging

 * $nailblog_session
   Default: "nailblog_"
   Session variable prefix

 * $nailblog_template
   Default: "default"
   Document footer

 * $nailblog_maincalls
   Default: array()
   Main functions calls

 * $nailblog_postcalls
   Default: array()
   Post processing functions calls

 * $nailblog_jsfiles
   Default: array("core.js")
   Loaded common JavaScript files

 * $nailblog_head
   Default: ""
   Document header output

 * $nailblog_title
   Default: "the Nailblog"
   Document title

 * $nailblog_header
   Default: "<h1><a href=\"?act=\"><sup>the</sup>Nailblog</a></h1><p>Developement version</p>\n"
   Document header

 * $nailblog_top
   Default: ""
   Top content output

 * $nailblog_left
   Default: ""
   Left content output

 * $nailblog_right
   Default: ""
   Right content output

 * $nailblog_center
   Default: ""
   Center content output

 * $nailblog_bottom
   Default: ""
   Bottom content output

 * $nailblog_footer
   Default: "<p>by Martin Wikström</p>\n"
   Document footer

 * $nailblog_readonly
   Default: false
   Set this to true in order to lock the system

 * $nailblog_lang
   Default: "en"
   Default language

 * $nailblog_curlang
   Default: "en"
   Default language

Core CSS classes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 * p.nailblog_alert
   Used for displaying important messages.

 * div.nailblog_adminbox
   Used for containing admin tools. These may take up more
   horizontal space than available so the style needs to support
   that with scrollbars or something similar.

 * div.nailblog_menu
   This is used as a container for menus.

 * span.nailblog_menuitem
   Container for one menu item.

 * div.nailblog_item
   Container for normal content.

 * div.nailblog_itemheader
   Container for the item header.

 * div.nailblog_itemmenu
   Container for item-connected menu.

 * div.nailblog_itemcontent
   Container for item content.

 * div.nailblog_itemfooter
   Container for item footer.

Core JavaScript functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note: the Nailblog uses one external JavaScript file for
      creating md5 hashes used in the password encryption.
      The file, nailblog/md5.js, is distributed under the BSD
      license. Credits goes to Paul Johnston, Greg Holt,
      Andrew Kepert, Ydnar and Lostinet.
      See http://pajhome.org.uk/crypt/md5 for more info.

 * nailblog_init()
   Calls functions when page loads.

 * nailblog_copyinput(from,to)
   Copies the value of one input box to another.
   If third value is the target input for title if source is a
   select box.

 * nailblog_appendinput(from,to)
   Appends the value of one input box to another.


Core JavaScript variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 * nailblog_onload
   Array containing references to functions to call when page
   loads.

Design guidelines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 * Menus
 
 * Headers
   Normal headers does not require containers.
   
 * Extra content
   Extra content can be contained in a div like this:
   <div class="nailblog_content">
     TEXT OR OTHER CONTENT
   </div>
   
 * Entries
   Entries such as blog entries consist of a title, optional
   toolbox, content, and a footer:
   <div class="nailblog_entry">
     <ul class="nailblog_entrytoolbox">
       <li>Tool</li>
       <li>Tool</li>
       <li>Tool</li>
     </ul>
     <div class="nailblog_entryhead">
       <h2>Title</h2>
       <p>An other stuff</p>
     </div>
     <div class="nailblog_entrymain">
       <p>The actual entry content</p>
     </div>
     <div class="nailblog_entryfoot">
       <p>Author, date, and such</p>
     </div>
   </div>
 
 * Comments
   Comments are part of entries and are added like this:
   <div class="nailblog_entry">
     <div... entry stuff .../div>
     <div class="nailblog_comment">
       <p>Comment content including title and author, etc</p>
       <p class="nailblog_fineprint">By this guy at that time</p>
     </div>
   </div>
 
 * Replies
   Replies work like comments:
   <div class="nailblog_entry">
     <div... entry stuff .../div>
     <div class="nailblog_reply">
       <p>Comment content including title and author, etc</p>
       <p class="nailblog_fineprint">By this guy at that time</p>
     </div>
   </div>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

