Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (19 June 2013 - 02:28 PM) Long Life To Asta New Era
@  agyat : (19 June 2013 - 01:58 PM) New Era Start At Asta Or Asta Start In New Era. :unsure:
@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?

Replying to Getting Ip


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

Quatrux

Posted 12 August 2008 - 10:42 AM

Here is also a way to get the ip address from a user using php language, even though this is not the best method, but I am using it and don't really have problems, I will show this example in a class, those who know php could easily just change it or something like that :mellow:

class MyClass {

	/**
	 * @access public
	 * @variables
	 */

	var $ipAddress, $proxyAddress = '';

	function setIPAddress() {

			if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {

				if (isset($_SERVER['HTTP_CLIENT_IP'])) { $this->proxyAddress = $_SERVER['HTTP_CLIENT_IP']; }
				else 												{ $this->proxyAddress = $_SERVER['REMOTE_ADDR']; }
																	  $this->ipAddress	= $_SERVER['HTTP_X_FORWARDED_FOR']; }
		elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {	  $this->ipAddress	= $_SERVER['HTTP_CLIENT_IP']; }
		  else 												 {	  $this->ipAddress	= $_SERVER['REMOTE_ADDR']; }

	}
}

and whenever you want to show the ip address you just do:

$MyClass = new MyClass();

and you can call the function once like $Myclass->setIPAddress(); and you'll get the value and you could use it like this:

echo $MyClass->ipAddress or echo $MyClass->proxyAddress but I would do it in a constructor of that class, the class constructor is a function/method of that class and needs to have the same name as the class in other languages it also can be init() like on Zend framework on PHP.. A constructor here is good because this function needs to be done/executed/called only once, also it could be done differently as I said, but this is just one of a lot of methods which is possible.

levimage

Posted 05 August 2008 - 06:38 PM

Do you mean like how some online messenger/chat(s) detect if more than one user logs in or is logged in from an IP address or if someone from a specific ip is creating multiple user accounts within a certain time period. Maybe you should just have like a cool off period verses denying or banning someone. Cause their may be multiple people using your services from the same place like a pubic wifi, school, or building.

Just something to think about.

sparkx

Posted 04 August 2008 - 03:49 PM

Just a side message there is NO way to track internet users other then real-time IP lookup or backtracking (which is very hard to do and is usually only used in movies). I would say probably not to even bother making a script like this but rather only accept the referral if the new user is active (for example if it is a forum then make a minimum of 10 posts and remove the referral if the new user gets banned for spamming est.). If one person wants to do that much work just to get a referral then let them have it...

Remember Cookies can be edited or deleted and IPs can be changed in less then 30 seconds.

Hope this helps,
Sparkx

Jeigh

Posted 03 August 2008 - 02:17 PM

You've probably already thought of this, but you might want to store a long term cookie as a secondary check. IP's don't change a lot anymore but they can still depending on the connection type or the users dedication lol, so adding a little cookie when they register just sort of adds a second layer that they would need to think to clear in order to get around your checks. Then again if it's not that important and you just want to limit it from happening frequently then the IP thing would be more then enough obviously.

FirefoxRocks

Posted 02 August 2008 - 06:27 PM

The IP address is stored in a $_SERVER[] variable, in this case it is the REMOTE_ADDR variable. So it would be:
$_SERVER['remote_addr'];

If you want to store that in a variable (which you probably can figure out) and display it, you do this:
$ip = $_SERVER['remote_addr'];
echo($ip);

khalilov

Posted 01 August 2008 - 03:09 PM

Whats the php code to get the users IP, i want to start a referal program and i don't want to people to refer themselves:P

Review the complete topic (launches new window)