<?php

(defined('COT_CODE') && defined('COT_PLUG')) or die('Wrong URL.');

global $structure, $cfg, $L, $usr, $sys;

list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('plug', 'ads', 'RWA');
cot_block($usr['auth_write']);

$out['subtitle'] = 'Моя реклама';
$out['head'] .= $R['code_noindex'];

$t = new XTemplate(cot_tplfile(array('ads', 'main'), 'plug'));

$list = $db->query("SELECT * FROM $db_ads WHERE item_userid=".$usr['id']." ORDER BY item_id DESC")->fetchAll();

require_once cot_incfile('market', 'module');

$jj=0;
foreach ($list as $item)
{
  $jj++;
  $t->assign(cot_generate_markettags($item['item_marketid'], 'PRD_ROW_', $cfg['market']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
	$t->assign(ads_generate_tags($item, 'ADS_ROW_'));
	$t->parse('MAIN.ADS_ROW');
}

$t->assign(array(
	'ADS_COUNT' => $jj,
  'ADS_NOW_PAY' => cot_import('pay', 'G', 'INT')
));

cot_display_messages($t);