FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


TXT COUNTER





ivant92
How I can create TXT COUNTER for WAP page?
b4r4t
I've found this one:

http://www.hicon.nl/ENG/freecode.html

But it's in Pearl i think...

Frihost support Pearl then You may use it if You can - there should be a readme or something - good luck Smile
yjwong
PHP can read the TXT file...

Code:

<?php
function show_counter(){
   // Create the counter.txt first before you use the script
   $usernum = file_get_contents("counter.txt");

   // Show the number of users
   echo $usernum;

   $fp = fopen("counter.txt", "w+");
   fwrite($fp, $usernum+1);
   fclose($fp);
}
DanielXP
Does PHP work on WAP?
ivant92
Yes!!!
Code of one PHP-WAP page
Code:
<?php
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="index" title="NAME OF PAGE">
<p align="center">
<a href="http://ivant92.rock.com">ivant92.rock.com</a><br/>
</p>
</card>
</wml>
bladesage
Let me show you a simple hit counter I made a while back...

Code:
<?php

header("Content-type: image/png");

$image = imagecreate(80,16);

//--------Here, specify settings for the image to create-------------------------------------------------//

// The background color (default is black)
$bgcolorr = 0;
$bgcolorg = 0;
$bgcolorb = 0;
$backgroundcolor = imagecolorallocate($image, $bgcolorr, $bgcolorg, $bgcolorb);

// The text color (default is white)
$txcolorr = 255;
$txcolorg = 255;
$txcolorb = 255;
$textcolor = imagecolorallocate($image, $txcolorr, $txcolorg, $txcolorb);

// Enter true for a border, or false for no border
$haveborder = true;

// Border color (default is cyan)
$brcolorr = 51;
$brcolorg = 255;
$brcolorb = 255;
$bordercolor = imagecolorallocate($image, $brcolorr, $brcolorg, $brcolorb);

//--------This makes the actual image--------------------------------------------------------------------//

if($haveborder)
   {
   imageline($image, 0, 0, 79, 0, $bordercolor);
   imageline($image, 0, 0, 0, 16, $bordercolor);
   imageline($image, 0, 15, 79, 15, $bordercolor);
   imageline($image, 79, 15, 79, 0, $bordercolor);
   }
   
//--------The entire image block ends here---------------------------------------------------------------//

//--------Here we get the number of actual hits----------------------------------------------------------//

$hits = 0;
$fr01 = fopen('3/hits.txt', 'r');
$hits = fgets($fr01);
$hits++;
fclose($fr01);
$fr01 = fopen('3/hits.txt', 'w');
fputs($fr01, $hits);
fclose($fr01);

//--------Finally, we write the number of hits to an image

imagestring($image, 2, 2, 2, $hits, $textcolor);
imagepng($image);

?>


This clever script actually takes the number of hits from a .txt file, increments it by one, displays it as an image, and puts the new number of hits back into the .txt file.

It comes out like this:


Because it's read as an image, it can work in any language that displays an image. Enjoy!!
Related topics
Counter strike
Favourite game? (OFFICIAL THREAD)
Robots.txt
robots.txt
Create a txt file
Need script
Counter Strike website!
Counter
My Counter-Strike: Source Clan
Flat file-based, MySQL-based counter
Simple, simple HIT counter
Is there a site can report my site ?
Counter Strike [2D]
Php users counter script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.