Zen Cart Logo
Forums / Zen Cart Code Suggestions / Admin IP should not count towards traffic hit counter

Admin IP should not count towards traffic hit counter

Locked

Views: 4,429

Results 1 to 19 of 19
This thread is locked. New replies are disabled.
23 Feb 2007, 10:45 PM
#1
azenuser avatar

azenuser

New Zenner

Join Date:
Jan 2006
Posts:
19
Plugin Contributions:
0

Admin IP should not count towards traffic hit counter

I can't imagine why anyone would want to count hits from their admin logon. I recommend an option or check box in shop admin to disable Admin IP from being counted as a hit. Anyone else who thinks the admin IP should not count towards hit counter unless specified?

23 Feb 2007, 11:48 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,608
Plugin Contributions:
0

Re: Admin IP should not count towards traffic hit counter

When you get this programmed- Let us know :)

24 Feb 2007, 10:48 PM
#3
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Admin IP should not count towards traffic hit counter

I'm not quite sure from which counter you're talking about. Would it be possible to post a text from that specific window where it states about counting IPs ?

24 Feb 2007, 11:11 PM
#4
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Admin IP should not count towards traffic hit counter

Ok, got it. Unfortunitely, the way Zen-Cart is being handled right now is that customers has their own access so does the admins. When you log into an account, from the store front, this is when the counter starts ticking. Althought, an admin cannot log in from the store front without having a test account (even though that would still be considered as a customer level and not as an admin level).

Meaning, unless you're looking for to stop the hit counter entirely for everyone (customers and admins), there's no way to stop it for the admins from the store-front. Another way, for admins, would be to cancel the TABLE_COUNTER selection from admin/index.php file so that you won't see the results but will only be added into your TABLE_COUNTER from the store-front if it's a biggy. :cool:

26 Feb 2007, 4:42 PM
#5
azenuser avatar

azenuser

New Zenner

Join Date:
Jan 2006
Posts:
19
Plugin Contributions:
0

Re: Admin IP should not count towards traffic hit counter

Thanks. Let me rephrase the question, "is it possible to block admin's IP from being counted by the hit counter on the admin homepage?" (In response to first reply, we would have just posted the code already if we knew how to do it. We'll leave the programming up to the programmers and donate to the cause accordingly.)

27 Feb 2007, 6:31 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Admin IP should not count towards traffic hit counter

If you were to edit the file:
/includes/counter.php

NOTE: there is no override for this file ...

And add to the file from under the first IF statement:

if (!strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])) {

Then go to the end of the file and before the closing php ?> ... this would be right after the:

$counter_startdate_formatted

Change that to read:

$counter_startdate_formatted
}

Now anyone defined in the Configuration ... Web Maintenance ...

Down For Maintenance (exclude this IP-Address)

Will not be included in the counts ...

27 Feb 2007, 7:04 PM
#7
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Admin IP should not count towards traffic hit counter

Thanks for your help

27 Feb 2007, 8:31 PM
#8
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Admin IP should not count towards traffic hit counter

@azenuser: You forgot a poll option:

"Don't care"

:smartass:

14 Nov 2008, 2:23 AM
#9
poohhbearr avatar

poohhbearr

New Zenner

Join Date:
Nov 2008
Posts:
1
Plugin Contributions:
0

Re: Admin IP should not count towards traffic hit counter

Any Update to this fix?

14 Nov 2008, 8:38 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Admin IP should not count towards traffic hit counter

What update are you looking for?

Did you try the posted code and add your current IP to the Down for Maintenance section?

NOTE: you will need to update that each time your IP changes ...

27 Nov 2009, 3:20 PM
#11
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Admin IP should not count towards traffic hit counter

Hello,

I'm having trouble implementing Ajeh's mod, the hit counter is not showing anything at all now. I visit the site on my i.p address and it shows nothing which is what i want BUT then I visit the site on a proxy server (which should show up in the hit counter) but still nothing...?

Heres my edited /includes/counter.php file:

<?php /** * counter.php * * @package general * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: counter.php 3194 2006-03-15 23:17:53Z wilt $ * @private */ if (!defined('IS_ADMIN_FLAG')) { if (!strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])) { die('Illegal Access'); } if (isset($_SESSION['session_counter']) && $_SESSION['session_counter'] == true) { $session_counter = 0; } else { $session_counter = 1; $_SESSION['session_counter'] = true; } $date_now = date('Ymd'); $counter_query = "select startdate, counter, session_counter from " . TABLE_COUNTER_HISTORY . " where startdate='" . $date_now . "'"; $counter = $db->Execute($counter_query); if ($counter->RecordCount() <= 0) { $date_now = date('Ymd'); $sql = "insert into " . TABLE_COUNTER_HISTORY . " (startdate, counter, session_counter) values ('" . $date_now . "', '1', '1')"; $db->Execute($sql); $counter_startdate = $date_now; $counter_now = 1; } else { $counter_startdate = $counter->fields['startdate']; $counter_now = ($counter->fields['counter'] + 1); $session_counter_now = ($counter->fields['session_counter'] + $session_counter); $sql = "update " . TABLE_COUNTER_HISTORY . " set counter = '" . $counter_now . "', session_counter ='" . $session_counter_now . "' where startdate='" . $date_now . "'"; $db->Execute($sql); } $counter_query = "select startdate, counter from " . TABLE_COUNTER; $counter = $db->Execute($counter_query); if ($counter->RecordCount() <= 0) { $date_now = date('Ymd'); $sql = "insert into " . TABLE_COUNTER . " (startdate, counter) values ('" . $date_now . "', '1')"; $db->Execute($sql); $counter_startdate = $date_now; $counter_now = 1; } else { $counter_startdate = $counter->fields['startdate']; $counter_now = ($counter->fields['counter'] + 1); $sql = "update " . TABLE_COUNTER . " set counter = '" . $counter_now . "'"; $db->Execute($sql); } $counter_startdate_formatted = strftime(DATE_FORMAT_LONG, mktime(0, 0, 0, substr($counter_startdate, 4, 2), substr($counter_startdate, -2), substr($counter_startdate, 0, 4))); } ?>

