- Timestamp:
- Mar 23, 2015 10:06:42 PM (9 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r504 r505 131 131 'error_reporting' => E_ALL, 132 132 133 // Don't display errors by default; it is preferable to log them to a file. 133 // Don't display errors by default; it is preferable to log them to a file. For CLI scripts, set this to the string 'stderr'. 134 134 'display_errors' => false, 135 135 … … 224 224 // Merge new parameters with old overriding only those passed. 225 225 $this->_params = array_merge($this->_params, $param); 226 227 if ($this->running) { 228 // Params that require processing if changed during runtime. 229 foreach ($param as $key => $val) { 230 switch ($key) { 231 case 'session_name': 232 session_name($val); 233 break; 234 235 case 'session_use_cookies': 236 ini_set('session.use_cookies', $val); 237 break; 238 239 case 'error_reporting': 240 ini_set('error_reporting', $val); 241 break; 242 243 case 'display_errors': 244 ini_set('display_errors', $val); 245 break; 246 247 case 'log_errors': 248 ini_set('log_errors', true); 249 break; 250 251 case 'log_directory': 252 if (is_dir($val) && is_writable($val)) { 253 ini_set('error_log', $val . '/' . $this->getParam('php_error_log')); 254 } 255 break; 256 } 257 } 258 } 226 259 } 227 260 } -
trunk/lib/Utilities.inc.php
r502 r505 135 135 136 136 /** 137 * Returns text with appropriate html translations .137 * Returns text with appropriate html translations (a smart wrapper for htmlspecialchars()). 138 138 * 139 139 * @param string $text Text to clean. … … 208 208 209 209 return preg_replace($search, $replace, $text); 210 } 211 212 /* 213 * Finds all URLs in text and hyperlinks them. 214 * 215 * @access public 216 * @param string $text Text to search for URLs. 217 * @param mixed $length Number of characters to truncate URL, or NULL to disable truncating. 218 * @param string $delim Delimiter to append, indicate truncation. 219 * @return string Same input text, but URLs hyperlinked. 220 * @author Quinn Comendant <quinn@strangecode.com> 221 * @version 1.0 222 * @since 22 Mar 2015 23:29:04 223 */ 224 function hyperlinkTxt($text, $length=null, $delim='âŠ') 225 { 226 return preg_replace_callback( 227 // Inspired by @stephenhay's regex from https://mathiasbynens.be/demo/url-regex 228 // Here we capture the full URL into the first match and only the first X characters into the second match. 229 sprintf('@\b(?<!")(?<!\')(?<!=)(((?:https?|s?ftps?)://[^\s/$.?#].[^\s]{0,%s})[^\s]*)@iS', $length), 230 // Use an anonymous function to decide when to append the delim. 231 // Also encode special chars with oTxt(). 232 function ($m) use ($length, $delim) { 233 if (is_null($length) || $m[1] == $m[2]) { 234 // If not truncating, or URL was not truncated. 235 return sprintf('<a href="%s">%s</a>', oTxt($m[1]), oTxt($m[1])); 236 } else { 237 // Truncated URL. 238 return sprintf('<a href="%s">%s%s</a>', oTxt($m[1]), oTxt(trim($m[2])), $delim); 239 } 240 }, 241 $text 242 ); 210 243 } 211 244
Note: See TracChangeset
for help on using the changeset viewer.