tce_functions_general.php

tce_functions_general.php source file reference

Package: com\tecnick\tcexam\shared

Tags

  • file: General functions.
  • author: Nicola Asuni
  • since: 2001-09-08

Functions

F_count_rows()

File: tce_functions_general.php line 29

F_count_rows(mixed $dbtable[, mixed $where = '' ]) : number

Parameters

  • $dbtable : mixed: (string) database table name
  • $where : mixed = ‘’: (string) optional where SQL clause (including the WHERE keyword).

Return values

number —

of rows

F_empty_to_null()

File: tce_functions_general.php line 52

F_empty_to_null(mixed $str) : string

Parameters

  • $str : mixed: (string) string to check.

Return values

string —

$str quoted if not empty, NULL otherwise

F_zero_to_null()

File: tce_functions_general.php line 69

F_zero_to_null(mixed $num) : string

Parameters

  • $num : mixed: (string) string to check.

Return values

string —

$num if != 0, NULL otherwise

F_getBoolean()

File: tce_functions_general.php line 86

F_getBoolean(mixed $str) : bool

Parameters

  • $str : mixed: (string) string to check.

Return values

bool —

value.

F_check_unique()

File: tce_functions_general.php line 107

F_check_unique(mixed $table, mixed $where[, mixed $fieldname = false ][, mixed $fieldid = false ]) : bool

Parameters

  • $table : mixed: (string) table name
  • $where : mixed: (string) SQL where clause
  • $fieldname : mixed = false: (mixed) name of table column to check
  • $fieldid : mixed = false: (mixed) ID of table row to check

Return values

bool —

true if unique, false otherwise

unhtmlentities()

File: tce_functions_general.php line 139

unhtmlentities(mixed $text_to_convert[, mixed $preserve_tagsign = false ]) : converted

Parameters

  • $text_to_convert : mixed: (string) input string to convert
  • $preserve_tagsign : mixed = false: (boolean) if true preserve <> symbols, default=FALSE

Return values

converted —

string

F_compact_string()

File: tce_functions_general.php line 161

F_compact_string(mixed $string[, mixed $dquotes = false ]) : converted

Parameters

  • $string : mixed: (string) input string to convert
  • $dquotes : mixed = false: (boolean) If true add slash in fron of double quotes;

Return values

converted —

string

F_replace_angulars()

File: tce_functions_general.php line 182

F_replace_angulars(mixed $str) : converted

Parameters

  • $str : mixed: (string) input string to convert

Return values

converted —

string

F_substr_utf8()

File: tce_functions_general.php line 198

F_substr_utf8(mixed $str, mixed $start, mixed $length) : substring

Parameters

  • $str : mixed: (string) input string
  • $start : mixed: (int) substring start index
  • $length : mixed: (int) substring max length

Return values

substring

F_text_to_xml()

File: tce_functions_general.php line 238

F_text_to_xml(mixed $str) : converted

Parameters

  • $str : mixed: (string) input string to convert

Return values

converted —

string

F_xml_to_text()

File: tce_functions_general.php line 258

F_xml_to_text(mixed $str) : converted

Parameters

  • $str : mixed: (string) input string to convert

Return values

converted —

string

F_text_to_tsv()

File: tce_functions_general.php line 277

F_text_to_tsv(mixed $str) : converted

Parameters

  • $str : mixed: (string) input string to convert

Return values

converted —

string

F_tsv_to_text()

File: tce_functions_general.php line 297

F_tsv_to_text(mixed $str) : converted

Parameters

  • $str : mixed: (string) input string to convert

Return values

converted —

string

showRequiredField()

File: tce_functions_general.php line 316

showRequiredField([mixed $mode = 1 ]) : html

Parameters

  • $mode : mixed = 1: (int) field mode: 1=not required; 2=required.

Return values

html —

string

utrim()

File: tce_functions_general.php line 332

utrim(mixed $txt) : string

Parameters

  • $txt : mixed: (string) The string that will be trimmed.

Return values

string —

The trimmed string.

getNormalizedIP()

File: tce_functions_general.php line 349

getNormalizedIP(mixed $ip) : string|false

Parameters

  • $ip : mixed: (string) IP address to normalize.

Tags

  • since: 7.1.000 (2009-02-13)

Return values

string|false —

IPv6 address in expanded notation or false in case of invalid input.

getIpAsBytes()

File: tce_functions_general.php line 426

getIpAsBytes(mixed $ip) : string|false

This preserves full 128-bit precision and is case-insensitive, so the returned fixed-width byte strings can be ordered and range-compared losslessly with strcmp() (see F_isValidIP). Input may use any notation accepted by getNormalizedIP() (IPv4, IPv6, or the expanded form already stored in the database).

Parameters

  • $ip : mixed: (string) IP address to convert.

Tags

  • since: 17.1.0 (2026-06-23)

Return values

string|false —

16-byte packed IPv6 address, or false on invalid input.

getIpAsString()

File: tce_functions_general.php line 445

getIpAsString(mixed $ip) : string

The stored form is the expanded IPv6 produced by getNormalizedIP(); this compacts it (and unwraps IPv4-mapped IPv6, e.g. ::ffff:127.0.0.1 -> 127.0.0.1) so it reads naturally and fits report/result columns.

