Home « Server software «
Documentation: servers/servers.php
Class Servers - The database abstraction layer for servers
This script is a reference file of this system.
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
- Florent
delete() - Delete one server in the database
function delete($id)
- $id - the id of the server to delete
- returns an error message, if any
get() - Get one server by id
function &get($id)
- $id - int the id of the server, or its nick name
- returns the resulting $item array, with at least keys: 'id', 'title', etc.
get_banned_pattern() - List banned servers
function get_banned_pattern()
- returns a string to be used in
preg_match()
preg_match()
out of this list.Banned hosts and domains are manually put in the configuration file for servers, as a list of words separated by spaces or commas.
Following domains are always banned:
- mail.yahoo.com
- gmail.google.com
- www.laposte.net
Here is an example of usage:
// the url to check
$url = ...
// list banned servers
include_once '../servers/servers.php';
$banned_pattern = Servers::get_banned_pattern();
// skip banned hosts
if(preg_match($banned_pattern, $url))
continue;
This function will always return a valid pattern string, even if no configuration file has been saved.
Voir aussi:
get_by_url() - Get one server by url
function &get_by_url($url)
- $url - string one of the URLs related to this server
- returns the resulting $item array, with at least keys: 'id', 'title', etc.
get_url() - Get the url to view a server profile
function get_url($id, $action='view')
- $id - int the id of the server to view
- $action='view' - string the expected action ('view', 'edit', 'delete', ...)
- returns an anchor to the viewing script
servers/view.php?id=512
'),
which may be not processed correctly by search engines.
If the parameter 'with_friendly_urls
' has been set to 'Y
' in the configuration panel,
this function will return an URL parsable by search engines (e.g. 'servers/view.php/512
').Voir aussi:
list_by_date() - List newest servers
function &list_by_date($offset=0, $count=10, $variant='full')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=10 - int the number of items to display
- $variant='full' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
list_by_date_for_anchor() - List servers anchored to the given reference
function &list_by_date_for_anchor($anchor, $offset=0, $count=10, $variant='compact')
- $anchor - string the anchor for this server (e.g., 'category:123')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=10 - int the number of items to display
- $variant='compact' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $type, $icon)
Voir aussi:
list_for_feed() - List servers that will feed us
function &list_for_feed($offset=0, $count=10, $variant='feed')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=10 - int the number of items to display
- $variant='feed' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $type, $icon)
All entries are seeked, and the active field is not taken into account.
Voir aussi:
list_for_ping() - List servers to be pinged
function &list_for_ping($offset=0, $count=10, $variant='ping')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=10 - int the number of items to display
- $variant='ping' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $type, $icon)
All entries are seeked, and the active field is not taken into account.
Voir aussi:
list_for_search() - List servers to be searched
function &list_for_search($offset=0, $count=10, $variant='search')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=10 - int the number of items to display
- $variant='search' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $type, $icon)
All entries are seeked, and the active field is not taken into account.
Voir aussi:
list_selected() - List selected servers
function &list_selected(&$result, $layout='compact', $capability='?')
- &$result - resource result of database query
- $layout='compact' - string 'full', etc or object, i.e., an instance of Layout_Interface
- $capability='?' - string '?' or 'A', to support editors and to impersonate associates, where applicable
- returns NULL on error, else an ordered array with $url => array ($prefix, $label, $suffix, $type, $icon)
- 'compact' - to build short lists in boxes and sidebars (this is the default)
- 'full' - include every piece of information
- 'feed' - return an array of $id => array($feed_url, $label, $anchor, $stamp)
- 'ping' - return an array of $url => array($ping_url, $label)
- 'search' - return an array of $url => array($search_url, $label)
ping() - Create or update a server entry
function ping($title, $url)
- $title - string the title of the updated server
- $url - string the link to it
- returns string either a null string, or some text describing an error to be inserted into the html response
If the provided URL does not exist, a new server profile is created. Else the profile is updated only if ping is still allowed for this server profile.
Voir aussi:
post() - Post a new server or an updated server
function post($fields)
- $fields - array an array of fields
- returns string either a null string, or some text describing an error to be inserted into the html response
Voir aussi:
setup() - Create or alter tables for servers
function setup()
Voir aussi:
stamp() - Stamp one server profile
function stamp($id)
- $id -
$param int the id of the server to update
stat() - Get some statistics
function &stat()
- returns the resulting ($count, $min_date, $max_date) array