
<!-- Page header -->
{capture name="buttons"}
{/capture}

{capture name="breadcrumb"}
	<a href="{$adminUrl}/bots" class="breadcrumb-item">{$title}</a>
{/capture}

{capture name="showBy"}
	{include file="module/show-by.tpl" url="{$adminUrl}/bot?visitorId={$visitorId|default:''}"}
{/capture}

{include file="components/page-header.tpl" buttons=$smarty.capture.buttons breadcrumb=$smarty.capture.breadcrumb showBy=$smarty.capture.showBy}
<!-- /page header -->

<div class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="card border shadow-sm">
				{include file="components/selectors.tpl" action="{$adminUrl}/bot?visitorId={$visitorId|default:''}" select=''}
			</div>
		</div>
		<div class="col-md-6">
			<div class="card border shadow-sm">
				<div class="card-header d-flex flex-wrap">
					<h6 class="mb-0">{stats:botInfo}</h6>
					<div class="d-inline-flex ms-auto">
						<a class="text-body" data-card-action="collapse"><i class="ph-caret-down"></i></a>
					</div>
				</div>
				<div class="collapse show">
					<table class="table table-xs table-striped table-actions table-hover">
						{if isset($visitor.referer)}
							<tr>
								<td class="" align="right">{stats:referer}:</td>
								<td class="">{if isset($visitor.refererUrl)}<a href="{$visitor.refererUrl}" target="_blank">{if $visitor.refererWebsite}{$visitor.refererWebsite|truncate:50}{else}{$visitor.refererUrl|truncate:50}{/if}</a>{else}{$visitor.referer|truncate:50}{/if}</td>
							</tr>
						{/if}
						{if isset($visitor.searchPhrase)}
							<tr>
								<td class="" align="right" nowrap="nowrap">{stats:searchQuery}:</td>
								<td class="">{$visitor.searchPhrase|truncate:50}</td>
							</tr>
						{/if}
						<tr>
							<td class="" align="right" nowrap="nowrap">{stats:botIp}:</td>
							<td class="">{$visitor.visitorIp} (<a href="http://whois.domaintools.com/{$visitor.visitorIp}" target="_blank">{stats:whois}</a>)</td>
						</tr>
						<tr>
							<td class="" align="right">{stats:useragent}:</td>
							<td class="small" title="{$visitor.userAgent}">{$visitor.userAgent}</td>
						</tr>

					</table>
				</div>
			</div>
		</div>

		<div class="col-md-6">
			<div class="card border shadow-sm">
				<div class="card-header d-flex flex-wrap">
					<h6 class="mb-0">{stats:firstVisit}</h6>
					<div class="d-inline-flex ms-auto">
						<a class="text-body" data-card-action="collapse"><i class="ph-caret-down"></i></a>
					</div>
				</div>
				<div class="collapse show">
					<table class="table table-xs table-striped table-actions table-hover">
						<tr>
							<td class="text-right" width="100">{general:date}:</td>
							<td class="text-nowrap">{$visitor.firstVisitOn nofilter}</td>
						</tr>
						<tr>
							<td class="text-right" nowrap="nowrap">{stats:type}:</td>
							<td class="text-left">
								{if $visitor.firstVisit.typeId eq 6}
									<span class="code{$visitor.firstVisit.errorCode}">{stats:error} {$visitor.firstVisit.errorCode}</span>
								{elseif $visitor.firstVisit.typeName}
									{$visitor.firstVisit.typeName nofilter}
								{/if}
							</td>
						</tr>
						<tr>
							<td class="text-right">{stats:page}:</td>
							<td class="">
								{if $visitor.firstVisit.typeId eq 1}
									<a href="{$SITE_URL}/" target="_blank">{stats:homePage}</a>
								{elseif $visitor.firstVisit.typeId eq 2 && isset($visitor.firstVisit.name) && $visitor.firstVisit.name}
									<a href="{$visitor.firstVisit.url}" target="_blank">{if isset($visitor.firstVisit.name)}{$visitor.firstVisit.name|truncate:50}{/if}</a>
								{elseif $visitor.firstVisit.typeId eq 3 && $visitor.firstVisit.title}
									<a href="{$visitor.firstVisit.url}" target="_blank">{$visitor.firstVisit.title|truncate:50}</a>
								{elseif $visitor.firstVisit.typeId eq 4}
									<a href="{$SITE_URL}/search.php?query={$visitor.firstVisit.searchQuery|escape:'url' nofilter}&page={$visitor.firstVisit.searchPage}" target="_blank">{$visitor.firstVisit.searchQuery|truncate:50}</a>
								{elseif $visitor.firstVisit.typeId eq 6}
									<a href="{$visitor.firstVisit.requestUri}" target="_blank">{$visitor.firstVisit.requestUri|truncate:50}</a>
									{if isset($visitor.firstVisit.refererUrl)}
										(<a href="{$visitor.firstVisit.refererUrl}" target="_blank">{"{stats:referer}"|lower}</a>)
									{/if}
								{elseif $visitor.firstVisit.typeId eq 7}
									{if !$visitor.firstVisit.section}
										<a href="{$SITE_URL}/rss.xml" target="_blank">{stats:genRss}</a>
									{elseif $visitor.firstVisit.section}
										<a href="{$visitor.firstVisit.section.path}/rss.xml" target="_blank">{$visitor.firstVisit.section.name|truncate:35}</a>
									{else}
										{stats:unknown}
									{/if}
								{elseif $visitor.firstVisit.typeId eq 8}
									<a href="{$SITE_URL}/sitemap.{$config.file_extension}" target="_blank">{stats:genSitemap}</a>
								{elseif $visitor.firstVisit.typeId eq 9}
									<a href="{$SITE_URL}/sitemap.xml" target="_blank">{stats:xmlSitemap}</a>
								{elseif $visitor.firstVisit.typeId eq 10}
									<a href="{$visitor.firstVisit.url}" target="_blank">{$visitor.firstVisit.alias|default:$visitor.firstVisit.title|truncate:45}</a>
								{else}
									{stats:unknown}
								{/if}
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>

		<div class="col-md-12">
			<div class="card border shadow-sm">
				<div class="card-header d-flex flex-wrap">
					<h6 class="mb-0">{stats:visit}</h6>
					<div class="d-inline-flex ms-auto">
						<a class="text-body" data-card-action="collapse"><i class="ph-caret-down"></i></a>
					</div>
				</div>
				<div class="collapse show">
					<table class="table table-xs table-striped table-actions table-hover" id="visits">
						<thead>
						<tr>
							<th class="text-left">{general:date}</th>
							<th class="text-center">{stats:type}</th>
							<th class="text-left">{stats:visit}</th>
						</tr>
						</thead>
						{if isset($visits)}
							<tbody>
							{foreach item=visit from=$visits name=visits}
								<tr id="visit-{$visit.visitId}"  {if isset($visit.isHidden)}style="display:none"{/if}>
									<td class="text-nowrap">{$visit.visitDate nofilter}</td>
									<td class="text-nowrap text-center">
										{if $visit.typeId eq 6}<span class="text-danger">{stats:error} {$visit.errorCode}</span>{else}<span>{$visit.typeName nofilter}</span>{/if}
									</td>
									<td class="text-nowrap" width="100%">
										{if $visit.typeId eq 1}
											<a href="{$SITE_URL}/" target="_blank">{stats:homePage}</a>
										{elseif $visit.typeId eq 2 && isset($visit.name)}
											<a href="{$visit.url}" target="_blank">{if isset($visit.name)}{$visit.name|truncate:60}{/if}</a>
										{elseif $visit.typeId eq 3 && isset($visit.title)}
											<a href="{$visit.url}" target="_blank">{if isset($visit.title)}{$visit.title|truncate:60}{/if}</a>
										{elseif $visit.typeId eq 4}
											<a href="{$SITE_URL}/search.php?query={$visit.searchQuery|escape:'url' nofilter}&page={$visit.searchPage}" target="_blank">{$visit.searchQuery|truncate:60}</a>
										{elseif $visit.typeId eq 6}
											<a href="{$visit.requestUri}" target="_blank">{$visit.requestUri|truncate:60}</a>
											{if isset($visit.refererUrl)}(<a href="{$visit.refererUrl}" target="_blank">{"{stats:referer}"|lower}</a>){/if}
										{elseif $visit.typeId eq 7}
											{if !$visit.section}
												<a href="{$SITE_URL}/rss.xml" target="_blank">{stats:genRss}</a>
											{elseif $visit.section}
												<a href="{$visit.section.path}/rss.xml" target="_blank">{$visit.section.name|truncate:60}</a>
											{else}
												{stats:unknown}
											{/if}
										{elseif $visit.typeId eq 8}
											<a href="{$SITE_URL}/sitemap.{$config.file_extension}" target="_blank">{stats:genSitemap}</a>
										{elseif $visit.typeId eq 9}
											<a href="{$SITE_URL}/sitemap.xml" target="_blank">{stats:xmlSitemap}</a>
										{elseif $visit.typeId eq 10}
											<a href="{$visit.url}" target="_blank">{$visit.alias|default:$visit.title|truncate:60}</a>
										{else}
											{stats:unknown}
										{/if}
									</td>
								</tr>
							{/foreach}
							</tbody>
						{else}
							<tbody><tr><td colspan="3" class="text-center">- {general:none} -</td></tr></tbody>
						{/if}
					</table>
				</div>
				{include file="module/pagination.tpl" url="{$adminUrl}/bot" params="&visitorId={$visitorId|default:''}{if isset($filterTypeId)}&filterTypeId={$filterTypeId}{/if}"}
			</div>
		</div>
	</div>

</div>
<!-- /content area -->
