dolibarr  7.0.0-beta
Functions
security.lib.php File Reference

Set of function used for dolibarr security (common function included into filefunc.inc.php) Warning, this file must not depends on other library files, except function.lib.php because it is used at low code level. More...

Go to the source code of this file.

Functions

 dol_encode ($chain)
 Encode a string with base 64 algorithm + specific change Code of this function is useless and we should use base64_encode only instead. More...
 
 dol_decode ($chain)
 Decode a base 64 encoded + specific string. More...
 
 dol_hash ($chain, $type='0')
 Returns a hash of a string. More...
 
 restrictedArea ($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
 Check permissions of a user to show a page and an object. More...
 
 checkUserAccessToObject ($user, $featuresarray, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='', $dbt_select='rowid')
 Check access by user to object. More...
 
 accessforbidden ($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
 Show a message to say access is forbidden and stop program Calling this function terminate execution of PHP. More...
 

Detailed Description

Set of function used for dolibarr security (common function included into filefunc.inc.php) Warning, this file must not depends on other library files, except function.lib.php because it is used at low code level.

Definition in file security.lib.php.

Function Documentation

accessforbidden (   $message = '',
  $printheader = 1,
  $printfooter = 1,
  $showonlymessage = 0 
)

Show a message to say access is forbidden and stop program Calling this function terminate execution of PHP.

Parameters
string$messageForce error message
int$printheaderShow header before
int$printfooterShow footer after
int$showonlymessageShow only message parameter. Otherwise add more information.
Returns
void

Definition at line 573 of file security.lib.php.

References llxFooter(), llxHeader(), llxHeaderVierge(), and print.

Referenced by restrictedArea().

checkUserAccessToObject (   $user,
  $featuresarray,
  $objectid = 0,
  $tableandshare = '',
  $feature2 = '',
  $dbt_keyfield = '',
  $dbt_select = 'rowid' 
)

Check access by user to object.

This function is also called by restrictedArea

Parameters
User$userUser to check
array$featuresarrayFeatures/modules to check. Example: ('user','service','member','project','task',...)
int | string$objectidObject ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
string$tableandshare'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional).
string$feature2Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
string$dbt_keyfieldField name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
string$dbt_selectField name for select if not rowid. Not used if objectid is null (optional)
Returns
bool True if user has access, False otherwise
See also
restrictedArea

Definition at line 368 of file security.lib.php.

References $resql, and dol_print_error().

Referenced by DolibarrApi\_checkAccessToResource(), and restrictedArea().

dol_decode (   $chain)

Decode a base 64 encoded + specific string.

This function is called by filefunc.inc.php at each page call. Code of this function is useless and we should use base64_decode only instead

Parameters
string$chainstring to decode
Returns
string decoded string

Definition at line 56 of file security.lib.php.

References dol_strlen().

Referenced by encodedecode_dbpassconf().

dol_encode (   $chain)

Encode a string with base 64 algorithm + specific change Code of this function is useless and we should use base64_encode only instead.

Parameters
string$chainstring to encode
Returns
string encoded string

Definition at line 36 of file security.lib.php.

References dol_strlen().

Referenced by encodedecode_dbpassconf().

dol_hash (   $chain,
  $type = '0' 
)

Returns a hash of a string.

If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function. If constant MAIN_SECURITY_SALT is defined, we use it as a salt.

Parameters
string$chainString to hash
string$typeType of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'.
Returns
string Hash of string

Definition at line 80 of file security.lib.php.

Referenced by Adherent\_load_ldap_info(), User\_load_ldap_info(), MailmanSpip\add_to_spip(), MailingTargets\add_to_target(), check_user_password_dolibarr(), BlockedLog\checkSignature(), EcmFiles\create(), BlockedLog\create(), CMailFile\findHtmlImages(), getPaypalPaymentUrl(), BlockedLog\getSignature(), Login\index(), RssParser\parser(), User\send_password(), SMTPs\setAttachment(), SMTPs\setBodyContent(), SMTPs\setImageInline(), Adherent\setPassword(), User\setPassword(), and Form\showphoto().

restrictedArea (   $user,
  $features,
  $objectid = 0,
  $tableandshare = '',
  $feature2 = '',
  $dbt_keyfield = 'fk_soc',
  $dbt_select = 'rowid',
  $objcanvas = null 
)

Check permissions of a user to show a page and an object.

Check read permission. If GETPOST('action','aZ09') defined, we also check write and delete permission.

Parameters
User$userUser to check
string$featuresFeatures to check (it must be module name. Examples: 'societe', 'contact', 'produit&service', 'produit|service', ...)
int$objectidObject ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
string$tableandshare'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional).
string$feature2Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
string$dbt_keyfieldField name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
string$dbt_selectField name for select if not rowid. Not used if objectid is null (optional)
Canvas$objcanvasObject canvas
Returns
int Always 1, die process if not allowed
See also
dol_check_secure_access_document

Definition at line 115 of file security.lib.php.

References accessforbidden(), checkUserAccessToObject(), and GETPOST().