[COLOR=#000000][B]function[/B][/COLOR] topnews_print ([COLOR=#000080][B]$custom_category[/B][/COLOR]){
[COLOR=#000000][B]global[/B][/COLOR] [COLOR=#000080][B]$db[/B][/COLOR];
[COLOR=#000080][B]$custom_category[/B][/COLOR] = [COLOR=#000080][B]$db[/B][/COLOR]->safesql([COLOR=#008080][B]str_replace[/B][/COLOR](',', '|', [COLOR=#000080][B]$custom_category[/B][/COLOR]));
[COLOR=#000000][B]if[/B][/COLOR](!defined('DATALIFEENGINE'))
{
die("Hacking attempt!");
}
[COLOR=#000080][B]$topnews[/B][/COLOR][COLOR=#000000] = [/COLOR]dle_cache("topnews", [COLOR=#000080][B]$config[/B][/COLOR]['skin']);
[COLOR=#000000][B]if[/B][/COLOR] (![COLOR=#000080][B]$topnews[/B][/COLOR]) {
[COLOR=#000080][B]$this_month[/B][/COLOR][COLOR=#000000] = [/COLOR]date ('Y-m-d', time()-(3600*24*27));
[COLOR=#000080][B]$db[/B][/COLOR]->query("SELECT id, title, date, alt_name FROM " . PREFIX . "_post WHERE approve='1' AND category regexp '[[:<:]]([COLOR=#000080][B]$custom_category[/B][/COLOR])[[:>:]]' AND date >= '[COLOR=#000080][B]$this_month[/B][/COLOR]'AND date < '[COLOR=#000080][B]$this_month[/B][/COLOR]' + INTERVAL 1 MONTH ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,10");
[COLOR=#000000][B]while[/B][/COLOR]([COLOR=#000080][B]$row[/B][/COLOR][COLOR=#000000] = [/COLOR][COLOR=#000080][B]$db[/B][/COLOR]->get_row()){
[COLOR=#000080][B]$row[/B][/COLOR]['date'][COLOR=#000000] = [/COLOR]strtotime([COLOR=#000080][B]$row[/B][/COLOR]['date']);
[COLOR=#000000][B]if[/B][/COLOR] ([COLOR=#008080][B]strlen[/B][/COLOR]([COLOR=#000080][B]$row[/B][/COLOR]['title']) > 55)
[COLOR=#000080][B]$title[/B][/COLOR][COLOR=#000000] = [/COLOR][COLOR=#008080][B]substr[/B][/COLOR] ([COLOR=#000080][B]$row[/B][/COLOR]['title'], 0, 55)." ...";
[COLOR=#000000][B]else[/B][/COLOR]
[COLOR=#000080][B]$title[/B][/COLOR][COLOR=#000000] = [/COLOR][COLOR=#000080][B]$row[/B][/COLOR]['title'];
[COLOR=#000080][B]$go_page[/B][/COLOR][COLOR=#000000] = [/COLOR]([COLOR=#000080][B]$config[/B][/COLOR]['ajax']) ? "onclick=\"DlePage('newsid=".[COLOR=#000080][B]$row[/B][/COLOR]['id']."'); [COLOR=#000000][B]return[/B][/COLOR] [COLOR=#000000][B]false[/B][/COLOR];\" " : "";
[COLOR=#000000][B]if[/B][/COLOR] ([COLOR=#000080][B]$config[/B][/COLOR]['allow_alt_url'][COLOR=#000000] == [/COLOR]"yes")
[COLOR=#000080][B]$link[/B][/COLOR][COLOR=#000000] = [/COLOR]"<a {[COLOR=#000080][B]$go_page[/B][/COLOR]}href=\"".[COLOR=#000080][B]$config[/B][/COLOR]['http_home_url'].date('Y/m/d/', [COLOR=#000080][B]$row[/B][/COLOR]['date']).[COLOR=#000080][B]$row[/B][/COLOR]['alt_name'].".html\">".[COLOR=#008080][B]stripslashes[/B][/COLOR]([COLOR=#000080][B]$title[/B][/COLOR])."</a>";
[COLOR=#000000][B]else[/B][/COLOR]
[COLOR=#000080][B]$link[/B][/COLOR][COLOR=#000000] = [/COLOR]"<a {[COLOR=#000080][B]$go_page[/B][/COLOR]}href=\"[COLOR=#000080][B]$PHP_SELF[/B][/COLOR]?newsid=".[COLOR=#000080][B]$row[/B][/COLOR]['id']."\">".[COLOR=#008080][B]stripslashes[/B][/COLOR]([COLOR=#000080][B]$title[/B][/COLOR])."</a>";
[COLOR=#000080][B]$topnews[/B][/COLOR] .= "» ".[COLOR=#000080][B]$link[/B][/COLOR]."<br />";
}
[COLOR=#000080][B]$db[/B][/COLOR]->free();
create_cache ("topnews", [COLOR=#000080][B]$topnews[/B][/COLOR], [COLOR=#000080][B]$config[/B][/COLOR]['skin']);
}
[COLOR=#000000][B]return[/B][/COLOR] [COLOR=#000080][B]$topnews[/B][/COLOR];
}