| 1 |
<? |
<? |
| 2 |
|
|
| 3 |
function split_line($str,$width=75,$pre="") |
function split_line($str,$pre="",$width=75) |
| 4 |
{ |
{ |
| 5 |
$lines = array(); |
$lines = array(); |
| 6 |
$lines_count = 0; |
$lines_count = 0; |
| 7 |
$len = strlen($str); |
$len = strlen($str); |
| 8 |
|
|
| 9 |
$hz_ok = true; |
$hz_ok = true; |
| 10 |
|
$en_ok = true; |
| 11 |
|
|
| 12 |
if ($width<=0) |
if ($width<=0) |
| 13 |
return $str; |
return $str; |
| 16 |
$line_count = strlen($line); |
$line_count = strlen($line); |
| 17 |
for($i=0;$i<$len;$i++) |
for($i=0;$i<$len;$i++) |
| 18 |
{ |
{ |
|
if ($line_count >= $width && $hz_ok) |
|
|
{ |
|
|
$lines[$lines_count++] = $line; |
|
|
$line = $pre; |
|
|
$line_count = strlen($line); |
|
|
} |
|
| 19 |
$line.=$str[$i]; |
$line.=$str[$i]; |
| 20 |
$line_count++; |
$line_count++; |
| 21 |
if (ord($str[$i])>127) |
if (ord($str[$i])>127) |
| 22 |
|
{ |
| 23 |
$hz_ok = (!$hz_ok); |
$hz_ok = (!$hz_ok); |
| 24 |
|
$en_ok = true; |
| 25 |
|
} |
| 26 |
if (ord($str[$i])<=127) |
if (ord($str[$i])<=127) |
| 27 |
|
{ |
| 28 |
$hz_ok = true; |
$hz_ok = true; |
| 29 |
|
if ($str[$i] == " ") |
| 30 |
|
{ |
| 31 |
|
$en_ok = true; |
| 32 |
|
} |
| 33 |
|
else |
| 34 |
|
{ |
| 35 |
|
$en_ok = false; |
| 36 |
|
} |
| 37 |
|
} |
| 38 |
|
if ($line_count >= $width && $hz_ok && $en_ok) |
| 39 |
|
{ |
| 40 |
|
$lines[$lines_count++] = $line; |
| 41 |
|
$line = $pre; |
| 42 |
|
$line_count = strlen($line); |
| 43 |
|
} |
| 44 |
} |
} |
| 45 |
$lines[$lines_count++] = $line; |
$lines[$lines_count++] = $line; |
| 46 |
|
|
| 52 |
return $result; |
return $result; |
| 53 |
} |
} |
| 54 |
|
|
| 55 |
function add_colon($str,$width=75) |
function str_process($str,$pre="",$width=75) |
| 56 |
{ |
{ |
| 57 |
$result = ""; |
$result = ""; |
| 58 |
|
|
| 60 |
|
|
| 61 |
foreach($lines as $line) |
foreach($lines as $line) |
| 62 |
{ |
{ |
| 63 |
$result .= split_line($line,$width,": "); |
$result .= split_line($line,$pre,$width); |
| 64 |
} |
} |
| 65 |
|
|
| 66 |
return $result; |
return $result; |