What am I doing wrong?

Thanks :smile:

27 Nov 2009, 6:34 PM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Admin IP should not count towards traffic hit counter

You need that code to be an IF around this line:

$counter_startdate_formatted = strftime(DATE_FORMAT_LONG, mktime(0, 0, 0, substr($counter_startdate, 4, 2), substr($counter_startdate, -2), substr($counter_startdate, 0, 4)));

You put it at the top of the file and are breaking it ... :unsure:

27 Nov 2009, 6:44 PM
#13
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Admin IP should not count towards traffic hit counter

Hi Linda,

Thanks for the response,

Sorry I don't quite understand what I need to do :blush:

Thanks.

27 Nov 2009, 6:54 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Admin IP should not count towards traffic hit counter

I didn't quite read that right to give you the right method to do this ...

Try this code:

NOTE: THIS CODE IS ONLY SUITABLE FOR v1.3.8a. IF YOU HAVE A DIFFERENT VERSION, THE FOLLOWING FILE CONTENTS MAY NOT BE SUITABLE FOR YOU. Your file contents may be different and incompatible. USE AT YOUR OWN RISK.

<?php
/**
 * counter.php
 *
 * @package general
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: counter.php 3194 2006-03-15 23:17:53Z wilt $
 * @private
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
if (isset($_SESSION['session_counter']) && $_SESSION['session_counter'] == true) {
  $session_counter = 0;
} else {
  $session_counter = 1;
  $_SESSION['session_counter'] = true;
}

[B]if (!strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])) {[/B]  
$date_now = date('Ymd');
$counter_query = "select startdate, counter, session_counter from " . TABLE_COUNTER_HISTORY . " where startdate='" . $date_now . "'";
$counter = $db->Execute($counter_query);
if ($counter->RecordCount() <= 0) {
  $date_now = date('Ymd');
  $sql = "insert into " . TABLE_COUNTER_HISTORY . " (startdate, counter, session_counter) values ('" . $date_now . "', '1', '1')";
  $db->Execute($sql);
  $counter_startdate = $date_now;
  $counter_now = 1;
} else {
  $counter_startdate = $counter->fields['startdate'];
  $counter_now = ($counter->fields['counter'] + 1);
  $session_counter_now = ($counter->fields['session_counter'] + $session_counter);
  $sql = "update " . TABLE_COUNTER_HISTORY . " set counter = '" . $counter_now . "', session_counter ='" . $session_counter_now . "' where startdate='" . $date_now . "'";
  $db->Execute($sql);
}

$counter_query = "select startdate, counter from " . TABLE_COUNTER;
$counter = $db->Execute($counter_query);
if ($counter->RecordCount() <= 0) {
  $date_now = date('Ymd');
  $sql = "insert into " . TABLE_COUNTER . " (startdate, counter) values ('" . $date_now . "', '1')";
  $db->Execute($sql);
  $counter_startdate = $date_now;
  $counter_now = 1;
} else {
  $counter_startdate = $counter->fields['startdate'];
  $counter_now = ($counter->fields['counter'] + 1);
  $sql = "update " . TABLE_COUNTER . " set counter = '" . $counter_now . "'";
  $db->Execute($sql);
}

$counter_startdate_formatted = strftime(DATE_FORMAT_LONG, mktime(0, 0, 0, substr($counter_startdate, 4, 2), substr($counter_startdate, -2), substr($counter_startdate, 0, 4)));
[B]}[/B]
?>

And you will see the changes in the two places in red ...

27 Nov 2009, 7:03 PM
#15
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Admin IP should not count towards traffic hit counter

Yep that seems to of worked, I'll check it over a few times and post again if i encounter any problems.

Thanks a bunch Linda :smile:

27 Nov 2009, 8:43 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Admin IP should not count towards traffic hit counter

You are most welcome ... thanks for the update that this worked for you ... :smile:

Just remember you made this change when trying to test the counter and you cannot figure out why the counter isn't working for you ... as you will be excluded from the counting ...

NOTE: if your IP address changes, you will start to be counted again, until you update the IP Address(es) to be excluded ...

13 Feb 2010, 5:24 AM
#17
dudemaaan avatar

dudemaaan

New Zenner

Join Date:
Feb 2010
Posts:
49
Plugin Contributions:
0

Re: Admin IP should not count towards traffic hit counter

Thanks for the code. just added it to mine. works perfectly!

31 May 2010, 3:38 PM
#18
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Admin IP should not count towards traffic hit counter

Hello Linda,

Will your code modification work with 1.3.9c?

Thanks.

31 May 2010, 7:26 PM
#19
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Admin IP should not count towards traffic hit counter

The IF statement (the part in red) should be the same ... the stuff inside the IF has changed ...

See if that works for you ...