bbcode url reverse help!
Started on the old forum in March 2012 · view the original in the archive · old links redirect here
$text = preg_replace("/<a href=\"(.*?)\">(.*?)<\/a>/is","[url=$1]$2[/url]",$text);
but far better off not saving it in database as html
something else wrote: but far better off not saving it in database as html
any problem/exploit can be happen if i use saving as html in database? i use htmlspecialchars() while input in database and htmlspecialchars_decode() to show in front end. please reply
na should be fine .... it just means your having to store more than you need in your database 🙂
pls does any one have johncms 4.4.0 bbcode for titled link, i.e if i post a link 9jamobile.net - File host it wil replace it to the site title
Added after 8 minutes:
just like what has happend above
asifnayem wrote: then what should i do to leverage this? btw, i also can't reverse the img bbcode
please reverse this.
$text = preg_replace("/<img src=\"(.*?)\" alt=\"(.*?)\"\/>/is","[img]$1[/img]",$text);
You may have to alter it slightly depending on number of space in your <img> tag
Added after 11 minutes:
bestman wrote: pls does any one have johncms 4.4.0 bbcode for titled link, i.e if i post a link 9jamobile.net - File host it wil replace it to the site title
Added after 8 minutes:
just like what has happend above
heres with DOM :
function gettitle($url)
{
$dom = new DOMDocument();
if($dom->loadHTMLFile($url))
{
$list = $dom->getElementsByTagName("title");
if ($list->length > 0)
{
return $list->item(0)->textContent;
}
}
}
$in=array('`((?:https?|ftp)://\S+[[:alnum:]]/?)`si','`((?<!//)(www\.\S+[[:alnum:]]/?))`si');
$out=array('<a href="$1">'.gettitle($1).'</a>','<a href="http://$1">'.gettitle('http://'.$1).'</a>');
$text = preg_replace($in,$out,$text);
//ugh some bug with opera doesnt let you see end of php file on this forum so i put this comment in there just so i can see the bottom line
otherwise you would have to use curl or get_file_contents()
something else wrote: heres with DOM :
function gettitle($url) { $dom = new DOMDocument(); if($dom->loadHTMLFile($url)) { $list = $dom->getElementsByTagName("title"); if ($list->length > 0) { return $list->item(0)->textContent; } } } $in=array('`((?:https?|ftp)://\S+[[:alnum:]]/?)`si','`((?<!//)(www\.\S+[[:alnum:]]/?))`si'); $out=array('<a href="$1">'.gettitle($1).'</a>','<a href="http://$1">'.gettitle('http://'.$1).'</a>'); $text = preg_replace($in,$out,$text); //ugh some bug with opera doesnt let you see end of php file on this forum so i put this comment in there just so i can see the bottom lineotherwise you would have to use curl or get_file_contents()
oops wont work with array but you can use the dom function to add to a different auto url bb 🙂
something else wrote: You may have to alter it slightly depending on number of space in your <img> tag
i am using this
$text = preg_replace("/\[img\](.*?)\[\/img\]/", "<img src=\"http://localhost/blog/thumb.php?image=$1&w=150&h=150\" alt='*' class='imf'/>", $text);
its not working then i use
$text = preg_replace("/<img src=\"(.*?)\" alt=\"(.*?)\" class=\"imf\"\/>/is","[img]$1[/img]",$text);
it shows the whole http://localhost/blog/............
Hi i found this html code for the live traffic feed. i want this converted to BBcode so that i can put ot on a site that supports only BBcode,. say a site like songs - Listen to free music.. I need help. Can someone help me out with converting this html to BBcode. i tried a few online converters.. but none of them work..
this is the code..
<script type="text/javascript" src="http://feedjit.com/serve/?vv=693&tf… href="http://feedjit.com/">Feedjit Live Blog Stats</a></noscript>