n(s+)/m", "] => ", $output ); $output = '
' . $label . ' => ' . $output . '
'; // Output if ( $echo == TRUE ) { echo $output; } else { return $output; } } } if ( ! function_exists( 'dump_exit' ) ) { function dump_exit( $var, $label = 'Dump', $echo = TRUE ) { dump( $var, $label, $echo ); exit; } } function mysql2text( $message ) { $regeleinden = ['\r\n', '\r', '\n']; $message = str_replace( $regeleinden, chr( 13 ), $message ); $message = stripslashes( $message ); return ( $message ); } function mysql2html( $message ) { $regeleinden = ['\r\n', '\r', '\n']; $message = str_replace( $regeleinden, "
", $message ); $message = stripslashes( $message ); return ( $message ); } function textarea2html( $message ) { $regeleinden = [chr( 13 )]; $message = str_replace( $regeleinden, "
", $message ); $message = stripslashes( $message ); return ( $message ); } function date2mysql( $date ) { if ( ! check_date( $date ) ) return NULL; return date( 'Y-m-d', strtotime( $date ) ); } function mysql2date( $date ) { if ( ! check_date( $date ) ) return ''; return date( 'd-m-Y', strtotime( $date ) ); } function mysql2dateWithTime( $date ) { if ( ! check_date( $date ) ) return ''; return date( 'd-m-Y H:i:s', strtotime( $date ) ); } function check_date( $date ) { if ( is_null( $date ) || ( strlen( $date ) < 6 ) ) return FALSE; return TRUE; } function mysql2timestamp( $date ) { $a = strptime( $date, '%Y-%m-%d' ); $timestamp = mktime( 0, 0, 0, $a['tm_mon'] + 1, $a['tm_mday'], $a['tm_year'] + 1900 ); return $timestamp; } function readTextFromStorage( $text ) { return base64_decode( $text ); } function cleanTextForStorage( $text ) { $text = str_replace( '/r/n', '', $text ); $text = str_replace( '\r\n', '', $text ); $text = str_replace( '/n', '', $text ); $text = str_replace( '\n', '', $text ); $text = strip_slashes( $text ); return base64_encode( $text ); } function setTextareaForStorage( $text ) { $text = setTextArea( $text ); return base64_encode( $text ); } function setTextArea( $text ) { $text = str_replace( '/r/n', chr( 13 ), $text ); $text = str_replace( '\r\n', chr( 13 ), $text ); $text = str_replace( '/n', chr( 13 ), $text ); $text = str_replace( '\n', chr( 13 ), $text ); $text = str_replace( '\r', chr( 13 ), $text ); $text = str_replace( '/r', chr( 13 ), $text ); $text = str_replace( '\n\n', chr( 13 ) . chr( 13 ), $text ); $text = strip_slashes( $text ); return $text; } function setTextAreaHtml( $text ) { $text = str_replace( '/r/n', '
', $text ); $text = str_replace( '\r\n', '
', $text ); $text = str_replace( '/n', '
', $text ); $text = str_replace( '\n', '
', $text ); $text = str_replace( '\r', '
', $text ); $text = str_replace( '/r', '
', $text ); $text = str_replace( '\n\n', '

', $text ); $text = strip_slashes( $text ); return $text; } function checkBsn( $bsn ) { if ( strlen( $bsn ) < 8 || strlen( $bsn ) > 9 ) { return FALSE; } else { $sum = 0; $counter = strlen( $bsn ); $pos = 0; for ( $i = $counter; $i > 0; $i -- ) { if ( $i == 1 ) { $sum = $sum + intval( $bsn{$pos} ) * - 1; } else { $sum = $sum + ( intval( $bsn{$pos} ) * $i ); } $pos ++; } if ( $sum % 11 != 0 ) { return FALSE; } } return TRUE; } /** * Validate an object property * * @param object $in * @param string $property Can be NULL, in that case the first parameter is evaluated * @param boolean $zeroAllowed , * default FALSE * * @return boolean TRUE if the property exists ans in not null or empty */ function isNotNullOrEmpty( $in, $property = NULL, $zeroAllowed = FALSE ) { if ( $property === NULL ) { if ( is_object( $in ) && count( (array) $in ) === 0 ) return FALSE; $isNotEmpty = $zeroAllowed ? ! empty ( $in ) : $in === 0 || $in === '0' || ! empty ( $in ); if ( is_string( $in ) ) { return $isNotEmpty && strtoupper( $in ) !== 'NULL' && strtoupper( $in ) !== 'FALSE' && strtoupper( $in ) !== 'UNDEFINED'; } else { return $isNotEmpty; } } if ( ! is_object( $in ) ) throw new Exception ( 'Provided test $in must be a class instance(object) or a valid classname(string)' ); if ( ! property_exists( $in, $property ) ) return FALSE; $prop = $in->{$property}; $isNotEmpty = $zeroAllowed ? ! empty ( $prop ) : $prop === 0 || $prop === '0' || ! empty ( $prop ); if ( is_string( $prop ) ) { return $isNotEmpty && strtoupper( $prop ) !== 'NULL' && strtoupper( $prop ) !== 'FALSE' && strtoupper( $prop ) !== 'UNDEFINED'; } else { return $isNotEmpty; } } /** * Validate an object property * * @param object $in * @param string $property Can be NULL, in that case the first parameter is evaluated * * @return boolean TRUE if the property exists and is not NULL or empty or zero */ function isNotNullOrEmptyOrZero( $in, $property = NULL ) { return isNotNullOrEmpty( $in, $property, TRUE ); } /** * Validate an object property * * @param object $in * @param string $property Can be NULL, in that case the first parameter is evaluated * * @return boolean TRUE if the property exists and is NULL or empty */ function isNullOrEmpty( $in, $property = NULL ) { return ! isNotNullOrEmpty( $in, $property ); } /** * Validate an object property * * @param object $in * @param string $property Can be NULL, in that case the first parameter is evaluated * * @return boolean TRUE if the property exists and is NULL or empty or zero */ function isNullOrEmptyOrZero( $in, $property = NULL ) { return ! isNotNullOrEmpty( $in, $property, TRUE ); } /** * * @param sting|integer $in * * @return string */ function parseNotNullField( $in ) { if ( isNullOrEmpty( $in ) ) { return ''; } return (string) $in; } function unique_multidim_array( $array, $key ) { $temp_array = []; $key_array = []; foreach ( $array as $val ) { $keyValue = is_array( $val ) ? $val[ $key ] : $val->$key; { if ( ! in_array( $keyValue, $key_array ) ) { $key_array[] = $keyValue; $temp_array[] = $val; } } } return $temp_array; }