WebOrbiton

Code

PriviMetrics 2

Modern, fast analytics for your websites.

Version history

Version 1.1.3 2026-11-20

Browse files
Files changed7
Lines added+234
Lines removed-24
dashboard.php Modified

Not shown (binary file or too large to diff).

functions.php Modified +77 -23
⋮ 350 unchanged lines ⋮
      return ['country' => 'Unknown', 'code' => 'XX'];
  }
  
- function getDateRange(string $range = '7d'): array
+ const PM_RANGE_OPTIONS = [
+     '24h' => 'Today',
+     '2d' => 'Last 2 days',
+     '5d' => 'Last 5 days',
+     '7d' => 'Last 7 days',
+     '14d' => 'Last 14 days',
+     '30d' => 'Last 30 days',
+     '90d' => 'Last 90 days',
+     '182d' => 'Last 182 days',
+     '1y' => 'Last year',
+     'all' => 'All time',
+     'custom' => 'Custom range',
+ ];
+ 
+ function pmParseDay(?string $value): ?int
  {
+     if ($value === null || !preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) return null;
+     $date = DateTime::createFromFormat('!Y-m-d', $value);
+     return $date && $date->format('Y-m-d') === $value ? $date->getTimestamp() : null;
+ }
+ 
+ function pmBucketForSpan(int $start, int $end): string
+ {
+     $days = (int) floor(($end - $start) / 86400) + 1;
+     if ($days <= 1) return 'hour';
+     return $days <= 190 ? 'day' : 'month';
+ }
+ 
+ function getDateRange(string $range = '7d', ?string $from = null, ?string $to = null): array
+ {
      $now = time();
-     $end = $now;
+     $todayStart = strtotime('today 00:00:00');
  
-     switch ($range) {
-         case '24h':
-             $start = strtotime('today 00:00:00');
-             $end = strtotime('tomorrow 00:00:00') - 1;
-             break;
-         case '7d':
-             $start = strtotime('-6 days 00:00:00');
-             break;
-         case '30d':
-             $start = strtotime('-29 days 00:00:00');
-             break;
-         case '90d':
-             $start = strtotime('-89 days 00:00:00');
-             break;
-         case '1y':
-             $start = strtotime('first day of January ' . date('Y') . ' 00:00:00');
-             $end = strtotime('last day of December ' . date('Y') . ' 23:59:59');
-             break;
-         default:
-             $start = strtotime('-6 days 00:00:00');
+     if ($range === '24h') {
+         return ['start' => $todayStart, 'end' => strtotime('tomorrow 00:00:00') - 1, 'bucket' => 'hour'];
      }
+     if ($range === '1y') {
+         return ['start' => strtotime(date('Y-m-01', strtotime('-11 months', strtotime(date('Y-m-01')))) . ' 00:00:00'), 'end' => $now, 'bucket' => 'month'];
+     }
+     if ($range === 'all') {
+         return ['start' => 0, 'end' => $now, 'bucket' => 'auto'];
+     }
+     if ($range === 'custom') {
+         $start = pmParseDay($from);
+         $endDay = pmParseDay($to);
+         if ($start !== null && $endDay !== null) {
+             if ($start > $endDay) [$start, $endDay] = [$endDay, $start];
+             $endDay = min($endDay, $todayStart);
+             $start = min($start, $endDay);
+             $end = strtotime('+1 day', $endDay) - 1;
+             return ['start' => $start, 'end' => $end, 'bucket' => pmBucketForSpan($start, $end)];
+         }
+         $range = '7d';
+     }
+     if (preg_match('/^(\d+)d$/', $range, $m) && isset(PM_RANGE_OPTIONS[$range])) {
+         $days = (int) $m[1];
+         return ['start' => strtotime('-' . ($days - 1) . ' days', $todayStart), 'end' => $now, 'bucket' => 'day'];
+     }
+     return ['start' => strtotime('-6 days', $todayStart), 'end' => $now, 'bucket' => 'day'];
+ }
  
-     return ['start' => $start, 'end' => $end];
+ function pmTimelineSlots(string $bucket, int $start, int $end): array
+ {
+     $now = time();
+     $slots = [];
+     if ($bucket === 'hour') {
+         $dayStart = strtotime(date('Y-m-d', $start) . ' 00:00:00');
+         for ($h = 0; $h < 24; $h++) {
+             $ts = strtotime('+' . $h . ' hours', $dayStart);
+             $slots[sprintf('%02d:00', $h)] = $ts > $now;
+         }
+         return $slots;
+     }
+     $cursor = new DateTime(date($bucket === 'month' ? 'Y-m-01' : 'Y-m-d', $start));
+     $last = new DateTime(date($bucket === 'month' ? 'Y-m-01' : 'Y-m-d', $end));
+     $step = $bucket === 'month' ? '+1 month' : '+1 day';
+     $format = $bucket === 'month' ? 'Y-m' : 'Y-m-d';
+     while ($cursor <= $last && count($slots) < 400) {
+         $slots[$cursor->format($format)] = $cursor->getTimestamp() > $now;
+         $cursor->modify($step);
+     }
+     return $slots;
  }
  
  function pmPixel(): string
⋮ 361 unchanged lines ⋮
install.php Modified +39 -0
⋮ 423 unchanged lines ⋮
              margin-top: 8px;
              line-height: 1.5;
          }
