counter

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Neb
-


Joined: 21 Apr 2004
Posts: 28

PostPosted: Sun Apr 25, 2004 3:31 am    Post subject: counter Reply with quote

I just downloaded a free counter off of hotscripts.com, there is a couple of brief instructions but seeing that I'm new to PHP, and a couple of other programming codes, plus the Web Server itself I don't really know what to do and hopefully when I learn from here, I'll absorb on how to do other scripts also.

If someone can take the time to look it over for me and go step-by-step, that would be extremely helpful.

LINK: http://www.hotscripts.com/cgi-bin/dload.cgi?ID=33251

That's the download. It's only 8 KB, so it's REAL fast. What I did was I just copied the folder and put it in the CGI-BIN. When to the HTML file on Notepad, put it in the PHP code but nothing came up. I'm obviously clueless, so if possible someone assist.
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 25, 2004 3:39 am    Post subject: Reply with quote

Let me recommend the one I use: Simple counter. It is as its name says; simple.

http://www.hotscripts.com/Detailed/3820.html
_________________
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
Neb
-


Joined: 21 Apr 2004
Posts: 28

PostPosted: Sun Apr 25, 2004 3:55 am    Post subject: .... Reply with quote

Link doesn't work anymore.. but if you can assist me with mine that would be great, just so I can learn from the installation, etc.. so I can incorporate it with other scripts irrelevant just to counters.
Back to top View user's profile Send private message
eznetlinks
-


Joined: 27 Sep 2003
Posts: 144

PostPosted: Sun Apr 25, 2004 3:58 am    Post subject: Reply with quote

iNaNimAtE
The Download link has been down for at least a week.

Neb
Be sure you have php installed correctly.Here are instructions http://www.aprelium.com/abyssws/php.html. The Counter you downloaded is complicated. Also it counts by 2. Goes from 1 to 3 to 5 and so on. PhP counters do not work in html files. Must be embeded or included in php file or included in shtml file using SSI.

Here is a simple counter:
<?
$data = fopen("countlog.txt","r");
$count = fgets($data,1000);
fclose($data);
$count=$count + 1 ;
echo "<font face=tahoma size=2>Vistor # $count</font><br>" ;
$data = fopen("countlog.txt","w");
fwrite($data, $count);
fclose($data);
?>

update: smoothstats works with E_NOTICE uncommented and register_globals = On in php.ini


Last edited by eznetlinks on Sun Apr 25, 2004 4:54 am; edited 2 times in total
Back to top View user's profile Send private message Visit poster's website
iNaNimAtE
-


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

PostPosted: Sun Apr 25, 2004 4:06 am    Post subject: Reply with quote

Anyway, for yours:
Note: You need to have PHP installed. If you haven't, check here.

Upload all files into your HTDOCS directory.
Rename the page you want to display the counter on as a .php page.
On the page, put <?php include "stats.php" ?> where you want the counter to appear.

That's it.

EDIT: These instructions are for the script you (Neb) wanted. These aren't for eznetlinks' script.
_________________
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
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Sun Apr 25, 2004 3:21 pm    Post subject: Reply with quote

So thats how they write counters in PHP , looks
easier than I thought it would be , PHP Rules!


Last edited by TRUSTAbyss on Tue May 17, 2005 4:55 am; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
Neb
-


Joined: 21 Apr 2004
Posts: 28

PostPosted: Sun Apr 25, 2004 3:45 pm    Post subject: Reply with quote

iNaNimAtE wrote:
Anyway, for yours:
Note: You need to have PHP installed. If you haven't, check here.

Upload all files into your HTDOCS directory.
Rename the page you want to display the counter on as a .php page.
On the page, put <?php include "stats.php" ?> where you want the counter to appear.

That's it.

EDIT: These instructions are for the script you (Neb) wanted. These aren't for eznetlinks' script.


I have PHP installed, but what I don't get is upload.. I know what the word means on FTP servers, etc.. but not here. Can you show me how to do this and plus, I have the .html file that I want the counter to be in but I dont get how you rename it because when I rename it, it comes out "index.php.html"
Back to top View user's profile Send private message
Moxxnixx
-


Joined: 21 Jun 2003
Posts: 1226
Location: Florida

PostPosted: Sun Apr 25, 2004 4:00 pm    Post subject: Reply with quote

Upload (not meant literally) = Just move or copy the files to the htdocs.

As far as renaming the extensions, just open a folder and at the very top:
Go to Tools > Folder Options > View
Un-checkmark "Hide extensions for known filetypes".
Then, press the button that says "Apply to all folders".
Then, press OK.

Now, you should be able to rename files with the proper extension.
Back to top View user's profile Send private message Visit poster's website
Neb
-


Joined: 21 Apr 2004
Posts: 28

PostPosted: Sun Apr 25, 2004 4:18 pm    Post subject: .... Reply with quote

I've done that but it isn't showing..

Here is the code that I've put it ONLY on Notepad:

Code:
<HTML><BODY><BODY BGCOLOR="CCCCCC"><?php include "stats.php" ?></BODY></HTML>


I only see the grayish background color, and nothing more.

