analytics.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. function dw_wik_places() {
  3. $url = "https://davidawindham.com/wik/";
  4. $url .= "?module=API&method=UserCountry.getCity";
  5. $url .= "&idSite=1&period=month&date=yesterday";
  6. $url .= "&format=JSON&filter_limit=50";
  7. $url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
  8. $fetched = file_get_contents($url);
  9. $content = json_decode($fetched,true);
  10. if (!$content) {
  11. print("Error, content fetched = " . $fetched);
  12. }
  13. foreach ($content as $row) {
  14. $location = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
  15. $hits = $row['nb_visits'];
  16. $logo = $row['logo'];
  17. $length = $row['sum_visit_length'];
  18. print("<li class='list-group-item'><img src='https://davidawindham.com/wik/$logo' style='width:20px;'/> &nbsp; $location <span class='badge'> $hits </span></li>");
  19. }
  20. }
  21. function dw_wik_url() {
  22. $url = "https://davidawindham.com/wik/";
  23. $url .= "?module=API&method=Actions.getPageUrls";
  24. $url .= "&idSite=1&period=month&date=yesterday";
  25. // flat=1 expands the hierarchical folder report into individual page URLs, so the
  26. // /til subpages (tracked via docusaurus-plugin-matomo) show instead of one "til" folder.
  27. $url .= "&format=JSON&filter_limit=50&flat=1";
  28. $url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
  29. $fetched = file_get_contents($url);
  30. $content = json_decode($fetched,true);
  31. if (!$content) {
  32. print("Error, content fetched = " . $fetched);
  33. }
  34. foreach ($content as $row) {
  35. $label = $row['label'];
  36. $hits = $row['nb_hits'];
  37. $path = '/' . ltrim( html_entity_decode( urldecode( $label ), ENT_QUOTES ), '/' ); // flat labels start with "/"
  38. $disp = htmlspecialchars( $path, ENT_QUOTES );
  39. $text = ( '/' === $path ) ? '/index' : $disp; // bare "/" is too small to click
  40. print("<li class='list-group-item'> <a href='https://davidwindham.com$disp'>$text</a> <span class='badge'> $hits </span></li>");
  41. }
  42. }
  43. function dw_wik_users() {
  44. $url = "https://davidawindham.com/wik/";
  45. $url .= "?module=API&method=DevicesDetection.getOsFamilies";
  46. $url .= "&idSite=1&period=month&date=yesterday";
  47. $url .= "&format=JSON&filter_limit=10";
  48. $url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
  49. $fetched = file_get_contents($url);
  50. $content = json_decode($fetched,true);
  51. if (!$content) {
  52. print("Error, content fetched = " . $fetched);
  53. }
  54. foreach ($content as $row) {
  55. $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
  56. $label = $row['label'];
  57. $hits = $row['nb_visits'];
  58. print("<li class='list-group-item'> $label <span class='badge'> $hits </span></li>");
  59. }
  60. }
  61. function dw_wik_keys() {
  62. $url = "https://davidawindham.com/wik/";
  63. $url .= "?module=API&method=Referrers.getReferrerType";
  64. $url .= "&idSite=1&period=month&date=yesterday";
  65. $url .= "&format=JSON&filter_limit=20";
  66. $url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
  67. $fetched = file_get_contents($url);
  68. $content = json_decode($fetched,true);
  69. if (!$content) {
  70. print("Error, content fetched = " . $fetched);
  71. }
  72. foreach ($content as $row) {
  73. $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
  74. $label = $row['label'];
  75. $hits = $row['nb_visits'];
  76. print("<li class='list-group-item'> $label <span class='badge'> $hits </span></li>");
  77. }
  78. }
  79. function dw_wik_refs() {
  80. $url = "https://davidawindham.com/wik/";
  81. $url .= "?module=API&method=Referrers.getAll";
  82. $url .= "&idSite=1&period=month&date=yesterday";
  83. $url .= "&format=JSON&filter_limit=20";
  84. $url .= "&token_auth=3910b0da85f448ae35d4b75b4e6912bb";
  85. $fetched = file_get_contents($url);
  86. $content = json_decode($fetched,true);
  87. if (!$content) {
  88. print("Error, content fetched = " . $fetched);
  89. }
  90. foreach ($content as $row) {
  91. $urls = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
  92. $label = $row['label'];
  93. $hits = $row['nb_visits'];
  94. print("<li class='list-group-item'> $label <span class='badge'> $hits </span></li>");
  95. }
  96. }
  97. ?>