Reprint of T-Count 5, High-Performance CGI Access Counter Released – Double Count Prevention Function Added and Remade as T-Count Ver.5.03+ 【Free CGI Redistribution/Download】

update Last updated: December 29, 2023 at 2:24 PM

We will remake the high-performance graphic CGI access counter "T-Count 5" that has disappeared from the net and release it as a reprint version T-Count 5 Ver. 5.03+.

【Software name】 T-Count 5
【Version】 5.03
【Last updated】 2004/06/02
【Type】 Counter
【Development】 T (
【Posted】 MyTools.NET (
【Latest version】
【Copyright】 Reproduction, modification, redistribution all free (please see the Terms of Use for details)
* Please contact us when posting in magazines, CD-ROMs, or other commercial media.

MyTools.NET – Counter CGI T-Count 5 Instructions (


The CGI program (Perl language) to be released has a total access count, a function to prevent double counting during continuous access by checking the IP address, is compatible with Perl 5.26, and includes numerical images (5 types).

Although the details will be explained later, T-Count 5 has traditionally been used for the pure number of accesses where multiple accesses from the same person are counted as 1, that is, the "number of host accesses" (ah, th, yh). We are compatible.

T-Count 5 is the successor to TcounT 4, which I published in the following article:

T-Count 5 is a highly functional graphic CGI access counter written in perl language published by Takahiro Nishida in 1996-2004. unknown whether).
Compared to the past, the number of sites that install access counters is decreasing, but I was looking for a provider of "T-Count 5" from the desire to preserve and inherit valuable Heisei era software assets.
The other day, fortunately, Mr. Kombat Nekomaru, who runs the following "Tank Laboratory" site, kindly accepted the purpose and contents of the request, and provided the source of T-Count 5 (Ver.5.03). Thank you for your cooperation with Combat Nekomaru.

2022.09,20 Postscript
Combat Nekomaru-san reported that he found a net archive of MyTools.NET, so I reflected the header and the archive link to "Counter CGI T-Count 5 manual" in this article. I was.
MyTools.NET – Counter CGI T-Count 5 Instructions ( You can also download the original program (T-Count 5 Ver. 5.03).
Once again, thank you for the efforts of Combat Nekomaru-sama.

Features of T-Count 5 reprint version

The above image is an example of displaying three types of counters (General, Today, and the Day Before) in the "T-Count 5 Reprint". This page also displays the modified date and time of the specified file by SSI.
If you want this screen to appear on the WordPress home page, you can do so by defining an iframe in the theme's program front-page.php and calling "view-counter5.shtml" as shown in the following example.
You can also display the counter by inserting a custom HTML block in your page or blog and defining an iframe there, or by writing CGI calls directly in HTML.

<iframe src="" name="counter" width="100%" height="100" seamless="seamless" scrolling="NO" align="middle" frameborder="0">この部分はインラインフレームを使用しています。</iframe>

* For reference, view-counter5.shtml is written as follows.
As with the HTML below, this CGI program was released with the utf-8 code system. Currently, all CGI programs have been rewritten in utf-8 code system, considering that the transition to utf-8 is progressing, which is compatible with pictograms and avoiding garbled characters such as "display".

<!DOCTYPE html>
<html lang="ja">
*  Function               : T-Count5+ Access counter display for WordPress
*  Designed & Written by  : Senri
*  Release date           : 2023/03/09
*  Copyright (C) 2023 Senri. All rights reserved.
<title>View Counter</title>
<meta charset="UTF-8">
<style type="text/css">
	font-size: 12px;
	font-family: "Times New Roman" ;

<body bgcolor="#000000" text="#999900">
<div align="center">
  <table border="0">
        <td><img src="" align="middle" height="25" width="80"></td>
        <td><nobr>Since 12 November 1997</nobr></td>
<div align="center">
  <table border="0">
        <td><img src="" align="middle" height="20" width="60" border="0"></td>
        <td> </td>
        <td><nobr>Day Before:</nobr></td>
        <td><img src="" align="middle" height="20" width="60" border="0"></td>
        <td colspan="6" align="center" valign="bottom" height="25"><nobr>⏰ <span style="font-style:italic;">Last Modified: <!--#config timefmt="%e %B %Y at %H:%M"--><!--#flastmod virtual="/index.php"--></span></nobr></td>

2023.03.09 update
In the previous version, the above HTML was written in the old format of HTML4, and included font tags and i tags that were abolished in HTML5, so it was corrected to the new format (HTML5). Regarding the difference of META tags, I think that the following article will be helpful.
In addition, HTML5 was abolished on January 28, 2021, and the new standard "HTML Living Standard" in line with the specifications of WHATWG became the standard.

* If you want to access pages other than the top page in WordPress, write it as shown in the following example in the theme program header.php.

		<!-- #header-image -->
		<?php if ( is_front_page() || ( get_option( 'show_on_front' ) == 'posts' && is_home()) ) : ?>
			<!-- フロントページ or ブログ投稿インデックスページ -->
			<div id="hpb-header-image"><img alt="千里のポータルサイトへようこそ!" src="<?php echo get_template_directory_uri(); ?>/header-main.jpg"></div>
		<?php else: ?>
			<!-- アクセスカウンタのCGI呼び出し(TOP以外のページ) -->
			<img src="" height="0" width="0">
		<?php endif; ?>

* By the way, in WordPress, if you want to secretly call an access counter in response to a URL query, write as follows (in the example below, for English pages).

		<?php if ( $_SERVER['QUERY_STRING'] == 'lang=en' ) : ?>
			<!-- アクセスカウンタのCGI呼び出し(Englishページ) -->
			<img src="" height="0" width="0">
		<?php endif; ?>

◆ T-Count 5 Ver. 5.03 (Reprint) Manual

We often see graphical access counters that use SSI or output the entire page as CGI, but this is a counter that is pasted into ordinary HTML with img tags.
This CGI program is the successor to the previous version of TcounT 4 and adds the ability to log in to the administration page, enhanced counters creation and editing, and supports various statistical functions.

T-Count 5 Ver. 5.03 has the following features: (★ is a new feature added in the reprint)

・ Because it is CGI, it can be used even on servers that can not use SSI
・ Multiple counters can be run in one program
・ Since it is only pasted with img tags, it is easy to design the page
・ Login function to the management page
・ You can display, add, modify, delete, etc. counters from the management page
・ Counter log (general statistics, monthly statistics, statistics by day of the week, statistics by day), host log, operation log can be displayed and cleared from the management page
You can use your favorite gif file for numeric images
・ It is possible to change the image for each counter
・Aggregate the number of accesses per day
・The count number from the previous day can be displayed (corresponding to the number of accesses “y” and the number of host accesses “yh”)
・Today's count number can be displayed (corresponds to the number of accesses “t” and the number of host accesses “th”)
・The total count number can be displayed (corresponding to the number of stated accesses “a” and the number of host accesses “ah”)
・ Support counter automatic recovery function
★ Prevent double counting during continuous access by checking IP addresses
★ Perl 5.26 support
★ Includes 5 types of numeric images
★ MyTools.NET – Includes counter CGI T-Count 5 manual (


Download it here 👉 📥
【 The current latest version is Ver. 5.04+ 】

tc.cgi ... substance
tcpadm.cgi ... Administrative
img ... Directory of standard numeric files ... Library for Linking GIF Images (Ver1.61) Copyright © 1997-2002 杜甫々
tcdall.txt ... Comprehensive file (empty)
tcdbak.txt ... Backup file (empty)
tcdhst.txt ... Statistics recording file (empty)
tcdlog.txt ... Activity log file (empty)
tcdyst.txt ... Yesterday file (empty)
lockdir ... Lock directory (empty)
★ How to use .txt ... "T-Count 5" Simple Manual (provided by Combat Nekomaru)
★ MyTools.NET – counter CGI T-Count 5 instructions .html ... Downloading from the archive
★ DigitalBlue ... Directory of the number file "DigitalBlue"
★ DigitalGreen ... Directory of the number file "DigitalGreen"
★ NeonBlue ... Directory of the number file "NeonBlue"
★ TinyRed ... Directory of the number file "TinyRed"


Download three files from the source: tc.cgi, tcpadm, .cgi, and

Correctly set the Perl path at the top of the .cgi file.

Edit the following variables in the .cgi file: ★ After editing, save with UTF-8 (no BOM) character encoding.
(1) tc.cgi、(2) tcpadm.cgi

$basedir ... Path of the directory where the data file is stored (*Note 1) (1)(2)
$time_fix ... Time difference correction value to local time, initial value = 0 (*Note 2) (1)
$itvl ... Interval (seconds) to skip countup for consecutive accesses of the same IP address, initial value = 60 ★ (1)
>> If you do not want to restrict IP addresses, set this value to 0 》
$password ... Administrative password (half-width alphanumeric characters), default value = "password" (2)
$admin_email ... E-mail address of the administrator (*Note 3) (2)
$backurl ... URLs to go to when you press "back" (2)

*Note 1: When placing the data file in the same location as the program$basedir=”.”;It may remain as it is.
*Note 2 Units are for hours. It is necessary to set it when using an overseas server.
*Note 3 Be sure to add '' before '@'. (Example, $admin_email = "";)

Below is a description of each directory/file that corresponds to the permission setting.
(*The first three digits are the value of the permission)

1. Create an arbitrary directory for this CGI
755 Any directory

2. Transfer in text mode to any directory
 Transfer the following files to any directory using FTP in text mode.

705 tc.cgi
705 tcpadm.cgi
606 tcdall.txt
606 tcdbak.txt
606 tcdhst.txt
606 tcdlog.txt
606 tcdyst.txt

3. Creating Directories and Transferring Numeric Files
Create the following directories under any directory and transfer the number files in binary mode.

707 lockdir
707 img ... Other numbers files as well
604 0~9.gif

Directory diagram

The overall directory structure of the work done so far looks like this: ($basedir=”.”; )
※ カッコ内の数字はパーミッション。<~>はディレクトリ。

+ tc.cgi (705)
+ tcpadm.cgi (705)
+ (604)
+ tcdall.txt (606)
+ tcdbak.txt (606)
+ tcdhst.txt (606)
+ tcdlog.txt (606)
+ tcdyst.txt (606)
+ <lockdir> (707)
+ <img> (707)
|     + 0.gif (604)
|     + 0.gif (604)
|     + 1.gif (604)
|     + ...
+ <ip> ★(注)
      + [カウンタ名]_IP.txt
      + ...

★ Note: When access occurs, the IP address check file (count_IP.txt, count2_IP.txt, ...) will be created automatically.

Attach a counter

Access the administration page (tcpadm.cgi), select "Create New Counter, Modify, Delete Counter" from the radio button, enter the password, and click "Execute" to display the above menu.

To create a new counter, click "Register New" from this menu and enter the new counter name in the counter code field.
Here, you can also set the initial values of the total number of accesses and the number of host accesses (cumulative total to date, cumulative total to yesterday, number of accesses to yesterday).
When you have finished entering the counter code and the initial value setting of the number of accesses, press "Execute Work".

* When creating a new counter, all 0 is OK.
* If you are switching from a counter you are already using, please enter the numerical value at that time.
* The difference between "number of stated accesses" and "number of host accesses" is explained in the form below or in the later chapter. Difference between total number of accesses and host access See also

Modifying Counters

From the form on the administration page, select the counter you want to modify and click "Load".
If you correct the total number of accesses, host accesses, etc. and click "Work Execute", the counter information will be corrected.

Delete a counter

From the form on the administration page, select the counter you want to delete and click "Load".
You can delete the counter by checking the check button "Delete ☑️ this counter" and clicking "Work execution". ★ In this case, the IP address check file is also automatically deleted (only if it exists).

Viewing counter logs and operation logs

At the top of the administration page (tdpcnt.cgi)Viewing counter logs, operation logs, and you can see the log for each counter code by pressing the "Execute Work" button. The specific contents are as follows. Both the total number of accesses and the number of host accesses are recorded, respectively. See the top of the log page for a detailed view.

  • synthesis(Total counts, average number of counts per day)
  • Monthly(Total counts, average number of counts per day)
  • By day of the week(Total counts, average number of counts per day)
  • By day(number of counts)
  • Host Log(Host and time information accessed since midnight of the day)
  • Activity Logs(Information on lock and crash recovery after midnight of the day)

By default, a password is not required to view the log,it is also possible to authenticate with a password。 For details Other settings See also


■ Meaning of parameters
T-Count 5 operates the counter movement by adding parameters after the tc.cgi URL. How to specify parameters is as follows. If you want multiple accesses from the same person to be counted as 1, specify the "Number of host accesses" (ah, th, yh) as the second parameter.

<img src="tc.cgi?(1)&(2)&(3)&(4)&(5)">

(1) ... Counter Name (required)
(2) ... Overall →"a" Today→"t", previous day→"Y" (if nothing is specified, the total count count)
General Host →"ah" Host Today→"th" Host Yesterday →"YH"
(3) ... Increase the number → "1" (does not increase if nothing is specified)
(4) ... Counter image directory name ("img" if not specified)
(5) ... The number of digits of counters to display (5 digits if nothing is specified)
途中のパラメータが必要ない場合は、”tc.cgi?test&&&&6″ という具合に、 & を続けて書いて下さい。

● Change the number of digits displayed
To specify the number of digits to display, write the number of digits in the fifth part of the parameter.
(Example) If you want to make it 3 digits

<img src="(tc.cgiのURL)?count&a&1&&3" width="48" height="21">

* If nothing is specified, it will be 5 digits.
* If you change the number of digits, don't forget to change the width accordingly.
* If it is not possible to display it completely, the number of digits will increase to the point where it can be displayed. (For example, if the fifth parameter is 3 but the count is 2234, it is displayed as 4 digits.) )

● Change the numerical image
Numeric images can be used as GIF files as you like.
※ Regular GIFs are recommended. Video GIFs and transparent GIFs may be displayed in a broken display. For details Causes of image collapse See also

The procedure is as follows.

Prepare the GIF image you want to use. The names should be 0.gif, 1.gif, ... , 9.gif.
Create a directory with an appropriate name under the directory where T-Count 5 was installed (e.g. TCount5). Set the permission to 707 (for example, img2).
% cd TCount5
% mkdir img2
% chmod 707 img2
Under the newly created directory (in this case, img2), transfer 0.gif, 1.gif, ... , 9.gif binary by FTP. Set the permission to 604.
% cd img2
% chmod 604 *.gif
The fourth parameter specifies the directory name.
Example: When you want to use images from the directory TCount5/img2/ (6-digit display)

<img src="(tc.cgiのURL)?count&a&1&img2&6" width="96" height="21">

* If nothing is specified, the image file under img is used.

● Display the number of accesses for the previous day
To display the number of accesses for the previous day, write y as the second parameter.
(Example) (3-digit display, using images in the directory ./old/)

<img src="tc.cgi?count&y&&old&3" width="48" height="21">

● Display today's number of accesses
To display today's number of accesses, write t as the second parameter.
(Example) (3-digit display, using images in the directory ./old/)

<img src="tc.cgi?count&t&&old&3" width="48" height="21">

● When you want to display the count of today and today H

今日の訪問者数: <img src="tc.cgi?count1&t">
(ホスト別:<img src="tc.cgi?count1&th">)

■ Example parameter specification and actual display
In the following, the position of the program (tc.cgi) is assumed to be /cgi-bin/count/tc.cgi. If it is on a different server, specify it with an absolute path starting with https://.

● Example 1 (counter name: test1)

<img src="/cgi-bin/count/tc.cgi?test1&a&1" WIDTH="80" HEIGHT="21">

It is an ordinary installation method. If no parameters are specified, a 5-digit display is used, and the image is that of ./img/.
* If you do not specify the size of the image file as WIDTH and HEIGHT, the HTML below it will not be displayed until the numeric image is loaded, so be sure to specify it.

● Example 2 (counter name: test2, 8 digits)

<img src="/cgi-bin/count/tcount.cgi?test2&a&1&&8" WIDTH="128" HEIGHT="21">

If it is 8 digits, the fifth parameter is set to 8. Don't forget to change the WIDTH to fit the number of digits.

● Example 3 (counter name: test3, 5-digit display, using the image of ./ball/)

<img src="/cgi-bin/count/tc.cgi?test3&a&1&ball&5" WIDTH="120" HEIGHT="24">

To change the image, specify the directory name containing the image file in the fourth part of the para.meter.

● Example 4 (counter name: test1, number of accesses from the previous day, 3-digit display, using ./old/ image)

<img src="/cgi-bin/count/tc.cgi?test1&y&&old&3" WIDTH="27" HEIGHT="13">

To display the number of accesses for the previous day, the second of the parameters is y. Use a smaller numeric image in the directory ./old/.

● Example 5 (counter name: test1, number of accesses today, 3-digit display, using ./old/ image)

<img src="/cgi-bin/count/tc.cgi?test1&t&&old&3" WIDTH="27" HEIGHT="13">

To display today's number of accesses, the second parameter is t.

● Example 6 (counter name: hidden, hidden counter)

<img src="/cgi-bin/count/tc.cgi?hidden&a&1&dmy" WIDTH="5" HEIGHT="5">

Make a small gif image of a solid color, put it in the directory ./dmy/ with the names 1.gif, 2.gif, ... , 9.gif (all the contents are the same), and specify dmy as the fourth parameter (the numeric image to be used). On the surface, it doesn't look like a counter, but the administration page and statistics record counts.

■ Clear the operation log
You can clear the operation log by checking "Clear operation log" at the top of the administration page (TDPCTNT.cgi), entering the administration password, and pressing the "Execute Work" button.
→ OK if "Clear counter operation log" is displayed.
In addition, the operation log is cleared once a day, so basically there is no need to do it. (It is a relic of the time when it was a specification that was not cleared.) )

■ Clear counter log
You cannot clear the counter log from the administration page. If you want to do it manually, create an empty file named tcdhst.txt and FTP it over to the same location as the existing file at $basedir.


■ Causes of image collapse
 T-Count 5 can also use GIF images created by themselves, but the display may be corrupted depending on the file. Statistically, it seems that the following images often do not go well.

・ Video GIF (Animation GIF) ... Symptoms such as not moving or not being displayed appear.
・ Transparent GIF with different transparent specified color ... If it is not uniform, symptoms such as not being transmitted and color collapsing will appear.
- GIFs with different pallets ... If you do not unify the palette, the color will collapse.
- Interres GIF

When creating your own, please do not create images like the one above.
Create your own with graphic software that can create GIF images such as Photoshop,Digit Mania Please take it from the site or other materials.

※ However, even if none of the above causes apply, the display may collapse. If you try to use it and it collapses, it is faster to give up and make another image.

■ About migrating from TcounT 4
T-Count 5 is relatively easy to deploy because it is powerful yet easy to manage counters. However, the data is not compatible with previous versions of TcounT 4, so automatic migration is not possible. Therefore, you need to create a new counter manually from the administration page of T-Count 5.

■ Difference between total number of accesses and host access

T-Count 5 isTotal number of accessesandNumber of host accessesBoth are always made to count. The differences are as follows:

  • Accessed number stated ... If the same person (host) visits multiple times a day,Count all the times
  • Host Access Count ... If the same person (host) visits multiple times a day,Count only once

To display the total number of accesses, add a, t, and y to the second parameter. To display the number of host accesses, add ah, th, and yh to the second parameter. T-Count 5 is always counted in both ways, so if you specify the display, it will display the number. By the way, it seems that CGI counters distributed to the general public can usually only count one or the other. (More of the latter?) )

■ How the automatic recovery function works and the scope of coverage

T-Count5 has a function to recover the count number to the previous number using the past log when a counter reset occurs due to multiple simultaneous access. The recovery is automatic, so the administrator does not need to be particularly aware.

When various data files disappear, the range of recorded data is as follows. (Other than 1. It hardly happens.) )

  1. tcdall.txt disappears → recovers until just before disappearing
  2. TCDall.txt, TCDBAK.txt disappear at the same time → recovered to the start of the day
  3. tcdall.txt, tcdbak.txt, tcdyst.txt disappear at the same time → automatic recovery is not possible (recovery by manually resetting the count)

