<?php
function makeClickableLinks($text)
{
$text = html_entity_decode($text);
$text = " ".$text;
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1" target=_blank>\\1</a>', $text);
$text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1" target=_blank>\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'\\1<a href="http://\\2" target=_blank>\\2</a>', $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
'<a href="mailto:\\1" target=_blank>\\1</a>', $text);
return $text;
}
$prefijo = substr(md5(uniqid(rand())),0,6);
$contenido=makeClickableLinks($_POST[comentarios]);
$fp=fopen("database/".$prefijo."_".$_POST["nombre"].".html","x");
fwrite($fp,$contenido);
fclose($fp) ;
echo "<center>Compartelo:<br>";
echo "Nombre del archivo:<span style='color:#fc0000;'> ".$prefijo."_".$_POST["nombre"]."</span><br>";
echo "Previsualiza el contenido: <br><iframe src='database/".$prefijo."_".$_POST["nombre"].".html' frameborder='0'></iframe><br>";
echo "</center>";
?>