counter script

 
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI
View previous topic :: View next topic  
Author Message
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Sun Apr 11, 2004 12:51 pm    Post subject: counter script Reply with quote

does anyone know where i can get a cgi counter script that works like this

1) i can just put a unique id after the script to creater a new counter

e.g. script?unique_id=12343

2) it has got to be free

3) and the counter has to be in text


thanx all

can also be in PHP but not mysql
Back to top View user's profile Send private message
eznetlinks
-


Joined: 27 Sep 2003
Posts: 144

PostPosted: Mon Apr 12, 2004 2:38 am    Post subject: Reply with quote

count.php

<?
//The counter is a link to Aprelium, please do not change, the counter is free
//add ?cntid=yourid to the end of your url
//Example:count.php?cntid=176999
//Use SSI to print to shtml files
//SSI Example: <!--#include virtual="/count.php?cntid=176999" -->
//PHP Example: copy and paste into php files
//HTML Example: <iframe src=count.php?cntid=176999 width=90 height=55></iframe>
//Recomended for windows.
//Will work with unix if root directory permission set to 777 On first Execution of script.
$color = "pink";//change this line to the color you desire
$root = $_SERVER["DOCUMENT_ROOT"];
$file = "/counters";
$path = "$root$file/";
$countid = $_GET['cntid'];
$self = $_SERVER["PHP_SELF"];
$host = $_SERVER["HTTP_HOST"];
$create = "$path$countid.txt";
if ($countid==''){header("Location: http://$host$self?cntid=noid");}
if(!is_dir($path))
{
mkdir($path);
chmod("$path", 0777);
header("Location: http://$host$self?cntid=$countid");
}
else
{
if(!is_file($create))
{
fopen("$create","w");
header("Location: http://$host$self?cntid=$countid");
}
else
{
$data = fopen("$path/$countid.txt","r");
$count = fgets($data,1000000);
fclose($data);
$count=$count + 1 ;
printf("<table bgcolor='$color'><tr><td>");
printf("<font face=tahoma size=2><b><a href=http://aprelium.com target=_blank>VISITOR #<BR>$count</a></b></font>");
printf('</td></tr></table>');$data = fopen("$path/$countid.txt","w");
fwrite($data,$count);
fclose($data);
}
}
?>


Last edited by eznetlinks on Sat Apr 17, 2004 3:14 pm; edited 5 times in total
Back to top View user's profile Send private message Visit poster's website
goose
-


Joined: 17 Sep 2002
Posts: 608
Location: The Land Of OZ! come here toto!

PostPosted: Mon Apr 12, 2004 5:05 pm    Post subject: Reply with quote

pretty simple and direct hehe ;p
_________________
living in an armish paradise.....no gates here!

mawuahahaha :)
Back to top View user's profile Send private message
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Mon Apr 12, 2004 11:51 pm    Post subject: Reply with quote

how do i incorparate that on to a web page i've tried a java script line but that didn't work
Back to top View user's profile Send private message
nquin321
-


Joined: 29 Jan 2004
Posts: 296
Location: Right Behind You

PostPosted: Mon Apr 12, 2004 11:56 pm    Post subject: Reply with quote

:roll:
ssi, iframes
_________________
How many forum members does it takes to change a light bulb?
Back to top View user's profile Send private message
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Tue Apr 13, 2004 12:35 am    Post subject: Reply with quote

yeah i know i put that

<!--#e...

crap after i tried the javascript but i forgot to change to stml / add html to the ssi thingy
Back to top View user's profile Send private message
iNaNimAtE
-


Joined: 05 Nov 2003
Posts: 2381
Location: Everywhere you're not.

PostPosted: Sun Apr 18, 2004 3:35 am    Post subject: Reply with quote

I use one a lot simpler. (You may have seen it on my index page). It is ironically called Simple Counter; available here.
_________________
Bienvenidos!
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Wed Dec 22, 2004 2:25 am    Post subject: Reply with quote

right after a while i thought about doing somthing with it other than counting hit

i was using the first one shown

<?php
$user = $_GET['id'];
$path = 'counter';
if (is_dir($path)) {
$data = fopen("$path/$user.txt","r");
$count = fgets($data,1000000);
fclose($data);
$count=$count + 1 ;
echo "You Are #$count to hit this site!";
$data = fopen("$path/$user.txt","w");
fwrite($data, $count);
fclose($data);
}
else
{
$self = $_SERVER["PHP_SELF"];
$host = $_SERVER["HTTP_HOST"];
mkdir($path);
header("Location: http://$host$self?id=$user");
}
}
}
?>


but how come on the first visit i get

Warning: fopen(counter/ext.txt): failed to open stream: No such file or directory in C:\Program Files\Abyss Web Server\htdocs\file.php on line ??

Warning: fgets(): supplied argument is not a valid stream resource in C:\Program Files\Abyss Web Server\htdocs\file.php on line ??

Warning: fclose(): supplied argument is not a valid stream resource in C:\Program Files\Abyss Web Server\htdocs\file.php on line ??

is their some way of doing this and

could you also look and help me with this

http://www.aprelium.com/forum/viewtopic.php?p=34052
Back to top View user's profile Send private message
Glitch2082
-


Joined: 02 Dec 2004
Posts: 194

PostPosted: Wed Dec 22, 2004 2:47 am    Post subject: Reply with quote

Quote:
Warning: fopen(counter/ext.txt): failed to open stream: No such file or directory in C:\Program Files\Abyss Web Server\htdocs\file.php on line ??


Make a file called ext.txt maybe, if(you already havn't); :P
Also make one called user.txt.
After that it should work, becuase i don't think it could open $data becuase it couldn't find it, and I know it couldn't open ext.txt. So the arguement error was becuase it couldn't find $data possibly :S.[/quote]
_________________
int main() {
cout << "Im Pro Apache";
cin.get();
}
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group