function nnmclub($text, $curl = null, $tracker_data = null)
{
// ------------------- Convert encoding -------------------
$text = mb_convert_encoding($text, "UTF-8", "windows-1251");
// ------------------- Get title -------------------
preg_match("#<title>(.*?) :: NNM-Club</title>#s", $text, $matches);
$title = isset($matches[1]) ? trim($matches[1]) : "";
// ------------------- Get download link -------------------
preg_match("#download\.php\?id=(\d+)#", $text, $matches);
$torrent = isset($matches[1]) ? $matches[1] : "";
// ------------------- Get content -------------------
preg_match('#<div class="postbody"[^>]*>(.*?)</div>#s', $text, $matches);
$content = isset($matches[1]) ? $matches[1] : "";
// Декодируем HTML сущности
$content = html_entity_decode($content, ENT_QUOTES | ENT_HTML401, "UTF-8");
$content = str_replace(" ", " ", $content);
$content = str_replace(":", ":", $content);
// Конвертация специфичных элементов nnmclub
$content = preg_replace(
'#<var class="postImg[^"]*" title="([^"]*)">[^<]*</var>#i',
'[img]$1[/img]',
$content,
);
$content = preg_replace(
'#<a href="([^"]*)"[^>]*class="highslide"[^>]*><var class="postImg[^"]*" title="([^"]*)">[^<]*</var></a>#i',
'[url=$1][img]$2[/img][/url]',
$content,
);
$content = preg_replace("#<meta[^>]*/?>#i", "", $content);
// Конвертация спойлеров
$content = preg_replace(
'#<div class="hide spoiler-wrap">.*?<div class="hide spoiler-body" title="([^"]*)"[^>]*>(.*?)</div>.*?</div>#is',
'[spoiler="$1"]$2[/spoiler]',
$content,
);
$content = preg_replace(
'#<div class="spoiler-wrap"[^>]*onmousedown[^>]*>.*?</div>#is',
"",
$content,
); // Удаляем список файлов
$content = preg_replace(
'#<div class="spoiler-wrap"[^>]*>.*?<div class="spoiler-head">([^<]*)</div>.*?</div>#is',
'$1',
$content,
);
// Конвертация цитат
$content = preg_replace(
'#<table[^>]*class="qt"[^>]*>.*?<td[^>]*><span[^>]*><b>([^<]*) пишет\(а\):[^<]*</span></td>.*?<td class="quote"><div class="q">(.*?)</div></td>.*?</table>#is',
'[quote="$1"]$2[/quote]',
$content,
);
// Базовая конвертация
$content = preg_replace("#<br\s*/?>#i", "\n", $content);
$content = preg_replace("#<hr\s*/?>#i", "[hr]", $content);
$content = preg_replace("#<script[^>]*>.*?</script>#is", "", $content);
$content = preg_replace("#<style[^>]*>.*?</style>#is", "", $content);
// Конвертация форматирования в цикле
for ($i = 0; $i <= 20; $i++) {
$content = preg_replace("#<b[^>]*>(.*?)</b>#is", '[b]$1[/b]', $content);
$content = preg_replace(
"#<strong[^>]*>(.*?)</strong>#is",
'[b]$1[/b]',
$content,
);
$content = preg_replace("#<i[^>]*>(.*?)</i>#is", '[i]$1[/i]', $content);
$content = preg_replace(
"#<em[^>]*>(.*?)</em>#is",
'[i]$1[/i]',
$content,
);
$content = preg_replace("#<u[^>]*>(.*?)</u>#is", '[u]$1[/u]', $content);
$content = preg_replace("#<s[^>]*>(.*?)</s>#is", '[s]$1[/s]', $content);
$content = preg_replace(
"#<strike[^>]*>(.*?)</strike>#is",
'[s]$1[/s]',
$content,
);
$content = preg_replace(
'#<span[^>]*style="[^"]*color:\s*([^;"]*)[^"]*"[^>]*>(.*?)</span>#is',
'[color=$1]$2[/color]',
$content,
);
$content = preg_replace(
'#<span[^>]*style="[^"]*font-weight:\s*bold[^"]*"[^>]*>(.*?)</span>#is',
'[b]$1[/b]',
$content,
);
$content = preg_replace(
'#<span[^>]*style="[^"]*font-style:\s*italic[^"]*"[^>]*>(.*?)</span>#is',
'[i]$1[/i]',
$content,
);
$content = preg_replace(
'#<span[^>]*style="[^"]*font-size:\s*(\d+)px[^"]*"[^>]*>(.*?)</span>#is',
'[size=$1]$2[/size]',
$content,
);
$content = preg_replace(
'#<span[^>]*style="[^"]*font-family:\s*([^;"]*)[^"]*"[^>]*>(.*?)</span>#is',
'[font="$1"]$2[/font]',
$content,
);
$content = preg_replace(
'#<span[^>]*style="[^"]*text-align:\s*center[^"]*"[^>]*>(.*?)</span>#is',
'[align=center]$1[/align]',
$content,
);
$content = preg_replace(
'#<font[^>]*color="([^"]*)"[^>]*>(.*?)</font>#is',
'[color=$1]$2[/color]',
$content,
);
$content = preg_replace(
'#<font[^>]*size="([^"]*)"[^>]*>(.*?)</font>#is',
'[size=$1]$2[/size]',
$content,
);
$content = preg_replace(
'#<font[^>]*style="font-size:\s*([^"]*?)pt"[^>]*>(.*?)</font>#is',
'[size=$1]$2[/size]',
$content,
);
$content = preg_replace(
'#<a[^>]*href="([^"]*)"[^>]*>(.*?)</a>#is',
'[url=$1]$2[/url]',
$content,
);
}
$content = preg_replace(
'#<img[^>]*src="([^"]*)"[^>]*/?>#i',
'[img]$1[/img]',
$content,
);
$content = preg_replace(
"#<center[^>]*>(.*?)</center>#is",
'[align=center]$1[/align]',
$content,
);
$content = preg_replace(
"#<blockquote[^>]*>(.*?)</blockquote>#is",
'[quote]$1[/quote]',
$content,
);
$content = preg_replace(
"#<ul[^>]*>(.*?)</ul>#is",
'[list]$1[/list]',
$content,
);
$content = preg_replace(
"#<ol[^>]*>(.*?)</ol>#is",
'[list=1]$1[/list]',
$content,
);
$content = preg_replace("#<li[^>]*>(.*?)</li>#is", '[*]$1', $content);
// Удаляем HTML теги
$content = preg_replace(
"#<noindex[^>]*>(.*?)</noindex>#is",
'$1',
$content,
);
$content = preg_replace(
'#<div[^>]*class="clear"[^>]*></div>#i',
"",
$content,
);
$content = preg_replace("#<div[^>]*>(.*?)</div>#is", '$1', $content);
$content = preg_replace("#<span[^>]*>(.*?)</span>#is", '$1', $content);
$content = preg_replace("#<p[^>]*>(.*?)</p>#is", '$1' . "\n\n", $content);
$content = preg_replace("#<table[^>]*>.*?</table>#is", "", $content);
$content = preg_replace("#<[^>]+>#", "", $content);
// Очистка битых BB-кодов
$content = preg_replace("#\[url=[^\]]*\]\[/url\]#", "", $content);
$content = preg_replace("#\[img\]\[/img\]#", "", $content);
// Очистка
$content = preg_replace('/\n{3,}/', "\n\n", $content);
$content = preg_replace('/([\r\n])[\s]+/is', "\\1", $content);
$content = trim($content);
// Вставка плеера
if (function_exists("insert_video_player")) {
insert_video_player($content);
}
return [
"title" => $title,
"torrent" => $torrent,
"content" => $content,
];
}