Documentation SGEngine 2.2

  1. Introduction
  2. What's new?
  3. Installation
    1. Upgrading from the previous versions
    2. New installation
    3. End of installation
  4. Core system and the basic functions
    1. Structure of files and folders
    2. Templates
    3. Modules
    4. Configurations file
    5. Multilanguage support
    6. Text and HTML files
    7. Administration
  5. Modules available in this package
    1. Public modules
    2. Administrative modules
  6. TO DO

1. Introduction

SGEngine - is a multipurpose and flexible in configuration Content Management System (CMS), which is written in programming language Perl.

Its main advantages are:

  • Support of individual templates, those are responsible for design of website. Templates differ not only in color but also in structure and maintenance! You can give your visitors the chose to adjust the view of website.
  • Modularity. Modules are small scripts, which can be written by anyone, who knows Perl. Modules provide dynamics of CMS.
  • All modules included in this package have own HTML templates. This feature delivers from direct interference in module code when only applying of design changes are needed. This is especially relevant to those people who do not know Perl.
  • Support of language packages.
  • SGEngine has administrative interface with advanced capabilities to website management.
  • As from version 2.0 of this bundle, script "Setup wizard" was included in it, which can help you to install CMS on your server within a few steps! You do not need any more to delve into configurations files!

So, if you are not Perl programmer also even do not know HTML, you can quite install SGEngine without someone's help and take advantage of one of prepared templates. If you are HTML guru or even be good on it, you are on forces to create own design and to use prepared modules. Well and if you besides work with programming language Perl, you can create own modules to your new site!

2. What's new?

+ Captcha - protection against spam-robots in guestbook and in comments
+ URLs are cut off by Apache mod_rewrite
+ New module "Navigating menu"
+ New template "Silver"
* HTML code of engine match with HTML 4.01 Transitional standard
* The module "Adding/Editing text files" is renamed into "File manager". Changes: listing of directories and files on a server and free navigation within a root directory; file upload to server directly from browser; and many other things. See 5.2 File manager
* URLs are unified
* A plenty of fine corrections and changes
- Not authorized users have no access to administrative interface
- Template "Black-White" is removed
- A plenty of fine bugs is corrected

The given documentation changes with each version. To receive the most extensive and clear representation about innovations in last version of this engine, we advise to familiarize with a variant of the documentation where all changes are noted by color.

3. Installation

3.1 Upgrading from the previous versions

If the version 1.1 or below of SGEngine has been already installed, consider that you does not become the current version 2.0 installed on top! However you can keep bases of news, comments and guestbook. They can be translated in a new format later. To install the new version of the engine with old bases do the following:

  1. Install the engine as it is specified in 3.2 New installation
  2. Start a script cbase.pl, by typing its address in an address line of a browser. This script converts old bases in new SGEngine format.

If you have installed version 2.0 or above, it is necessary to do following steps:

  1. Make the backup of all files on a server to keep all the changes done by you
  2. Install the engine as it is specified in 3.2 New installation
  3. Replace all bases from earlier made backup. Consider that since version 2.1 the switching of languages is supported, and the location of all base files has changed!
  4. If you changed design of already existing templates all changes will not be kept and, most likely, it is necessary to apply them again. If you created your own template it will need to be compared with new one. The last concerns basically only modular templates.

3.2 New installation

  1. Unzip contents of archive on a disk.
  2. Keeping structure, transfer all folders and files from a directory "www" to a directory on your server where are HTML documents stored. Most likely, it will refer to - "www", but not always! The variation "public_html" is possible.
  3. Keeping structure, transfer all folders and files from a directory "cgi-bin" to a directory on your server where are CGI scripts stored. Probably, it will refer to "cgi".
  4. It is necessary to give the rights 0755 ("drwxr-xr-x") to all files-scripts having extension .pl, .pm. This could be realizing by your FTP-client in a file properties. But consider, that some hosting-providers require own script rights to run it.
  5. Transfer, keeping structure, all other folders and files in the root home directory on your server.
  6. Start the script setup.pl with a browser. The "Setup wizard" will help you to finish the installation in few steps.

3.3 End of installation

