View file top/inc/counter.php

File size: 1.56Kb
<?php
error_reporting(0);
$today_array=file($daylog_data);
$base_array=file($hit_data);
$total=trim($base_array[0]);
$hit_today=trim($base_array[1]);
if ($today_array[0]) $record = explode("¤", trim($today_array[0]));
if ($record) $host_today=trim(count($record)-1); else $host_today = 0;
function string_size($string)
{
  if (strlen($string)=="1")  { $string="         $string"; }
  if (strlen($string)=="2")  { $string="        $string"; }
  if (strlen($string)=="3")  { $string="       $string"; }
  if (strlen($string)=="4")  { $string="      $string"; }
  if (strlen($string)=="5")  { $string="     $string"; }
  if (strlen($string)=="6")  { $string="    $string"; }
  if (strlen($string)=="7")  { $string="   $string"; }
  if (strlen($string)=="8")  { $string="  $string"; }
  if (strlen($string)=="9")  { $string=" $string"; }
  if (strlen($string)>="10") { $string="$string"; }
  return $string;
}
$total=string_size($total);
$hit_today=string_size($hit_today);
$host_today=string_size($host_today);
header("Content-Type:image/png");
if ((isset($_GET['counters'])) && ($_GET['counters']=="yes")) $image="./images/counter2.png"; else $image="./images/counter.png";
$coin=imagecreatefrompng ($image);
$total_color=imagecolorallocate($coin, 0, 0, 205);
$host_color=imagecolorallocate($coin, 0, 0, 205);
$hit_color=imagecolorallocate($coin, 0, 0, 205);
ImageString($coin, 1, 36, 2, $total, $total_color);
ImageString($coin, 1, 36, 22, $host_today, $host_color);
ImageString($coin, 1, 36, 13, $hit_today, $hit_color);
ImagePNG ($coin);
ImageDestroy ($coin);
?>