Author |
Message |
Fphilip84
Regular


Joined: Oct 27, 2003
Posts: 73
|
Posted:
Mon Oct 27, 2003 5:07 pm |
|
Hi, I like your site info block but I just have one problem, that is my counter adds a hit whenever I go anywhere on my site. I checked around nukecops for a thread that showed me how to disable it so that it will add a hit only when I reload the page, but when I did that, I noticed that after a new user registration, they get an _ERROR. The moment i put the original counter.php file back into the includes, then the _ERROR goes away for new registrations. Is there anyway to fix this issue so that the counter will only add a hit when the page is reloaded rather then whenever I go anywhere on my site? I'm a newbie! Sorry!! |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Tue Oct 28, 2003 6:58 am |
|
Hmmmm. Would you post the modified counter.php code here? Be sure to use the code tags. I will see if I can see what would cause a registration error. The 2 are unrelated, so you may have a copy and paste error or something like that. |
|
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 7:27 am |
|
This is the code for the counter.php file.
Quote: | <?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* Enhanced with NukeStats Module Version 1.0 */
/* ========================================== */
/* Copyright ©2002 by Harry Mangindaan (sens@indosat.net) and */
/* Sudirman (sudirman@akademika.net) */
/* http://www.nuketest.com */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (eregi("counter.php",$_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
if(!strstr($_SERVER["HTTP_REFERER"], $_SERVER["SERVER_NAME"])) {
global $prefix, $db;
/* Get the Browser data */
if((ereg("Nav", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Gold", $_SERVER["HTTP_USER_AGENT"])) || (ereg("X11", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Mozilla", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Netscape", $_SERVER["HTTP_USER_AGENT"])) AND (!ereg("MSIE", $_SERVER["HTTP_USER_AGENT"]) AND (!ereg("Konqueror", $_SERVER["HTTP_USER_AGENT"])))) $browser = "Netscape";
elseif(ereg("MSIE", $_SERVER["HTTP_USER_AGENT"])) $browser = "MSIE";
elseif(ereg("Lynx", $_SERVER["HTTP_USER_AGENT"])) $browser = "Lynx";
elseif(ereg("Opera", $_SERVER["HTTP_USER_AGENT"])) $browser = "Opera";
elseif(ereg("WebTV", $_SERVER["HTTP_USER_AGENT"])) $browser = "WebTV";
elseif(ereg("Konqueror", $_SERVER["HTTP_USER_AGENT"])) $browser = "Konqueror";
elseif((eregi("bot", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Google", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Slurp", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Scooter", $_SERVER["HTTP_USER_AGENT"])) || (eregi("Spider", $_SERVER["HTTP_USER_AGENT"])) || (eregi("Infoseek", $_SERVER["HTTP_USER_AGENT"]))) $browser = "Bot";
else $browser = "Other";
/* Get the Operating System data */
if(ereg("Win", $_SERVER["HTTP_USER_AGENT"])) $os = "Windows";
elseif((ereg("Mac", $_SERVER["HTTP_USER_AGENT"])) || (ereg("PPC", $_SERVER["HTTP_USER_AGENT"]))) $os = "Mac";
elseif(ereg("Linux", $_SERVER["HTTP_USER_AGENT"])) $os = "Linux";
elseif(ereg("FreeBSD", $_SERVER["HTTP_USER_AGENT"])) $os = "FreeBSD";
elseif(ereg("SunOS", $_SERVER["HTTP_USER_AGENT"])) $os = "SunOS";
elseif(ereg("IRIX", $_SERVER["HTTP_USER_AGENT"])) $os = "IRIX";
elseif(ereg("BeOS", $_SERVER["HTTP_USER_AGENT"])) $os = "BeOS";
elseif(ereg("OS/2", $_SERVER["HTTP_USER_AGENT"])) $os = "OS/2";
elseif(ereg("AIX", $_SERVER["HTTP_USER_AGENT"])) $os = "AIX";
else $os = "Other";
/* Save on the databases the obtained values */
$db->sql_query("UPDATE ".$prefix."_counter SET count=count+1 WHERE (type='total' AND var='hits') OR (var='$browser' AND type='browser') OR (var='$os' AND type='os')");
/* Start Detailed Statistics */
$dot = date("d-m-Y-H");
$now = explode ("-",$dot);
$nowHour = $now[3];
$nowYear = $now[2];
$nowMonth = $now[1];
$nowDate = $now[0];
$sql = "SELECT year FROM ".$prefix."_stats_year WHERE year='$nowYear'";
$resultyear = $db->sql_query($sql);
$jml = $db->sql_numrows($resultyear);
if ($jml <= 0) {
$sql = "INSERT INTO ".$prefix."_stats_year VALUES ('$nowYear','0')";
$db->sql_query($sql);
for ($i=1;$i<=12;$i++) {
$db->sql_query("INSERT INTO ".$prefix."_stats_month VALUES ('$nowYear','$i','0')");
if ($i == 1) $TotalDay = 31;
if ($i == 2) {
if (date("L") == true) {
$TotalDay = 29;
} else {
$TotalDay = 28;
}
}
if ($i == 3) $TotalDay = 31;
if ($i == 4) $TotalDay = 30;
if ($i == 5) $TotalDay = 31;
if ($i == 6) $TotalDay = 30;
if ($i == 7) $TotalDay = 31;
if ($i == $TotalDay = 31;
if ($i == 9) $TotalDay = 30;
if ($i == 10) $TotalDay = 31;
if ($i == 11) $TotalDay = 30;
if ($i == 12) $TotalDay = 31;
for ($k=1;$k<=$TotalDay;$k++) {
$db->sql_query("INSERT INTO ".$prefix."_stats_date VALUES ('$nowYear','$i','$k','0')");
}
}
}
$sql = "SELECT hour FROM ".$prefix."_stats_hour WHERE (year='$nowYear') AND (month='$nowMonth') AND (date='$nowDate')";
$result = $db->sql_query($sql);
$numrows = $db->sql_numrows($result);
if ($numrows <= 0) {
for ($z = 0;$z<=23;$z++) {
$db->sql_query("INSERT INTO ".$prefix."_stats_hour VALUES ('$nowYear','$nowMonth','$nowDate','$z','0')");
}
}
$db->sql_query("UPDATE ".$prefix."_stats_year SET hits=hits+1 WHERE year='$nowYear'");
$db->sql_query("UPDATE ".$prefix."_stats_month SET hits=hits+1 WHERE (year='$nowYear') AND (month='$nowMonth')");
$db->sql_query("UPDATE ".$prefix."_stats_date SET hits=hits+1 WHERE (year='$nowYear') AND (month='$nowMonth') AND (date='$nowDate')");
$db->sql_query("UPDATE ".$prefix."_stats_hour SET hits=hits+1 WHERE (year='$nowYear') AND (month='$nowMonth') AND (date='$nowDate') AND (hour='$nowHour')");
}
?> |
If you go to Only registered users can see links on this board! Get registered or login! you will see what changes I made to the counter.php
The only change I made was that I added:
Quote: | if(!strstr($_SERVER["HTTP_REFERER"], $_SERVER["SERVER_NAME"])) { |
before the line:
Quote: | global $prefix, $db; |
and I added:
before:
I have made no other changes to anything. Just for reference, I am using Nuke 6.9.
Thanks! |
|
|
|
 |
Raven

|
Posted:
Tue Oct 28, 2003 7:32 am |
|
Does that code work w/o the lins you added? |
|
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 9:54 am |
|
Yes that code works fine, and the user registration goes through successfully too. The only thing is that, it adds a hit for everywhere I go on my site. Say if I go from Feedback to Forums....it'll add a hit....etc.. |
|
|
|
 |
Raven

|
Posted:
Tue Oct 28, 2003 10:00 am |
|
Just a shot in the dark. Move that line you added after the global statement. |
|
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 10:11 am |
|
Na that does not work, I still get "_ERROR"..This is using the Site info block from your site...Let me try my other counter and see if I get the same prob |
|
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 10:16 am |
|
No luck, I get the same error with my regular counter block as well...Theres got to be a way around this. Is there a way to put the counter like in the story home page?? This way I can avoid the counter being updated for anywhere else I go, instead it'll update only when I'm on the homepage...Ahhh this is not cool!! |
|
|
|
 |
Raven

|
Posted:
Tue Oct 28, 2003 10:20 am |
|
It's the counter script, not the other blocks. By adding your code it's showing that _ERROR message, but the registrations are being added to the temp table. I'll look closer at the code to see what you're blocking when you do that. |
|
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 10:33 am |
|
Yeah I figured it was the code for the counter.php that was causing the problem. I really appreciate you looking in for me man. Thanks!
Frank |
|
|
|
 |
Raven

|
Posted:
Tue Oct 28, 2003 10:58 am |
|
This will resolve the error, but you will have to determine if it has any counter issues
In additionto the closing } that you placed before the ?>, add this code
else $result=1;
[Raven updated coding instructions] |
Last edited by Raven on Tue Oct 28, 2003 2:54 pm; edited 1 time in total |
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 11:18 am |
|
Nope, that did not work. I still get the _ERROR on new user signups, and also now I get this error...
Quote: | Parse error: parse error in /home/blueradi/public_html/main/includes/counter.php on line 110 |
|
|
|
|
 |
Raven

|
Posted:
Tue Oct 28, 2003 12:02 pm |
|
It does work. You haven't added it correctly, I imagine. Once I added my code that I mention above, the error went away and I could register. |
|
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 2:51 pm |
|
Can you give me the code to your counter.php file? I added it in place of the } like you told me to, and for some reason I get that parse error. I dont know, maybe its something else....I will include my code anyway....
Quote: | <?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* Enhanced with NukeStats Module Version 1.0 */
/* ========================================== */
/* Copyright ©2002 by Harry Mangindaan (sens@indosat.net) and */
/* Sudirman (sudirman@akademika.net) */
/* http://www.nuketest.com */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
if (eregi("counter.php",$_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
global $prefix, $db;
if(!strstr($_SERVER["HTTP_REFERER"], $_SERVER["SERVER_NAME"])) {
/* Get the Browser data */
if((ereg("Nav", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Gold", $_SERVER["HTTP_USER_AGENT"])) || (ereg("X11", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Mozilla", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Netscape", $_SERVER["HTTP_USER_AGENT"])) AND (!ereg("MSIE", $_SERVER["HTTP_USER_AGENT"]) AND (!ereg("Konqueror", $_SERVER["HTTP_USER_AGENT"])))) $browser = "Netscape";
elseif(ereg("MSIE", $_SERVER["HTTP_USER_AGENT"])) $browser = "MSIE";
elseif(ereg("Lynx", $_SERVER["HTTP_USER_AGENT"])) $browser = "Lynx";
elseif(ereg("Opera", $_SERVER["HTTP_USER_AGENT"])) $browser = "Opera";
elseif(ereg("WebTV", $_SERVER["HTTP_USER_AGENT"])) $browser = "WebTV";
elseif(ereg("Konqueror", $_SERVER["HTTP_USER_AGENT"])) $browser = "Konqueror";
elseif((eregi("bot", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Google", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Slurp", $_SERVER["HTTP_USER_AGENT"])) || (ereg("Scooter", $_SERVER["HTTP_USER_AGENT"])) || (eregi("Spider", $_SERVER["HTTP_USER_AGENT"])) || (eregi("Infoseek", $_SERVER["HTTP_USER_AGENT"]))) $browser = "Bot";
else $browser = "Other";
/* Get the Operating System data */
if(ereg("Win", $_SERVER["HTTP_USER_AGENT"])) $os = "Windows";
elseif((ereg("Mac", $_SERVER["HTTP_USER_AGENT"])) || (ereg("PPC", $_SERVER["HTTP_USER_AGENT"]))) $os = "Mac";
elseif(ereg("Linux", $_SERVER["HTTP_USER_AGENT"])) $os = "Linux";
elseif(ereg("FreeBSD", $_SERVER["HTTP_USER_AGENT"])) $os = "FreeBSD";
elseif(ereg("SunOS", $_SERVER["HTTP_USER_AGENT"])) $os = "SunOS";
elseif(ereg("IRIX", $_SERVER["HTTP_USER_AGENT"])) $os = "IRIX";
elseif(ereg("BeOS", $_SERVER["HTTP_USER_AGENT"])) $os = "BeOS";
elseif(ereg("OS/2", $_SERVER["HTTP_USER_AGENT"])) $os = "OS/2";
elseif(ereg("AIX", $_SERVER["HTTP_USER_AGENT"])) $os = "AIX";
else $os = "Other";
/* Save on the databases the obtained values */
$db->sql_query("UPDATE ".$prefix."_counter SET count=count+1 WHERE (type='total' AND var='hits') OR (var='$browser' AND type='browser') OR (var='$os' AND type='os')");
/* Start Detailed Statistics */
$dot = date("d-m-Y-H");
$now = explode ("-",$dot);
$nowHour = $now[3];
$nowYear = $now[2];
$nowMonth = $now[1];
$nowDate = $now[0];
$sql = "SELECT year FROM ".$prefix."_stats_year WHERE year='$nowYear'";
$resultyear = $db->sql_query($sql);
$jml = $db->sql_numrows($resultyear);
if ($jml <= 0) {
$sql = "INSERT INTO ".$prefix."_stats_year VALUES ('$nowYear','0')";
$db->sql_query($sql);
for ($i=1;$i<=12;$i++) {
$db->sql_query("INSERT INTO ".$prefix."_stats_month VALUES ('$nowYear','$i','0')");
if ($i == 1) $TotalDay = 31;
if ($i == 2) {
if (date("L") == true) {
$TotalDay = 29;
} else {
$TotalDay = 28;
}
}
if ($i == 3) $TotalDay = 31;
if ($i == 4) $TotalDay = 30;
if ($i == 5) $TotalDay = 31;
if ($i == 6) $TotalDay = 30;
if ($i == 7) $TotalDay = 31;
if ($i == $TotalDay = 31;
if ($i == 9) $TotalDay = 30;
if ($i == 10) $TotalDay = 31;
if ($i == 11) $TotalDay = 30;
if ($i == 12) $TotalDay = 31;
for ($k=1;$k<=$TotalDay;$k++) {
$db->sql_query("INSERT INTO ".$prefix."_stats_date VALUES ('$nowYear','$i','$k','0')");
}
}
}
$sql = "SELECT hour FROM ".$prefix."_stats_hour WHERE (year='$nowYear') AND (month='$nowMonth') AND (date='$nowDate')";
$result = $db->sql_query($sql);
$numrows = $db->sql_numrows($result);
if ($numrows <= 0) {
for ($z = 0;$z<=23;$z++) {
$db->sql_query("INSERT INTO ".$prefix."_stats_hour VALUES ('$nowYear','$nowMonth','$nowDate','$z','0')");
}
}
$db->sql_query("UPDATE ".$prefix."_stats_year SET hits=hits+1 WHERE year='$nowYear'");
$db->sql_query("UPDATE ".$prefix."_stats_month SET hits=hits+1 WHERE (year='$nowYear') AND (month='$nowMonth')");
$db->sql_query("UPDATE ".$prefix."_stats_date SET hits=hits+1 WHERE (year='$nowYear') AND (month='$nowMonth') AND (date='$nowDate')");
$db->sql_query("UPDATE ".$prefix."_stats_hour SET hits=hits+1 WHERE (year='$nowYear') AND (month='$nowMonth') AND (date='$nowDate') AND (hour='$nowHour')");
else $result=1;
?> |
That is the code currently for my counter.php ... |
|
|
|
 |
Raven

|
Posted:
Tue Oct 28, 2003 2:52 pm |
|
My fault. It should be, at the end,
}
else $result = 1;
?>
Sorry! |
|
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 3:02 pm |
|
Yes that did it!! Thanks so much!.. |
|
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 3:06 pm |
|
Hey Raven, is there anyway to hook up this counter with MS-Analysis rather then the Statistics module? |
|
|
|
 |
Fphilip84

|
Posted:
Tue Oct 28, 2003 3:21 pm |
|
Nevermind, I got it.......Thanks |
|
|
|
 |
Fphilip84

|
Posted:
Wed Jan 07, 2004 1:18 pm |
|
Hey Raven, I dont know what I did, but for some reason the hits counter is back to the way it was before (adding hits for every page refresh)...Is it because now I upgraded to Nuke 7 beta? |
|
|
|
 |
Raven

|
Posted:
Wed Jan 07, 2004 2:38 pm |
|
Very well could be, but Nuke 7 is no longer beta. |
|
|
|
 |
Fphilip84

|
Posted:
Wed Jan 07, 2004 5:37 pm |
|
ah, u wouldnt know how to fix it on this new version right? I shouldnt have upgraded  |
|
|
|
 |
jondvb
Regular


Joined: Oct 25, 2003
Posts: 67
|
Posted:
Thu Jan 08, 2004 9:11 am |
|
Will this fix the double hits in version 7.0? If someone goes to my site, it's one hit, but if they enter a module, it's two hits. |
|
|
|
 |
|