Parameters

  • $ip : mixed: (string) IP address to convert.

Tags

  • since: 9.0.033 (2009-11-03)

Return values

string —

IP address as a readable string.

F_formatFloat()

File: tce_functions_general.php line 475

F_formatFloat(mixed $num) : formatted

Parameters

  • $num : mixed: (float) number to be formatted

Return values

formatted —

string

F_formatPercentage()

File: tce_functions_general.php line 486

F_formatPercentage(mixed $num[, mixed $ratio = true ]) : formatted

Parameters

  • $num : mixed: (float) Number to be formatted.
  • $ratio : mixed = true: (boolean) Set to true if the number is a ratio between 0 and 1, false if is a percentage number between 0 an 100.

Return values

formatted —

string

F_formatPdfPercentage()

File: tce_functions_general.php line 501

F_formatPdfPercentage(mixed $num[, mixed $ratio = true ]) : string

Parameters

  • $num : mixed: (float) number to be formatted
  • $ratio : mixed = true: (boolean) Set to true if the number is a ratio between 0 and 1, false if is a percentage number between 0 an 100.

Return values

string

F_formatXMLPercentage()

File: tce_functions_general.php line 516

F_formatXMLPercentage(mixed $num[, mixed $ratio = true ]) : string

Parameters

  • $num : mixed: (float) number to be formatted
  • $ratio : mixed = true: (boolean) Set to true if the number is a ratio between 0 and 1, false if is a percentage number between 0 an 100.

Return values

string

F_getUTCoffset()

File: tce_functions_general.php line 530

F_getUTCoffset(mixed $timezone) : int

Parameters

  • $timezone : mixed: (string) current user timezone

Return values

int —

UTC time offset in seconds

F_db_getUTCoffset()

File: tce_functions_general.php line 542

F_db_getUTCoffset(mixed $timezone) : string

Parameters

  • $timezone : mixed: (string) current user timezone

Return values

string —

UTC time offset (+HH:mm)

getDataXML()

File: tce_functions_general.php line 555

getDataXML(mixed $data[, mixed $level = 1 ]) : string

Parameters

  • $data : mixed: (array) Array of data (key => value).
  • $level : mixed = 1: (int) Indentation level.

Return values

string —

XML data

getDataTSVHeader()

File: tce_functions_general.php line 585

getDataTSVHeader(mixed $data[, mixed $prefix = '' ]) : string

Parameters

  • $data : mixed: (array) Array of data (key => value).
  • $prefix : mixed = ‘’: (string) Prefix to add to keys.

Return values

string —

data

getDataTSV()

File: tce_functions_general.php line 604

getDataTSV(mixed $data) : string

Parameters

  • $data : mixed: (array) Array of data.

Return values

string —

XML data

F_html_to_TSV()

File: tce_functions_general.php line 623

F_html_to_TSV(mixed $str) : string

Parameters

  • $str : mixed: (string) HTML string to convert.

Return values

string —

TSV

F_select_table_header_element()

File: tce_functions_general.php line 678

F_select_table_header_element(mixed $order_field, mixed $orderdir, mixed $title, mixed $name[, mixed $current_order_field = '' ][, mixed $filter = '' ]) : table

Parameters

  • $order_field : mixed: (string) name of table field
  • $orderdir : mixed: (string) order direction
  • $title : mixed: title (string) field of anchor link
  • $name : mixed: column (string) name
  • $current_order_field : mixed = ‘’: (string) current order field name
  • $filter : mixed = ‘’: (string) additional parameters to pass on URL

Return values

table —

header element string

getContrastColor()

File: tce_functions_general.php line 716

getContrastColor(mixed $color) : string

Parameters

  • $color : mixed: (string) color in HEX format.

Return values

string —

Color.

F_isURL()

File: tce_functions_general.php line 737

F_isURL(mixed $str) : bool

Parameters

  • $str : mixed: (string) String to check.

Return values

bool —

true or false.

F_utf8_normalizer()

File: tce_functions_general.php line 750

F_utf8_normalizer(mixed $str[, mixed $mode = 'NONE' ]) : normalized

Modes greater than 0 requires php5-intl module. Please edit this function to implement your custom normalization method.

Parameters

  • $str : mixed: (string) UTF-8 string to normalize.
  • $mode : mixed = ‘NONE’: (int) Normalization type: NONE=None; C=Normalization Form C (NFC) - Canonical Decomposition followed by Canonical Composition; D=Normalization Form D (NFD) - Canonical Decomposition; KC=Normalization Form KC (NFKC) - Compatibility Decomposition, followed by Canonical Composition; KD=Normalization Form KD (NFKD) - Compatibility Decomposition; CUSTOM=Custom normalization using user defined function ‘user_utf8_custom_normalizer’.

Return values

normalized —

string using the specified algorithm.

bcdechex()

File: tce_functions_general.php line 803

bcdechex(string|int $dec) : string

Parameters

  • $dec : string|int: Decimal number to convert.

Tags

  • author: Nicola Asuni
  • since: 2013-07-02

Return values

string —

containing the HEX representation in uppercase.