<?php

	# mark core  v1.0
    # author Drk in
	# date 24.10.19 	

	# core

	require_once ( $_SERVER['DOCUMENT_ROOT']."/_core/system.php" );

	# meta

	$title = system::check($config['title']);
	$description = system::check($config['description']);
	$keywords = system::check($config['keywords']);
	$tl = null;
	
	# head

	require_once ( head );

    #  ADS
	
	echo '<div class="hide"><a href ="/pay/ads">Купить рекламу ('.DAYS.' руб.)</a>';

	$q_ads = DB :: $dbh -> query("SELECT id FROM ads WHERE time_end > ? ORDER BY RAND() LIMIT 6", array(time()));	

	while ($ads = $q_ads -> fetch()):

	$ads = cache_ads::get($ads['id']);		

	$name = ($ads['color'] != null ? '<font color="'.$ads['color'].'">':null).($ads['bold'] == 1 ? '<b>':null).
	($ads['italic'] == 1 ? '<i>':null).system::check($ads['name']).($ads['color'] != null ? '</font>':null).
	($ads['bold'] == 1 ? '</b>':null).($ads['italic'] == 1 ? '</i>':null);	
	
	echo '<a href ="'.system::check($ads['url']).'" target="_blank">'.$name.'</a><br>';

 	endwhile;	

	echo '</div>';

	# COLD

	$query = DB :: $dbh -> query("SELECT id FROM platforms WHERE mode = ? AND ban = ? AND gold > ?  ORDER BY RAND() LIMIT 2", array(0,0,time()));	

	while ($gold = $query -> fetch()):

	$gold = cache_pf::check($gold['id']);	

	echo '
	<div class ="hide">
	<img src="'.save_img::fav($gold['url']).'">
	<a referrerpolicy="origin" rel="nofollow" title="Посетить сайт '.system::check($gold['url']).'" href ="'.site.'ou/'.$gold['id'].'" target="_blank"><b>'.system::check($gold['url']).'</b></a> '.system::gold().'
	</div>
	';		

	endwhile;	

	echo '
	<table class="block_h" width="100%" style="padding: 2px;">
	<tbody><tr>
	<td><center><b>Топ-100</b></center></td> 
	<td><a href="'.site.'cat"><font color="white"><center>Категории</center></font></a></td>
	<td><a href="'.site.'gold"><font color="white"><center>GOLD сайты</center></font></a></td>
	</tr></tbody></table>
	';

	# top 100

	$cn =  DB :: $dbh -> querySingle("SELECT count(id) FROM platforms WHERE mode = ? AND ban = ? AND hs > ?", array(0,0,0));	

	if ($cn == 0)echo '<div class="err">Cписок пуст!</div>';

	$page = new page($cn);

	$limit = $cn > $page -> elements ? $page -> limit : null;

	if ($cn > 0)echo '<table style="background: #ECEBE7;" width="100%"><tbody>';

	$query = DB :: $dbh -> query("SELECT id FROM platforms WHERE mode = ? AND ban = ? AND hs > ? ORDER BY hs DESC {$limit}", array(0,0,0));		

	$i = $page -> start;

	while ($act = $query -> fetch()):

	$i++;	

	$act = cache_pf::check($act['id']);	

	echo '
	<tr><td class="hide"><div class="cn"><center>'.$i.'</center></div></td>
	<td class="hide"><img src="'.save_img::fav($act['url']).'"> 
	<a referrerpolicy="origin" target="_blank" href="'.site.'ou/'.$act['id'].'" rel="nofollow" title="Посетить сайт '.system::check($act['url']).'">
	<b>'.system::check($act['url']).'</b></a>
	<font color="#999999">('.$act['hs'].'/'.$act['ht'].')</font> '.($act['gold'] > time() ? system::gold():'').'
	<a href="'.site.'link/'.$act['id'].'">
	<font style="float: right">
	<img src="'.ico.'stats.png" alt="">
	</font></a>
	<br>'.system::num(system::check($act['message']),86).'<br>
	</td>
	</tr>
	';	
	
	endwhile;
	
	if ($cn > 0)echo '</tbody></table>';

	$page -> get('?');

	if ($cn > 0)echo '<div class="touch"><center><a target="_blank" referrerpolicy="origin" rel="nofollow" href="/rand"><img src="'.ico.'cube.png"> Случайный сайт </a> — Накликай удачу!</center> </div>';

	# foot 

	require_once ( foot );

?>