<?php

require_once dirname(__FILE__) . "/../../../../base/settings.php";
require_once dirname(__FILE__) . "/../../../../base/database.php";
require_once dirname(__FILE__) . "/functions.php";

$db = DB::openConnection();

$start = strlen($_SERVER["REQUEST_URI"]) - 256;
$siteID = substr($_SERVER["REQUEST_URI"], $start);

$visitorCount = getHits($siteID, $db);

addHit($siteID, $db);

DB::closeConnection($db);

?>

<style>
  .span-v3Yq3 {
    display: inline-block;
    padding: 6px 6px 4px;
    border-radius: 3px;
    background: #cccccc;
    margin-right: -2px;
  }

  .center-v3Yq3 {
    text-align: center;
    width: 50%;
    margin: 20px auto;
  }

  .message-v3Yq3 {
    color: #aaaaaa;
    font-size: 12px;
  }
</style>
<div>
  <div class="center-v3Yq3">
    <?php
    foreach (mb_str_split(($visitorCount + 1) . "") as $digit) { ?>
      <span class="span-v3Yq3"><?= $digit ?></span>
    <?php } ?>
  </div>
  <div class="center-v3Yq3 message-v3Yq3">
    Have visited this site
  </div>
</div>