Changeset 86df152 in github for program/include/rcube_shared.inc
- Timestamp:
- Dec 29, 2006 4:06:39 PM (6 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- e93a2d7
- Parents:
- 3b12aee
- File:
-
- 1 edited
-
program/include/rcube_shared.inc (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/rcube_shared.inc
r2bca6e1 r86df152 6 6 | | 7 7 | This file is part of the RoundCube PHP suite | 8 | Copyright (C) 2005 , RoundCube Dev. - Switzerland|8 | Copyright (C) 2005-2006, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 130 130 131 131 // set default page title 132 if ( !strlen($this->title))132 if (empty($this->title)) 133 133 $this->title = 'RoundCube Mail'; 134 134 … … 159 159 } 160 160 161 if ( strlen($this->scripts['head']))161 if (!empty($this->scripts['head'])) 162 162 $__page_header .= sprintf($this->script_tag, $this->scripts['head']); 163 163 … … 168 168 } 169 169 170 if ( strlen($this->scripts['foot']))170 if (!empty($this->scripts['foot'])) 171 171 $__page_footer .= sprintf($this->script_tag, $this->scripts['foot']); 172 172 … … 177 177 178 178 // find page header 179 if($hpos = strpos(strtolower($output), '</head>'))179 if($hpos = rc_strpos(rc_strtolower($output), '</head>')) 180 180 $__page_header .= "\n"; 181 181 else 182 182 { 183 183 if (!is_numeric($hpos)) 184 $hpos = strpos(strtolower($output), '<body');185 if (!is_numeric($hpos) && ($hpos = strpos(strtolower($output), '<html')))184 $hpos = rc_strpos(rc_strtolower($output), '<body'); 185 if (!is_numeric($hpos) && ($hpos = rc_strpos(rc_strtolower($output), '<html'))) 186 186 { 187 187 while($output[$hpos]!='>') … … 195 195 // add page hader 196 196 if($hpos) 197 $output = substr($output,0,$hpos) . $__page_header . substr($output,$hpos,strlen($output));197 $output = rc_substr($output,0,$hpos) . $__page_header . rc_substr($output,$hpos,rc_strlen($output)); 198 198 else 199 199 $output = $__page_header . $output; … … 201 201 202 202 // find page body 203 if($bpos = strpos(strtolower($output), '<body'))203 if($bpos = rc_strpos(rc_strtolower($output), '<body')) 204 204 { 205 205 while($output[$bpos]!='>') $bpos++; … … 207 207 } 208 208 else 209 $bpos = strpos(strtolower($output), '</head>')+7;209 $bpos = rc_strpos(rc_strtolower($output), '</head>')+7; 210 210 211 211 // add page body 212 212 if($bpos && $__page_body) 213 $output = substr($output,0,$bpos) . "\n$__page_body\n" . substr($output,$bpos,strlen($output));213 $output = rc_substr($output,0,$bpos) . "\n$__page_body\n" . rc_substr($output,$bpos,rc_strlen($output)); 214 214 215 215 216 216 // find and add page footer 217 $output_lc = strtolower($output);217 $output_lc = rc_strtolower($output); 218 218 if(($fpos = strrstr($output_lc, '</body>')) || 219 219 ($fpos = strrstr($output_lc, '</html>'))) 220 $output = substr($output,0,$fpos) . "$__page_footer\n" .substr($output,$fpos);220 $output = rc_substr($output,0,$fpos) . "$__page_footer\n" . rc_substr($output,$fpos); 221 221 else 222 222 $output .= "\n$__page_footer"; … … 879 879 unset($this->attrib['value']); 880 880 881 if ( strlen($value) && !isset($this->attrib['mce_editable']))881 if (!empty($value) && !isset($this->attrib['mce_editable'])) 882 882 $value = Q($value, 'strict', FALSE); 883 883 … … 1013 1013 foreach ($this->options as $option) 1014 1014 { 1015 $selected = (( strlen($option['value']) && in_array($option['value'], $select, TRUE)) ||1015 $selected = ((!empty($option['value']) && in_array($option['value'], $select, TRUE)) || 1016 1016 (in_array($option['text'], $select, TRUE))) ? $this->_conv_case(' selected', 'attrib') : ''; 1017 1017 1018 1018 $options_str .= sprintf("<%s%s%s>%s</%s>\n", 1019 1019 $this->_conv_case('option', 'tag'), 1020 strlen($option['value']) ? sprintf($value_str, $option['value']) : '',1020 !empty($option['value']) ? sprintf($value_str, $option['value']) : '', 1021 1021 $selected, 1022 1022 Q($option['text'], 'strict', FALSE), … … 1105 1105 $vars = isset($attrib['vars']) ? $attrib['vars'] : ''; 1106 1106 1107 $command_name = strlen($attrib['command']) ? $attrib['command'] : NULL;1107 $command_name = !empty($attrib['command']) ? $attrib['command'] : NULL; 1108 1108 $alias = $attrib['name'] ? $attrib['name'] : ($command_name && $command_label_map[$command_name] ? $command_label_map[$command_name] : ''); 1109 1109 … … 1278 1278 $value = $value ? "true" : "false"; 1279 1279 } 1280 else if ((($type=='mixed' && is_numeric($value)) || $type=='int') && strlen($value)<16) // js interprets numbers with digits >15 as ...e+...1280 else if ((($type=='mixed' && is_numeric($value)) || $type=='int') && rc_strlen($value)<16) // js interprets numbers with digits >15 as ...e+... 1281 1281 $is_string = FALSE; 1282 1282 else … … 1335 1335 1336 1336 1337 // parse a human readable string for a number of bytes 1338 function parse_bytes($str) 1339 { 1340 if (is_numeric($str)) 1341 return intval($str); 1342 1343 if (preg_match('/([0-9]+)([a-z])/i', $str, $regs)) 1344 { 1345 $bytes = floatval($regs[1]); 1346 switch (strtolower($regs[2])) 1347 { 1348 case 'g': 1349 $bytes *= 1073741824; 1350 break; 1351 case 'm': 1352 $bytes *= 1048576; 1353 break; 1354 case 'k': 1355 $bytes *= 1024; 1356 break; 1357 } 1358 } 1359 1360 return intval($bytes); 1361 } 1362 1337 1363 // create a human readable string for a number of bytes 1338 1364 function show_bytes($bytes) … … 1394 1420 1395 1421 1422 // wrapper function for strlen 1423 function rc_strlen($str) 1424 { 1425 if (function_exists('mb_strlen')) 1426 return mb_strlen($str); 1427 else 1428 return strlen($str); 1429 } 1430 1431 // wrapper function for strtolower 1432 function rc_strtolower($str) 1433 { 1434 if (function_exists('mb_strtolower')) 1435 return mb_strtolower($str); 1436 else 1437 return strtolower($str); 1438 } 1439 1440 // wrapper function for substr 1441 function rc_substr($str, $start, $len) 1442 { 1443 if (function_exists('mb_substr')) 1444 return mb_substr($str, $start, $len); 1445 else 1446 return substr($str, $start, $len); 1447 } 1448 1449 // wrapper function for strpos 1450 function rc_strpos($haystack, $needle, $offset=0) 1451 { 1452 if (function_exists('mb_strpos')) 1453 return mb_strpos($haystack, $needle, $offset); 1454 else 1455 return strpos($haystack, $needle, $offset); 1456 } 1457 1458 // wrapper function for strrpos 1459 function rc_strrpos($haystack, $needle, $offset=0) 1460 { 1461 if (function_exists('mb_strrpos')) 1462 return mb_strrpos($haystack, $needle, $offset); 1463 else 1464 return strrpos($haystack, $needle, $offset); 1465 } 1466 1467 1396 1468 // replace the middle part of a string with ... 1397 1469 // if it is longer than the allowed length 1398 1470 function abbrevate_string($str, $maxlength, $place_holder='...') 1399 1471 { 1400 $length = strlen($str);1401 $first_part_length = floor($maxlength/2) - strlen($place_holder);1472 $length = rc_strlen($str); 1473 $first_part_length = floor($maxlength/2) - rc_strlen($place_holder); 1402 1474 1403 1475 if ($length > $maxlength) 1404 1476 { 1405 1477 $second_starting_location = $length - $maxlength + $first_part_length + 1; 1406 $str = substr($str, 0, $first_part_length) . $place_holder .substr($str, $second_starting_location, $length);1478 $str = rc_substr($str, 0, $first_part_length) . $place_holder . rc_substr($str, $second_starting_location, $length); 1407 1479 } 1408 1480
Note: See TracChangeset
for help on using the changeset viewer.
