$newline], $options), true); $result = $is_html ? '
'.$result.'
' : $result; if ($return) return $result; else echo $result; } function get($field, $data = null, $default = null, $possible_values = []) { return Util::get($field, $data, $default, $possible_values); } function br2nl($text) { return Util::br2nl($text); } function array_delete($array, $items) { return array_diff($array, is_array($items) ? $items : [$items]); } function dt_valid($date, $min_date = null, $max_date = null, $timezone = null) { $valid = false; $date = dt($date, \DateTime::ISO8601, $timezone); if (!$date) return false; if ($max_date) $valid = $date < dt($max_date, \DateTime::ISO8601, $timezone); if ($min_date) $valid = $date > dt($min_date, \DateTime::ISO8601, $timezone); return $valid; } function dt($date = 'now', $format = null, $timezone = null, $src_format = null) { if (!$format) $format = 'Y-m-d H:i:s'; if ($date) { try { if ($src_format) $date = \Moment\Moment::createFromFormat($src_format, $date, $timezone) ?: $date; if ($date instanceof DateTime) { $dt = $date; } else { // Warning: specifying the timezone will change the output date if (is_string($date)) { $date = strtotime($date); if ($date < 0) return null; $date = '@'.$date; } $dt = new \Moment\Moment($date, $timezone); } return $dt->format($format); } catch (Exception $ex) { trigger_error($ex->getMessage()); } } return null; } function token($length = 16) { return Util::token($length); } function uuid() { return Util::uuid(); } function phone($input, $country_code = 1, $format = '+%1$s%2$s%3$s%4$s') { return Util::formatPhone($input, $country_code, $format); } function ssn($input) { return Util::formatSsn($input); } function escape($str, $nl2br = false) { return Util::escapeHtml($str, $nl2br); } function encrypt($data, $iv) { $iv = hash_hmac('sha256', $iv, ENCRYPTION_KEY); return Util::encrypt($data, ENCRYPTION_KEY, $iv); } function decrypt($data, $iv) { $iv = hash_hmac('sha256', $iv, ENCRYPTION_KEY); return Util::decrypt($data, ENCRYPTION_KEY, $iv); } ?>