If all has passed successfully do not forget to remove scripts cbase.pl and setup.pl, or to move them to the directory, where anybody except for you cannot start them. If there were problems go to our forum.

4. Core system and the basic functions

SGEngine is written in programming language Perl, that basic and distinctive property is fast and flexible work with text files. Whole package consists of two types of documents:

  • scripts(.pl, .pm) - are executed on the server side files;
  • content(.html, .css, .js, .tmpl, .ini, .lng, .jpg, .gif è ò. ä.) - are files which are generated or processed by scripts;

Templates consist only from content files. Modules are scripts which use modular templates for a conclusion of the information.

4.1 Structure of files and folders

  • cgi-bin - root directory with scripts
    • mylib - directory with configurations files
      • menu - directory with menu language packages
        • *.lng - menu language packages
      • config.ini - main configurations file created by "Setup wizard"
      • config_default.ini - default configurations file
      • font.ttf - font file used by "Captcha" module
      • russian.lng - language package
      • Subs.pm - package with subroutines available for all modules
    • sources - directory with modules
      • admin - administrative modules
        • accessman.pl - access manager module
        • add_news.pl - news manager module
        • filemanager.pl - file manager module
        • blist.pl - ban-list / bad words module
        • dlcheck.pl - statistic and administrating of downloaded file module
        • gbadmin.pl - administrating of guestbook module
        • last_update.pl - last updating module
        • navigation.pl - navigating menu module
        • searchlog.pl - search logging module
      • archive_news.pl - archive news module
      • captcha.pl - "Captcha" module
      • comment.pl - news comments module
      • dl.pl - files download module
      • feedback.pl - feedback module
      • guestbook.pl - guestbook module
      • last_update.pl - last updating module
      • news.pl - news module
      • rss.pl - RSS - news feed module
      • sgsearch.pl - news searching module
      • txt.pl - output of HTML and text files module
      • view_news.pl - news viewing module
    • admin.pl - access to an administrative part of the website
    • index.pl - main script of the website
    • cbase.pl - script "Old bases converter"
    • setup.pl - script "Setup wizard"
  • close - closed directory for storage of passwords
    • .htpasswd - file storing a login/password pair for access to an administrative part of a website
    • administrators - file storing user logins for access to an administrative part of a website
    • maccess - file storing names of modules, which are forbidden for starting to moderators
  • log - directory with logs and bases
    • language - directory defining language of logs and bases
      • comments - comment bases
      • guestbook.bas - base with messages in the guestbook
      • l_update.log - log with last updating date
      • news.bas - news base
      • search.log - the cache of the news searching module
    • badwords.bas - list with the forbidden words in the guestbook and comments
    • banlist.bas - list with banned IP and nicknames for the guestbook and comments
    • captcha.log - the cache of the "Captcha" module
    • dl.log - downloaded files log
  • tmpl - directory with templates
    • silver - "Silver" template
    • dotted - "Dotted" template
      • *.html - template files which are responsible for its structure
      • accessman.tmpl - access manager module template
      • add_news.tmpl - news manager module template
      • blist.tmpl - ban list / bad words module template
      • blist_table.tmpl -ban list / bad words module template
      • comment.tmpl - news comments module template
      • dlcheck.tmpl - statistic and administrating of downloaded file module template
      • error.tmpl - output of a error or event template
      • feedback.tmpl - feedback module template
      • filemanager.tmpl - file manager module template
      • form.tmpl - forms template
      • guestbook.tmpl - guestbook module template
      • navigation.tmpl - navigating menu module template
      • rule.tmpl - template of the page rule
      • search_list.tmpl - news searching module template
      • searchlog.tmpl - search logging module template
      • view_news.tmpl - news viewing module template
  • text - root directory for text and HTML files used by engine
    • language - directory defining language of text and HTML files
  • www - root directory with HTML files, used by server
    • css - directory with Cascading Style Sheets
    • dload - directory with files downloaded from the server
    • img - directory with graphic files
    • js - directory with javascript-files
    • index.html - index file redirecting on the main script

4.2 Templates

