<?php

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

	# core

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

	$s =  isset( $_GET['s'] ) ? system::abs($_GET['s']): 0;

	# meta

	$title = 'GOLD сайты » Мобильные WAP сайты';
	$description = system::check($config['description']);
	$keywords = system::check($config['keywords']);
	$tl = 'GOLD сайты';
	
	# adm

	system::adm();

	# head

	require_once ( head );

	echo '<div class ="touch"> <a href ="?"> Все</a> | <a href ="?&s=1"> Активные</a> |  <a href ="?&s=2"> Просроченные</a> </div>';

	if ($s == 1)$sr = 'AND gold > ?'; 
	if ($s == 2)$sr = 'AND gold != 0 AND gold < ?'; 
	if ($s == 0)$sr = 'AND gold != 0 || gold > '.time().' AND gold < ?';

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

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

	$page = new page($cn);

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

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

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

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

	echo '
	<div class="touch"><img src="'.save_img::fav($act['url']).'"> 
	<strong>'.system::check($act['url']).'</strong>
	[ID: '.$act['id'].''.($act['gold'] > time() ? ' | '.system::gold(): null).' |
	<a href="'.site.'admin/gold/edit/id'.$act['id'].'">Cнять</a>] 
	<br>'.($act['gold'] > time() ? 'Активен до '.system::time($act['gold']):'Просрочен '.system::time($act['gold'])).'
	</div>
	';	

	endwhile;	

	$page -> get($s == 0 ? '?':'?&s='.$s.'&');

	echo '
	<a href="'.site.'admin/gold/add" class="touch">- Добавить GOLD</a>
	<a href="'.site.'admin" class="touch">« Назад</a>
	';

	# foot

	require_once ( foot ) ;
?>