It also says "Notice: Undefined variable: a in C:\Program Files\Abyss Web Server\htdocs\stats.php on line 5"
Back to top View user's profile Send private message
eznetlinks
-


Joined: 27 Sep 2003
Posts: 144

PostPosted: Sun Apr 25, 2004 4:40 pm    Post subject: Reply with quote

try this:
<?php include "stats.php"; ?>
Back to top View user's profile Send private message Visit poster's website
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Mon Apr 26, 2004 3:35 pm    Post subject: Reply with quote

Here is an even better counter script that I wrote , its similar
to the original but this one doesn't count you as a hit if your
IP Address matches the one in the code , check it out!

Image version Coming Soon!
Code:

<?php
if ($REMOTE_ADDR=="127.0.0.1") {
$datafile = "counted.dat";
$opendata = fopen ("$datafile" , "r");
$getdata  = fgets ($opendata);
print "Your Visitor: $getdata";
fclose ($opendata);
}else{
$datafile = "counted.dat";
$opendata = fopen ("$datafile" , "r");
$getdata  = fgets ($opendata);
$counter = $getdata + 1;
print "<b>Your Visitor: $counter</b>";
fclose ($opendata);
$writedata = fopen ("$datafile" , "w");
fwrite ($writedata , $counter);
fclose ($writedata);
}
?>

than just include the file counter.php in your html
using SSI or PHP Includes , its that simple !


Last edited by TRUSTAbyss on Tue May 17, 2005 4:56 am; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
Neb
-


Joined: 21 Apr 2004
Posts: 28

PostPosted: Mon Apr 26, 2004 4:07 pm    Post subject: ... Reply with quote

I see the PHP code, I renamed the page .php and it's fine. The counter works but the problem is upon it is the error..

"Notice: Undefined variable: a in C:\Program Files\Abyss Web Server\htdocs\stats.php on line 5"

Below is the stats.php file, and if someone can look through it and sort the problem out, that would be great.




Code:
<?
include "config.php";
$browser = getenv("HTTP_USER_AGENT");

if ($a == "viewstats") {viewstats();} else {writestats();};

// Write stats to log
function writestats() {
global $statslog, $browser, $font;

// Open and split-up stats log
$statsfile = file($statslog);
$stats = explode("|", $statsfile[0]);

// Amaya
if (preg_match("/Amaya/i", $browser)) {
$amaya = chop($stats[1]);
$amaya2 = $amaya+1;
} else {
$amaya2 = chop($stats[1]);
}

// Epiphany
if (preg_match("/Epiphany/i", $browser)) {
$epiphany = chop($stats[3]);
$epiphany2 = $epiphany+1;
} else {
$epiphany2 = chop($stats[3]);
}

// Firefox
if (preg_match("/Firefox/i", $browser)) {
$firefox = chop($stats[5]);
$firefox2 = $firefox+1;
} else {
$firefox2 = chop($stats[5]);
}

// Galeon
if (preg_match("/Galeon/i", $browser)) {
$galeon = chop($stats[7]);
$galeon2 = $galeon+1;
} else {
$galeon2 = chop($stats[7]);
}

// Internet Explorer
if (preg_match("/MSIE/i", $browser)) {
$ie = chop($stats[9]);
$ie2 = $ie+1;
} else {
$ie2 = chop($stats[9]);
}

// Konqueror
if (preg_match("/Konqueror/i", $browser)) {
$konqueror = chop($stats[11]);
$konqueror2 = $konqueror+1;
} else {
$konqueror2 = chop($stats[11]);
}

// Lynx
if (preg_match("/Lynx/i", $browser)) {
$lynx = chop($stats[13]);
$lynx2 = $lynx+1;
} else {
$lynx2 = chop($stats[13]);
}

// Mozilla
if (preg_match("/rv:/i", $browser) &! preg_match("/Firefox/i", $browser)) {
$mozilla = chop($stats[15]);
$mozilla2 = $mozilla+1;
} else {
$mozilla2 = chop($stats[15]);
}

// Netscape
if (preg_match("/Netscape/i", $browser)) {
$netscape = chop($stats[17]);
$netscape2 = $netscape+1;
} else {
$netscape2 = chop($stats[17]);
}

// Opera
if (preg_match("/Opera/i", $browser)) {
$opera = chop($stats[19]);
$opera2 = $opera+1;
} else {
$opera2 = chop($stats[19]);
}

// Safari
if (preg_match("/Safari/i", $browser)) {
$safari = chop($stats[21]);
$safari2 = $safari+1;
} else {
$safari2 = chop($stats[21]);
}

// Oher
if (preg_match("/Amaya/i", $browser) || preg_match("/Epiphany/i", $browser) || preg_match("/Firefox/i", $browser) || preg_match("/Galeon/i", $browser) || preg_match("/MSIE/i", $browser) || preg_match("/Konqueror/i", $browser) || preg_match("/Lynx/i", $browser) || preg_match("/rv:/i", $browser) || preg_match("/Netscape/i", $browser) || preg_match("/Opera/i", $browser) || preg_match("/Safari/i", $browser)) {
$other2 = chop($stats[23]);
} else {
$other = chop($stats[23]);
$other2 = $other+1;
}

// Total count
$totalcount = $amaya2+$epiphany2+$firefox2+$galeon2+$ie2+$konqueror2+$lynx2+$mozilla2+$netscape2+$opera2+$safari2+$other2;
$showcount = $stats[24]+1;
echo "<center><font face='$font' size='2'>Visitors: <b>$showcount</b></font><br>\n";
echo "<font face='$font' size='1'><a href='stats.php?a=viewstats'>(Details)</a></font></center>\n";

// Write all data to log
$fp = fopen ($statslog, "w+");
fputs($fp, "Amaya|$amaya2|Epiphany|$epiphany2|Firefox|$firefox2|Galeon|$galeon2|Internet Explorer|$ie2|Konqueror|$konqueror2|Lynx|$lynx2|Mozilla|$mozilla2|Netscape|$netscape2|Opera|$opera2|Safari|$safari2|Other|$other2|$totalcount");
fclose ($fp);
}