Each template of SGEngine represents a set of text files written on html, and also a file of Cascading Style Sheets. Cascading Style Sheets file is in directory /www/css. Html files could be found in the subdirectory of /tmpl, having a unique name and being name of a template. They share on two groups:

  1. "structural" have extension .html - are templates responsible for structure of the website, define its general appearance and the content.
  2. "modular" have extension .tmpl - are templates used by modules.

Structural

These template files, except for standard html-tags, contain internal tags of engine, which allow substituting other files of the template on their place, to start on this place a module or to substitute a variable from the language package. If the substituted file of the template also has internal tags they will be processed too. By default it is allowed to have 10 enclosed levels, this number can be changed in the configurations file. In structural templates following internal tags are used:

<engine main{txt/file.html}> This tag specifies, that the dynamic part of the website will be deduced here, i.e. result of work of the modules called from an address line. In braces the name of the module which will be used by default with parameters is indicated. In this case the output of text and html files module is called and the file.html file is passed.
<engine run{module}> Instead of this tag the result of work of the module module will be inserted.
<engine tmpl{file.html}> Inserts content of the file.html file from a folder of an actual template.
<engine txt{file.html}> Inserts content of file.html file from directory with text and html files used by engine.
<engine print lng{xxx}>
<engine print conf{xxx}>
Inserts a line with a key "xxx" from the language package or the configurations file.
<engine print lng{copyrights}> Deduces "All rights reserved" text. It necessarily should be in a template.

Modular

These templates are used by modules and have extension .tmpl; their primary goal is to facilitate creation and editing of website design. With them it is not necessary each time to get into code of modules and try to discover html lines. Each module can use several templates and even to have the shared with others that besides saves time for correction. A modular template also as well as structural represents the text with html marking, into certain parts of which are variables of this module inserted. All these variables are described in the beginning of a modular template and look like: [%VARIABLE%]. The important areas of a template actively used by modules are marked out <!--AREA--><!--END:AREA-->.

Template setting

The website visitors can choose one of templates for permanent using. The template is set with the reference constructed as follows:

http://www.your_domain.zone/language/set_template/template

Where,

language - a kind of language (ru, en, de). This word is absolutely identical with the name of the directory, where dependent on language bases and logs are stored, and also the directory with text and HTML files;
template - a name of a template (dotted, silver), simultaneously being the name of the directory where files of a template are stored;

The name of this template is written in a cookie file which should be supported by browser. It enables each visitor to set the liked template and to see the website in that kind in which he find it most of all attracted.

4.3 Modules

Modules are the executed scripts written in programming language Perl. They give dynamic to a website working on SGEngine CMS. As a matter of fact, modules are not independent programs, it only a piece of the code which is called from the basic script index.pl. Therefore, to create a module it is necessary to know the following:

  1. A Module should begin with lines:
    use strict;
    use vars qw(%conf %lng @query $template);
    my $tmp = '';
    Where,
    %conf - global hash-array with configurations;
    %lng - global hash-array with lines of the language package;
    @query - global array with module parameters, passed through a URL;
    $template - global variable with a name of an actual template;
    $tmp - local variable for output of result.
  2. A module can contain any program code, including subroutines, a call of other modules, etc., except for a direct output in STDOUT. The direct output in STDOUT should be replaced with an output in a variable $tmp.
  3. A module should return a variable $tmp with the line:
    return $tmp;
  4. A module should be terminated, as it is necessary to any external subroutine in Perl, with the line:
    1;

Parameters can be passed to the module through the reference. For example:

http://www.your_domain.zone/language/module/param_1/param_2/.../param_n

Where,

language - a kind of language (ru, en, de). This word is absolutely identical with the name of the directory, where dependent on language bases and logs are stored, and also the directory with text and HTML files;
module - a module which will work at present;
param_1/param_2/.../param_n - parameters of this module;

4.4 Configurations file

The configurations file config.ini stores the basic CMS settings. It will be created by "Setup wizard" (setup.pl) during installation. This file consists of comments lines beginning with the sign # ignored by engine, and also the lines defining configurations variable. Such lines look like:

variable_name          variable_value

Furthermore in the configurations file work "aliases" which are designated %alias%. These are the variables certain earlier. For example:

path          /home/sgengine2
log_dir          %path%/log

In this case the variable log_dir will matter /home/sgengine2/log