+         .brand .mark,
+         .logo {
+             position: relative;
+             overflow: hidden;
+             background: linear-gradient(155deg, color-mix(in srgb, var(--accent) 72%, #fff) 0%, var(--accent) 48%, var(--accent-hover) 100%);
+             border: 1px solid color-mix(in srgb, var(--accent) 65%, #000);
+             box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
+             transition: transform 0.2s ease, box-shadow 0.2s ease;
+         }
+ 
+         .brand .mark::after,
+         .logo::after {
+             content: "";
+             position: absolute;
+             inset: 0 0 52% 0;
+             background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
+             pointer-events: none;
+         }
+ 
+         .brand .mark img,
+         .logo img {
+             position: relative;
+             z-index: 1;
+             filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
+         }
+ 
+         .brand:hover .mark,
+         .logo:hover {
+             transform: translateY(-1px);
+             box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 18px -4px color-mix(in srgb, var(--accent) 70%, transparent);
+         }
+ 
+         @media (prefers-reduced-motion: reduce) {
+             .brand .mark,
+             .logo {
+                 transition: none;
+             }
+         }
+ 
      </style>
  </head>
  
⋮ 123 unchanged lines ⋮
login.php Modified +39 -0
⋮ 258 unchanged lines ⋮
              border: 1px solid var(--info-border);
              color: var(--info-text);
          }
+         .brand .mark,
+         .logo {
+             position: relative;
+             overflow: hidden;
+             background: linear-gradient(155deg, color-mix(in srgb, var(--accent) 72%, #fff) 0%, var(--accent) 48%, var(--accent-hover) 100%);
+             border: 1px solid color-mix(in srgb, var(--accent) 65%, #000);
+             box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
+             transition: transform 0.2s ease, box-shadow 0.2s ease;
+         }
+ 
+         .brand .mark::after,
+         .logo::after {
+             content: "";
+             position: absolute;
+             inset: 0 0 52% 0;
+             background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
+             pointer-events: none;
+         }
+ 
+         .brand .mark img,
+         .logo img {
+             position: relative;
+             z-index: 1;
+             filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
+         }
+ 
+         .brand:hover .mark,
+         .logo:hover {
+             transform: translateY(-1px);
+             box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 18px -4px color-mix(in srgb, var(--accent) 70%, transparent);
+         }
+ 
+         @media (prefers-reduced-motion: reduce) {
+             .brand .mark,
+             .logo {
+                 transition: none;
+             }
+         }
+ 
      </style>
  </head>
  
⋮ 56 unchanged lines ⋮
settings.php Modified +39 -0
⋮ 815 unchanged lines ⋮
          #mysql-cred-fields {
              display: <?= env('DB_ENABLED', 'false') === 'true' ? 'block' : 'none' ?>;
          }
+         .brand .mark,
+         .logo {
+             position: relative;
+             overflow: hidden;
+             background: linear-gradient(155deg, color-mix(in srgb, var(--accent) 72%, #fff) 0%, var(--accent) 48%, var(--accent-hover) 100%);
+             border: 1px solid color-mix(in srgb, var(--accent) 65%, #000);
+             box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
+             transition: transform 0.2s ease, box-shadow 0.2s ease;
+         }
+ 
+         .brand .mark::after,
+         .logo::after {
+             content: "";
+             position: absolute;
+             inset: 0 0 52% 0;
+             background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
+             pointer-events: none;
+         }
+ 
+         .brand .mark img,
+         .logo img {
+             position: relative;
+             z-index: 1;
+             filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
+         }
+ 
+         .brand:hover .mark,
+         .logo:hover {
+             transform: translateY(-1px);
+             box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 18px -4px color-mix(in srgb, var(--accent) 70%, transparent);
+         }
+ 
+         @media (prefers-reduced-motion: reduce) {
+             .brand .mark,
+             .logo {
+                 transition: none;
+             }
+         }
+ 
      </style>
  </head>
  
⋮ 605 unchanged lines ⋮
updater.php Modified +39 -0
⋮ 725 unchanged lines ⋮
          .upd-files .tag { display: inline-block; min-width: 62px; text-align: center; font-size: 11px; padding: 1px 7px; border-radius: 10px; margin-right: 6px; }
          .upd-files .tag.mod { background: var(--accent-soft); color: var(--accent); }
          .upd-files .tag.add { background: var(--success-soft); color: var(--success); }
+         .brand .mark,
+         .logo {
+             position: relative;
+             overflow: hidden;
+             background: linear-gradient(155deg, color-mix(in srgb, var(--accent) 72%, #fff) 0%, var(--accent) 48%, var(--accent-hover) 100%);
+             border: 1px solid color-mix(in srgb, var(--accent) 65%, #000);
+             box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
+             transition: transform 0.2s ease, box-shadow 0.2s ease;
+         }
+ 
+         .brand .mark::after,
+         .logo::after {
+             content: "";
+             position: absolute;
+             inset: 0 0 52% 0;
+             background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
+             pointer-events: none;
+         }
+ 
+         .brand .mark img,
+         .logo img {
+             position: relative;
+             z-index: 1;
+             filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
+         }
+ 
+         .brand:hover .mark,
+         .logo:hover {
+             transform: translateY(-1px);
+             box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 18px -4px color-mix(in srgb, var(--accent) 70%, transparent);
+         }
+ 
+         @media (prefers-reduced-motion: reduce) {
+             .brand .mark,
+             .logo {
+                 transition: none;
+             }
+         }
+ 
      </style>
  </head>
  
⋮ 189 unchanged lines ⋮
version.txt Modified +1 -1
- 1.1.1
+ 1.1.3