My first PHP script (counter)
- EviLDoG
-
EviLDoG
- Member since: Oct. 18, 2000
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
Yep it is and i hope to make more of 'em
Just copy and paste this into a php page.
<?php
###########################################
#Simple counter
###########################################
#Created by EviLDoG
#email:evildoguk@aol.com website=http://www.evildog.f2s.com
#
#Create a page called count.txt then CHMOD it to 666
$filename="count.txt";
$digit_max=6;
#put your start date where 00/00/0000 is
$counterBeginDate="00/00/0000";
#Now it uses $filename to read and add to the last count number.
$file = fopen($filename, "r");
$content = fread( $file, $digit_max);
#now we have to close the file
fclose($file);
#and then we open the file and add +1 to it's current count number.
$file = fopen($filename, "w");
$i=$content+1;
fputs($file, $i);
fclose($file);
#Shows how many times the page has been visited.
echo "
This page has been visited $i times since $counterBeginDate. <p>";
?>
- liljim
-
liljim
- Member since: Dec. 16, 1999
- Offline.
-
- Send Private Message
- Browse All Posts (11,644)
- Block
-
- Forum Stats
- Staff
- Level 28
- Blank Slate
Hrms,
Looks like someone has been copying and pasting bits from the manual. ;)
- pyroarchy
-
pyroarchy
- Member since: Jan. 30, 2001
- Offline.
-
- Forum Stats
- Member
- Level 16
- Blank Slate
At 9/4/01 04:51 AM, liljim wrote: Hrms,
Looks like someone has been copying and pasting bits from the manual. ;)
yay i made one too!!
<?php
###########################################
#Simple counter
###########################################
#Created by pyroarchy
#email:none@none.com
#website=http://www.none.com
#Create a page called count.txt then CHMOD it to 666
$filename="count.txt";
$digit_max=6;
#put your start date where 00/00/0000 is
$counterBeginDate="00/00/0000";
#Now it uses $filename to read and add to the last count number.
$file = fopen($filename, "r");
$content = fread( $file, $digit_max);
#now we have to close the file
fclose($file);
#and then we open the file and add +1 to it's current count number.
$file = fopen($filename, "w");
$i=$content+1;
fputs($file, $i);
fclose($file);
#Shows how many times the page has been visited.
echo "
This page has been visited $i times since $counterBeginDate. <p>";
?>
- EviLDoG
-
EviLDoG
- Member since: Oct. 18, 2000
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
At 9/4/01 07:34 AM, pyroarchy wrote:At 9/4/01 04:51 AM, liljim wrote: Hrms,yay i made one too!!
Looks like someone has been copying and pasting bits from the manual. ;)
<?php
###########################################
#Simple counter
###########################################
#Created by pyroarchy
#email:none@none.com
#website=http://www.none.com
#Create a page called count.txt then CHMOD it to 666
$filename="count.txt";
$digit_max=6;
#put your start date where 00/00/0000 is
$counterBeginDate="00/00/0000";
#Now it uses $filename to read and add to the last count number.
$file = fopen($filename, "r");
$content = fread( $file, $digit_max);
#now we have to close the file
fclose($file);
#and then we open the file and add +1 to it's current count number.
$file = fopen($filename, "w");
$i=$content+1;
fputs($file, $i);
fclose($file);
#Shows how many times the page has been visited.
echo "
This page has been visited $i times since $counterBeginDate. <p>";
?>
Good counter, and i added the notes for some php beginners like me to understand what the functions are.
- Pecos
-
Pecos
- Member since: Dec. 29, 1999
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
At 9/4/01 08:03 PM, EviLDoG wrote: Good counter, and i added the notes for some php beginners like me to understand what the functions are.
Yes, you copy well. Now write your own!


