A little change to this unique visiter script...help?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

A little change to this unique visiter script...help?

Post by gaogier »

hello,

I wish to use, this script found in this tutorial

http://www.spoono.com/php/tutorials/tutorial.php?id=16


My only question, is, how can i make it so that it will put up all the users on the site, so the script wont show on all pages, just the main page?

This will go on different places on the site, forums, desktop, a game.
Last edited by gaogier on Sun Jun 17, 2007 9:07 am, edited 1 time in total.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

My only question, is, how can i make it so that it will put up all the users on the site, so the script wont show on all pages, just the main page?
I'm not sure I know exactly what you're asking. Try and give more details when you ask a question please. If I understand you correctly, you want to display how many users are on your site, but only on your home page. If that's what you're asking, it says in the second sentence on that page how to do it.
This script will explain how to display the number of users online using your website. You have to put this on everypage you want it to appear.
If you don't want it to show up on a certain page, don't put it on that page.

I have to advise against this script though. It's very poorly written. Why?

For one, it requires register_globals to be turned on, which I try to never do unless absolutely necessary.

Also, this just $PHP_SELF right into the query, totally unchecked. Did you know that PHP_SELF contains user input? This opens you up to SQL injection. There are better methods of getting the current file, for example -- basename(__FILE__).

Code: Select all

//insert the values
$insert = mysql_db_query($database, "INSERT INTO useronline VALUES
('$timestamp','$REMOTE_ADDR','$PHP_SELF')"); 
if(!($insert)) { 
print "Useronline Insert Failed > "; 
}
This is why I generally discourage online tutorials to PHP newcomers. People don't have to know what they're doing to write a tutorial. They just have to think they know what they're doing. A good majority of the tutorials you'll find on the internet are total crap.

If you explain more about your website / application, maybe I can help you roll your own?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Descriptive subjects

Post by feyd »

[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Re: Descriptive subjects

Post by gaogier »

feyd wrote:
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
Sorry, i thought it was descriptive as much as i could think at the time.






Also, what im trying to do, is, show all the users who have gone on the site, even if there is no script.

I have forums, topsites, a RPG, and a site, which all uses, php's include files. so i can just put the file on the header, or footer.

But i dont want the script so show, on the RPG, Topsites, and the forums, just the main site, i know php wont show in the source, but can it not be shown in the page?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

yes, you just include all the necessary logic in your "php's include files", then echo out the result only on the pages you want it to show up on. Once again, I'd advise against using this script, or at least modifying this script to not suck so much.
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

would anyone know where i can find such a good tut, what can do what i want?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

If you make an honest attempt to write it yourself, and then you run into troubles, ask questions here, I'm sure that this community will help you.
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

im not that great with php


I would have to use a book, but the book i use is the same book as what they use
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

But you have so much on your site?

What you want to do is have every page that you want counted to check who's visited and store it, and then just output it to the page you want to output it to. PHP only exists where you make it...
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

gaogier wrote:im not that great with php
The only way to get great with php is to use it. You will never get any better at it by having people tell you how to do everything. Use the code you found in that tutorial, and rewrite it to do exactly what you want. We'll help you, but I don't see "I'm not that great with php" as a good enough reason why you can't write it on your own (with our guidance of course)
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

a few of the scripts was created, and the rest was done by me.

Also, iv changed the name of this post.
superdezign wrote:But you have so much on your site?

What you want to do is have every page that you want counted to check who's visited and store it, and then just output it to the page you want to output it to. PHP only exists where you make it...
thats what i want.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I'm aware that it is what you want... That's why I said that it was what you want. :lol:

So, make it. It's just a little SQL interaction.
Post Reply