This is a search engine friendly CGI program that outputs help documents.
The LufDoc (Live User Fed Documentation) comment system will be implemented soon.

PSP Help Doc Indexer System

(Version 1.4.1)


PSP - Web Unit Reference

Introduction

Constants

Types

Procedures and Functions:

Tips and Tricks

Examples:

  • PSP_ROOT/src/examples/web_hello.pp
  • PSP_ROOT/src/examples/web_dump.pp
  • PSP_ROOT/src/examples/web_outtest.pp
  • PSP_ROOT/src/examples/web_sess.pp
  • PSP_ROOT/src/examples/web_trim.pp

Introduction

    Web is the main unit you need for web programming with PSP. It contains only those functions which are connected with CGI programming and attempts to provide about everything you need.

    Getting form data. To get data from HTML for you should use functions containing cgi in their name (e.g. web_get_cgi). CGI is Common Gateway Interface that is used to connect CGI scripts and the webserver. PSP calls "CGI variables" both GET and POST method variables. To learn about the exact request method calling your program you should get REQUEST_METHOD environment variable.

    Environment variables. Environment variables are usually set by webserver and sent to your CGI program. They help to learn about such things as server software, system paths, request headers and lots of useful information. env part in function name means that it operates on environment variables.

    Cookies. Cookies help you to save multisesion variables. You use them just as other PSP variables but phisically they are stored by user's browser. cookie part in function name means that it operates on cookies.

    Configuration variables. You can get and customize PSP configuration file options at run time with functions containing config in their name.

    Run Time Information (RTI). RTI is some important information PSP defines during run time. You can access it with functions containing rti in their names. Currently defined RTI variables are:
  • HEADERS_SENT - 'TRUE' if HTTP headers are already sent to server/browser, 'FALSE' if not.
  • ERRORS - this RTI variable couts number of errors occured during execution.
  • SESSION_REGISTERED - 'TRUE' if registered session is being used, 'FALSE' if not.
    Headers. You can customize HTTP headers of your CGI application output with functions containing header in their names. Ability of setting headers is avaiable until headers are sent (any time when output buffering is enabled, before any web_print[xxx] calls when output buffering is disabled).
    Sessions. Session variables are kept and used during one user session. Session life time can be customized in PSP configuration file. PSP operates on session variables same way as on other variables but with functions containing sess in their names.

    Custom variables. Custom variables are defined by you and used in templates or in your own needs. They have var part in their names. Exception is web_get_var which returns value of variable which can be also cgi, cookie, sess, etc.

    Output. PSP provides buffered and direct output depending on configuration file options. Unbuffered output is just the same as write/writeln calls, the difference is that PSP sends headers automatically and you should use functions which present in this unit only for output (no standard output function). Buffered output takes more memory but allows you to customize header, cookie and session data at any moment. It also makes output compression possible (GZIP output compression is available since PSP 1.4.1).

    PSP allows string and output formatting/templating in two ways. First is .NET-like with {0}, {1},.. {n} sequences in source string which are replaced with array elements they stand for. Second is Perl/PHP/PSP-style with $var_name and {$var_name} sequences which are replaced with value returned by web_get_var('var_name'). To protect your templates from Cross Site Scripting attacks you may either filter incomming data or enable automatic filtering in PSP configuration file.

Constants

Name Value Description
PSP_INI_PATH 'psp.conf' Configuration file name.
PSP_VERSION '1.4.1' PSP version.

Types

// Dynamic array of strings
StrArray = array of string;

Tips and Tricks

  • Exact web_get_xxx methods are a bit faster than abstract web_get_var.
  • Don't forget to filter all incomming data before using it in SQL queries or templates.
  • Use GZIP output_compression to save your brandwidth and download time. But remember that it slows your program down a little bit. The best way of compression your web contents is mod_gzip installed on Apache. But if you don't have it installed, use GZIP output_compression in PSP.

PSP Help documents