// Display stats
function viewstats() {
global $statslog, $font;
$statsfile = file($statslog);
$stats = explode("|", $statsfile[0]);
echo "<font face='$font' size='2'><b>Web Browsers</b></font>\n";
echo "<table border='0' width='100%' cellspacing='2' cellpadding='2'>\n";
// Amaya
$percentageamaya = round($stats[1]/$stats[24]*100, 1);
$baramaya = round($percentageamaya*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[0]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$baramaya' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentageamaya% [$stats[1] hits]</font></td>\n</tr>\n";

// Epiphany
$percentageepiphany = round($stats[3]/$stats[24]*100, 1);
$barepiphany = round($percentageepiphany*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[2]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$barepiphany' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentageepiphany% [$stats[3] hits]</font></td>\n</tr>\n";

// Firefox
$percentagefirefox = round($stats[5]/$stats[24]*100, 1);
$barfirefox = round($percentagefirefox*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[4]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$barfirefox' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentagefirefox% [$stats[5] hits]</font></td>\n</tr>\n";

// Galeon
$percentagegaleon = round($stats[7]/$stats[24]*100, 1);
$bargaleon = round($percentagegaleon*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[6]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$bargaleon' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentagegaleon% [$stats[7] hits]</font></td>\n</tr>\n";

// Internet Explorer
$percentageie = round($stats[9]/$stats[24]*100, 1);
$barie = round($percentageie*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[8]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$barie' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentageie% [$stats[9] hits]</font></td>\n</tr>\n";

// Konqueror
$percentagekonqueror = round($stats[11]/$stats[24]*100, 1);
$barkonqueror = round($percentagekonqueror*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[10]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$barkonqueror' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentagekonqueror% [$stats[11] hits]</font></td>\n</tr>\n";

// Lynx
$percentagelynx = round($stats[13]/$stats[24]*100, 1);
$barlynx = round($percentagelynx*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[12]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$barlynx' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentagelynx% [$stats[13] hits]</font></td>\n</tr>\n";

// Mozilla
$percentagemozilla = round($stats[15]/$stats[24]*100, 1);
$barmozilla = round($percentagemozilla*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[14]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$barmozilla' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentagemozilla% [$stats[15] hits]</font></td>\n</tr>\n";

// Netscape
$percentagenetscape = round($stats[17]/$stats[24]*100, 1);
$barnetscape = round($percentagenetscape*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[16]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$barnetscape' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentagenetscape% [$stats[17] hits]</font></td>\n</tr>\n";

// Opera
$percentageopera = round($stats[19]/$stats[24]*100, 1);
$baropera = round($percentageopera*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[18]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$baropera' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentageopera% [$stats[19] hits]</font></td>\n</tr>\n";

// Safari
$percentagesafari = round($stats[21]/$stats[24]*100, 1);
$barsafari = round($percentagesafari*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[20]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$barsafari' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentagesafari% [$stats[21] hits]</font></td>\n</tr>\n";

// Other
$percentageother = round($stats[23]/$stats[24]*100, 1);
$barother = round($percentageother*2, 0);
echo "<tr>\n<td width='115' align='right'><font face='$font' size='2'>$stats[22]</font></td>\n";
echo "<td width='200'><img src='bar.jpg' height='5' width='$barother' align='middle' border='0'></td>\n";
echo "<td><font face='$font' size='2'>$percentageother% [$stats[23] hits]</font></td>\n</tr>\n";
echo "</table>\n";
}
?>
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Mon Apr 26, 2004 4:26 pm    Post subject: Reply with quote

Insert the following code after <?php
Code:

ini_set ("display_errors", 1);
error_reporting (E_ALL & ~E_NOTICE);
Back to top View user's profile Send private message Visit poster's website
Neb
-


Joined: 21 Apr 2004
Posts: 28

PostPosted: Mon Apr 26, 2004 4:38 pm    Post subject: .... Reply with quote

Thanks a lot. It worked.

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


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

PostPosted: Tue Apr 27, 2004 2:09 am    Post subject: Reply with quote

Let me just remind that notices (that say "Notice:") at the front are just that; notices. You need not worry about them. They just say potential problems.

To disable them, search for "e_notice" in these forums.
_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP 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