Skip to main content Help Control Panel

Aubagne HipHop

Tout le Hip Hop d'Aubagne et des alentours

Home «   Server software «  

Documentation: shared/surfer.php

Class Surfer - What we know about the current surfer

This module uses cookies to control user login, logout, and access to protected resources.

When users enter this server and sign on, their related profile is saved into session data. This module is able to change and retrieve these data.

The security model is quite simple. The community as defined by this system is made of:

YACS saves the address of the surfer host, as reported by the network sub-system, in session data. This address is checked on each capability check (eg, Surfer::is_logged()) to prevent risks related to cookie steal.

During the login process the root path (e.g., /yacs/) is saved in session data. This session attribute is checked afterwards to evaluate actual surfer capability. Therefore, even if several YACS instances are installed at the same host, cross-authentication is blocked. For example, if you have two separate installations at /yacs/ and at /yacs_demo/, users authenticating as associates at the demo site would not be considered as being associates at the main instance.

On load, and if the surfer is not an associate, this script will strip any HTML tag from the $_REQUEST array. Note that special HTML characters encoded as Unicode numerical entities are correctly unmasked, to prevent related code injections. (Thanks to Mordread on this).

This script is a reference file of this system.

Licence: GNU Lesser General Public License

Auteurs:

Testeurs:

Reste à faire:

assigned_sections() - List sections assigned to this surfer

function assigned_sections($id=NULL, $maximum=21)

If a member is acting as a managing editor for some sections, this function returns ids of these sections.

For subscribers, this function will return the list of accessible sections.

build_user_menu() - Build the navigation menu for this surfer

function build_user_menu($type = 'submenu')

This function has to be called from the template, once the skin has been loaded.

Voir aussi:

check_default_editor() - Set default attributes for this surfer

function check_default_editor($fields)

This function is called before writing records in the database, to ensure attributes 'edit_name', 'edit_id', 'edit_address' and 'edit_date' have been properly set.

Voir aussi:

from_GMT() - Adjust a time stamp to surfer time zone

function &from_GMT($stamp)

get_capability() - Get the capability of the current surfer, if known

function get_capability()

get_editor() - Get the preferred editor

function get_editor($name='description', $value='')

Provides XHTML snippet to invoke one of the available editors, based on user preference.

Curently YACS supports following choices:

Voir aussi:

get_email_address() - Get the e-mail address of the current surfer, if known

function get_email_address()

get_gmt_offset() - Get offset to GMT

function get_gmt_offset()



Voir aussi:

get_handle() - Get the handle of a managed page

function get_handle()

When an anonymous surfer provides the handle of a page, this is recorded in session data. This functions allows to retrieve this handle and then, to identify which resource the surfer may interact with.

get_id() - Get the id of the current surfer, if known

function get_id()

get_name() - Get the name of the current surfer, if known

function get_name()

This function will remove mention of originating server for shadow records.

get_robot_stopper() - Ask surfer to replicate random data

function get_robot_stopper()

This function complements a web form to stop anonymous robots.

If the global parameter 'users_without_robot_check' is set to 'Y', or if the surfer has been authenticated, this function returns NULL.

In every other cases, the function returns an array to be inserted in current form

Example of usage:
if($field Surfer::get_robot_stopper())
    
$fields[] = $field;


Data submitted through the form can be checked using function Surfer::may_be_a_robot().

is_associate() - Is the current user an associate?

function is_associate($capability='?')

The additional parameter allows for user empowerment on a per-transaction basis.

is_crawler() - Is the surfer a software robot?

function is_crawler()

is_creator() - Is the current surfer the creator of one item?

function is_creator($id)

To control that a surfer is the actual creator of one article, following code may be used:
// load the article from the database, including the editors list
$item =& Articles::get($id);

// check that the current surfer is a valid editor
include '../shared/surfer.php';
if(
Surfer::is_creator($item['create_id']) {
  ...
}


is_editor() - Is the current surfer part of the editors list?

function is_editor($editors)

This function seeks the list to locate the id of the current surfer. The list is made of user ids separated by space or comma characters.

Members are allowed to alter the part of the server they are in charge of. For example, one associate can create a section or an article and designate some members as valid editors for this item. This is done explicitly by altering the 'editors' field in the related table.

To control that a surfer is a valid editor for one article, following code may be used:
// load the article from the database, including the editors list
$item =& Articles::get($id);

// check that the current surfer is a valid editor
include '../shared/surfer.php';
if(
Surfer::is_editor($item['editors']) {
  ...
}


is_logged() - Has the current surfer been authenticated?

function is_logged()

is_member() - Is the current user a member?

function is_member($capability='?')

The additional parameter allows for user empowerment on a per-transaction basis.

may_be_a_robot() - Check salt and pepper

function may_be_a_robot()

This function helps to stop robots, by checking outcome of user challenge.

It has to be used in cuonjonction with Surfer::get_robot_stopper().

may_handle() - Back door to some resource

function may_handle($handle='', $item, $poster)

This function checks the provided handle against the secret one, and either authenticate the surfer as resource poster, or only restore poster data in surfer session.

may_upload() - Check upload capability

function may_upload()

This function checks surfer overall capability against the parameter users_without_uploads set in the configuration panel for users.

Voir aussi:

reset() - Kill the current session

function reset()

Voir aussi:

set() - Save user information as session data

function set($fields, $offset=0)

This function copies user attributes in session storage area.

Following named attributes from the provided array are copied in session storage area:

We also remember the IP address of the authenticating workstation, and the root path of the instance that has validated the surfer.

track() - Remember surfer data

function track($fields)

This function is used to track anonymous surfers.

Following named attributes from the provided array are copied in session storage area:

strip_tags() - Strip all HTML tags

function strip_tags($input, $allowed_tags='')



Voir aussi:

to_GMT() - Adjust a time stamp to GMT

function &to_GMT($stamp)

Tools
Browse the source of this script
Server software