Php image COUNTER Code (enhanced version)
- // Session_start ();
- $ Dir = 'cookie.txt ';
- $ File = fopen ($ dir, 'r ');
- $ Content = fgets ($ file );
- Fclose ($ file );
- // If (empty ($ _ SESSION ['viewer ']) {
- $ Content ++;
- $ Newopen = fopen ($ dir, 'w ');
- Fwrite ($ newopen, $ content );
- Fclose ($ newopen );
- // $ _ SESSION ['viewer '] = 1;
- //}
- // Echo "website visits: {$ content }";
- $ New = strval ($ content); // Convert it to a string
- $ Len = strlen ($ new );
-
- $ Str = str_repeat ('0', 6-$ len );
- For ($ I = 0; $ I $ Result = $ str [$ I];
- $ Result = '';
- Echo $ result;
- }
- For ($ j = 0; $ j <$ len; $ j ++ ){
- $ Result = $ new [$ j];
- Switch ($ result ){
- Case 0:
- $ Ret [$ j] = 'Images/0.png ';
- Break;
- Case 1:
- $ Ret [$ j] = 'Images/1.png ';
- Break;
- Case 2:
- $ Ret [$ j] = 'Images/2.png ';
- Break;
- Case 3:
- $ Ret [$ j] = 'Images/3.png ';
- Break;
- Case 4:
- $ Ret [$ j] = 'Images/4.png ';
- Break;
- Case 5:
- $ Ret [$ j] = 'Images/5.png ';
- Break;
- Case 6:
- $ Ret [$ j] = 'Images/6.png ';
- Break;
- Case 7:
- $ Ret [$ j] = 'Images/7.png ';
- Break;
- Case 8:
- $ Ret [$ j] = 'Images/8.png ';
- Break;
- Case 9:
- $ Ret [$ j] = 'Images/9.png ';
- Break;
- } // By bbs.it-home.org
- Echo '';
- }
- ?>
-
In the above code, in order to achieve page refresh and preview, the session is commented out to avoid repeated page refresh. This counter code is more complete and practical than php text counters. Attachment, picture material: http://liangqi000.googlecode.com/files/image-counter.rar You can also go to some material websites to find some good-looking counter images and make the displayed images more professional. |