![]() |
|
![]() |
||||||
![]() |
Искал функцию для конвертирования html кода в bbcode, но так и не нашел подходящую, пришлось написать самому. Функция неполная, но ее легко дополнить нужными тегами или модифицировать. peter
[Добавлено 26.04.2010 20:58:55]
Вери сенкс peter
[Добавлено 26.04.2010 21:09:50]
Жаль что много мусорного кода остаётся peter
[Добавлено 27.04.2010 01:08:15]
Вот мой кодер ту bb-code: Лучше не чего не трогать:) Хлипко держится. Простите меня заранее:) Можно добавить <script и <style если спарсена страница: //attributes $text = preg_replace('(style=["\'].*?["\'])is', '', $text); $text = preg_replace('(height=["\'].*?["\'])is', '', $text); $text = preg_replace('(width=["\'].*?["\'])is', '', $text); $text = preg_replace('(title=["\'].*?["\'])is', '', $text); $text = preg_replace('(alt=["\'].*?["\'])is', '', $text); $text = preg_replace('(class=["\'].*?["\'])is', '', $text); $text = preg_replace('(id=["\'].*?["\'])is', '', $text); $text = preg_replace('(target=["\'].*?["\'])is', '', $text); //events $text = preg_replace('(onAbort=["\'].*?["\'])is', '', $text); $text = preg_replace('(onBlur=["\'].*?["\'])is', '', $text); $text = preg_replace('(onChange=["\'].*?["\'])is', '', $text); $text = preg_replace('(onClick=["\'].*?["\'])is', '', $text); $text = preg_replace('(onCopy=["\'].*?["\'])is', '', $text); $text = preg_replace('(onCut=["\'].*?["\'])is', '', $text); $text = preg_replace('(onDblClick=["\'].*?["\'])is', '', $text); $text = preg_replace('(onDrag=["\'].*?["\'])is', '', $text); $text = preg_replace('(onDragEnter=["\'].*?["\'])is', '', $text); $text = preg_replace('(onDragLeave=["\'].*?["\'])is', '', $text); $text = preg_replace('(onDragOver=["\'].*?["\'])is', '', $text); $text = preg_replace('(onDragStart=["\'].*?["\'])is', '', $text); $text = preg_replace('(onDrop=["\'].*?["\'])is', '', $text); $text = preg_replace('(onDragDrop=["\'].*?["\'])is', '', $text); $text = preg_replace('(onError=["\'].*?["\'])is', '', $text); $text = preg_replace('(onFocus=["\'].*?["\'])is', '', $text); $text = preg_replace('(onKeyDown=["\'].*?["\'])is', '', $text); $text = preg_replace('(onKeyPress=["\'].*?["\'])is', '', $text); $text = preg_replace('(onKeyUp=["\'].*?["\'])is', '', $text); $text = preg_replace('(onLoad=["\'].*?["\'])is', '', $text); $text = preg_replace('(OnLoseCapture=["\'].*?["\'])is', '', $text); $text = preg_replace('(onMouseDown=["\'].*?["\'])is', '', $text); $text = preg_replace('(onMouseEnter=["\'].*?["\'])is', '', $text); $text = preg_replace('(onMouseLeave=["\'].*?["\'])is', '', $text); $text = preg_replace('(onMouseMove=["\'].*?["\'])is', '', $text); $text = preg_replace('(onMouseOut=["\'].*?["\'])is', '', $text); $text = preg_replace('(onMouseOver=["\'].*?["\'])is', '', $text); $text = preg_replace('(onMouseUp=["\'].*?["\'])is', '', $text); $text = preg_replace('(onSelect=["\'].*?["\'])is', '', $text); //simple tags $text = str_replace('<h6>', '[h]', $text); $text = str_replace('</h6>', '[/h]', $text); $text = str_replace('<h5>', '[h]', $text); $text = str_replace('</h5>', '[/h]', $text); $text = str_replace('<h4>', '[h]', $text); $text = str_replace('</h4>', '[/h]', $text); $text = str_replace('<h3>', '[h]', $text); $text = str_replace('</h3>', '[/h]', $text); $text = str_replace('<h1>', '[h]', $text); $text = str_replace('</h1>', '[/h]', $text); $text = str_replace('<h2>', '[h]', $text); $text = str_replace('</h2>', '[/h]', $text); $text = str_replace('</td>', '', $text); $text = str_replace('</tr>', '', $text); $text = str_replace('</td >', '', $text); $text = str_replace('</tr >', '', $text); $text = str_replace('</table>', '', $text); $text = str_replace('</tbody>', '', $text); $text = str_replace('</span>', '', $text); $text = str_replace('<sup>', '', $text); $text = str_replace('<tbody', '', $text); $text = str_replace('<table', '', $text); $text = str_replace('<td >', '', $text); $text = str_replace('<tr >', '', $text); $text = str_replace('<td ', '', $text); $text = str_replace('<tr ', '', $text); $text = str_replace('<td>', '', $text); $text = str_replace('<tr>', '', $text); $text = str_replace('<span>', '', $text); $text = str_replace('<strong>', '[b]', $text); $text = str_replace('<strong />', '[/b]', $text); $text = str_replace('<strong>', '[b]', $text); $text = str_replace('</strong>', '[/b]', $text); $text = str_replace('<br>', ' ', $text); $text = str_replace('<br />', ' ', $text); $text = str_replace('<b>', '[b]', $text); $text = str_replace('</b>', '[/b]', $text); $text = str_replace('<p>', ' ', $text); $text = str_replace('<p />', ' ', $text); $text = str_replace('<p>', ' ', $text); $text = str_replace('</p>', ' ', $text); $text = str_replace('<img', '', $text); $text = str_replace('<p', '', $text); $text = str_replace('<a', '', $text); $text = str_replace('<div', ' ', $text); $text = str_replace('</div', ' ', $text); //not simple tags $text = preg_replace('(href=["\'](.*?)["\'] >(.*?)<\/a)is', "[url=http://best-game.info/go/?\$1]\$2[/url]", $text); $text = preg_replace('(href=["\'](.*?)["\']>(.*?)<\/a)is', "[url=http://best-game.info/go/?\$1]\$2[/url]", $text); $text = preg_replace('(<img src=["\'](.*?)["\'])is', "[img]\$1]", $text); $text = preg_replace('(src=["\'](.*?)["\'])is',"[img]\$1[/img]", $text); $text = preg_replace('(border=["\'](.*?)["\'])is',"", $text); $text = preg_replace('<!--.*-->',"", $text); $text = preg_replace('(cellpadding=["\'](.*?)["\'])is',"", $text); $text = preg_replace('(cellspacing=["\'](.*?)["\'])is',"", $text); $text = preg_replace('(align=["\'].*?["\'])is', " ", $text); $text = preg_replace('("\'].*?["\'])is', " ", $text); //simple tags $text = str_replace('href="', '[url=http://best-game.info/go/?', $text); $text = str_replace('/a', ']', $text); $text = str_replace('/>', ' ', $text); $text = str_replace(' // ', '', $text); $text = str_replace('<', '', $text); $text = str_replace('>', '', $text); $text = str_replace('<>', '', $text); $text = str_replace(' ]', '', $text); $text = str_replace(' ]', '', $text); $text = str_replace(' ', '', $text); $text = str_replace(' ', '', $text); $text = str_replace(' ', '', $text); echo '</td><td><textarea rows="30" cols="55">'.$text.'</textarea></td></tr></tbody></table>'; echo '<br />'. " "; echo $str[0]; echo '<br />'. " "; $string_result = strip_tags($string_result); echo '<br />'. " "; |
Меню
Подписка на RSS:
Поиск
Облако тегов
.net
array
asp
bash
browser
charset
check
class
clean
convert
count
create
css
curl
database
date
delete
directory
download
element
email
equivalent
extension
file
find
form
format
function
get
height
html
http
ie
image
javascript
jquery
load
mysql
number
page
perl
php
random
scriplet
send
shell
size
sql
string
text
time
url
utf8
variable
vb
visual basic
width
window
xml
xslt
|
![]() |
![]() |
![]() |
||
![]() |
![]() |