差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

id_contentfooter [2026/06/17 05:51] – 建立 hostid_contentfooter [2026/06/17 06:04] (目前版本) host
行 1: 行 1:
-<div class="pageviews text-end text-muted small mt-4">+<div class="pageviews text-end text-muted small mt-3 pt-3 border-top">
   Views:    Views: 
   <?php   <?php
   global $ID;   global $ID;
   $counter_dir = DOKU_CONF . 'pagecounters/';   $counter_dir = DOKU_CONF . 'pagecounters/';
-  if (!is_dir($counter_dir)) @mkdir($counter_dir, 0755, true);+  if (!is_dir($counter_dir)) 
 +      @mkdir($counter_dir, 0755, true); 
 +  }
  
   $counter_file = $counter_dir . md5($ID) . '.txt';   $counter_file = $counter_dir . md5($ID) . '.txt';
   $count = file_exists($counter_file) ? (int)file_get_contents($counter_file) : 0;   $count = file_exists($counter_file) ? (int)file_get_contents($counter_file) : 0;
  
-  // Increment only for real users (ignore most bots) +  // Increment only for real visitors (ignore bots) 
-  if (!isset($_SERVER['HTTP_USER_AGENT']) ||  +  $ua = $_SERVER['HTTP_USER_AGENT'?? ''; 
-      !preg_match('/bot|crawl|spider|slurp|pingdom|semrush|ahrefs/i', $_SERVER['HTTP_USER_AGENT'])) {+  if (!preg_match('/bot|crawl|spider|slurp|pingdom|semrush|ahrefs|mj12bot|googlebot/i', $ua)) {
       $count++;       $count++;
       file_put_contents($counter_file, $count);       file_put_contents($counter_file, $count);
   }   }
  
-  echo $count;+  echo number_format($count);
   ?>   ?>
 </div> </div>