Be a Supporter!

My first PHP script (counter)

  • 309 Views
  • 4 Replies
New Topic Respond to this Topic
EviLDoG
EviLDoG
  • Member since: Oct. 18, 2000
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
My first PHP script (counter) 2001-09-03 22:20:29 Reply

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.
Forum Stats
Staff
Level 28
Blank Slate
Response to My first PHP script (counter) 2001-09-04 04:51:52 Reply

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
Response to My first PHP script (counter) 2001-09-04 07:34:20 Reply

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
Response to My first PHP script (counter) 2001-09-04 20:03:58 Reply

At 9/4/01 07:34 AM, pyroarchy wrote:
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>";
?>

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
Response to My first PHP script (counter) 2001-09-05 11:06:51 Reply

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!