PHP Web Host - Quality Web Hosting For All PHP Applications $35/month $250/year (Unlimited) - $25/month - 200,000 impressions - Your Ad Could be Here - Click For Details
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Author Message
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Mon Oct 27, 2003 5:07 pm Reply with quote Back to top

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!!
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Oct 28, 2003 6:58 am Reply with quote Back to top

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.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 7:27 am Reply with quote Back to top

This is the code for the counter.php file.

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!
*/
/* */
/* Enhanced with NukeStats Module Version 1.0 */
/* ========================================== */
/* Copyright ©2002 by Harry Mangindaan (sens@indosat.net) and */
/* Sudirman (sudirman@akademika.net) */
/*
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;

/* 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 == Cool $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

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:
Quote:
}


before:
Quote:
?>


I have made no other changes to anything. Just for reference, I am using Nuke 6.9.

Thanks!
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Oct 28, 2003 7:32 am Reply with quote Back to top

Does that code work w/o the lins you added?
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 9:54 am Reply with quote Back to top

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..
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Oct 28, 2003 10:00 am Reply with quote Back to top

Just a shot in the dark. Move that line you added after the global statement.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 10:11 am Reply with quote Back to top

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
View user's profile Send private message
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 10:16 am Reply with quote Back to top

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!!
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Oct 28, 2003 10:20 am Reply with quote Back to top

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.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 10:33 am Reply with quote Back to top

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
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Oct 28, 2003 10:58 am Reply with quote Back to top

This will resolve the error, but you will have to determine if it has any counter issues Wink

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 11:18 am Reply with quote Back to top

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
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Oct 28, 2003 12:02 pm Reply with quote Back to top

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.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 2:51 pm Reply with quote Back to top

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!
*/
/* */
/* Enhanced with NukeStats Module Version 1.0 */
/* ========================================== */
/* Copyright ©2002 by Harry Mangindaan (sens@indosat.net) and */
/* Sudirman (sudirman@akademika.net) */
/*
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"])) {

/* 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 == Cool $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 ...
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Tue Oct 28, 2003 2:52 pm Reply with quote Back to top

My fault. It should be, at the end,
}
else $result = 1;
?>

Sorry!
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 3:02 pm Reply with quote Back to top

Yes that did it!! Thanks so much!..
View user's profile Send private message
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 3:06 pm Reply with quote Back to top

Hey Raven, is there anyway to hook up this counter with MS-Analysis rather then the Statistics module?
View user's profile Send private message
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Tue Oct 28, 2003 3:21 pm Reply with quote Back to top

Nevermind, I got it.......Thanks
View user's profile Send private message
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Wed Jan 07, 2004 1:18 pm Reply with quote Back to top

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 user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Wed Jan 07, 2004 2:38 pm Reply with quote Back to top

Very well could be, but Nuke 7 is no longer beta.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Fphilip84
Regular
Regular


Joined: Oct 27, 2003
Posts: 73

PostPosted: Wed Jan 07, 2004 5:37 pm Reply with quote Back to top

ah, u wouldnt know how to fix it on this new version right? I shouldnt have upgraded Embarassed
View user's profile Send private message
jondvb
Regular
Regular


Joined: Oct 25, 2003
Posts: 67

PostPosted: Thu Jan 08, 2004 9:11 am Reply with quote Back to top

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.
View user's profile Send private message
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum