dolibarr 21.0.0-alpha
functions2.lib.php File Reference

A set of functions for Dolibarr This file contains all rare functions. More...

Go to the source code of this file.

Functions

 jsUnEscape ($source)
 Same function than javascript unescape() function but in PHP.
 
 dolGetModulesDirs ($subdir='')
 Return list of directories that contain modules.
 
 dol_getDefaultFormat (Translate $outputlangs=null)
 Try to guess default paper format according to language into $langs.
 
 dol_print_object_info ($object, $usetable=0)
 Show information on an object TODO Move this into html.formother.
 
 dolAddEmailTrackId ($email, $trackingid)
 Return an email formatted to include a tracking id For example myema.nosp@m.il@e.nosp@m.xampl.nosp@m.e.co.nosp@m.m becom myema.nosp@m.il+t.nosp@m.racki.nosp@m.ngid.nosp@m.@exam.nosp@m.ple..nosp@m.com.
 
 isValidMailDomain ($mail)
 Return true if email has a domain name that can be resolved to MX type.
 
 isValidUrl ($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
 Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].
 
 isValidVATID ($company)
 Check if VAT numero is valid (check done on syntax only, no database or remote access)
 
 clean_url ($url, $http=1)
 Clean an url string.
 
 dolObfuscateEmail ($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true)
 Returns an email value with obfuscated parts.
 
 array2tr ($data, $troptions='', $tdoptions='')
 Return lines of an html table from an array Used by array2table function only.
 
 array2table ($data, $tableMarkup=1, $tableoptions='', $troptions='', $tdoptions='')
 Return an html table from an array.
 
 get_next_value ($db, $mask, $table, $field, $where='', $objsoc='', $date='', $mode='next', $bentityon=true, $objuser=null, $forceentity=null)
 Return last or next value for a mask (according to area we should not reset)
 
 get_string_between ($string, $start, $end)
 Get string from "$start" up to "$end".
 
 check_value ($mask, $value)
 Check value.
 
 binhex ($bin, $pad=false, $upper=false)
 Convert a binary data to string that represent hexadecimal value.
 
 hexbin ($hexa)
 Convert an hexadecimal string into a binary string.
 
 numero_semaine ($time)
 Retourne le numero de la semaine par rapport a une date.
 
 weight_convert ($weight, &$from_unit, $to_unit)
 Convertit une masse d'une unite vers une autre unite.
 
 dol_set_user_param ($db, $conf, &$user, $tab)
 Save personal parameter.
 
 dol_print_reduction ($reduction, $langs)
 Returns formatted reduction.
 
 version_os ($option='')
 Return OS version.
 
 version_php ()
 Return PHP version.
 
 version_db ()
 Return DB version.
 
 version_dolibarr ()
 Return Dolibarr version.
 
 version_webserver ()
 Return web server version.
 
 getListOfModels ($db, $type, $maxfilenamelength=0)
 Return list of activated modules usable for document generation.
 
 is_ip ($ip)
 This function evaluates a string that should be a valid IPv4 Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patches of PHP (5.6.25).
 
 dol_buildlogin ($lastname, $firstname)
 Build a login from lastname, firstname.
 
 getSoapParams ()
 Return array to use for SoapClient constructor.
 
 dolGetElementUrl ($objectid, $objecttype, $withpicto=0, $option='')
 Return link url to an object.
 
 cleanCorruptedTree ($db, $tabletocleantree, $fieldfkparent)
 Clean corrupted tree (orphelins linked to a not existing parent), record linked to themself and child-parent loop.
 
 colorArrayToHex ($arraycolor, $colorifnotfound='888888')
 Convert an array with RGB value into hex RGB value.
 
 colorStringToArray ($stringcolor, $colorifnotfound=array(88, 88, 88))
 Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,255).
 
 colorValidateHex ($color, $allow_white=true)
 
 colorAgressiveness ($hex, $ratio=-50, $brightness=0)
 Change color to make it less aggressive (ratio is negative) or more aggressive (ratio is positive)
 
 colorAdjustBrightness ($hex, $steps)
 
 colorDarker ($hex, $percent)
 
 colorLighten ($hex, $percent)
 
 colorHexToRgb ($hex, $alpha=false, $returnArray=false)
 
 colorHexToHsl ($hex, $alpha=false, $returnArray=false)
 Color Hex to Hsl (used for style)
 
 cartesianArray (array $input)
 Applies the Cartesian product algorithm to an array Source: http://stackoverflow.com/a/15973172.
 
 getModuleDirForApiClass ($moduleobject)
 Get name of directory where the api_...class.php file is stored.
 
 randomColorPart ($min=0, $max=255)
 Return 2 hexa code randomly.
 
 randomColor ($min=0, $max=255)
 Return hexadecimal color randomly.
 
