473,473 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Array problem

Hi all. I'm making a counter for my webpage, and I thought it would be
neat if it wouldn't count my own page requests. So I wrote this code below:

// Don't count requests from these addresses ('*' is permitted)
$exclude_ip = array(
'213.114.222.215',
'213.114.222.216',
'123.123.123.*'
);

// Get user IP
$user_ip = getenv("REMOTE_ADDR");

// Make a flag
$exclude_user = 0;

// For each IP in the array
foreach($exclude_ip as $ip)
{
// If a wildcard is found
if (strpos($ip, '*') > 0)
{
// Get position for wildcard
$w_pos = strpos($ip, '*');

// Shorten the compare strings to the wildcard position
$ip = substr($ip, 0, $w_pos - 1);
$user_ip = substr($user_ip, 0, $w_pos - 1);
}

// If an excluded IP is found
if ($ip == $user_ip) $exclude_user = 1;
break;
}

My current IP is 213.114.222.216, but the flag $exclude_user is still 0.
I hope someone can spot the error.

Gustaf
Jul 17 '05 #1
2 1637
> Hi all. I'm making a counter for my webpage, and I thought it would be
neat if it wouldn't count my own page requests. So I wrote this code

below:

I had the same idea and came up with a script that you might find
interesting. You can download the complete code at
http://www.clearpointsystems.com/software.php - look for "Viscount"
Jul 17 '05 #2
deko wrote:
Hi all. I'm making a counter for my webpage, and I thought it would be
neat if it wouldn't count my own page requests. So I wrote this code


below:

I had the same idea and came up with a script that you might find
interesting. You can download the complete code at
http://www.clearpointsystems.com/software.php - look for "Viscount"


Thanks deko. I'll have a look at your code. I found the problem now. Had
just worked on it for too long... :-)

Gustaf
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
9
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I...
5
by: ritchie | last post by:
Hi, I am writing to ask if anyone can see why my array is not being sorted correctly? It's an array of 4 elements(ints 1,2,3,4) but after calling the selection sort it comes back sorted as...
8
by: Gerald | last post by:
I have a problem with an array of pointers. In a program I'm writing, I have to read a file, containing thousands of short lines. The content of another file will be compared against each line...
12
by: arkobose | last post by:
my earlier post titled: "How to input strings of any lengths into arrays of type: char *array ?" seems to have created a confusion. therefore i paraphrase my problem below. consider the...
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
4
by: assgar | last post by:
Hi Seasons Greetings Its back, I am being haunted. I thought I had resolved this problem but I am intermittently the receving the warnings below. This code consist of a 1) HTML form, 2)...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.