4.5 Multilanguage support

The language package is constructed in a similar way as the configurations file see 4.4 Configurations file.

The website visitors have the possibility to choose, in what language contents of the website will be displayed. Language is set with the reference constructed as follows:

http://www.your_domain.zone/old_language/set_lng/new_language

Where,

old_language, new_language - a kind of language (ru, en, de). This word is absolutely identical with the name of the directory, where dependent on language bases and logs are stored, and also the directory with text and HTML files;

That to the chosen language be active in all parts of the website, it is necessary to fulfill the following conditions:

  1. There should be a corresponding language package /cgi-bin/mylib/ language.lng, and also menu language package /cgi-bin/mylib/menu/language.lng
  2. There should be all bases and logs in the directory /log/language see. 4.1 Structure of files and folders
  3. All text and HTML files should exist in the directory /txt/language see. 4.1 Structure of files and folders

However if the condition 2 and 3 are not fulfilled or fulfilled not completely, the website will work correctly and without errors! For example, you have decided to not post news in German then you do not put news base in the directory /log/de. During processing of files, the engine will not find German base and will use a file stored in the directory of the language specified by /log/ru. The same is valid for text and HTML files.

Important! Relative links inside of structural and modular templates should not contain a kind of language as the SGEngine itself substitutes it during processing. Usual html files can use this opportunity too. For example, referring to the module of the guestbook, it is enough to specify /guestbook.

4.5 Text and HTML files

SGEngine allows to output usual text and html files in the dynamic part of the website by means of the module 5.1 Output of text and HTML files, or through a corresponding internal tag <engine txt{file.html}>. Thus html files will be outputted according to html marking, and text files which should have necessarily extension .txt as is! In other words, if in a text file there is a paragraph, a space or line feed, on the website the paragraph, a space or line feed will be displayed.

4.7 Administration

For management of SGEngine the special administrative part of the website with own modules is provided. It is closed for the usual visitor by the password. Only following types of users have access to this area:

  • Administrator - has full access to all administrative modules;
  • Moderator - has the limited access to modules of an administrative part;

The administrator can add, delete moderators, downgrade or upgrade them, and also defines, which modules those have the right to start. Also the administrator sees all news posted on the website. To the moderator only those news are accessible, which it has added itself.

The administrative part should be necessarily protected by the password. Not authorized users have no access to this part of engine. For the organization of access please use the /cgi-bin/.htaccess file

5 Modules available in this package

SGEngine offer a solid package of already prepared modules which quite suffices for high-grade work of many websites. With each version of the engine, modules are updated and improve, their number grows constantly.

5.1 Public modules

This group of modules is accessible to all visitors of the website

News

This module outputs news in a blog form. The number of outputted news is adjusted in the configurations file. If a tag <!--cut--> will be found, the text after it will not be outputted, and the link "read next" will be deduced. It allows cutting off very long news and not "inflating" a blog.

News viewing

This module outputs the full text of news which unique number is passed by parameter. The tag <!--cut--> is ignored by this module.

News archive

This module outputs news in the form of more reduced blog. News is cut off on tags <!--cut--> and <br>. The page rule is deduced below. From this module all news are accessible.

News comments

This module outputs news completely and all comments to it. By means of the form, this module allows visitors to leave comments to news on the website. The form uses smiles which can be disabled by changing a corresponding variable in the configurations file. The module also writes IP-address of the author of each message. If the visitor will be found out in ban-list, he cannot write to the guestbook. If a forbidden word from the bad words list will be found in the message, it will not be sent.

Comments are protected by 5.1 Captcha - protection against spam-robots module.

RSS - news feed

This module outputs the news in format RSS. Requested URL looks as follows:

http://www.your_domain.zone/language/rss

Where,

language - a kind of language (ru, en, de) in which the news feed will be outputted. Condition - availability of the news base in a language folder;

Output of text and HTML files

This module allows to output text and html files. The path to a text file is passed by parameter. If the text file will not be found in a directory of language, which was chosen by the visitor, the module will output a file, which is stored in the directory of the language specified by default. Important! The passed path should not include the language directory itself! See also 4.5 Text and HTML files

Feedback form

