Skip to content

Instantly share code, notes, and snippets.

@dtinth
Created July 14, 2010 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtinth/475437 to your computer and use it in GitHub Desktop.
Save dtinth/475437 to your computer and use it in GitHub Desktop.
// find links to convert
if (strstr($msg, 'http://'))
{
$links = array();
foreach (explode(' ', $msg) as $w)
if (substr($w, 0, 7) == 'http://' && $smcFunc['strlen']($w) > 7)
$links[] = '<a href="' . $w . '" target="_blank">' . ($smcFunc['strlen']($w) > $shoutbox['maxLinkLenght'] ? substr($w, 0, $shoutbox['maxLinkLenght'] - 8) . '...' . substr($w, -8) : $w) . '</a>';
else
$links[] = $w;
$msg = implode(' ', $links);
}
// find links to convert
if (strstr($msg, 'http://'))
{
$links = array();
foreach (explode(' ', $msg) as $w) {
$lhtml = ($func['strlen']($w) > $shoutbox['maxLinkLenght'] ? substr($w, 0, $shoutbox['maxLinkLenght'] - 8) . '...' . substr($w, -8) : $w);
$ext = strtolower(substr($w, -4));
if ($ext == '.jpg' || $ext == '.png' || $ext == '.gif')
$lhtml = '<span><i>Loading Image...</i></span><img style="display:none" onload="if(this.height>400)this.height=300;else if(this.width>400)this.width=400;this.style.display=&quot;inline&quot;;this.previousSibling.style.display=&quot;none&quot;;document.getElementById(&quot;shoutbox_banned&quot;).scrollTop+=this.offsetHeight" src="' . $w . '" alt="Image"/>';
if (substr($w, 0, 7) == 'http://' && $func['strlen']($w) > 7)
$links[] = '<a href="' . $w . '" target="_blank">' . $lhtml . '</a>';
else
$links[] = $w;
}
$msg = implode(' ', $links);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment