Changeset 845 in ExiteCMS
- Timestamp:
- 09/28/07 00:02:59 (4 years ago)
- Location:
- trunk/includes
- Files:
-
- 3 edited
-
core_functions.php (modified) (2 diffs)
-
forum_functions_include.php (modified) (1 diff)
-
templates/forum.renderpost.tpl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/core_functions.php
r843 r845 268 268 269 269 // Trim a line of text to a preferred length 270 function trimlink($text, $length ) {270 function trimlink($text, $length, $filler="...") { 271 271 $dec = array("\"", "'", "\\", '\"', "\'", "<", ">"); 272 272 $enc = array(""", "'", "\", """, "'", "<", ">"); 273 273 $text = str_replace($enc, $dec, $text); 274 if (strlen($text) > $length) $text = substr($text, 0, ($length-3)). "...";274 if (strlen($text) > $length) $text = substr($text, 0, ($length-3)).$filler; 275 275 $text = str_replace($dec, $enc, $text); 276 276 return $text; 277 } 278 279 // Trim a URI to a preferred length by cutting out the middle (preserve the hostname if possible) 280 function shortenlink($text, $length, $filler="...") { 281 282 $dec = array("\"", "'", "\\", '\"', "\'", "<", ">"); 283 $enc = array(""", "'", "\", """, "'", "<", ">"); 284 $returner = str_replace($enc, $dec, $text); 285 if (strlen($returner) > $length) { 286 $url = preg_match("=[^/]/[^/]=",$returner,$treffer,PREG_OFFSET_CAPTURE); 287 $cutpos = $treffer[0][1]+2; 288 $part[0] = substr($returner,0,$cutpos); 289 $part[1] = substr($returner,$cutpos); 290 $strlen1 = $cutpos; 291 if ($strlen1 > $length) { 292 $returner = substr($returner,0,$length-3).$filler; 293 } else { 294 $strlen2 = strlen($part[1]); 295 $cutpos = $strlen2-($length-3-$strlen1); 296 $returner = $part[0].$filler.substr($part[1],$cutpos); 297 } 298 } 299 $returner = str_replace($dec, $enc, $returner); 300 return $returner; 277 301 } 278 302 … … 490 514 $text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\'\";]*?)\](.*?)([\r\n]*)\[/url\]#si', '<a href=\'\2\3\' target=\'_blank\'>\4</a>', $text); 491 515 $text = preg_replace('#\[url=([\r\n]*)([^\s\'\";\+]*?)\](.*?)([\r\n]*)\[/url\]#si', '<a href=\'http://\2\' target=\'_blank\'>\3</a>', $text); 492 516 493 517 $text = preg_replace('#\[mail\]([\r\n]*)([^\s\'\";:\+]*?)([\r\n]*)\[/mail\]#si', '<a href=\'mailto:\2\'>\2</a>', $text); 494 518 $text = preg_replace('#\[mail=([\r\n]*)([^\s\'\";:\+]*?)\](.*?)([\r\n]*)\[/mail\]#si', '<a href=\'mailto:\2\'>\2</a>', $text); -
trunk/includes/forum_functions_include.php
r834 r845 297 297 if (strlen($rawmsg)) $message .= $rawmsg; 298 298 299 // find URL's in the text, and convert them to a [url] BBcode 300 $message = preg_replace("#(^|\s)(www|WWW)\.([^\s<>\/]+)\/([^\s\r\n<>\)\,\:\;\[]+)#sm", "\\1[url=http://\\2.\\3/\\4]http://\\2.\\3[/url]", $message); 301 $message = preg_replace("#(^|[^\"=\]]{1})(http|HTTP|ftp)(s|S)?://([^\s<>\/]+)\/([^\s\r\n<>\)\,\:\;\[]+)#sm", "\\1[url=\\2\\3://\\4/\\5]\\2\\3://\\4[/url]", $message); 299 // Split off the [url] blocks to exclude them from url parsing 300 $rawmsg = $message; 301 $message = ""; 302 $urlblocks = array(); 303 304 // find the code [url] occurence 305 $i = strpos($rawmsg, "[url"); 306 307 // loop through the message until all are found and processed 308 while ($i !== false) { 309 // strip the bit before the [url] BBcode, and add a placeholder 310 $message .= substr($rawmsg, 0, $i+4)."{@@**@@}"; 311 // strip the processed bit 312 $rawmsg = substr($rawmsg, $i+4); 313 // find the end of the [url] block 314 $j = strpos($rawmsg, "[/url]"); 315 // if not found, add the remaining bit, a forced [/url], and stop processing 316 if ($j === false) { 317 $message = str_replace("{@@**@@}", $rawmsg, $message); 318 break; 319 } 320 // store this url block 321 $urlblocks[] = substr($rawmsg, 0, $j); 322 // strip the processed bit 323 $rawmsg = substr($rawmsg, $j); 324 // check if there are more code segments 325 $i = strpos($rawmsg, "[url"); 326 } 327 328 // any text left? 329 if (strlen($rawmsg)) $message .= $rawmsg; 330 331 // find remaining URL's in the text, and convert them to a href as well 332 $pattern = '#(^|[^\"=]{1})(https?://|ftp://|mailto:|news:)([^(,\s<>\[\]\)]+)([,\s\n<>\)]|$)#sme'; 333 $message = preg_replace($pattern,"'$1<a href=\'$2$3\' target=\'_blank\'>'.shortenlink('$2$3',75).'</a>$4'",$message); 334 335 // re-insert the saved url blocks 336 foreach($urlblocks as $urlblock) { 337 // find the first placeholder 338 $i = strpos($message, "{@@**@@}"); 339 $message = substr($message, 0, $i).$urlblock.substr($message, $i+8); 340 } 302 341 303 342 // parse the message, and convert all BBcode found -
trunk/includes/templates/forum.renderpost.tpl
r843 r845 16 16 {***************************************************************************} 17 17 <tr> 18 <td class='tbl1' colspan=' 3' height='5'>18 <td class='tbl1' colspan='4' height='5'> 19 19 <a name='post_{$posts[pid].post_id}' id='post_{$posts[pid].post_id}'></a> 20 20 </td> … … 37 37 {/if} 38 38 </td> 39 <td class='tbl_top_ right' style='text-align:right;'>39 <td class='tbl_top_mid' style='text-align:right;'> 40 40 {if $smarty.const.iMEMBER && $user_can_post} 41 41 {if $posts[pid].user_can_edit} … … 52 52 {buttonlink name=$locale.569 link="post.php?action=quote&forum_id="|cat:$forum_id|cat:"&thread_id="|cat:$posts[pid].thread_id|cat:"&reply_id="|cat:$posts[pid].post_id} 53 53 {/if} 54 {/if} 55 </td> 56 <td width='1%' class='tbl_top_right'> 54 57 {if $posts[pid].show_ip} 55 58 {if $user_can_blacklist} … … 61 64 {/if} 62 65 {/if} 63 {/if}64 66 </td> 65 67 </tr> … … 123 125 <span class='alt'>{$locale.504}</span> {$posts[pid].user_joined|date_format:"%d.%m.%y"} 124 126 </td> 125 <td valign='top' colspan=' 2' height='{$height}' class='{if $posts[pid].unread}unread{else}tbl_right{/if}' style='border-bottom:none;'>127 <td valign='top' colspan='3' height='{$height}' class='{if $posts[pid].unread}unread{else}tbl_right{/if}' style='border-bottom:none;'> 126 128 {$posts[pid].post_message|default:" "} 127 129 {section name=id loop=$posts[pid].attachments} … … 146 148 <td> 147 149 {if $smarty.const.DOWNLOAD_IMAGES} 148 <a href='{$smarty.const.BASEDIR}getfile.php?type=a&file_id={$posts[pid].attachments[id].attach_id}' alt='{$posts[pid].attachments[id].attach_comment}'>{$posts[pid].attachments[id].attach_realname}150 <a href='{$smarty.const.BASEDIR}getfile.php?type=a&file_id={$posts[pid].attachments[id].attach_id}' title='{$posts[pid].attachments[id].attach_comment}'>{$posts[pid].attachments[id].attach_realname} 149 151 {else} 150 152 <a href='{$posts[pid].attachments[id].link}' alt='{$posts[pid].attachments[id].attach_comment}' target='_blank'>{$posts[pid].attachments[id].attach_realname} … … 161 163 {else} 162 164 {if $smarty.const.DOWNLOAD_IMAGES} 163 <a href='{$smarty.const.BASEDIR}getfile.php?type=a&file_id={$posts[pid].attachments[id].attach_id}' alt='{$posts[pid].attachments[id].attach_comment}'>{$posts[pid].attachments[id].attach_realname}</a> ({$posts[pid].attachments[id].imagesize.x} x {$posts[pid].attachments[id].imagesize.y} {$locale.518})165 <a href='{$smarty.const.BASEDIR}getfile.php?type=a&file_id={$posts[pid].attachments[id].attach_id}' title='{$posts[pid].attachments[id].attach_comment}'>{$posts[pid].attachments[id].attach_realname}</a> ({$posts[pid].attachments[id].imagesize.x} x {$posts[pid].attachments[id].imagesize.y} {$locale.518}) 164 166 {else} 165 167 <a href='{$posts[pid].attachments[id].link}' alt='{$posts[pid].attachments[id].attach_comment}' target='_blank'>{$posts[pid].attachments[id].attach_realname}</a> ({$posts[pid].attachments[id].imagesize.x} x {$posts[pid].attachments[id].imagesize.y} {$locale.518}) … … 171 173 {$posts[pid].attachments[id].attach_realname} ( {$posts[pid].attachments[id].size} ) 172 174 {else} 173 <a href='{$smarty.const.BASEDIR}getfile.php?type=a&file_id={$posts[pid].attachments[id].attach_id}' alt='{$posts[pid].attachments[id].attach_comment}'>{$posts[pid].attachments[id].attach_realname}</a> ( {$posts[pid].attachments[id].size} )175 <a href='{$smarty.const.BASEDIR}getfile.php?type=a&file_id={$posts[pid].attachments[id].attach_id}' title='{$posts[pid].attachments[id].attach_comment}'>{$posts[pid].attachments[id].attach_realname}</a> ( {$posts[pid].attachments[id].size} ) 174 176 {/if} 175 177 … … 230 232 {/if} 231 233 </td> 232 <td colspan=' 2' class='{if $posts[pid].unread}unread{else}tbl_right{/if}' style='border-top:none;'>234 <td colspan='3' class='{if $posts[pid].unread}unread{else}tbl_right{/if}' style='border-top:none;'> 233 235 {if $posts[pid].post_showsig && $posts[pid].user_sig|default:"" != ""} 234 236 <hr />
Note: See TracChangeset
for help on using the changeset viewer.