if(!function_exists( 'dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks ($notetoshow)
 Convert links to local wrapper to medias files into a string into a public external URL readable on internet.
 
 price2fec ($amount)
 Function to format a value into a defined format for French administration (no thousand separator & decimal separator force to ',' with two decimals) Function used into accountancy FEC export.
 
 phpSyntaxError ($code)
 Check the syntax of some PHP code.
 
 acceptLocalLinktoMedia ()
 Check the syntax of some PHP code.
 
 removeGlobalParenthesis ($string)
 Remove first and last parenthesis but only if first is the opening and last the closing of the same group.
 
 getArrayOfEmojiBis ()
 Return array of Emojis for miscellaneous use.
 
 removeEmoji ($text, $allowedemoji=1)
 Remove EMoji from email content.
 

Detailed Description

A set of functions for Dolibarr This file contains all rare functions.

Definition in file functions2.lib.php.

Function Documentation

◆ acceptLocalLinktoMedia()

acceptLocalLinktoMedia ( )

Check the syntax of some PHP code.

Returns
int >0 if OK, 0 if no Return if we accept link added from the media browser into HTML field for public usage

Definition at line 2900 of file functions2.lib.php.

References getDolGlobalInt().

◆ array2table()

array2table ( $data,
$tableMarkup = 1,
$tableoptions = '',
$troptions = '',
$tdoptions = '' )

Return an html table from an array.

Parameters
array$dataArray of data
int$tableMarkupTable markup
string$tableoptionsOptions for table
string$troptionsOptions for tr
string$tdoptionsOptions for td
Returns
string

Definition at line 866 of file functions2.lib.php.

References array2tr().

◆ array2tr()

array2tr ( $data,
$troptions = '',
$tdoptions = '' )

Return lines of an html table from an array Used by array2table function only.

Parameters
array$dataArray of data
string$troptionsOptions for tr
string$tdoptionsOptions for td
Returns
string

Definition at line 846 of file functions2.lib.php.

Referenced by array2table().

◆ binhex()

binhex ( $bin,
$pad = false,
$upper = false )

Convert a binary data to string that represent hexadecimal value.

Parameters
string$binValue to convert
boolean$padAdd 0
boolean$upperConvert to tupper
Returns
string x

Definition at line 1592 of file functions2.lib.php.

References dol_strlen().

◆ cartesianArray()

cartesianArray ( array $input)

Applies the Cartesian product algorithm to an array Source: http://stackoverflow.com/a/15973172.

Parameters
array$inputArray of products
Returns
array Array of combinations

Definition at line 2622 of file functions2.lib.php.

◆ check_value()

check_value ( $mask,
$value )

Check value.

Parameters
string$maskMask to use
string$valueValue
Returns
int|string Return integer <0 or error string if KO, 0 if OK

Definition at line 1468 of file functions2.lib.php.

References dol_string_nospecial(), dol_strlen(), and dol_syslog().

Referenced by mod_codeclient_elephant\verif(), mod_codeproduct_elephant\verif(), mod_barcode_product_standard\verif_syntax(), and mod_barcode_thirdparty_standard\verif_syntax().

◆ clean_url()

clean_url ( $url,
$http = 1 )

Clean an url string.

Parameters
string$urlUrl
integer$http1 = keep both http:// and https://, 0: remove http:// but not https://
Returns
string Cleaned url

Definition at line 759 of file functions2.lib.php.

Referenced by Adherent\update(), Link\update(), and Societe\update().

◆ cleanCorruptedTree()

cleanCorruptedTree ( $db,
$tabletocleantree,
$fieldfkparent )

Clean corrupted tree (orphelins linked to a not existing parent), record linked to themself and child-parent loop.

Parameters
DoliDB$dbDatabase handler
string$tabletocleantreeTable to clean
string$fieldfkparentField name that contains id of parent
Returns
int Nb of records fixed/deleted

Definition at line 2249 of file functions2.lib.php.

References dol_print_error().

◆ colorAdjustBrightness()

colorAdjustBrightness ( $hex,
$steps )
Parameters
string$hexColor in hex ('#AA1122' or 'AA1122' or '#a12' or 'a12')
integer$stepsStep/offset added to each color component. It should be between -255 and 255. Negative = darker, positive = lighter
Returns
string New color with format '#AA1122'
See also
colorAgressiveness()

Definition at line 2482 of file functions2.lib.php.

Referenced by colorDarker(), and colorLighten().

◆ colorAgressiveness()

colorAgressiveness ( $hex,
$ratio = -50,
$brightness = 0 )

Change color to make it less aggressive (ratio is negative) or more aggressive (ratio is positive)

Parameters
string$hexColor in hex ('#AA1122' or 'AA1122' or '#a12' or 'a12')
integer$ratioDefault=-50. Note: 0=Component color is unchanged, -100=Component color become 88, +100=Component color become 00 or FF
integer$brightnessDefault=0. Adjust brightness. -100=Decrease brightness by 100%, +100=Increase of 100%.
Returns
string New string of color
See also
colorAdjustBrightness()

Definition at line 2426 of file functions2.lib.php.

◆ colorArrayToHex()

colorArrayToHex ( $arraycolor,
$colorifnotfound = '888888' )

Convert an array with RGB value into hex RGB value.

This is the opposite function of colorStringToArray

Parameters
array$arraycolorArray
string$colorifnotfoundColor code to return if entry not defined or not a RGB format
Returns
string RGB hex value (without # before). For example: 'FF00FF', '01FF02'
See also
colorStringToArray(), colorHexToRgb()

Definition at line 2362 of file functions2.lib.php.

Referenced by FormSetupItem\generateInputFieldColor(), FormSetupItem\generateOutputFieldColor(), box_graph_nb_tickets_type\loadBox(), WebPortalTheme\loadPrimaryColor(), and showSkins().

◆ colorDarker()

colorDarker ( $hex,
$percent )
Parameters
string$hexcolor in hex
integer$percent0 to 100
Returns
string

Definition at line 2511 of file functions2.lib.php.

References colorAdjustBrightness().

◆ colorHexToHsl()

colorHexToHsl ( $hex,
$alpha = false,
$returnArray = false )

Color Hex to Hsl (used for style)

Parameters
string$hexColor in hex
float | false$alpha0 to 1 to add alpha channel
bool$returnArraytrue=return an array instead, false=return string
Returns
string|array String or array

Definition at line 2566 of file functions2.lib.php.

Referenced by WebPortalTheme\loadPrimaryColor().

◆ colorHexToRgb()

colorHexToRgb ( $hex,
$alpha = false,
$returnArray = false )
Parameters
string$hexcolor in hex
float | false$alpha0 to 1 to add alpha channel
bool$returnArraytrue=return an array instead, false=return string
Returns
string|array String or array

Definition at line 2535 of file functions2.lib.php.

◆ colorLighten()

colorLighten ( $hex,
$percent )
Parameters
string$hexcolor in hex
integer$percent0 to 100
Returns
string

Definition at line 2522 of file functions2.lib.php.

References colorAdjustBrightness().

◆ colorStringToArray()

colorStringToArray ( $stringcolor,
$colorifnotfound = array(88, 88, 88) )

Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,255).

This is the opposite function of colorArrayToHex. If entry is already an array, return it.

Parameters
string$stringcolorString with hex (FFFFFF) or comma RGB ('255,255,255')
array$colorifnotfoundColor code array to return if entry not defined
Returns
array RGB hex value (without # before). For example: FF00FF
See also
colorArrayToHex(), colorHexToRgb()

Definition at line 2383 of file functions2.lib.php.

Referenced by FormSetupItem\generateInputFieldColor(), FormSetupItem\generateOutputFieldColor(), WebPortalTheme\loadPrimaryColor(), and showSkins().

◆ colorValidateHex()

colorValidateHex ( $color,
$allow_white = true )
Parameters
string$colorthe color you need to valid
boolean$allow_whitein case of white isn't valid
Returns
boolean

Definition at line 2405 of file functions2.lib.php.

Referenced by WebPortalTheme\loadPrimaryColor().

◆ convertBackOfficeMediasLinksToPublicLinks()

◆ dol_buildlogin()

dol_buildlogin ( $lastname,
$firstname )

Build a login from lastname, firstname.

Parameters
string$lastnameLastname
string$firstnameFirstname
Returns
string Login

Definition at line 2012 of file functions2.lib.php.

References dol_string_nospecial(), dol_string_unaccent(), dol_trunc(), and getDolGlobalString().

Referenced by ActionsAdherentCardCommon\assign_values(), ActionsContactCardCommon\assign_values(), User\create_from_contact(), and User\create_from_member().

◆ dol_getDefaultFormat()

dol_getDefaultFormat ( Translate $outputlangs = null)

Try to guess default paper format according to language into $langs.

Parameters
Translate | null$outputlangsOutput lang to use to autodetect output format if setup not done
Returns
string Default paper format code

Definition at line 123 of file functions2.lib.php.

Referenced by pdf_getFormat().

◆ dol_print_object_info()

dol_print_object_info ( $object,
$usetable = 0 )

Show information on an object TODO Move this into html.formother.

Parameters
object$objectObject to show
int$usetableOutput into a table
Returns
void

Definition at line 150 of file functions2.lib.php.

References $object, dol_print_date(), and getServerTimeZoneInt().

◆ dol_print_reduction()

dol_print_reduction ( $reduction,
$langs )

Returns formatted reduction.

Parameters
int$reductionReduction percentage
Translate$langsOutput language
Returns
string Formatted reduction

Definition at line 1810 of file functions2.lib.php.

References vatrate().

Referenced by pdf_getlineremisepercent().

◆ dol_set_user_param()

dol_set_user_param ( $db,
$conf,
& $user,
$tab )

Save personal parameter.

Parameters
DoliDB$dbHandler database
Conf$confObject conf
User$userObject user
array$tabArray (key=>value) with all parameters to save/update
Returns
int Return integer <0 if KO, >0 if OK
See also
dolibarr_get_const(), dolibarr_set_const(), dolibarr_del_const()

Definition at line 1746 of file functions2.lib.php.

References dol_print_error(), and dol_syslog().

Referenced by InfoBox\saveboxorder().

◆ dolAddEmailTrackId()

dolAddEmailTrackId ( $email,
$trackingid )

Return an email formatted to include a tracking id For example myema.nosp@m.il@e.nosp@m.xampl.nosp@m.e.co.nosp@m.m becom myema.nosp@m.il+t.nosp@m.racki.nosp@m.ngid.nosp@m.@exam.nosp@m.ple..nosp@m.com.

Parameters
string$emailEmail address (Ex: "toto@example.com", "John Do <johndo@example.com>")
string$trackingidTracking id (Ex: thi123 for thirdparty with id 123)
Returns
string Return email tracker string

Definition at line 651 of file functions2.lib.php.

◆ dolGetElementUrl()

dolGetElementUrl ( $objectid,
$objecttype,
$withpicto = 0,
$option = '' )

Return link url to an object.

Parameters
int$objectidId of record
string$objecttypeType of object ('invoice', 'order', 'expedition_bon', 'myobject@mymodule', ...)
int$withpictoPicto to show
string$optionMore options
Returns
string URL of link to object id/type

Definition at line 2089 of file functions2.lib.php.

References $object, dol_include_once(), and dol_syslog().

Referenced by show_actions_done().

◆ dolGetModulesDirs()

dolGetModulesDirs ( $subdir = '')

Return list of directories that contain modules.

Detects directories that contain a subdirectory /core/modules. Modules that contains 'disabled' in their name are excluded.

Parameters
string$subdirSub directory (Example: '/mailings' will look for /core/modules/mailings/)
Returns
array<string,string> Array of directories that can contain module descriptors ($key==value)

Definition at line 84 of file functions2.lib.php.

Referenced by activateModule(), activateModulesRequiredByCountry(), complete_dictionary_with_modules(), complete_elementList_with_modules(), Export\load_arrays(), Import\load_arrays(), and unActivateModule().

◆ dolObfuscateEmail()

dolObfuscateEmail ( $mail,
$replace = "*",
$nbreplace = 8,
$nbdisplaymail = 4,
$nbdisplaydomain = 3,
$displaytld = true )

Returns an email value with obfuscated parts.

Parameters
string$mailEmail
string$replaceReplacement character (default: *)
int$nbreplaceNumber of replacement character (default: 8)
int$nbdisplaymailNumber of character unchanged (default: 4)
int$nbdisplaydomainNumber of character unchanged of domain (default: 3)
bool$displaytldDisplay tld (default: true)
Returns
string Return email with hidden parts or '';

Definition at line 804 of file functions2.lib.php.

References isValidEmail().

◆ get_next_value()

get_next_value ( $db,
$mask,
$table,
$field,
$where = '',
$objsoc = '',
$date = '',
$mode = 'next',
$bentityon = true,
$objuser = null,
$forceentity = null )

Return last or next value for a mask (according to area we should not reset)

Parameters
DoliDB$dbDatabase handler
string$maskMask to use. Must contains {0...0}. Can contains {t..}, {u...}, {user_extra_xxx}, .;.
string$tableTable containing field with counter
string$fieldField containing already used values of counter
string$whereTo add a filter on selection (for example to filter on invoice types)
Societe|''$objsoc The company that own the object we need a counter for
string$dateDate to use for the {y},{m},{d} tags.
string$mode'next' for next value or 'last' for last value
bool$bentityonActivate the entity filter. Default is true (for modules not compatible with multicompany)
User$objuserObject user we need data from.
int$forceentityEntity id to force
Returns
string New value (numeric) or error message

Definition at line 904 of file functions2.lib.php.

References dol_mktime(), dol_now(), dol_print_error(), dol_string_nospecial(), dol_string_unaccent(), dol_strlen(), dol_substr(), dol_syslog(), get_string_between(), getDolGlobalInt(), and getDolGlobalString().

Referenced by mod_arctic\getNextValue(), mod_asset_advanced\getNextValue(), mod_barcode_product_standard\getNextValue(), mod_barcode_thirdparty_standard\getNextValue(), mod_bom_advanced\getNextValue(), mod_chequereceipt_thyme\getNextValue(), mod_codeclient_elephant\getNextValue(), mod_codeproduct_elephant\getNextValue(), mod_commande_fournisseur_orchidee\getNextValue(), mod_commande_saphir\getNextValue(), mod_contract_magre\getNextValue(), mod_delivery_saphir\getNextValue(), mod_evaluation_advanced\getNextValue(), mod_expedition_ribera\getNextValue(), mod_expensereport_sand\getNextValue(), mod_facture_fournisseur_tulip\getNextValue(), mod_facture_mercure\getNextValue(), mod_holiday_immaculate\getNextValue(), mod_knowledgerecord_advanced\getNextValue(), mod_lot_advanced\getNextValue(), mod_mo_advanced\getNextValue(), mod_myobject_advanced\getNextValue(), mod_partnership_advanced\getNextValue(), mod_payment_ant\getNextValue(), mod_project_universal\getNextValue(), mod_propale_saphir\getNextValue(), mod_reception_moonstone\getNextValue(), mod_recruitmentcandidature_advanced\getNextValue(), mod_recruitmentjobposition_advanced\getNextValue(), mod_sn_advanced\getNextValue(), mod_stocktransfer_advanced\getNextValue(), mod_supplier_payment_brodator\getNextValue(), mod_supplier_proposal_saphir\getNextValue(), mod_takepos_ref_universal\getNextValue(), mod_task_universal\getNextValue(), mod_ticket_universal\getNextValue(), and mod_workstation_advanced\getNextValue().

◆ get_string_between()

get_string_between ( $string,
$start,
$end )

Get string from "$start" up to "$end".

If string is "STARTcontentEND" and $start is "START" and $end is "END", then this function returns "content"

Parameters
string$stringString to test
string$startString Value for start
string$endString Value for end
Returns
string Return part of string

Definition at line 1447 of file functions2.lib.php.

Referenced by get_next_value().

◆ getArrayOfEmojiBis()

getArrayOfEmojiBis ( )

Return array of Emojis for miscellaneous use.

Returns
array<string,array<string>> Array of Emojis in hexadecimal
See also
getArrayOfEmoji()

Definition at line 2995 of file functions2.lib.php.

Referenced by removeEmoji().

◆ getListOfModels()

getListOfModels ( $db,
$type,
$maxfilenamelength = 0 )

Return list of activated modules usable for document generation.

Parameters
DoliDB$dbDatabase handler
string$typeType of models (company, invoice, ...)
int$maxfilenamelengthMax length of value to show
Returns
array|int 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename".

Definition at line 1893 of file functions2.lib.php.

References dol_dir_list(), dol_print_error(), dol_syslog(), dol_trunc(), and getDolGlobalString().

Referenced by ModeleAction\liste_modeles(), ModeleBankAccountDoc\liste_modeles(), ModeleChequeReceipts\liste_modeles(), ModeleDon\liste_modeles(), ModeleExpenseReport\liste_modeles(), ModelePDFAsset\liste_modeles(), ModelePDFBom\liste_modeles(), ModelePDFCards\liste_modeles(), ModelePDFCommandes\liste_modeles(), ModelePDFContract\liste_modeles(), ModelePDFDeliveryOrder\liste_modeles(), ModelePDFEvaluation\liste_modeles(), ModelePdfExpedition\liste_modeles(), ModelePDFFactures\liste_modeles(), ModelePDFFicheinter\liste_modeles(), ModelePDFHoliday\liste_modeles(), ModelePDFKnowledgeRecord\liste_modeles(), ModelePDFLabels\liste_modeles(), ModelePDFMember\liste_modeles(), ModelePDFMo\liste_modeles(), ModelePDFMovement\liste_modeles(), ModelePDFMyObject\liste_modeles(), ModelePDFPartnership\liste_modeles(), ModelePDFProduct\liste_modeles(), ModelePDFProductBatch\liste_modeles(), ModelePDFProjects\liste_modeles(), ModelePDFPropales\liste_modeles(), ModelePdfReception\liste_modeles(), ModelePDFRecruitmentCandidature\liste_modeles(), ModelePDFRecruitmentJobPosition\liste_modeles(), ModelePDFStock\liste_modeles(), ModelePDFStockTransfer\liste_modeles(), ModelePDFSupplierProposal\liste_modeles(), ModelePDFSuppliersInvoices\liste_modeles(), ModelePDFSuppliersOrders\liste_modeles(), ModelePDFSuppliersPayments\liste_modeles(), ModelePDFTask\liste_modeles(), ModelePDFTicket\liste_modeles(), ModelePDFUser\liste_modeles(), ModelePDFUserGroup\liste_modeles(), ModelePDFWorkstation\liste_modeles(), and ModeleThirdPartyDoc\liste_modeles().

◆ getModuleDirForApiClass()

getModuleDirForApiClass ( $moduleobject)

Get name of directory where the api_...class.php file is stored.

Parameters
string$moduleobjectModule object name
Returns
string Directory name

Definition at line 2652 of file functions2.lib.php.

◆ getSoapParams()

getSoapParams ( )

Return array to use for SoapClient constructor.

Returns
array

Definition at line 2042 of file functions2.lib.php.

References getDolGlobalString().

◆ hexbin()

hexbin ( $hexa)

Convert an hexadecimal string into a binary string.

Parameters
string$hexaHexadecimal string to convert (example: 'FF')
Returns
string bin

Definition at line 1617 of file functions2.lib.php.

References dol_strlen().

◆ is_ip()

is_ip ( $ip)

This function evaluates a string that should be a valid IPv4 Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patches of PHP (5.6.25).

See https://github.com/php/php-src/pull/1954.

Parameters
string$ipIP Address
Returns
int 0 if not valid or reserved range, 1 if valid and public IP, 2 if valid and private range IP

Definition at line 1985 of file functions2.lib.php.

Referenced by SMTPs\_server_connect().

◆ isValidMailDomain()

isValidMailDomain ( $mail)

Return true if email has a domain name that can be resolved to MX type.

Parameters
string$mailEmail address (Ex: "toto@example.com", "John Do <johndo@example.com>")
Returns
int -1 if error (function not available), 0=Not valid, 1=Valid

Definition at line 663 of file functions2.lib.php.

References isValidMXRecord().

◆ isValidUrl()

isValidUrl ( $url,
$http = 0,
$pass = 0,
$port = 0,
$path = 0,
$query = 0,
$anchor = 0 )

Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].

Parameters
string$urlUrl
int$http1: verify http is provided, 0: not verify http
int$pass1: verify user and pass is provided, 0: not verify user and pass
int$port1: verify port is provided, 0: not verify port
int$path1: verify a path is provided "/" or "/..." or "/.../", 0: not verify path
int$query1: verify query is provided, 0: not verify query
int$anchor1: verify anchor is provided, 0: not verify anchor
Returns
int 1=Check is OK, 0=Check is KO

Definition at line 682 of file functions2.lib.php.

◆ isValidVATID()

isValidVATID ( $company)

Check if VAT numero is valid (check done on syntax only, no database or remote access)

Parameters
Societe$companyVAT number
Returns
int 1=Check is OK, 0=Check is KO

Definition at line 735 of file functions2.lib.php.

◆ jsUnEscape()

jsUnEscape ( $source)

Same function than javascript unescape() function but in PHP.

Parameters
string$sourceString to decode
Returns
string Unescaped string

Definition at line 42 of file functions2.lib.php.

References dol_html_entity_decode().

◆ numero_semaine()

numero_semaine ( $time)

Retourne le numero de la semaine par rapport a une date.

Parameters
string$timeDate au format 'timestamp'
Returns
string Number of week

Definition at line 1633 of file functions2.lib.php.

References dol_print_date().

◆ phpSyntaxError()

phpSyntaxError ( $code)

Check the syntax of some PHP code.

Parameters
string$codePHP code to check.
Returns
boolean|array If false, then check was successful, otherwise an array(message,line) of errors is returned.

Definition at line 2805 of file functions2.lib.php.

◆ price2fec()

price2fec ( $amount)

Function to format a value into a defined format for French administration (no thousand separator & decimal separator force to ',' with two decimals) Function used into accountancy FEC export.

Parameters
float$amountAmount to format
Returns
string Chain with formatted upright
See also
price2num() Format a numeric into a price for FEC files

Definition at line 2776 of file functions2.lib.php.

References getDolGlobalString().

Referenced by AccountancyExport\exportCegid(), AccountancyExport\exportCiel(), AccountancyExport\exportFEC(), and AccountancyExport\exportFEC2().

◆ randomColor()

randomColor ( $min = 0,
$max = 255 )

Return hexadecimal color randomly.

Parameters
int$minBetween 0 and 255
int$maxBetween 0 and 255
Returns
string A color string '123456'

Encode string for xml usage

Parameters
string$stringString to encode
Returns
string String encoded

Definition at line 2731 of file functions2.lib.php.

References randomColorPart().

◆ randomColorPart()

randomColorPart ( $min = 0,
$max = 255 )

Return 2 hexa code randomly.

Parameters
int$minBetween 0 and 255
int$maxBetween 0 and 255
Returns
string A color string '12'

Definition at line 2719 of file functions2.lib.php.

Referenced by randomColor().

◆ removeEmoji()

removeEmoji ( $text,
$allowedemoji = 1 )

Remove EMoji from email content.

Parameters
string$textString to sanitize
int$allowedemojiMode to allow emoji
Returns
string Sanitized string

Definition at line 3019 of file functions2.lib.php.

References getArrayOfEmojiBis().

◆ removeGlobalParenthesis()

removeGlobalParenthesis ( $string)

Remove first and last parenthesis but only if first is the opening and last the closing of the same group.

Parameters
string$stringString to sanitize
Returns
string String without global parenthesis

Definition at line 2955 of file functions2.lib.php.

References dol_strlen(), and dol_substr().

Referenced by Form\searchComponent().

◆ version_db()

version_db ( )

Return DB version.

Returns
string PHP version

Definition at line 1855 of file functions2.lib.php.

◆ version_dolibarr()

version_dolibarr ( )

Return Dolibarr version.

Returns
string Dolibarr version
See also
versiondolibarrarray(), versioncompare()

Definition at line 1870 of file functions2.lib.php.

Referenced by getVersions().

◆ version_os()

version_os ( $option = '')

Return OS version.

Note that PHP_OS returns only OS (not version) and OS PHP was built on, not necessarily OS PHP runs on.

Parameters
string$optionOption string
Returns
string OS version

Definition at line 1829 of file functions2.lib.php.

Referenced by getVersions().

◆ version_php()

version_php ( )

Return PHP version.

Returns
string PHP version
See also
versionphparray(), versioncompare()

Definition at line 1845 of file functions2.lib.php.

Referenced by getVersions().

◆ version_webserver()

version_webserver ( )

Return web server version.

Returns
string Web server version

Definition at line 1880 of file functions2.lib.php.

Referenced by getVersions().

◆ weight_convert()

weight_convert ( $weight,
& $from_unit,
$to_unit )

Convertit une masse d'une unite vers une autre unite.

Parameters
float$weightMasse a convertir
int$from_unitUnite originale en puissance de 10
int$to_unitNouvelle unite en puissance de 10
Returns
float Masse convertie

Definition at line 1711 of file functions2.lib.php.

References weight_convert().

Referenced by weight_convert().