$val) {
$url = modifyLocation($key, $val, $url);
}
return $url;
}
function modifyLocation($var, $val, $url = false) {
if (!$url) $url = $_SERVER['REQUEST_URI'];
$urlComponents = parse_url($url);
parse_str($urlComponents['query'], $queryParams);
if (isset($queryParams[$var])) {
$queryParams[$var] = $val;
} else {
$queryParams[$var] = $val;
}
if ($val == "unset") unset($queryParams[$var]);
$newQuery = http_build_query($queryParams);
$modifiedUrl = $urlComponents['path'] . '?' . $newQuery;
return $modifiedUrl;
}
$db = new Medoo([
'type' => 'mysql',
'host' => DB_HOST,
'port' => DB_PORT,
'database' => DB_NAME,
'username' => DB_USER,
'password' => DB_PASSWORD,
'charset' => 'utf8mb4'
]);
if ($db->error) dieWithCode(404, "db connect error");
$logged = false;
if(isset($_GET["action"])) {
if ($_GET["action"] == "clear") {
file_put_contents("stat.dat", "");
header("location:index.php?pass=".base64_encode($pass));
}
}
if(isset($_GET["pass"]) && base64_decode($_GET["pass"]) == $pass) {
echo "";
$logged = true;
}
?>
Statistics
Enter password
Download Statistics
"unset", "page"=>1]); ?>" class="flex items-center justify-center bg-blue-600 border-none text-white h-10 px-6 rounded-sm hover:bg-blue-900 filter">All
"action,Download", "page"=>1]); ?>" class="flex items-center justify-center bg-blue-600 border-none text-white h-10 px-6 rounded-sm hover:bg-blue-900 filter">Downloads
"action,Visit", "page"=>1]); ?>" class="flex items-center justify-center bg-blue-600 border-none text-white h-10 px-6 rounded-sm hover:bg-blue-900 filter">Visits
"useragent,Windows", "page"=>1]); ?>" class="flex items-center justify-center bg-blue-600 border-none text-white h-10 px-6 rounded-sm hover:bg-blue-900 filter">WIN
"useragent,Macintosh", "page"=>1]); ?>" class="flex items-center justify-center bg-blue-600 border-none text-white h-10 px-6 rounded-sm hover:bg-blue-900 filter">MAC
"useragent,Android", "page"=>1]); ?>" class="flex items-center justify-center bg-blue-600 border-none text-white h-10 px-6 rounded-sm hover:bg-blue-900 filter">Android
"useragent,iPhone", "page"=>1]); ?>" class="flex items-center justify-center bg-blue-600 border-none text-white h-10 px-6 rounded-sm hover:bg-blue-900 filter">iPhone
| Action |
Date |
IP |
Browser |
[$offset, $perPage],
"ORDER" => [
"date" => "DESC"
]
];
if (isset($_GET["clear"])) {
$db->delete("stat", "*");
echo "";
die();
}
if(isset($_GET["filter"])) {
$ex = explode(",", $_GET["filter"]);
$where[$ex[0]."[~]"] = trim($ex[1]);
}
$where_no_pagination = $where;
unset ($where_no_pagination["LIMIT"]);
$existingRowCount = $db->count("stat", "*", $where_no_pagination);
$existing = $db->select("stat", "*", $where);
$totalRows = $db->count("stat");
$rows = $totalRows;
if (isset($_GET["filter"])) {
$rows = $existingRowCount;
}
$totalPages = ceil($rows / $perPage);
if ($existing) {
foreach($existing as $item) {
$clr = "#00cc00";
if ($item["action"] == "Download") $clr = "#F04903";
echo "| ".$item["action"]." | ".$item["date"]." | ".$item["ip"]." | ".$item["useragent"]." |
";
}
}
?>
" class="flex items-center justify-center w-64 font-bold bg-black border-none text-red-500 text-xl h-12 px-12 rounded-sm hover:bg-red-500 hover:text-white">Clear statistics