Counter styling
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
Allow from 127.0.0.1
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
include_once dirname(__FILE__) . "/../../../../base/settings.php";
|
||||
include_once dirname(__FILE__) . "/../../../../base/database.php";
|
||||
include_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>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
include_once dirname(__FILE__) . "/./queries.php";
|
||||
|
||||
function getHits($id, $db)
|
||||
{
|
||||
global $getHitsQuery;
|
||||
$stmt = $db->prepare($getHitsQuery);
|
||||
$stmt->bindValue(":SID", $id);
|
||||
$stmt->execute();
|
||||
$hits = $stmt->fetch(PDO::FETCH_COLUMN);
|
||||
return $hits !== false ? $hits : 0;
|
||||
}
|
||||
|
||||
function addHit($id, $db)
|
||||
{
|
||||
global $setHitsQuery;
|
||||
$stmt = $db->prepare($setHitsQuery);
|
||||
$stmt->bindValue(":SID", $id);
|
||||
$stmt->execute();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
$getHitsQuery = "
|
||||
SELECT
|
||||
hits
|
||||
FROM
|
||||
Counter
|
||||
WHERE
|
||||
siteID LIKE :SID";
|
||||
|
||||
$setHitsQuery = "
|
||||
INSERT INTO
|
||||
Counter(siteID, hits)
|
||||
VALUES
|
||||
(:SID, 1)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
hits = hits + 1";
|
||||
Reference in New Issue
Block a user