| 1 |
<? |
<? |
| 2 |
|
|
| 3 |
function split_line($str,$width=75,$pre="") |
function split_line($str,$prefix="",$width=75) |
| 4 |
{ |
{ |
| 5 |
$lines = array(); |
$lines = array(); |
| 6 |
$lines_count = 0; |
$lines_count = 0; |
| 11 |
if ($width<=0) |
if ($width<=0) |
| 12 |
return $str; |
return $str; |
| 13 |
|
|
| 14 |
$line = $pre; |
$line = $prefix; |
| 15 |
$line_count = strlen($line); |
$line_count = strlen($line); |
| 16 |
for($i=0;$i<$len;$i++) |
for($i=0;$i<$len;$i++) |
| 17 |
{ |
{ |
|
if ($line_count >= $width && $hz_ok) |
|
|
{ |
|
|
$lines[$lines_count++] = $line; |
|
|
$line = $pre; |
|
|
$line_count = strlen($line); |
|
|
} |
|
| 18 |
$line.=$str[$i]; |
$line.=$str[$i]; |
| 19 |
$line_count++; |
$line_count++; |
| 20 |
if (ord($str[$i])>127) |
if (ord($str[$i])>127) |
| 21 |
|
{ |
| 22 |
$hz_ok = (!$hz_ok); |
$hz_ok = (!$hz_ok); |
| 23 |
|
} |
| 24 |
if (ord($str[$i])<=127) |
if (ord($str[$i])<=127) |
| 25 |
|
{ |
| 26 |
$hz_ok = true; |
$hz_ok = true; |
| 27 |
|
} |
| 28 |
|
if ($line_count >= $width && $hz_ok) |
| 29 |
|
{ |
| 30 |
|
$lines[$lines_count++] = $line; |
| 31 |
|
$line = $prefix; |
| 32 |
|
$line_count = strlen($line); |
| 33 |
|
} |
| 34 |
} |
} |
| 35 |
$lines[$lines_count++] = $line; |
$lines[$lines_count++] = $line; |
| 36 |
|
|
| 42 |
return $result; |
return $result; |
| 43 |
} |
} |
| 44 |
|
|
| 45 |
function add_colon($str,$width=75) |
function str_process($str,$prefix="",$width=75) |
| 46 |
{ |
{ |
| 47 |
$result = ""; |
$result = ""; |
| 48 |
|
|
| 50 |
|
|
| 51 |
foreach($lines as $line) |
foreach($lines as $line) |
| 52 |
{ |
{ |
| 53 |
$result .= split_line($line,$width,": "); |
$result .= split_line($line,$prefix,$width); |
| 54 |
} |
} |
| 55 |
|
|
| 56 |
return $result; |
return $result; |
| 57 |
} |
} |
| 58 |
|
|
| 59 |
|
function str_b_lines($str,$max_line=1) |
| 60 |
|
{ |
| 61 |
|
$result = ""; |
| 62 |
|
$l = 0; |
| 63 |
|
$lines = explode("\n",str_replace("\r\n","\n",$str)); |
| 64 |
|
foreach($lines as $line) |
| 65 |
|
{ |
| 66 |
|
$result .= ($line."\r\n"); |
| 67 |
|
$l += (strlen($line)/256 + 1); |
| 68 |
|
if ($l >= $max_line) |
| 69 |
|
break; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
return $result; |
| 73 |
|
} |
| 74 |
|
|
| 75 |
?> |
?> |