Changeset 454
- Timestamp:
- Jan 4, 2014 3:25:57 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/css/utilities.inc.css
r406 r454 1 1 /** 2 * utilities.css 2 * utilities.css 3 3 * 4 4 * CSS used often in Strangecode applications. Do not arbitrarily … … 47 47 } 48 48 .sc-note:hover { cursor: help; } 49 .sc-ellipsis { 50 overflow: hidden; 51 white-space: nowrap; 52 text-overflow: ellipsis; 53 } 49 54 50 55 /* .sc-pkg class wraps enclosing block element around inner floated elements */ -
trunk/lib/Email.inc.php
r424 r454 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 28 28 * @author Quinn Comendant <quinn@strangecode.com> 29 29 * @version 1.0 30 * 31 30 * 31 32 32 // Example. 33 33 $email = new Email(array( … … 50 50 } 51 51 52 * 52 * 53 53 */ 54 54 class Email { … … 61 61 'headers' => null, 62 62 'regex' => null, 63 63 64 64 // A single carriage return (\n) should terminate lines for locally injected mail. 65 65 // A carriage return + line-feed (\r\n) should be used if sending mail directly with SMTP. 66 66 'crlf' => "\n", 67 67 68 68 // RFC 2822 says line length MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF. 69 69 // http://mailformat.dan.info/body/linelength.html … … 120 120 { 121 121 $app =& App::getInstance(); 122 122 123 123 if (isset($params) && is_array($params)) { 124 124 // Enforce valid email addresses. … … 147 147 { 148 148 $app =& App::getInstance(); 149 149 150 150 if (isset($this->_params[$param])) { 151 151 return $this->_params[$param]; … … 167 167 { 168 168 $app =& App::getInstance(); 169 169 170 170 // Load file, using include_path. 171 171 if (!$this->_template = file_get_contents($template, true)) { … … 191 191 { 192 192 $app =& App::getInstance(); 193 193 194 194 if ('' == trim($string)) { 195 195 $app->logMsg(sprintf('Empty string provided.', null), LOG_ERR, __FILE__, __LINE__); … … 215 215 { 216 216 $app =& App::getInstance(); 217 217 218 218 // Ensure template exists. 219 219 if (!isset($this->_template)) { … … 285 285 $final_body = isset($this->_template_replaced) ? $this->_template_replaced : $this->_template; 286 286 if (false !== $this->getParam('wrap')) { 287 $final_body = wordwrap($final_body, $this->getParam('line_length'), $this->getParam('crlf')); 287 $final_body = wordwrap($final_body, $this->getParam('line_length'), $this->getParam('crlf')); 288 288 } 289 289 … … 320 320 $envelope_sender_header = sprintf('-f %s', $envelope_sender_address); 321 321 } else { 322 $envelope_sender_header = ''; 322 $envelope_sender_header = ''; 323 323 } 324 324 … … 331 331 } 332 332 333 // Send email without 5th parameter if safemode is enabled. 333 // Send email without 5th parameter if safemode is enabled. 334 334 if (ini_get('safe_mode')) { 335 335 $ret = mb_send_mail($final_to, $this->_params['subject'], $final_body, $final_headers); … … 337 337 $ret = mb_send_mail($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header); 338 338 } 339 339 340 340 // Ensure message was successfully accepted for delivery. 341 341 if ($ret) { … … 345 345 $app->logMsg(sprintf('Email failure with parameters: %s, %s, %s, %s', $final_to, $this->_params['subject'], str_replace("\r\n", '\r\n', $final_headers), $envelope_sender_header), LOG_NOTICE, __FILE__, __LINE__); 346 346 return false; 347 } 347 } 348 348 } 349 349 … … 366 366 { 367 367 $app =& App::getInstance(); 368 368 369 369 // If an array, check values recursively. 370 370 if (is_array($email)) { -
trunk/lib/Utilities.inc.php
r419 r454 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 37 37 if (defined('_CLI')) { 38 38 echo "\n"; 39 } else { 39 } else { 40 40 echo $display ? "\n<br /><pre>\n" : "\n\n\n<!--\n"; 41 41 } … … 47 47 if (defined('_CLI')) { 48 48 echo "\n"; 49 } else { 49 } else { 50 50 echo $display ? "\n</pre><br />\n" : "\n-->\n\n\n"; 51 51 } … … 180 180 { 181 181 $words = preg_split('/[^\w]/', $search, -1, PREG_SPLIT_NO_EMPTY); 182 182 183 183 $search = array(); 184 184 $replace = array(); 185 185 186 186 foreach ($words as $w) { 187 187 if ('' != trim($w)) { … … 266 266 267 267 /** 268 * Turns "a really long string" into "a rea...string" 268 * Truncates "a really long string" into a string of specified length 269 * at the beginning: "âŠlong string" 270 * at the middle: "a reaâŠstring" 271 * or at the end: "a reallyâŠ". 272 * 273 * The regular expressions below first match and replace the string to the specified length and position, 274 * and secondly they remove any whitespace from around the delimiter (to avoid "this ⊠" from happening). 269 275 * 270 276 * @access public … … 272 278 * @param int $len Maximum string length. 273 279 * @param string $where Where to cut the string. One of: 'start', 'middle', or 'end'. 274 * @return string Truncated output string 280 * @return string Truncated output string. 275 281 * @author Quinn Comendant <quinn@strangecode.com> 276 282 * @since 29 Mar 2006 13:48:49 277 283 */ 278 function truncate($str, $len, $where='end', $delim='âŠ') 279 { 280 if ($len <= 3 || mb_strlen($str) <= 3) { 281 return ''; 282 } 283 $part1 = floor(($len - 3) / 2); 284 $part2 = ceil(($len - 3) / 2); 284 function truncate($str, $len=50, $where='end', $delim='âŠ') 285 { 286 $dlen = mb_strlen($delim); 287 if ($len <= $dlen || mb_strlen($str) <= $dlen) { 288 return substr($str, 0, $len); 289 } 290 $part1 = floor(($len - $dlen) / 2); 291 $part2 = ceil(($len - $dlen) / 2); 285 292 switch ($where) { 286 293 case 'start' : 287 return preg_replace(array(sprintf('/^.{4,}(.{%s})$/sU', $part1 + $part2), '/\s*\.{3,}\s*/sU'), array($delim . '$1', $delim), $str); 288 break; 294 return preg_replace(array(sprintf('/^.{%s,}(.{%s})$/sU', $dlen + 1, $part1 + $part2), sprintf('/\s*%s{%s,}\s*/sU', preg_quote($delim), $dlen)), array($delim . '$1', $delim), $str); 295 296 case 'middle' : 297 return preg_replace(array(sprintf('/^(.{%s}).{%s,}(.{%s})$/sU', $part1, $dlen + 1, $part2), sprintf('/\s*%s{%s,}\s*/sU', preg_quote($delim), $dlen)), array('$1' . $delim . '$2', $delim), $str); 298 299 case 'end' : 289 300 default : 290 case 'middle' : 291 return preg_replace(array(sprintf('/^(.{%s}).{4,}(.{%s})$/sU', $part1, $part2), '/\s*\.{3,}\s*/sU'), array('$1' . $delim . '$2', $delim), $str); 292 break; 293 case 'end' : 294 return preg_replace(array(sprintf('/^(.{%s}).{4,}$/sU', $part1 + $part2), '/\s*\.{3,}\s*/sU'), array('$1' . $delim, $delim), $str); 295 break; 301 return preg_replace(array(sprintf('/^(.{%s}).{%s,}$/sU', $part1 + $part2, $dlen + 1), sprintf('/\s*%s{%s,}\s*/sU', preg_quote($delim), $dlen)), array('$1' . $delim, $delim), $str); 296 302 } 297 303 } … … 307 313 * @since 06 Dec 2008 17:04:01 308 314 */ 309 if (!function_exists('mb_ucfirst')) { 315 if (!function_exists('mb_ucfirst')) { 310 316 function mb_ucfirst($string) 311 317 { … … 326 332 * @since 20 Jan 2013 12:33:26 327 333 */ 328 if (!function_exists('mb_strtr')) { 334 if (!function_exists('mb_strtr')) { 329 335 function mb_strtr($string, $from, $to) 330 336 { … … 367 373 /* 368 374 * Returns a human readable amount of time for the given amount of seconds. 369 * 375 * 370 376 * 45 seconds 371 377 * 12 minutes … … 374 380 * 1 week 375 381 * 4 months 376 * 382 * 377 383 * Months are calculated using the real number of days in a year: 365.2422 / 12. 378 384 * … … 400 406 'century' => array(3155692608, _("century"), _("centuries")), 401 407 ); 402 408 403 409 // Max unit to calculate. 404 410 $max_unit = isset($units[$max_unit]) ? $max_unit : 'year'; … … 416 422 } 417 423 $final_time = sprintf($format, $final_time); 418 return sprintf('%s %s', $final_time, (1 == $final_time ? $units[$final_unit][1] : $units[$final_unit][2])); 424 return sprintf('%s %s', $final_time, (1 == $final_time ? $units[$final_unit][1] : $units[$final_unit][2])); 419 425 } 420 426 … … 430 436 { 431 437 $app =& App::getInstance(); 432 438 433 439 foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) { 434 440 $fullpath = $path . DIRECTORY_SEPARATOR . $file; … … 680 686 * escaped. This is useful for putting values coming in from posted 681 687 * checkboxes into a SET column of a database. 682 * 688 * 683 689 * 684 690 * @param array $in Array to convert. … … 688 694 { 689 695 $db =& DB::getInstance(); 690 696 691 697 if (is_array($in) && !empty($in)) { 692 698 return join($separator, array_map(array($db, 'escapeString'), $in)); … … 839 845 { 840 846 $app =& App::getInstance(); 841 847 842 848 if ('' == trim($val)) { 843 849 $app->logMsg(sprintf('Cannot add signature to an empty string.', null), LOG_INFO, __FILE__, __LINE__); … … 848 854 $salt = $app->getParam('signing_key'); 849 855 } 850 856 851 857 // TODO: consider using more bits-per-character, such as done with: 852 858 // http://www.php.net/manual/en/function.sha1.php#86239 … … 916 922 { 917 923 $app =& App::getInstance(); 918 924 919 925 $add_members = '/usr/lib/mailman/bin/add_members'; 920 926 /// FIXME: checking of executable is disabled. … … 948 954 { 949 955 $app =& App::getInstance(); 950 956 951 957 $remove_members = '/usr/lib/mailman/bin/remove_members'; 952 958 /// FIXME: checking of executable is disabled.
Note: See TracChangeset
for help on using the changeset viewer.