WebOrbiton
v1.3.0

PriviMetrics 2

1,549 lines · 76.9 KB
  1. <?php
  2. ​
  3. declare(strict_types=1);
  4. require_once __DIR__ . '/functions.php';
  5. require_once __DIR__ . '/font-options.php';
  6. ​
  7. if (!envIsInstalled()) {
  8. header('Location: install.php');
  9. exit;
  10. }
  11. require_once __DIR__ . '/storage.php';
  12. require_once __DIR__ . '/updater-functions.php';
  13. ​
  14. requireLogin();
  15. pmSecurityHeaders();
  16. ​
  17. $storage = new StorageManager();
  18. $csrfToken = generateCSRFToken();
  19. $flash = null;
  20. ​
  21. function resolveReturnUrl(?string $raw): string
  22. {
  23. $default = 'dashboard.php';
  24. if (!$raw) return $default;
  25. if (preg_match('#^(https?:)?//#i', $raw) || str_starts_with($raw, '\\')) {
  26. return $default;
  27. }
  28. if (!preg_match('#^[A-Za-z0-9_\-]+\.php(\?[^\s]*)?$#', $raw)) {
  29. return $default;
  30. }
  31. return $raw;
  32. }
  33. ​
  34. $returnUrl = resolveReturnUrl($_POST['return'] ?? $_GET['return'] ?? null);
  35. ​
  36. ​
  37. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  38. if (!verifyCSRFToken($_POST['csrf_token'] ?? null)) {
  39. $flash = ['type' => 'error', 'text' => 'Invalid security token.'];
  40. } else {
  41. $action = $_POST['action'] ?? '';
  42. ​
  43. if ($action === 'general') {
  44. $ok = envSetMany([
  45. 'SITE_NAME' => sanitize($_POST['site_name'] ?? 'PriviMetrics'),
  46. 'DEFAULT_THEME' => in_array($_POST['default_theme'] ?? '', ['dark', 'light'], true) ? $_POST['default_theme'] : 'dark',
  47. 'RESPECT_DNT' => isset($_POST['respect_dnt']) ? 'true' : 'false',
  48. 'TRACK_IP_DEFAULT' => isset($_POST['track_ip_default']) ? 'true' : 'false',
  49. 'SESSION_TIMEOUT' => (string) max(300, (int) ($_POST['session_timeout'] ?? 86400)),
  50. 'TOP_LISTS_LIMIT' => (string) max(1, min(50, (int) ($_POST['top_lists_limit'] ?? 8))),
  51. 'CHART_STYLE' => in_array($_POST['chart_style'] ?? '', ['line', 'dots', 'aurora'], true) ? $_POST['chart_style'] : 'bars',
  52. 'TOP_LISTS_SHOW_ALL' => isset($_POST['top_lists_show_all']) ? 'true' : 'false',
  53. ]);
  54. $flash = $ok ? ['type' => 'success', 'text' => 'General settings saved.'] : ['type' => 'error', 'text' => 'Save failed.'];
  55. } elseif ($action === 'fonts') {
  56. $bodySlug = $_POST['font_body'] ?? '';
  57. $headingSlug = $_POST['font_heading'] ?? '';
  58. $valueSlug = $_POST['font_value'] ?? '';
  59. ​
  60. $ok = envSetMany([
  61. 'FONT_BODY' => array_key_exists($bodySlug, fontOptions('body')) ? $bodySlug : fontDefaultSlug('body'),
  62. 'FONT_HEADING' => array_key_exists($headingSlug, fontOptions('heading')) ? $headingSlug : fontDefaultSlug('heading'),
  63. 'FONT_VALUE' => array_key_exists($valueSlug, fontOptions('value')) ? $valueSlug : fontDefaultSlug('value'),
  64. ]);
  65. $flash = $ok ? ['type' => 'success', 'text' => 'Fonts saved.'] : ['type' => 'error', 'text' => 'Save failed.'];
  66. } elseif ($action === 'geo') {
  67. $ok = envSetMany([
  68. 'GEO_PROVIDER' => $_POST['geo_provider'] === 'external' ? 'external' : 'privacy-friendly',
  69. 'GEO_EXTERNAL_SERVICE' => in_array($_POST['geo_external_service'] ?? '', ['ip-api', 'ipinfo', 'ipstack', 'ip2location', 'dbip'], true) ? $_POST['geo_external_service'] : 'ip-api',
  70. 'GEO_API_KEY' => trim((string) ($_POST['geo_api_key'] ?? '')),
  71. ]);
  72. $flash = $ok ? ['type' => 'success', 'text' => 'Geolocation settings saved.'] : ['type' => 'error', 'text' => 'Save failed.'];
  73. } elseif ($action === 'data_collection') {
  74. $ok = envSetMany([
  75. 'FEATURE_TRAFFIC_SOURCES' => isset($_POST['feature_traffic_sources']) ? 'true' : 'false',
  76. 'FEATURE_VISITOR_COUNTRIES' => isset($_POST['feature_visitor_countries']) ? 'true' : 'false',
  77. 'FEATURE_SEARCH_QUERIES' => isset($_POST['feature_search_queries']) ? 'true' : 'false',
  78. 'FEATURE_DEVICE_TYPE' => isset($_POST['feature_device_type']) ? 'true' : 'false',
  79. 'FEATURE_BROWSER_DETECTION' => isset($_POST['feature_browser_detection']) ? 'true' : 'false',
  80. 'FEATURE_SEARCH_ENGINES' => isset($_POST['feature_search_engines']) ? 'true' : 'false',
  81. 'FEATURE_CRAWLERS' => isset($_POST['feature_crawlers']) ? 'true' : 'false',
  82. ]);
  83. $flash = $ok ? ['type' => 'success', 'text' => 'Data collection settings saved.'] : ['type' => 'error', 'text' => 'Save failed.'];
  84. } elseif ($action === 'rate_limits') {
  85. $ok = envSetMany([
  86. 'RATE_LIMIT_XML' => (string) max(0, (int) ($_POST['rate_limit_xml'] ?? 2)),
  87. 'RATE_LIMIT_MYSQL' => (string) max(0, (int) ($_POST['rate_limit_mysql'] ?? 5)),
  88. 'RATE_LIMIT_PMAF' => (string) max(0, (int) ($_POST['rate_limit_pmaf'] ?? 5)),
  89. ]);
  90. $flash = $ok ? ['type' => 'success', 'text' => 'Rate limits saved.'] : ['type' => 'error', 'text' => 'Save failed.'];
  91. } elseif ($action === 'mysql') {
  92. $enable = isset($_POST['db_enabled']);
  93. $dbHost = trim((string) ($_POST['db_host'] ?? 'localhost'));
  94. $dbPort = trim((string) ($_POST['db_port'] ?? '3306'));
  95. $dbName = trim((string) ($_POST['db_name'] ?? ''));
  96. $dbUser = trim((string) ($_POST['db_user'] ?? ''));
  97. $dbPass = (string) ($_POST['db_pass'] ?? '');
  98. $keepPass = $dbPass === '' ? env('DB_PASS', '') : $dbPass;
  99. ​
  100. $testOk = true;
  101. $paramsError = $enable ? pmDbParamsError($dbHost, $dbPort, $dbName) : null;
  102. if ($paramsError !== null) {
  103. $testOk = false;
  104. $flash = ['type' => 'error', 'text' => $paramsError];
  105. } elseif ($enable) {
  106. try {
  107. $testPdo = new PDO("mysql:host={$dbHost};port={$dbPort};dbname={$dbName};charset=utf8mb4", $dbUser, $keepPass, [
  108. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  109. ]);
  110. } catch (PDOException $e) {
  111. $testOk = false;
  112. $flash = ['type' => 'error', 'text' => 'Could not connect to MySQL: ' . $e->getMessage()];
  113. }
  114. }
  115. ​
  116. if ($testOk) {
  117. $ok = envSetMany([
  118. 'DB_ENABLED' => $enable ? 'true' : 'false',
  119. 'DB_HOST' => $dbHost,
  120. 'DB_PORT' => $dbPort,
  121. 'DB_NAME' => $dbName,
  122. 'DB_USER' => $dbUser,
  123. 'DB_PASS' => $keepPass,
  124. ]);
  125. if ($ok && $enable) {
  126. $freshStorage = new StorageManager();
  127. if ($freshStorage->isMySQLAvailable()) {
  128. $freshStorage->ensureSchema();
  129. }
  130. }
  131. $flash = $ok ? ['type' => 'success', 'text' => 'MySQL configuration saved.'] : ['type' => 'error', 'text' => 'Save failed.'];
  132. }
  133. } elseif ($action === 'password') {
  134. $current = (string) ($_POST['current_password'] ?? '');
  135. $new = (string) ($_POST['new_password'] ?? '');
  136. $confirm = (string) ($_POST['new_password_confirm'] ?? '');
  137. $validHash = env('ADMIN_PASSWORD_HASH', '');
  138. ​
  139. if (!verifyPassword($current, $validHash)) {
  140. $flash = ['type' => 'error', 'text' => 'Current password is incorrect.'];
  141. } elseif (strlen($new) < 8) {
  142. $flash = ['type' => 'error', 'text' => 'New password must be at least 8 characters.'];
  143. } elseif ($new !== $confirm) {
  144. $flash = ['type' => 'error', 'text' => 'New passwords do not match.'];
  145. } else {
  146. $ok = envSetMany(['ADMIN_PASSWORD_HASH' => hashPassword($new)]);
  147. $flash = $ok ? ['type' => 'success', 'text' => 'Password changed successfully.'] : ['type' => 'error', 'text' => 'Save failed.'];
  148. }
  149. }
  150. }
  151. }
  152. ​
  153. $currentVersion = pmUpdateCurrent();
  154. ​
  155. $siteName = env('SITE_NAME', 'PriviMetrics');
  156. $theme = env('DEFAULT_THEME', 'dark');
  157. ?>
  158. <!DOCTYPE html>
  159. <html lang="en" data-theme="<?= sanitize($theme) ?>">
  160. ​
  161. <head>
  162. <meta charset="UTF-8">
  163. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  164. <title>Settings - <?= sanitize($siteName) ?></title>
  165. <?= fontFaceStyleTag() ?>
  166. <script>
  167. (function() {
  168. var t = localStorage.getItem('pm_theme') || '<?= sanitize($theme) ?>';
  169. document.documentElement.setAttribute('data-theme', t);
  170. ​
  171. if (sessionStorage.getItem('pm_intro_played')) {
  172. document.documentElement.setAttribute('data-no-intro', '1');
  173. } else {
  174. sessionStorage.setItem('pm_intro_played', '1');
  175. }
  176. })();
  177. </script>
  178. <style>
  179. :root {
  180. --font-body: <?= fontFamilyCss('body') ?>;
  181. --font-heading: <?= fontFamilyCss('heading') ?>;
  182. --font-value: <?= fontFamilyCss('value') ?>;
  183. }
  184. ​
  185. :root[data-theme="dark"] {
  186. --bg-primary: #0a0a0a;
  187. --bg-secondary: #141414;
  188. --bg-tertiary: #1c1c1c;
  189. --bg-hover: #222222;
  190. --border-color: #262626;
  191. --text-primary: #eaeaea;
  192. --text-secondary: #9a9a9a;
  193. --text-tertiary: #6b6b6b;
  194. --accent: #f1484e;
  195. --accent-hover: #d53b40;
  196. --accent-soft: rgba(241, 72, 78, 0.12);
  197. --success: #22c55e;
  198. --success-soft: rgba(34, 197, 94, 0.12);
  199. }
  200. ​
  201. :root[data-theme="light"] {
  202. --bg-primary: #f7f7f8;
  203. --bg-secondary: #ffffff;
  204. --bg-tertiary: #f2f2f3;
  205. --bg-hover: #ececed;
  206. --border-color: #e5e5e7;
  207. --text-primary: #16171a;
  208. --text-secondary: #6b6d73;
  209. --text-tertiary: #9799a0;
  210. --accent: #f1484e;
  211. --accent-hover: #d53b40;
  212. --accent-soft: rgba(241, 72, 78, 0.08);
  213. --success: #16a34a;
  214. --success-soft: rgba(22, 163, 74, 0.1);
  215. }
  216. ​
  217. * {
  218. margin: 0;
  219. padding: 0;
  220. box-sizing: border-box;
  221. }
  222. ​
  223. html {
  224. overflow-y: scroll;
  225. scrollbar-gutter: stable;
  226. }
  227. ​
  228. body {
  229. font-family: var(--font-body);
  230. background: var(--bg-primary);
  231. color: var(--text-primary);
  232. font-size: 14px;
  233. line-height: 1.5;
  234. }
  235. ​
  236. h1 {
  237. font-family: var(--font-heading);
  238. }
  239. ​
  240. a {
  241. color: inherit;
  242. text-decoration: none;
  243. }
  244. ​
  245. .app {
  246. display: flex;
  247. min-height: 100vh;
  248. }
  249. ​
  250. .sidebar {
  251. width: 250px;
  252. flex-shrink: 0;
  253. background: linear-gradient(180deg, color-mix(in srgb, var(--bg-secondary) 94%, #fff) 0%, var(--bg-secondary) 100%);
  254. border: 1px solid var(--border-color);
  255. border-radius: 16px;
  256. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.2), 0 12px 28px -14px rgba(0, 0, 0, 0.35);
  257. display: flex;
  258. flex-direction: column;
  259. padding: 18px 14px;
  260. position: sticky;
  261. top: 14px;
  262. align-self: flex-start;
  263. margin: 14px 0 14px 14px;
  264. height: calc(100vh - 28px);
  265. overflow-y: auto;
  266. scrollbar-width: none;
  267. -ms-overflow-style: none;
  268. z-index: 10;
  269. }
  270. ​
  271. .sidebar::-webkit-scrollbar {
  272. display: none;
  273. }
  274. ​
  275. .brand {
  276. display: flex;
  277. align-items: center;
  278. gap: 10px;
  279. padding: 6px 8px 18px;
  280. margin-bottom: 12px;
  281. border-bottom: 1px solid var(--border-color);
  282. }
  283. ​
  284. .brand .mark {
  285. width: 34px;
  286. height: 34px;
  287. border-radius: 9px;
  288. background: var(--accent);
  289. display: flex;
  290. align-items: center;
  291. justify-content: center;
  292. font-weight: 700;
  293. color: white;
  294. font-size: 14px;
  295. flex-shrink: 0;
  296. }
  297. ​
  298. .brand .name {
  299. font-family: var(--font-heading);
  300. font-weight: 600;
  301. font-size: 15px;
  302. }
  303. ​
  304. .brand .sub {
  305. font-size: 11px;
  306. color: var(--text-tertiary);
  307. }
  308. ​
  309. .nav {
  310. display: flex;
  311. flex-direction: column;
  312. gap: 2px;
  313. }
  314. ​
  315. .nav a {
  316. display: flex;
  317. align-items: center;
  318. gap: 10px;
  319. padding: 9px 12px;
  320. border-radius: 10px;
  321. font-size: 13.5px;
  322. font-weight: 500;
  323. color: var(--text-secondary);
  324. border: 1px solid transparent;
  325. transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  326. }
  327. ​
  328. .nav a svg {
  329. width: 17px;
  330. height: 17px;
  331. flex-shrink: 0;
  332. }
  333. ​
  334. .nav a:hover {
  335. background: var(--bg-tertiary);
  336. color: var(--text-primary);
  337. transform: translateX(2px);
  338. }
  339. ​
  340. .nav a.active {
  341. background: var(--accent-soft);
  342. color: var(--accent);
  343. font-weight: 600;
  344. border-color: color-mix(in srgb, var(--accent) 22%, transparent);
  345. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.18);
  346. transform: none;
  347. }
  348. ​
  349. .sidebar-footer {
  350. margin-top: auto;
  351. padding-top: 14px;
  352. border-top: 1px solid var(--border-color);
  353. }
  354. ​
  355. .sidebar-footer a {
  356. display: flex;
  357. align-items: center;
  358. gap: 10px;
  359. padding: 9px 12px;
  360. border-radius: 8px;
  361. font-size: 13px;
  362. color: var(--text-secondary);
  363. }
  364. ​
  365. .sidebar-footer a:hover {
  366. background: var(--bg-hover);
  367. color: var(--text-primary);
  368. }
  369. ​
  370. .sidebar-footer .user {
  371. font-size: 12px;
  372. color: var(--text-tertiary);
  373. padding: 6px 12px 10px;
  374. }
  375. ​
  376. .main {
  377. flex: 1;
  378. min-width: 0;
  379. }
  380. ​
  381. .topbar {
  382. display: flex;
  383. align-items: center;
  384. gap: 14px;
  385. padding: 16px 28px;
  386. margin: 14px 14px 0;
  387. border: 1px solid var(--border-color);
  388. border-radius: 16px;
  389. background: linear-gradient(180deg, color-mix(in srgb, var(--bg-secondary) 94%, #fff) 0%, var(--bg-secondary) 100%);
  390. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.18), 0 12px 28px -14px rgba(0, 0, 0, 0.35);
  391. min-height: 68px;
  392. box-sizing: border-box;
  393. }
  394. ​
  395. .topbar h1 {
  396. font-size: 17px;
  397. font-weight: 600;
  398. }
  399. ​
  400. .mobile-topbar {
  401. display: none;
  402. }
  403. ​
  404. .mobile-menu-btn {
  405. width: 38px;
  406. height: 38px;
  407. display: flex;
  408. align-items: center;
  409. justify-content: center;
  410. background: var(--bg-tertiary);
  411. border: 1px solid var(--border-color);
  412. border-radius: 8px;
  413. }
  414. ​
  415. @media (max-width: 880px) {
  416. .app {
  417. flex-direction: column;
  418. }
  419. ​
  420. .sidebar {
  421. position: fixed;
  422. top: auto;
  423. bottom: calc(8px + env(safe-area-inset-bottom));
  424. left: calc(8px + env(safe-area-inset-left));
  425. right: calc(8px + env(safe-area-inset-right));
  426. width: auto;
  427. height: auto;
  428. margin: 0;
  429. flex-direction: row;
  430. align-items: center;
  431. padding: 6px;
  432. border-radius: 24px;
  433. border-color: var(--border-color);
  434. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  435. overflow: visible;
  436. z-index: 60;
  437. }
  438. ​
  439. .sidebar .brand,
  440. .sidebar-footer .user {
  441. display: none;
  442. }
  443. ​
  444. .nav {
  445. flex: 3 1 0;
  446. min-width: 0;
  447. flex-direction: row;
  448. justify-content: space-around;
  449. gap: 0;
  450. }
  451. ​
  452. .sidebar-footer {
  453. margin: 0;
  454. padding: 0;
  455. border: none;
  456. flex: 1 1 0;
  457. min-width: 0;
  458. display: flex;
  459. }
  460. ​
  461. .nav a,
  462. .sidebar-footer a {
  463. flex-direction: column;
  464. align-items: center;
  465. justify-content: center;
  466. gap: 3px;
  467. padding: 8px 4px;
  468. font-size: 10px;
  469. font-weight: 600;
  470. border-radius: 18px;
  471. text-align: center;
  472. flex: 1;
  473. transform: none;
  474. }
  475. ​
  476. .nav a:hover {
  477. transform: none;
  478. }
  479. ​
  480. .nav a svg {
  481. width: 20px;
  482. height: 20px;
  483. }
  484. ​
  485. .sidebar-footer a svg {
  486. width: 20px;
  487. height: 20px;
  488. }
  489. ​
  490. .sidebar-backdrop,
  491. .sidebar-backdrop.show {
  492. display: none;
  493. }
  494. ​
  495. .mobile-menu-btn {
  496. display: none;
  497. }
  498. ​
  499. .main {
  500. background: var(--bg-secondary);
  501. overflow-x: clip;
  502. }
  503. ​
  504. .mobile-topbar {
  505. display: flex;
  506. align-items: center;
  507. justify-content: space-between;
  508. padding: 12px 16px;
  509. background: var(--bg-primary);
  510. position: sticky;
  511. top: 0;
  512. z-index: 30;
  513. }
  514. ​
  515. .mobile-topbar::after {
  516. content: "";
  517. position: absolute;
  518. left: 0;
  519. right: 0;
  520. top: calc(100% - 1px);
  521. height: 24px;
  522. pointer-events: none;
  523. background:
  524. radial-gradient(circle at 100% 100%, transparent 23.5px, var(--bg-primary) 24.5px) left top / 24px 24px no-repeat,
  525. radial-gradient(circle at 0 100%, transparent 23.5px, var(--bg-primary) 24.5px) right top / 24px 24px no-repeat;
  526. }
  527. ​
  528. .content {
  529. padding: 18px 16px 110px;
  530. }
  531. ​
  532. .topbar {
  533. padding: 14px 16px;
  534. margin: 12px 12px 0;
  535. }
  536. }
  537. ​
  538. .content {
  539. max-width: 720px;
  540. margin: 0 auto;
  541. padding: 28px 20px 60px;
  542. }
  543. ​
  544. .panel {
  545. position: relative;
  546. background: linear-gradient(180deg, color-mix(in srgb, var(--bg-secondary) 94%, #fff) 0%, var(--bg-secondary) 100%);
  547. border: 1px solid var(--border-color);
  548. border-radius: 16px;
  549. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.18), 0 12px 28px -14px rgba(0, 0, 0, 0.35);
  550. padding: 24px;
  551. margin-bottom: 18px;
  552. opacity: 0;
  553. transform: translateY(10px);
  554. animation: panelIn 0.45s ease forwards;
  555. }
  556. ​
  557. .content .panel:nth-of-type(2) {
  558. animation-delay: 0.05s;
  559. }
  560. ​
  561. .content .panel:nth-of-type(3) {
  562. animation-delay: 0.1s;
  563. }
  564. ​
  565. .content .panel:nth-of-type(4) {
  566. animation-delay: 0.15s;
  567. }
  568. ​
  569. .content .panel:nth-of-type(5) {
  570. animation-delay: 0.2s;
  571. }
  572. ​
  573. .content .panel:nth-of-type(6) {
  574. animation-delay: 0.25s;
  575. }
  576. ​
  577. @keyframes panelIn {
  578. to {
  579. opacity: 1;
  580. transform: translateY(0);
  581. }
  582. }
  583. ​
  584. @media (prefers-reduced-motion: reduce) {
  585. .panel {
  586. animation: none;
  587. opacity: 1;
  588. transform: none;
  589. }
  590. }
  591. ​
  592. :root[data-no-intro] .panel {
  593. animation: none;
  594. opacity: 1;
  595. transform: none;
  596. }
  597. ​
  598. .panel h2 {
  599. font-size: 15px;
  600. font-weight: 600;
  601. margin-bottom: 4px;
  602. }
  603. ​
  604. .panel .desc {
  605. font-size: 12.5px;
  606. color: var(--text-secondary);
  607. margin-bottom: 18px;
  608. }
  609. ​
  610. .form-group {
  611. margin-bottom: 16px;
  612. }
  613. ​
  614. .form-group label {
  615. display: block;
  616. font-size: 12.5px;
  617. font-weight: 500;
  618. color: var(--text-secondary);
  619. margin-bottom: 6px;
  620. }
  621. ​
  622. .form-group input,
  623. .form-group select {
  624. width: 100%;
  625. padding: 10px 12px;
  626. background: var(--bg-primary);
  627. border: 1px solid var(--border-color);
  628. border-radius: 10px;
  629. color: var(--text-primary);
  630. font-size: 13.5px;
  631. font-family: inherit;
  632. box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  633. transition: border-color 0.2s ease, box-shadow 0.2s ease;
  634. }
  635. ​
  636. .form-group input:focus,
  637. .form-group select:focus {
  638. outline: none;
  639. border-color: var(--accent);
  640. box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  641. }
  642. ​
  643. .row {
  644. display: grid;
  645. grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  646. gap: 12px;
  647. }
  648. ​
  649. @media (max-width: 560px) {
  650. .row {
  651. grid-template-columns: minmax(0, 1fr);
  652. }
  653. }
  654. ​
  655. .checkbox-row {
  656. display: flex;
  657. align-items: center;
  658. gap: 10px;
  659. margin-bottom: 16px;
  660. }
  661. ​
  662. .checkbox-row label {
  663. margin: 0;
  664. font-size: 13px;
  665. color: var(--text-primary);
  666. font-weight: 500;
  667. cursor: pointer;
  668. }
  669. ​
  670. .switch {
  671. position: relative;
  672. display: inline-block;
  673. width: 42px;
  674. height: 24px;
  675. flex-shrink: 0;
  676. }
  677. ​
  678. .switch input {
  679. position: absolute;
  680. opacity: 0;
  681. width: 100%;
  682. height: 100%;
  683. margin: 0;
  684. cursor: pointer;
  685. z-index: 1;
  686. }
  687. ​
  688. .switch .track {
  689. position: absolute;
  690. inset: 0;
  691. background: var(--bg-tertiary);
  692. border: 1px solid var(--border-color);
  693. border-radius: 20px;
  694. box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
  695. transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  696. }
  697. ​
  698. .switch .track::after {
  699. content: '';
  700. position: absolute;
  701. top: 2px;
  702. left: 2px;
  703. width: 18px;
  704. height: 18px;
  705. background: white;
  706. border-radius: 50%;
  707. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  708. transition: transform 0.25s cubic-bezier(.22, 1, .36, 1);
  709. }
  710. ​
  711. .switch input:checked+.track {
  712. background: linear-gradient(155deg, var(--accent-hover), var(--accent));
  713. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 12px color-mix(in srgb, var(--accent) 35%, transparent);
  714. border-color: var(--accent);
  715. }
  716. ​
  717. .switch input:checked+.track::after {
  718. transform: translateX(18px);
  719. }
  720. ​
  721. .switch input:focus-visible+.track {
  722. outline: 2px solid var(--accent);
  723. outline-offset: 2px;
  724. }
  725. ​
  726. .btn {
  727. padding: 9px 16px;
  728. border-radius: 10px;
  729. font-size: 13px;
  730. font-weight: 600;
  731. cursor: pointer;
  732. border: 1px solid color-mix(in srgb, var(--border-color) 60%, var(--text-tertiary));
  733. background: var(--bg-tertiary);
  734. color: var(--text-primary);
  735. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.18);
  736. transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  737. }
  738. ​
  739. .btn:hover {
  740. background: var(--bg-hover);
  741. }
  742. ​
  743. .btn:active {
  744. transform: scale(0.97);
  745. }
  746. ​
  747. .btn.primary {
  748. background: linear-gradient(155deg, var(--accent-hover), var(--accent));
  749. border-color: var(--accent);
  750. color: white;
  751. box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(0, 0, 0, 0.2);
  752. }
  753. ​
  754. .btn.primary:hover {
  755. background: linear-gradient(155deg, var(--accent-hover), var(--accent-hover));
  756. box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  757. transform: translateY(-1px);
  758. }
  759. ​
  760. .btn.primary:active {
  761. transform: translateY(0) scale(0.98);
  762. }
  763. ​
  764. .flash {
  765. padding: 12px 16px;
  766. border-radius: 10px;
  767. font-size: 13px;
  768. margin-bottom: 18px;
  769. }
  770. ​
  771. .flash.success {
  772. background: var(--success-soft);
  773. color: var(--success);
  774. border: 1px solid var(--success);
  775. }
  776. ​
  777. .flash.error {
  778. background: var(--accent-soft);
  779. color: var(--accent);
  780. border: 1px solid var(--accent);
  781. }
  782. ​
  783. .hint {
  784. font-size: 12px;
  785. color: var(--text-tertiary);
  786. margin-top: -8px;
  787. margin-bottom: 16px;
  788. line-height: 1.5;
  789. }
  790. ​
  791. .field-warning {
  792. display: none;
  793. align-items: center;
  794. gap: 6px;
  795. font-size: 12px;
  796. color: #b45309;
  797. background: rgba(180, 83, 9, 0.1);
  798. border: 1px solid rgba(180, 83, 9, 0.35);
  799. border-radius: 6px;
  800. padding: 6px 10px;
  801. margin-top: 6px;
  802. line-height: 1.4;
  803. }
  804. ​
  805. .field-warning.show {
  806. display: flex;
  807. }
  808. ​
  809. .field-warning svg {
  810. flex-shrink: 0;
  811. }
  812. ​
  813. #external-fields {
  814. display: <?= env('GEO_PROVIDER', 'privacy-friendly') === 'external' ? 'block' : 'none' ?>;
  815. }
  816. ​
  817. #mysql-cred-fields {
  818. display: <?= env('DB_ENABLED', 'false') === 'true' ? 'block' : 'none' ?>;
  819. }
  820. .brand .mark,
  821. .logo {
  822. position: relative;
  823. overflow: hidden;
  824. background: linear-gradient(155deg, color-mix(in srgb, var(--accent) 72%, #fff) 0%, var(--accent) 48%, var(--accent-hover) 100%);
  825. border: 1px solid color-mix(in srgb, var(--accent) 65%, #000);
  826. 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);
  827. transition: transform 0.2s ease, box-shadow 0.2s ease;
  828. }
  829. ​
  830. .brand .mark::after,
  831. .logo::after {
  832. content: "";
  833. position: absolute;
  834. inset: 0 0 52% 0;
  835. background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
  836. pointer-events: none;
  837. }
  838. ​
  839. .brand .mark img,
  840. .logo img {
  841. position: relative;
  842. z-index: 1;
  843. filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
  844. }
  845. ​
  846. .brand:hover .mark,
  847. .logo:hover {
  848. transform: translateY(-1px);
  849. 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);
  850. }
  851. ​
  852. @media (prefers-reduced-motion: reduce) {
  853. .brand .mark,
  854. .logo {
  855. transition: none;
  856. }
  857. }
  858. ​
  859. .topbar {
  860. width: min(1144px, calc(100% - 56px));
  861. margin: 14px auto 0;
  862. }
  863. ​
  864. .content {
  865. max-width: 1200px;
  866. padding: 24px 28px 60px;
  867. box-sizing: border-box;
  868. columns: 2 440px;
  869. column-gap: 18px;
  870. }
  871. ​
  872. .content > .panel {
  873. break-inside: avoid;
  874. margin: 0 0 18px;
  875. }
  876. ​
  877. .content > .flash {
  878. column-span: all;
  879. }
  880. ​
  881. @media (max-width: 880px) {
  882. .topbar {
  883. width: calc(100% - 32px);
  884. margin: 12px auto 0;
  885. }
  886. ​
  887. .content {
  888. columns: 1;
  889. padding: 18px 16px 110px;
  890. }
  891. }
  892. ​
  893. @media (prefers-reduced-motion: no-preference) {
  894. @view-transition {
  895. navigation: auto;
  896. }
  897. ​
  898. .sidebar {
  899. view-transition-name: pm-sidebar;
  900. }
  901. ​
  902. ::view-transition-old(root),
  903. ::view-transition-new(root) {
  904. animation-duration: 0.18s;
  905. }
  906. ​
  907. ::view-transition-group(pm-sidebar) {
  908. animation-duration: 0s;
  909. }
  910. }
  911. ​
  912. </style>
  913. </head>
  914. ​
  915. <body>
  916. <div class="app">
  917. ​
  918. <div class="sidebar-backdrop" id="backdrop" onclick="closeSidebar()"></div>
  919. <aside class="sidebar" id="sidebar">
  920. <div class="brand">
  921. <div class="mark">
  922. <img src="logo.webp" alt="Logo" width="24" height="24" loading="lazy">
  923. </div>
  924. <div>
  925. <div class="name"><?= sanitize($siteName) ?></div>
  926. <div class="sub">PriviMetrics 2</div>
  927. </div>
  928. </div>
  929. <nav class="nav">
  930. <a href="dashboard.php?view=overview">
  931. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  932. <path d="M7 12v7M12 4v15M17 8v11"></path>
  933. </svg>
  934. Analytics
  935. </a>
  936. <a href="dashboard.php?view=sites">
  937. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  938. <path d="M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1 1"></path>
  939. <path d="M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1-1"></path>
  940. </svg>
  941. Sites
  942. </a>
  943. <a href="settings.php" class="active">
  944. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  945. <circle cx="12" cy="12" r="3" />
  946. <path d="M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 11-2.83 2.83l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-4 0v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 11-2.83-2.83l.06-.06a1.65 1.65 0 00.33-1.82 1.65 1.65 0 00-1.51-1H3a2 2 0 010-4h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 112.83-2.83l.06.06a1.65 1.65 0 001.82.33H9a1.65 1.65 0 001-1.51V3a2 2 0 014 0v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 112.83 2.83l-.06.06a1.65 1.65 0 00-.33 1.82V9a1.65 1.65 0 001.51 1H21a2 2 0 010 4h-.09a1.65 1.65 0 00-1.51 1z" />
  947. </svg>
  948. Settings
  949. </a>
  950. </nav>
  951. <div class="sidebar-footer">
  952. <div class="user">Signed in as <strong><?= sanitize($_SESSION['admin_username'] ?? '') ?></strong></div>
  953. <a href="logout.php">
  954. <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
  955. <path d="M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4" />
  956. <path d="M16 17l5-5-5-5" />
  957. <path d="M21 12H9" />
  958. </svg>
  959. Sign out
  960. </a>
  961. </div>
  962. </aside>
  963. ​
  964. <div class="main">
  965. <div class="mobile-topbar">
  966. <div class="mobile-menu-btn" onclick="openSidebar()">
  967. <svg width="24" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  968. <line x1="3" y1="12" x2="21" y2="12" />
  969. <line x1="3" y1="6" x2="21" y2="6" />
  970. <line x1="3" y1="18" x2="21" y2="18" />
  971. </svg>
  972. </div>
  973. <strong style="font-size:14px;"><?= sanitize($siteName) ?></strong>
  974. <div style="width:38px;"></div>
  975. </div>
  976. ​
  977. <div class="topbar">
  978. <h1>Settings</h1>
  979. <button type="button" class="btn" onclick="toggleTheme()" style="margin-left:auto;width:36px;height:36px;padding:0;display:flex;align-items:center;justify-content:center;background:var(--bg-tertiary);border:1px solid var(--border-color);border-radius:8px;cursor:pointer;"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  980. <circle cx="12" cy="12" r="5" />
  981. <path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42" />
  982. </svg></button>
  983. </div>
  984. ​
  985. <div class="content">
  986. <?php if ($flash): ?><div class="flash <?= $flash['type'] ?>"><?= sanitize($flash['text']) ?></div><?php endif; ?>
  987. ​
  988. <div class="panel">
  989. <h2>General</h2>
  990. <p class="desc">Basic configuration for this installation.</p>
  991. <form method="post">
  992. <input type="hidden" name="csrf_token" value="<?= sanitize($csrfToken) ?>">
  993. <input type="hidden" name="return" value="<?= sanitize($returnUrl) ?>">
  994. <input type="hidden" name="action" value="general">
  995. <div class="form-group">
  996. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  997. <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
  998. <line x1="3" y1="9" x2="21" y2="9"></line>
  999. <line x1="9" y1="21" x2="9" y2="9"></line>
  1000. </svg>Installation name</label>
  1001. <input type="text" name="site_name" value="<?= sanitize(env('SITE_NAME', 'PriviMetrics')) ?>" required>
  1002. </div>
  1003. <div class="row">
  1004. <div class="form-group">
  1005. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1006. <circle cx="12" cy="12" r="5"></circle>
  1007. <path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"></path>
  1008. </svg>Default theme</label>
  1009. <select name="default_theme" id="default_theme" onchange="setTheme(this.value)">
  1010. <option value="dark" <?= $theme === 'dark' ? 'selected' : '' ?>>Dark</option>
  1011. <option value="light" <?= $theme === 'light' ? 'selected' : '' ?>>Light</option>
  1012. </select>
  1013. </div>
  1014. <div class="form-group">
  1015. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1016. <circle cx="12" cy="12" r="10"></circle>
  1017. <polyline points="12 6 12 12 16 14"></polyline>
  1018. </svg>Session timeout (seconds)</label>
  1019. <input type="number" name="session_timeout" value="<?= sanitize(env('SESSION_TIMEOUT', '86400')) ?>" min="300">
  1020. </div>
  1021. </div>
  1022. <div class="form-group">
  1023. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1024. <line x1="8" y1="6" x2="21" y2="6"></line>
  1025. <line x1="8" y1="12" x2="21" y2="12"></line>
  1026. <line x1="8" y1="18" x2="21" y2="18"></line>
  1027. <line x1="3" y1="6" x2="3.01" y2="6"></line>
  1028. <line x1="3" y1="12" x2="3.01" y2="12"></line>
  1029. <line x1="3" y1="18" x2="3.01" y2="18"></line>
  1030. </svg>Top lists max rows</label>
  1031. <input type="number" name="top_lists_limit" value="<?= sanitize(env('TOP_LISTS_LIMIT', '8')) ?>" min="1" max="50">
  1032. </div>
  1033. <div class="form-group">
  1034. <label for="chart_style"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1035. <polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
  1036. </svg>Visits over time chart</label>
  1037. <select name="chart_style" id="chart_style">
  1038. <option value="bars" <?= in_array(env('CHART_STYLE', 'bars'), ['line', 'dots', 'aurora'], true) ? '' : 'selected' ?>>Bars (default)</option>
  1039. <option value="line" <?= env('CHART_STYLE', 'bars') === 'line' ? 'selected' : '' ?>>Smooth line</option>
  1040. <option value="dots" <?= env('CHART_STYLE', 'bars') === 'dots' ? 'selected' : '' ?>>Dot matrix</option>
  1041. <option value="aurora" <?= env('CHART_STYLE', 'bars') === 'aurora' ? 'selected' : '' ?>>Aurora (neon)</option>
  1042. </select>
  1043. </div>
  1044. <div class="checkbox-row">
  1045. <span class="switch">
  1046. <input type="checkbox" name="top_lists_show_all" id="top_lists_show_all" <?= env('TOP_LISTS_SHOW_ALL', 'false') === 'true' ? 'checked' : '' ?>>
  1047. <span class="track"></span>
  1048. </span>
  1049. <label for="top_lists_show_all"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1050. <path d="M3 3h18v18H3z"></path>
  1051. <line x1="3" y1="9" x2="21" y2="9"></line>
  1052. <line x1="3" y1="15" x2="21" y2="15"></line>
  1053. <line x1="9" y1="9" x2="9" y2="21"></line>
  1054. </svg>Detailed data: show all rows (ignores the max rows limit)</label>
  1055. </div>
  1056. <div class="checkbox-row">
  1057. <span class="switch">
  1058. <input type="checkbox" name="respect_dnt" id="respect_dnt" <?= env('RESPECT_DNT', 'true') === 'true' ? 'checked' : '' ?>>
  1059. <span class="track"></span>
  1060. </span>
  1061. <label for="respect_dnt"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1062. <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path>
  1063. <line x1="12" y1="8" x2="12" y2="12"></line>
  1064. <line x1="12" y1="16" x2="12.01" y2="16"></line>
  1065. </svg>Respect the Do Not Track header</label>
  1066. </div>
  1067. <div class="checkbox-row">
  1068. <span class="switch">
  1069. <input type="checkbox" name="track_ip_default" id="track_ip_default" <?= env('TRACK_IP_DEFAULT', 'false') === 'true' ? 'checked' : '' ?>>
  1070. <span class="track"></span>
  1071. </span>
  1072. <label for="track_ip_default"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1073. <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
  1074. <circle cx="12" cy="12" r="3"></circle>
  1075. </svg>Track partial IP by default (unless the script says otherwise)</label>
  1076. </div>
  1077. <button type="submit" class="btn primary">Save</button>
  1078. </form>
  1079. </div>
  1080. ​
  1081. <div class="panel">
  1082. <h2>Data Collection</h2>
  1083. <p class="desc">Turn specific kinds of tracking on or off across all sites. Any individual site can still override these from its own settings (Add/Edit site).</p>
  1084. <form method="post">
  1085. <input type="hidden" name="csrf_token" value="<?= sanitize($csrfToken) ?>">
  1086. <input type="hidden" name="return" value="<?= sanitize($returnUrl) ?>">
  1087. <input type="hidden" name="action" value="data_collection">
  1088. <div class="checkbox-row">
  1089. <span class="switch">
  1090. <input type="checkbox" name="feature_traffic_sources" id="feature_traffic_sources" <?= pmFeatureGlobalEnabled('traffic_sources') ? 'checked' : '' ?>>
  1091. <span class="track"></span>
  1092. </span>
  1093. <label for="feature_traffic_sources"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1094. <circle cx="12" cy="12" r="10"></circle>
  1095. <line x1="2" y1="12" x2="22" y2="12"></line>
  1096. <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path>
  1097. </svg>Track traffic sources (referrers and utm_source)</label>
  1098. </div>
  1099. <div class="checkbox-row">
  1100. <span class="switch">
  1101. <input type="checkbox" name="feature_visitor_countries" id="feature_visitor_countries" <?= pmFeatureGlobalEnabled('visitor_countries') ? 'checked' : '' ?>>
  1102. <span class="track"></span>
  1103. </span>
  1104. <label for="feature_visitor_countries"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1105. <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
  1106. <circle cx="12" cy="10" r="3"></circle>
  1107. </svg>Track visitor countries</label>
  1108. </div>
  1109. <div class="checkbox-row">
  1110. <span class="switch">
  1111. <input type="checkbox" name="feature_search_queries" id="feature_search_queries" <?= pmFeatureGlobalEnabled('search_queries') ? 'checked' : '' ?>>
  1112. <span class="track"></span>
  1113. </span>
  1114. <label for="feature_search_queries"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1115. <circle cx="11" cy="11" r="8"></circle>
  1116. <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
  1117. </svg>Track on-site search queries</label>
  1118. </div>
  1119. <div class="checkbox-row">
  1120. <span class="switch">
  1121. <input type="checkbox" name="feature_device_type" id="feature_device_type" <?= pmFeatureGlobalEnabled('device_type') ? 'checked' : '' ?>>
  1122. <span class="track"></span>
  1123. </span>
  1124. <label for="feature_device_type"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1125. <rect x="5" y="2" width="14" height="20" rx="2" ry="2"></rect>
  1126. <line x1="12" y1="18" x2="12.01" y2="18"></line>
  1127. </svg>Track device type (mobile/tablet/desktop)</label>
  1128. </div>
  1129. <div class="checkbox-row">
  1130. <span class="switch">
  1131. <input type="checkbox" name="feature_browser_detection" id="feature_browser_detection" <?= pmFeatureGlobalEnabled('browser_detection') ? 'checked' : '' ?>>
  1132. <span class="track"></span>
  1133. </span>
  1134. <label for="feature_browser_detection"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1135. <rect x="2" y="3" width="20" height="18" rx="2" ry="2"></rect>
  1136. <line x1="2" y1="8" x2="22" y2="8"></line>
  1137. <circle cx="5.5" cy="5.5" r="0.5"></circle>
  1138. <circle cx="8" cy="5.5" r="0.5"></circle>
  1139. </svg>Detect browser (off by default, detected locally on your server)</label>
  1140. </div>
  1141. <div class="checkbox-row">
  1142. <span class="switch">
  1143. <input type="checkbox" name="feature_search_engines" id="feature_search_engines" <?= pmFeatureGlobalEnabled('search_engines') ? 'checked' : '' ?>>
  1144. <span class="track"></span>
  1145. </span>
  1146. <label for="feature_search_engines"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1147. <circle cx="11" cy="11" r="8"></circle>
  1148. <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
  1149. </svg>Show search engines and AI search (uses traffic sources)</label>
  1150. </div>
  1151. <div class="checkbox-row">
  1152. <span class="switch">
  1153. <input type="checkbox" name="feature_crawlers" id="feature_crawlers" <?= pmFeatureGlobalEnabled('crawlers') ? 'checked' : '' ?>>
  1154. <span class="track"></span>
  1155. </span>
  1156. <label for="feature_crawlers"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1157. <rect x="4" y="8" width="16" height="12" rx="3"></rect>
  1158. <line x1="12" y1="8" x2="12" y2="4"></line>
  1159. <line x1="9" y1="13" x2="9.01" y2="13"></line>
  1160. <line x1="15" y1="13" x2="15.01" y2="13"></line>
  1161. </svg>Show crawlers and AI agents</label>
  1162. </div>
  1163. <button type="submit" class="btn primary">Save</button>
  1164. </form>
  1165. </div>
  1166. ​
  1167. <div class="panel">
  1168. <h2>System Version</h2>
  1169. <p class="desc">Current application version.</p>
  1170. ​
  1171. <div class="form-group">
  1172. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1173. <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
  1174. <polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
  1175. <line x1="12" y1="22.08" x2="12" y2="12"></line>
  1176. </svg>Version</label>
  1177. <input type="text" value="<?= sanitize($currentVersion) ?>" disabled style="opacity: 0.8; cursor: not-allowed;">
  1178. </div>
  1179. </div>
  1180. ​
  1181. <div class="panel">
  1182. <h2>Fonts</h2>
  1183. <p class="desc">Choose the typeface used for each part of the interface — body text, headings, and the big stat numbers on the dashboard.</p>
  1184. <form method="post">
  1185. <input type="hidden" name="csrf_token" value="<?= sanitize($csrfToken) ?>">
  1186. <input type="hidden" name="return" value="<?= sanitize($returnUrl) ?>">
  1187. <input type="hidden" name="action" value="fonts">
  1188. <div class="form-group">
  1189. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1190. <line x1="4" y1="8" x2="18" y2="8"></line>
  1191. <line x1="4" y1="12" x2="18" y2="12"></line>
  1192. <line x1="4" y1="16" x2="13" y2="16"></line>
  1193. </svg>Body text</label>
  1194. <select name="font_body">
  1195. <?php foreach (fontOptions('body') as $slug => $opt): ?>
  1196. <option value="<?= sanitize($slug) ?>" style="font-family:<?= sanitize($opt['family']) ?>;" <?= fontSlug('body') === $slug ? 'selected' : '' ?>><?= sanitize($opt['label']) ?></option>
  1197. <?php endforeach; ?>
  1198. </select>
  1199. </div>
  1200. <div class="form-group">
  1201. <label>
  1202. <svg viewBox="0 0 40 24" width="18" height="10.5" style="vertical-align:-2px;margin-right:6px;">
  1203. <text x="0" y="20" font-family="Arial, sans-serif" font-size="24" font-weight="bold" fill="currentColor">Aa</text>
  1204. </svg>
  1205. Headings
  1206. </label>
  1207. <select name="font_heading">
  1208. <?php foreach (fontOptions('heading') as $slug => $opt): ?>
  1209. <option value="<?= sanitize($slug) ?>" style="font-family:<?= sanitize($opt['family']) ?>;" <?= fontSlug('heading') === $slug ? 'selected' : '' ?>><?= sanitize($opt['label']) ?></option>
  1210. <?php endforeach; ?>
  1211. </select>
  1212. </div>
  1213. <div class="form-group">
  1214. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1215. <line x1="7" y1="17" x2="7" y2="12"></line>
  1216. <line x1="12" y1="17" x2="12" y2="8"></line>
  1217. <line x1="17" y1="17" x2="17" y2="4"></line>
  1218. </svg>Dashboard stat numbers</label>
  1219. <select name="font_value">
  1220. <?php foreach (fontOptions('value') as $slug => $opt): ?>
  1221. <option value="<?= sanitize($slug) ?>" style="font-family:<?= sanitize($opt['family']) ?>;" <?= fontSlug('value') === $slug ? 'selected' : '' ?>><?= sanitize($opt['label']) ?></option>
  1222. <?php endforeach; ?>
  1223. </select>
  1224. </div>
  1225. <button type="submit" class="btn primary">Save</button>
  1226. </form>
  1227. </div>
  1228. ​
  1229. <div class="panel">
  1230. <h2>Geolocation</h2>
  1231. <p class="desc">By default, PriviMetrics 2 never sends any IP address anywhere — the country is guessed from the visitor's timezone and browser language. An external provider requires sending the IP address off-server.</p>
  1232. <form method="post">
  1233. <input type="hidden" name="csrf_token" value="<?= sanitize($csrfToken) ?>">
  1234. <input type="hidden" name="return" value="<?= sanitize($returnUrl) ?>">
  1235. <input type="hidden" name="action" value="geo">
  1236. <div class="form-group">
  1237. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1238. <circle cx="12" cy="12" r="10"></circle>
  1239. <line x1="2" y1="12" x2="22" y2="12"></line>
  1240. <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path>
  1241. </svg>Method</label>
  1242. <select name="geo_provider" id="geo_provider" onchange="document.getElementById('external-fields').style.display = this.value === 'external' ? 'block' : 'none'">
  1243. <option value="privacy-friendly" <?= env('GEO_PROVIDER', 'privacy-friendly') !== 'external' ? 'selected' : '' ?>>Privacy-first (no IP) — recommended</option>
  1244. <option value="external" <?= env('GEO_PROVIDER', 'privacy-friendly') === 'external' ? 'selected' : '' ?>>External provider (sends IP)</option>
  1245. </select>
  1246. </div>
  1247. <div id="external-fields">
  1248. <div class="form-group">
  1249. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1250. <rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
  1251. <rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
  1252. <line x1="6" y1="6" x2="6.01" y2="6"></line>
  1253. <line x1="6" y1="18" x2="6.01" y2="18"></line>
  1254. </svg>Provider</label>
  1255. <select name="geo_external_service">
  1256. <?php $svc = env('GEO_EXTERNAL_SERVICE', 'ip-api'); ?>
  1257. <option value="ip-api" <?= $svc === 'ip-api' ? 'selected' : '' ?>>ip-api.com (free, no key)</option>
  1258. <option value="ipinfo" <?= $svc === 'ipinfo' ? 'selected' : '' ?>>IPinfo.io</option>
  1259. <option value="ipstack" <?= $svc === 'ipstack' ? 'selected' : '' ?>>ipstack</option>
  1260. <option value="ip2location" <?= $svc === 'ip2location' ? 'selected' : '' ?>>IP2Location.io</option>
  1261. <option value="dbip" <?= $svc === 'dbip' ? 'selected' : '' ?>>DB-IP (free, no key)</option>
  1262. </select>
  1263. </div>
  1264. <div class="form-group">
  1265. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1266. <path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"></path>
  1267. </svg>API key (if required)</label>
  1268. <input type="text" name="geo_api_key" value="<?= sanitize(env('GEO_API_KEY', '')) ?>" placeholder="leave blank for ip-api / dbip">
  1269. </div>
  1270. </div>
  1271. <button type="submit" class="btn primary">Save</button>
  1272. </form>
  1273. </div>
  1274. ​
  1275. <div class="panel">
  1276. <h2>Rate limits</h2>
  1277. <p class="desc">How many requests per second are allowed per tracking code, separately for XML, PMAF and MySQL.</p>
  1278. <form method="post">
  1279. <input type="hidden" name="csrf_token" value="<?= sanitize($csrfToken) ?>">
  1280. <input type="hidden" name="return" value="<?= sanitize($returnUrl) ?>">
  1281. <input type="hidden" name="action" value="rate_limits">
  1282. <div class="row">
  1283. <div class="form-group">
  1284. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1285. <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
  1286. <polyline points="14 2 14 8 20 8"></polyline>
  1287. <line x1="16" y1="13" x2="8" y2="13"></line>
  1288. <line x1="16" y1="17" x2="8" y2="17"></line>
  1289. <polyline points="10 9 9 9 8 9"></polyline>
  1290. </svg>XML — requests / second</label>
  1291. <input type="number" name="rate_limit_xml" value="<?= sanitize(env('RATE_LIMIT_XML', '2')) ?>" min="0" max="50">
  1292. <div class="field-warning" id="warn_rate_limit_xml">
  1293. <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  1294. <path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
  1295. <line x1="12" y1="9" x2="12" y2="13"></line>
  1296. <line x1="12" y1="17" x2="12.01" y2="17"></line>
  1297. </svg>
  1298. <span></span>
  1299. </div>
  1300. </div>
  1301. <div class="form-group">
  1302. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1303. <ellipse cx="12" cy="5" rx="9" ry="3"></ellipse>
  1304. <path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path>
  1305. <path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path>
  1306. </svg>MySQL — requests / second</label>
  1307. <input type="number" name="rate_limit_mysql" value="<?= sanitize(env('RATE_LIMIT_MYSQL', '5')) ?>" min="0" max="100">
  1308. <div class="field-warning" id="warn_rate_limit_mysql">
  1309. <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  1310. <path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
  1311. <line x1="12" y1="9" x2="12" y2="13"></line>
  1312. <line x1="12" y1="17" x2="12.01" y2="17"></line>
  1313. </svg>
  1314. <span></span>
  1315. </div>
  1316. </div>
  1317. </div>
  1318. <div class="form-group">
  1319. <label><svg viewBox="0 0 813 800" width="14" height="14" fill="currentColor" style="vertical-align:-2px;margin-right:6px;">
  1320. <g transform="translate(0,800) scale(1,-1)">
  1321. <path d="M763 707V443L660 340H360V40H440V0H50V40H130V760H50V800H670ZM315 40V760H175V40ZM360 380H533V760H360ZM718 690 648 760H578V380H638L718 460Z"></path>
  1322. </g>
  1323. </svg>PriviMetrics Analytics Format — requests / second</label>
  1324. <input type="number" name="rate_limit_pmaf" value="<?= sanitize(env('RATE_LIMIT_PMAF', '4')) ?>" min="0" max="80">
  1325. <div class="field-warning" id="warn_rate_limit_pmaf">
  1326. <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  1327. <path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
  1328. <line x1="12" y1="9" x2="12" y2="13"></line>
  1329. <line x1="12" y1="17" x2="12.01" y2="17"></line>
  1330. </svg>
  1331. <span></span>
  1332. </div>
  1333. </div>
  1334. <button type="submit" class="btn primary">Save</button>
  1335. </form>
  1336. </div>
  1337. ​
  1338. <div class="panel">
  1339. <h2>MySQL database</h2>
  1340. <p class="desc">Optional. You can enable MySQL as an additional storage engine — individual sites can still use XML.</p>
  1341. <form method="post">
  1342. <input type="hidden" name="csrf_token" value="<?= sanitize($csrfToken) ?>">
  1343. <input type="hidden" name="return" value="<?= sanitize($returnUrl) ?>">
  1344. <input type="hidden" name="action" value="mysql">
  1345. <div class="checkbox-row">
  1346. <span class="switch">
  1347. <input type="checkbox" name="db_enabled" id="db_enabled" <?= env('DB_ENABLED', 'false') === 'true' ? 'checked' : '' ?> onchange="document.getElementById('mysql-cred-fields').style.display = this.checked ? 'block' : 'none'">
  1348. <span class="track"></span>
  1349. </span>
  1350. <label for="db_enabled"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1351. <ellipse cx="12" cy="5" rx="9" ry="3"></ellipse>
  1352. <path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path>
  1353. <path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path>
  1354. </svg>Enable MySQL</label>
  1355. </div>
  1356. <div id="mysql-cred-fields">
  1357. <div class="row">
  1358. <div class="form-group">
  1359. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1360. <rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect>
  1361. <rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect>
  1362. <line x1="6" y1="6" x2="6.01" y2="6"></line>
  1363. <line x1="6" y1="18" x2="6.01" y2="18"></line>
  1364. </svg>Host</label>
  1365. <input type="text" name="db_host" value="<?= sanitize(env('DB_HOST', 'localhost')) ?>">
  1366. </div>
  1367. <div class="form-group">
  1368. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1369. <circle cx="12" cy="12" r="10"></circle>
  1370. <line x1="2" y1="12" x2="22" y2="12"></line>
  1371. <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path>
  1372. </svg>Port</label>
  1373. <input type="text" name="db_port" value="<?= sanitize(env('DB_PORT', '3306')) ?>">
  1374. </div>
  1375. </div>
  1376. <div class="form-group">
  1377. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1378. <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path>
  1379. </svg>Database name</label>
  1380. <input type="text" name="db_name" value="<?= sanitize(env('DB_NAME', '')) ?>">
  1381. </div>
  1382. <div class="row">
  1383. <div class="form-group">
  1384. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1385. <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
  1386. <circle cx="12" cy="7" r="4"></circle>
  1387. </svg>User</label>
  1388. <input type="text" name="db_user" value="<?= sanitize(env('DB_USER', '')) ?>">
  1389. </div>
  1390. <div class="form-group">
  1391. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1392. <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
  1393. <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
  1394. </svg>Password</label>
  1395. <input type="password" name="db_pass" placeholder="leave blank to keep unchanged" autocomplete="new-password">
  1396. </div>
  1397. </div>
  1398. </div>
  1399. <button type="submit" class="btn primary">Save &amp; test connection</button>
  1400. </form>
  1401. </div>
  1402. ​
  1403. <div class="panel" id="updates">
  1404. <h2>Updates</h2>
  1405. <p class="desc">Installed version <strong><?= sanitize($currentVersion) ?></strong>. <?= env('AUTO_UPDATE', 'false') === 'true' ? '<strong>Automatic updates are enabled:</strong> new versions are installed by cron without review.' : 'The update server is contacted only when you open the updater and press a button.' ?></p>
  1406. <a href="updater.php" class="btn" style="display:inline-block;">Check for updates</a>
  1407. </div>
  1408. ​
  1409. <div class="panel">
  1410. <h2>Change password</h2>
  1411. <p class="desc">Updates the admin password stored in .env.</p>
  1412. <form method="post">
  1413. <input type="hidden" name="csrf_token" value="<?= sanitize($csrfToken) ?>">
  1414. <input type="hidden" name="return" value="<?= sanitize($returnUrl) ?>">
  1415. <input type="hidden" name="action" value="password">
  1416. <div class="form-group">
  1417. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1418. <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
  1419. <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
  1420. </svg>Current password</label>
  1421. <input type="password" name="current_password" required autocomplete="current-password">
  1422. </div>
  1423. <div class="row">
  1424. <div class="form-group">
  1425. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1426. <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
  1427. <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
  1428. <circle cx="12" cy="16" r="1"></circle>
  1429. </svg>New password</label>
  1430. <input type="password" name="new_password" required minlength="8" autocomplete="new-password">
  1431. </div>
  1432. <div class="form-group">
  1433. <label><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:6px;">
  1434. <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
  1435. <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
  1436. <polyline points="13 16 11 18 13 20"></polyline>
  1437. </svg>Confirm new password</label>
  1438. <input type="password" name="new_password_confirm" required minlength="8" autocomplete="new-password">
  1439. </div>
  1440. </div>
  1441. <button type="submit" class="btn primary">Change password</button>
  1442. </form>
  1443. </div>
  1444. </div>
  1445. </div>
  1446. </div>
  1447. <script>
  1448. function checkRateLimit(input, lowThreshold, highThreshold, tooHighMsg) {
  1449. var warn = document.getElementById('warn_' + input.name);
  1450. if (!warn) return;
  1451. var span = warn.querySelector('span');
  1452. var val = input.value === '' ? NaN : parseInt(input.value, 10);
  1453. ​
  1454. if (isNaN(val)) {
  1455. warn.classList.remove('show');
  1456. return;
  1457. }
  1458. if (val === 0) {
  1459. span.textContent = 'Set to 0 — this format will be blocked entirely.';
  1460. warn.classList.add('show');
  1461. } else if (val < lowThreshold) {
  1462. span.textContent = 'Very low limit — busy sites may have hits dropped and lose tracking data.';
  1463. warn.classList.add('show');
  1464. } else if (val > highThreshold) {
  1465. span.textContent = tooHighMsg;
  1466. warn.classList.add('show');
  1467. } else {
  1468. warn.classList.remove('show');
  1469. }
  1470. }
  1471. ​
  1472. (function() {
  1473. var el;
  1474. el = document.getElementsByName('rate_limit_xml')[0];
  1475. if (el) el.addEventListener('input', function() {
  1476. checkRateLimit(this, 1, 5, 'High for XML — every hit rewrites the whole file, so cost grows with total history, not just rate. Consider PMAF or MySQL instead.');
  1477. });
  1478. el = document.getElementsByName('rate_limit_mysql')[0];
  1479. if (el) el.addEventListener('input', function() {
  1480. checkRateLimit(this, 1, 50, 'Very high — check your MySQL max_connections and server capacity can actually sustain this.');
  1481. });
  1482. el = document.getElementsByName('rate_limit_pmaf')[0];
  1483. if (el) el.addEventListener('input', function() {
  1484. checkRateLimit(this, 1, 15, 'High — writes serialize on a per-site file lock, so requests will queue rather than run in parallel at this rate.');
  1485. });
  1486. ​
  1487. ['rate_limit_xml', 'rate_limit_mysql', 'rate_limit_pmaf'].forEach(function(name) {
  1488. var el = document.getElementsByName(name)[0];
  1489. if (el) el.dispatchEvent(new Event('input'));
  1490. });
  1491. })();
  1492. ​
  1493. function setTheme(t) {
  1494. document.documentElement.setAttribute('data-theme', t);
  1495. localStorage.setItem('pm_theme', t);
  1496. }
  1497. ​
  1498. function toggleTheme() {
  1499. var h = document.documentElement;
  1500. var n = h.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
  1501. setTheme(n);
  1502. }
  1503. ​
  1504. function openSidebar() {
  1505. document.getElementById('sidebar').classList.add('open');
  1506. document.getElementById('backdrop').classList.add('show');
  1507. }
  1508. ​
  1509. function closeSidebar() {
  1510. document.getElementById('sidebar').classList.remove('open');
  1511. document.getElementById('backdrop').classList.remove('show');
  1512. }
  1513. (function() {
  1514. var sel = document.getElementById('default_theme');
  1515. var saved = localStorage.getItem('pm_theme');
  1516. if (sel && saved) sel.value = saved;
  1517. new MutationObserver(function(ms) {
  1518. ms.forEach(function(m) {
  1519. if (m.attributeName === 'data-theme' && sel) {
  1520. sel.value = document.documentElement.getAttribute('data-theme');
  1521. }
  1522. });
  1523. }).observe(document.documentElement, {
  1524. attributes: true
  1525. });
  1526. })();
  1527. </script>
  1528. <script>
  1529. (function() {
  1530. var view = new URLSearchParams(location.search).get('view') || 'overview';
  1531. var key = 'pm_scroll:' + location.pathname + ':' + view;
  1532. try {
  1533. if ('scrollRestoration' in history) history.scrollRestoration = 'manual';
  1534. var saved = sessionStorage.getItem(key);
  1535. if (saved !== null) {
  1536. var y = parseInt(saved, 10) || 0;
  1537. window.scrollTo(0, y);
  1538. requestAnimationFrame(function() { window.scrollTo(0, y); });
  1539. window.addEventListener('load', function() { window.scrollTo(0, y); }, { once: true });
  1540. }
  1541. } catch (e) {}
  1542. window.addEventListener('pagehide', function() {
  1543. try { sessionStorage.setItem(key, String(Math.round(window.scrollY))); } catch (e) {}
  1544. });
  1545. })();
  1546. </script>
  1547. </body>
  1548. ​
  1549. </html>