Outputs the form which allows visitors of the website to send a e-mail on the address of the administrator specified in the configurations file. It is a reliable way to hide the e-mail address from the spam-robots.

Files download

This module allows visitors to download files from the website and thus to keep a log with number of downloading's. Thus the server directory where files are storing remains invisible for visitor and is defined in the configurations file. The reference to a file, for example archiv.zip, should look as follows:

/dl/archiv.zip

Last updating

Outputs last updating date which is being written by the adding news module in a separate log file.

Guestbook

The guestbook module allows website visitors to leave messages and wishes. Messages are outputted in a belt form with a pages rule. The number of messages pro page is defined in the configurations file. The module also writes IP-address of the author of each message. If the visitor will be found out in ban-list he cannot write to the guestbook. If a forbidden word from the bad words list will be found in the message, it will not be sent.

Guestbook is protected by 5.1 Captcha - protection against spam-robots module.

News searching

This module holds a search of words or phrase in news. The result is being given out in the comfortable and easily adjusted form. The basic features:

  • Search with use of logic: AND, OR, Phrase
  • "Star Mode" (for example if to set win*, than words beginning on "word" will be found, if *win, than words that ends on "word" will be found)
  • The comfortable form of the advanced search is outputted together with result, there is an opportunity to disable it.
  • The result is outputted either in the news blog form with the highlighted found words (the structure of news is completely kept, references, pictures, etc.), or like known search engines google.com, yandex.ru, with fragments from the text.
  • The Result is split into pages. Value by default - 5 results pro page.
  • Use of the cache that increases speed of search.

Captcha - protection against spam-robots

This module protects message send forms from spam-robots. The visitor get a picture, which containing a casual combination of letters and figures, which he should enter into a corresponding field of the form.

Navigating menu

The module processes a menu language package and outputs the navigating menu, according to the modular template. Menu can have two levels of an enclosure.

5.2 Administrative modules

This group of modules is accessible only to the administrators and moderators in an administrative part of the website.

News manager

This module allows posting recent news to the website, deleting or editing of existing. There is a preview of news function and a tools panel which include buttons to insert the html-tags, the form to URL adding and the form to uploading image files with next placing in news. For such files it is possible to automatically create thumbnails (presence of Perl libraries Image:: Magick or GD plus Image:: Size is necessary). The module determines, under what name the user has logged in, and take it as a name of the news author. After news will be added, the module clears the cache of the search module.

By means of this module it is also possible to manage comments of news. There is a possibility of editing, removal, putting of the author in the ban list, and also additions of comments on behalf of logged in user.

The administrator has access to all news of the website, and the moderator only to own. Also see. 4.7 Administration

File manager

This module outputs the structured list of files and directories on a server, allows to move on it and to make the basic actions: creation of new objects, renaming, removal, editing. There is also an opportunity of loading of any quantity of files on a server.

Administrating of guestbook

By means of this module the advanced administration control of the guestbook is managed. The administrator can leave answer to each message, or remove/correct the message. Together with records of the guestbook, IP address of the author is showed and there is a possibility to ban on it or by name.

Ban-list / Bad words

This module outputs the list of banned IP addresses and forbidden words. Extensive support by both lists: addition, editing, removal. At change of lists the additional analysis is tacked - existing words and addresses will not to be added repeatedly. There is an automatic determination of presence of several addresses at one subarea and the offer to add it all.
It is meaningful to put in the list of forbidden words the Internet addresses of websites, boosted by spammers, or, for example such words as "viagra".

Statistic and administrating of downloaded files

The Module outputs the list of files accessible to downloading, the general number of downloading's for every file, and also number of new downloading's from the moment of last user visiting. Allows zeroizing statistics or to remove a file from the list. The file himself will not be removed!

Search logging

Shows all the words saved in the cache of search in news. There is a possibility of manual cash clearing.

Access manager

This module allows administrator to add new users, to delete old, and also to change passwords. Besides there is a possibility to downgrade them to moderator or to upgrade to administrator.

The moderator can change own password by means of this module.

Also see 4.7 Administration

6. TO DO

It is planned in the future versions:

- New templates
- Voting module
- Menu editing module
- Files download module with display of downloading's number
- Your ideas are required!