13 define(
'REPORT_WIDTH' , 80 );
22 $t = strtoupper(
$t );
32 return (
$d === NULL ) ? date(
$f ) : date(
$f,
$d );
38 return str_repeat(
$c,
$w );
62 $m =
$w - ( strlen(
$d ) );
64 if( strlen(
$l ) >
$m ) {
68 $w -= strlen(
$l ) + strlen(
$d );
78 if( empty(
$l ) ) {
$l = array_keys(
$h ); }
80 array_unshift(
$d, array_combine( array_keys(
$h ),
$l ) );
82 foreach(
$d as
$n =>
$r ) {
83 foreach(
$h as
$k => $v ) {
84 if( substr(
$k, 0, 9 ) ==
'timestamp' && is_numeric( trim(
$r[
$k ] ) ) && ! empty(
$r[ $k ] ) ) {
$r[
$k ] = date(
'Y-m-d H:i:s',
$r[ $k ] ); }
85 if( empty(
$r[ $k ] ) ) {
$r[
$k ] =
'-'; }
89 if(
$n === array_key_first(
$d ) ) { echo
txtLine() . PHP_EOL; }
96 $t = wordwrap(
$t,
$w,
"\n" );
99 $lines = explode(
"\n",
$t );
100 foreach( $lines as &$line ) {
101 if( substr( $line, -1 ) !=
'.' ) {
105 return implode(
"\n", $lines );
116 $strlen = mb_strlen($str);
118 if ($strlen >= $maxlen) {
119 $str = wordwrap($str, $maxlen);
120 $str = explode(
"\n", $str);
122 $strlen = mb_strlen($str);
125 $space_count = mb_substr_count($str,
' ');
126 if ($space_count === 0) {
127 return str_pad($str, $maxlen,
' ', STR_PAD_BOTH);
130 $extra_spaces_needed = $maxlen - $strlen;
131 $total_spaces = $extra_spaces_needed + $space_count;
133 $space_string_avg_length = $total_spaces / $space_count;
134 $short_string_multiplier = floor($space_string_avg_length);
135 $long_string_multiplier = ceil($space_string_avg_length);
137 $short_fill_string = str_repeat(
' ', $short_string_multiplier);
138 $long_fill_string = str_repeat(
' ', $long_string_multiplier);
140 $offset = $space_string_avg_length - $short_string_multiplier;
141 $limit = ceil( $offset * $space_count );
142 $explode_limit = $limit + 1;
143 # echo gettype( $limit ) . PHP_EOL; 144 # var_dump( $limit ); 147 $words_split_by_long = explode(
' ', $str, $explode_limit );
148 # $words_split_by_long = explode(' ', $str, 3); 149 $words_split_by_short = $words_split_by_long[$limit];
150 $words_split_by_short = str_replace(
' ', $short_fill_string, $words_split_by_short);
151 $words_split_by_long[$limit] = $words_split_by_short;
153 # print_r( $words_split_by_long ); 155 $result = implode($long_fill_string, $words_split_by_long);
178 if( strlen(
$t ) >=
$w ) {
181 $x = str_pad(
$t,
$w - 1 );
if(!empty($_REQUEST['id'])) $d