■ Other settings

The following settings can be made using the parameters directly under the "Variable Setting Section" of the CGI (tcpadm.cgi) for management: ([~] is the initial value)

    ... Setting whether a password is required (1) or not (0) when viewing the log.
    ... Set the number of days for the "Statistics of the last × days" displayed at the top of the log.
    ... Specifies the number of days to exclude from statistics immediately after the start of counting. (It is recommended to exclude only the first day of installation because it is thought that the number of counts may be small depending on the installation time, which may affect the average value.)

2022.09.21 update
In T-Count 5 Ver. 5.03, the file locking method was changed from symlink to mkdir and the logic was also changed, but as a result of our testing, it was found to be defective.
As a specific event, if you display three counters on one screen at the same time and redisplay the screen several times with the browser, the display of the access counter may fail.
Therefore, we hurriedly performed maintenance on T-Count 5 Ver. 5.03+ and decided to release it again.

The cause of the failure is that the status is output to the operation log each time it is in the locked state, and an error is also displayed on the screen. In order to solve this problem, the error display for the specified number of times has been disabled.
If the specified time is exceeded, the lock is forcibly unlocked as in the conventional logic.
This eliminates the problem with the counter display and allows for comfortable operation as with the TcounT 4.

2023.12.24 Added
T-Count 5 Ver. 5.04+ has been released.
In T-Count 5 Ver.5.03+, when multiple tasks access at the time of the date change, double summary output occurs, and yesterday's counter (tcdyst .txt) becomes 0.
As a countermeasure, we are releasing version 5.04+ to prevent double output of summaries.

This is a countermeasure for adjusting the unlock timing. Our test results were OK, but in the unlikely event that this phenomenon occurs, you can restore it using the following method.

  • Open tcdhst.txt in an editor and delete the duplicate log
  • Open tcdyst.txt in an editor, view yesterday's daily statistics, and set yesterday's counter.

Program Terms of Use and Disclaimer

This source is intended to be a redistribution (modified) version of the freeware, but the license provisions belong to the distributors "T-Count 5"* and "".
In addition, we are not responsible for any damage as a result of use, and we do not accept any support at all. (However, bug reports will be accepted.)

Please use this program after knowing the above in advance.

* Unfortunately, the distributor of "TcounT 5" has disappeared at the moment. At least it existed until May 2015.

Add this entry to the hasebookmark
X (post)

Leave a Reply