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!!
Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
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.
Only registered users can see links on this board! Get registered or login to the forums!
*/
/* */
/* 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;
$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 to the forums!
you will see what changes I made to the counter.php
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..
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
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!!
Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
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.
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 */
/*
Only registered users can see links on this board! Get registered or login to the forums!
Only registered users can see links on this board! Get registered or login to the forums!
*/
/* */
/* 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"])) {
$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;
?>
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?
View next topic View previous topic
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