Misc - staffcheck/api GitHub Wiki
- Class name: Misc
- Namespace:
null|string Misc::findSubmitButton(string $prefix)
- Visibility: public
- This method is static.
- $prefix string
array Misc::getSortDirectionArray(boolean $text_keys)
- Visibility: public
- This method is static.
- $text_keys boolean
array|boolean Misc::ArrayAssocSum($array, null $element, null $decimals, boolean $include_non_numeric)
- Visibility: public
- This method is static.
- $array mixed
- $element null
- $decimals null
- $include_non_numeric boolean
array Misc::ArrayGroupBy($array, $group_by_elements, array $ignore_elements)
- Visibility: public
- This method is static.
- $array mixed
- $group_by_elements mixed
- $ignore_elements array
boolean|float|integer Misc::ArrayAvg($arr)
- Visibility: public
- This method is static.
- $arr mixed
array|boolean Misc::prependArray($prepend_arr, $arr)
- Visibility: public
- This method is static.
- $prepend_arr mixed
- $arr mixed
array|boolean|null Misc::arrayColumn(null $input, null $columnKey, null $indexKey)
- Visibility: public
- This method is static.
- $input null
- $columnKey null
- $indexKey null
array Misc::flattenArray($array, boolean $preserve, array $r)
- Visibility: public
- This method is static.
- $array mixed
- $preserve boolean
- $r array
array|null Misc::arrayIntersectByKey($keys, $options)
- Visibility: public
- This method is static.
- $keys mixed
- $options mixed
boolean|mixed Misc::arrayIntersectByRow($rows)
- Visibility: public
- This method is static.
- $rows mixed
array|boolean Misc::arrayCommonValuesForEachKey($rows, null $filter_columns)
Returns the most common values for each key (column) in the rows.
- Visibility: public
- This method is static.
- $rows mixed
- $filter_columns null - Specific columns to get common data for.
array|null Misc::arrayDiffByKey($keys, $options)
- Visibility: public
- This method is static.
- $keys mixed
- $options mixed
array Misc::arrayMergeRecursiveDistinct(array $array1, array $array2)
- Visibility: public
- This method is static.
- $array1 array
- $array2 array
array Misc::arrayMergeRecursive(array $array1, array $array2)
- Visibility: public
- This method is static.
- $array1 array
- $array2 array
array|boolean Misc::arrayDiffAssocRecursive($array1, $array2)
- Visibility: public
- This method is static.
- $array1 mixed
- $array2 mixed
mixed Misc::arrayCommonValue($arr)
- Visibility: public
- This method is static.
- $arr mixed
array Misc::arrayIUnique($array)
Case insensitive array_unique().
- Visibility: public
- This method is static.
- $array mixed
array Misc::addKeyPrefix($prefix, $arr, null $ignore_elements)
- Visibility: public
- This method is static.
- $prefix mixed
- $arr mixed
- $ignore_elements null
array|boolean Misc::removeKeyPrefix($prefix, $arr, null $ignore_elements)
- Visibility: public
- This method is static.
- $prefix mixed
- $arr mixed
- $ignore_elements null
array|boolean Misc::addSortPrefix($arr, integer $begin_counter)
- Visibility: public
- This method is static.
- $arr mixed
- $begin_counter integer
array|mixed Misc::trimSortPrefix($value, boolean $trim_arr_value)
- Visibility: public
- This method is static.
- $value mixed
- $trim_arr_value boolean
mixed Misc::strReplaceOnce($str_pattern, $str_replacement, $string)
- Visibility: public
- This method is static.
- $str_pattern mixed
- $str_replacement mixed
- $string mixed
boolean Misc::FileDownloadHeader($file_name, $type, $size)
- Visibility: public
- This method is static.
- $file_name mixed
- $type mixed
- $size mixed
boolean Misc::APIFileDownload($file_name, $type, $data)
- Visibility: public
- This method is static.
- $file_name mixed
- $type mixed
- $data mixed
string Misc::removeTrailingZeros($value, integer $minimum_decimals)
value should be a float and not a string. be sure to run this before TTi18n currency or number formatter due to foreign numeric formatting for decimal being a comma.
- Visibility: public
- This method is static.
- $value mixed - float
- $minimum_decimals integer
string Misc::MoneyFormat($value, boolean $pretty)
Just a number format that looks like currency without currency symbol can maybe be replaced by TTi18n::numberFormat()
- Visibility: public
- This method is static.
- $value mixed
- $pretty boolean
boolean|string Misc::abbreviateString($str)
- Visibility: public
- This method is static.
- $str mixed
string Misc::TruncateString($str, $length, integer $start, boolean $abbreviate)
- Visibility: public
- This method is static.
- $str mixed
- $length mixed
- $start integer
- $abbreviate boolean
string Misc::HumanBoolean($bool)
- Visibility: public
- This method is static.
- $bool mixed
integer Misc::getBeforeDecimal($float)
- Visibility: public
- This method is static.
- $float mixed
integer Misc::getAfterDecimal($float, boolean $format_number)
- Visibility: public
- This method is static.
- $float mixed
- $format_number boolean
mixed Misc::removeDecimal($value)
- Visibility: public
- This method is static.
- $value mixed
string Misc::encodeInteger($int)
- Visibility: public
- This method is static.
- $int mixed
integer Misc::decodeInteger($str, integer $max)
- Visibility: public
- This method is static.
- $str mixed
- $max integer
float|integer Misc::calculatePercent($current, $maximum, integer $precision)
- Visibility: public
- This method is static.
- $current mixed
- $maximum mixed
- $precision integer
boolean|integer|string Misc::sumMultipleColumns($data, $sum_elements)
- Visibility: public
- This method is static.
- $data mixed
- $sum_elements mixed
integer Misc::calculateIncludeExcludeAmount($amount, $element, array $include_elements, array $exclude_elements)
- Visibility: public
- This method is static.
- $amount mixed
- $element mixed
- $include_elements array
- $exclude_elements array
boolean|integer|string Misc::calculateMultipleColumns($data, array $include_elements, array $exclude_elements)
- Visibility: public
- This method is static.
- $data mixed
- $include_elements array
- $exclude_elements array
mixed Misc::getPointerFromArray($array, $element, integer $start)
- Visibility: public
- This method is static.
- $array mixed
- $element mixed
- $start integer
mixed Misc::AdjustXY($coord, $adjust_coord)
- Visibility: public
- This method is static.
- $coord mixed
- $adjust_coord mixed
boolean Misc::writeBarCodeFile($file_name, $num, boolean $print_text, integer $height)
- Visibility: public
- This method is static.
- $file_name mixed
- $num mixed
- $print_text boolean
- $height integer
array|string Misc::hex2rgb($hex, boolean $asString)
- Visibility: public
- This method is static.
- $hex mixed
- $asString boolean
mixed Misc::escapeCSVTriggerChars($input)
Mititage CSV Injection attacks: See below links for more information: [1] https://www.owasp.org/index.php/CSV_Excel_Macro_Injection [2] https://hackerone.com/reports/72785 [3] https://hackerone.com/reports/90131
- Visibility: public
- This method is static.
- $input mixed
boolean|null|string Misc::Array2CSV($data, null $columns, boolean $ignore_last_row, boolean $include_header, string $eol)
- Visibility: public
- This method is static.
- $data mixed
- $columns null
- $ignore_last_row boolean
- $include_header boolean
- $eol string
boolean|null|string Misc::Array2JSON($data, null $columns)
- Visibility: public
- This method is static.
- $data mixed
- $columns null
boolean|null|string Misc::Array2XML($data, null $columns, null $column_format, boolean $ignore_last_row, boolean $include_xml_header, string $root_element_name, string $row_element_name)
- Visibility: public
- This method is static.
- $data mixed
- $columns null
- $column_format null
- $ignore_last_row boolean
- $include_xml_header boolean
- $root_element_name string
- $row_element_name string
mixed Misc::Export2XML($factory_arr, $filter_data, $output_file)
- Visibility: public
- This method is static.
- $factory_arr mixed
- $filter_data mixed
- $output_file mixed
boolean Misc::ExportListFactory2XML($lf, $filter_data, $file_pointer)
- Visibility: public
- This method is static.
- $lf mixed
- $filter_data mixed
- $file_pointer mixed
boolean Misc::inArrayByKeyAndValue($arr, $search_key, $search_value)
- Visibility: public
- This method is static.
- $arr mixed
- $search_key mixed
- $search_value mixed
array|boolean Misc::preSetArrayValues($arr, $keys, null $preset_value)
- Visibility: public
- This method is static.
- $arr mixed
- $keys mixed
- $preset_value null
boolean|mixed|string Misc::getMimeType($file_name, boolean $buffer, boolean $keep_charset, string $unknown_type)
- Visibility: public
- This method is static.
- $file_name mixed
- $buffer boolean
- $keep_charset boolean
- $unknown_type string
integer Misc::countLinesInFile($file)
- Visibility: public
- This method is static.
- $file mixed
array|boolean Misc::parseCSV($file, boolean $head, boolean $first_column, string $delim, integer $len, null $max_lines)
- Visibility: public
- This method is static.
- $file mixed
- $head boolean
- $first_column boolean
- $delim string
- $len integer
- $max_lines null
array|boolean Misc::importApplyColumnMap($column_map, $csv_arr)
- Visibility: public
- This method is static.
- $column_map mixed
- $csv_arr mixed
boolean|string Misc::censorString($str, string $censor_char, integer|null $min_first_chunk_size, integer|null $max_first_chunk_size, integer|null $min_last_chunk_size, integer|null $max_last_chunk_size)
censor part of a string for purposes of displaying things like SIN, bank accounts, credit card numbers.
- Visibility: public
- This method is static.
- $str mixed
- $censor_char string
- $min_first_chunk_size integer|null
- $max_first_chunk_size integer|null
- $min_last_chunk_size integer|null
- $max_last_chunk_size integer|null
boolean|string Misc::encrypt($str, null $salt, null $key)
- Visibility: public
- This method is static.
- $str mixed
- $salt null
- $key null
boolean|string Misc::decrypt($str, null $salt, null $key)
We can't reliably test that decryption was successful, so type checking should be done in the calling function. (see RemittanceDestinationAccountFactory::getValue3())
- Visibility: public
- This method is static.
- $str mixed
- $salt null
- $key null
string Misc::getJSArray($values, null $name, boolean $assoc, boolean $object)
- Visibility: public
- This method is static.
- $values mixed
- $name null
- $assoc boolean
- $object boolean
array Misc::getArrayNeighbors($arr, $key, string $neighbor)
- Visibility: public
- This method is static.
- $arr mixed
- $key mixed
- $neighbor string
string Misc::getURLProtocol()
- Visibility: public
- This method is static.
boolean|mixed Misc::getRemoteHTTPFileSize($url)
- Visibility: public
- This method is static.
- $url mixed
boolean|integer Misc::downloadHTTPFile($url, $file_name)
- Visibility: public
- This method is static.
- $url mixed
- $file_name mixed
string Misc::getEmailDomain()
- Visibility: public
- This method is static.
string Misc::getEmailLocalPart()
- Visibility: public
- This method is static.
string Misc::getEmailReturnPathLocalPart(null $email)
- Visibility: public
- This method is static.
- $email null
boolean Misc::checkValidDomain()
- Visibility: public
- This method is static.
boolean Misc::checkValidReferer(boolean $referer)
- Visibility: public
- This method is static.
- $referer boolean
string Misc::getHostNameWithoutSubDomain($host_name)
- Visibility: public
- This method is static.
- $host_name mixed
string Misc::getHostName(boolean $include_port)
- Visibility: public
- This method is static.
- $include_port boolean
array Misc::parseDatabaseHostString($database_host_string)
- Visibility: public
- This method is static.
- $database_host_string mixed
boolean Misc::isOpenPort($address, integer $port, integer $timeout)
- Visibility: public
- This method is static.
- $address mixed
- $port integer
- $timeout integer
array|boolean|mixed Misc::findClosestMatch($search_str, $search_arr, integer $minimum_percent_match, boolean $return_all_matches)
Accepts a search_str and key=>val array that it searches through, to return the array key of the closest fuzzy match.
- Visibility: public
- This method is static.
- $search_str mixed
- $search_arr mixed
- $minimum_percent_match integer
- $return_all_matches boolean
boolean|string Misc::NumberToLetter($number)
- Visibility: public
- This method is static.
- $number mixed
float|integer Misc::reScaleRange($value, integer $old_min, integer $old_max, integer $new_min, integer $new_max)
- Visibility: public
- This method is static.
- $value mixed
- $old_min integer
- $old_max integer
- $new_min integer
- $new_max integer
null Misc::issetOr($var, null $default)
- Visibility: public
- This method is static.
- $var mixed
- $default null
boolean|string Misc::getFullName($first_name, $middle_name, $last_name, boolean $reverse, boolean $include_middle)
- Visibility: public
- This method is static.
- $first_name mixed
- $middle_name mixed
- $last_name mixed
- $reverse boolean
- $include_middle boolean
string Misc::getCityAndProvinceAndPostalCode($city, $province, $postal_code)
- Visibility: public
- This method is static.
- $city mixed
- $province mixed
- $postal_code mixed
boolean|string Misc::parseCallerID($number)
Caller ID numbers can come in in all sorts of forms: 2505551234 12505551234 +12505551234 (250) 555-1234 Parse out just the digits, and use only the last 10 digits.
Currently this will not support international numbers
- Visibility: public
- This method is static.
- $number mixed
boolean|string Misc::generateCopyName($name, boolean $strict)
- Visibility: public
- This method is static.
- $name mixed
- $strict boolean
boolean|string Misc::generateShareName($from, $name, boolean $strict)
- Visibility: public
- This method is static.
- $from mixed
- $name mixed
- $strict boolean
boolean Misc::cleanDir($path, $recursive, boolean $del_dirs, boolean $del_root, $exclude_regex_filter)
Delete all files in directory
- Visibility: public
- This method is static.
- $path mixed - string directory to clean
- $recursive mixed - boolean delete files in subdirs
- $del_dirs boolean
- $del_root boolean
- $exclude_regex_filter mixed - string regex to exclude paths
mixed Misc::deleteEmptyDirectory($path, $recurse_parent_levels)
- Visibility: public
- This method is static.
- $path mixed
- $recurse_parent_levels mixed
boolean Misc::rename($old_name, $new_name)
If rename fails for some reason, attempt a copy instead as that might work, specifically on windows where if the file is in use.
Might fix possible "Access is denied. (code: 5)" errors on Windows when using PHP v5.2 (https://bugs.php.net/bug.php?id=43817)
- Visibility: public
- This method is static.
- $old_name mixed
- $new_name mixed
array|boolean Misc::getFileList($start_dir, null $regex_filter, boolean $recurse)
- Visibility: public
- This method is static.
- $start_dir mixed
- $regex_filter null
- $recurse boolean
boolean Misc::isSubDirectory($child_dir, $parent_dir)
- Visibility: public
- This method is static.
- $child_dir mixed
- $parent_dir mixed
array Misc::convertObjectToArray(object $obj)
- Visibility: public
- This method is static.
- $obj object
integer|string Misc::getBytesFromSize($val)
- Visibility: public
- This method is static.
- $val mixed
integer|string Misc::getSystemMemoryInfo()
- Visibility: public
- This method is static.
integer|mixed Misc::getSystemLoad()
- Visibility: public
- This method is static.
boolean Misc::isSystemLoadValid()
- Visibility: public
- This method is static.
string Misc::formatEmailAddress($email, object $user_obj)
- Visibility: public
- This method is static.
- $email mixed
- $user_obj object
boolean Misc::parseRFC822EmailAddress($input, boolean $return_just_key)
- Visibility: public
- This method is static.
- $input mixed
- $return_just_key boolean
boolean Misc::sendSystemMail($subject, $body, null $attachments, boolean $force)
- Visibility: public
- This method is static.
- $subject mixed
- $body mixed
- $attachments null
- $force boolean
mixed Misc::isCurrentOSUserRoot()
- Visibility: public
- This method is static.
mixed Misc::getCurrentOSUser()
- Visibility: public
- This method is static.
mixed Misc::setProcessUID($uid)
- Visibility: public
- This method is static.
- $uid mixed
mixed Misc::findWebServerOSUser()
- Visibility: public
- This method is static.
boolean Misc::disableCaching(boolean $email_notification)
- Visibility: public
- This method is static.
- $email_notification boolean
boolean|string Misc::getMapURL($address1, $address2, $city, $province, $postal_code, $country, string $service)
- Visibility: public
- This method is static.
- $address1 mixed
- $address2 mixed
- $city mixed
- $province mixed
- $postal_code mixed
- $country mixed
- $service string
boolean Misc::isEmail($email, boolean $check_dns, boolean $error_level, $return_raw_result)
- Visibility: public
- This method is static.
- $email mixed
- $check_dns boolean
- $error_level boolean
- $return_raw_result mixed
integer Misc::getPasswordStrength($password)
- Visibility: public
- This method is static.
- $password mixed
integer Misc::getCurrentCompanyProductEdition()
- Visibility: public
- This method is static.
boolean Misc::redirectMobileBrowser()
- Visibility: public
- This method is static.
boolean Misc::redirectUnSupportedBrowser()
- Visibility: public
- This method is static.
boolean Misc::isUnSupportedBrowser(null $useragent)
- Visibility: public
- This method is static.
- $useragent null
boolean Misc::isSearchEngineBrowser(null $useragent)
- Visibility: public
- This method is static.
- $useragent null
boolean|string Misc::detectMobileBrowser(null $useragent)
- Visibility: public
- This method is static.
- $useragent null
array|boolean Misc::PercentDistribution($amount, $percent_arr, string $remainder_operation, integer $precision)
- Visibility: public
- This method is static.
- $amount mixed
- $percent_arr mixed
- $remainder_operation string
- $precision integer
array|boolean Misc::arrayChangeValueCase($input, integer $case)
- Visibility: public
- This method is static.
- $input mixed
- $case integer
boolean Misc::isWritable($path)
Checks to see if a file/directory is writable.
- Visibility: public
- This method is static.
- $path mixed
boolean Misc::getRemoteIPAddress()
- Visibility: public
- This method is static.
boolean Misc::isSSL(boolean $ignore_force_ssl)
- Visibility: public
- This method is static.
- $ignore_force_ssl boolean
mixed Misc::MajorVersionCompare($version1, $version2, $operator)
- Visibility: public
- This method is static.
- $version1 mixed
- $version2 mixed
- $operator mixed
string Misc::getInstanceIdentificationString($primary_company, $system_settings)
- Visibility: public
- This method is static.
- $primary_company mixed
- $system_settings mixed
boolean|string Misc::stripThe($str, boolean $add_to_end)
- Visibility: public
- This method is static.
- $str mixed
- $add_to_end boolean
mixed Misc::stripHTMLSpecialChars($str)
- Visibility: public
- This method is static.
- $str mixed
boolean Misc::checkValidImage($file_data)
- Visibility: public
- This method is static.
- $file_data mixed
string Misc::formatAddress($name, boolean $address1, boolean $address2, boolean $city, boolean $province, boolean $postal_code, boolean $country, $condensed)
- Visibility: public
- This method is static.
- $name mixed
- $address1 boolean
- $address2 boolean
- $city boolean
- $province boolean
- $postal_code boolean
- $country boolean
- $condensed mixed
string Misc::getUniqueID()
- Visibility: public
- This method is static.
mixed|string|array<mixed,string>|null Misc::sanitizeFileName($file_name)
Sanitize strings to be used in file names by converting spaces to underscore and removing non-alpha numeric characters
- Visibility: public
- This method is static.
- $file_name mixed
array Misc::zip($file_array, boolean $zip_file_name, boolean $ignore_single_file)
zips an array of files and returns a file array for download
- Visibility: public
- This method is static.
- $file_array mixed
- $zip_file_name boolean
- $ignore_single_file boolean
integer Misc::getAmountUpToLimit($amount, $limit)
- Visibility: public
- This method is static.
- $amount mixed
- $limit mixed
string Misc::getAmountDifferenceUpToLimit($amount, $limit)
This is can be used to handle YTD amounts.
- Visibility: public
- This method is static.
- $amount mixed
- $limit mixed
mixed Misc::getHardwareID()
- Visibility: public
- This method is static.