Jump to content
php.lv forumi

ciemiņu skaitīšana vai ari guest counting


Faks

Recommended Posts

Labvakar Dāmas un Kungi Šodien mēs esam savākušies lai izveidot ejošu lietotāju skaitītaju ar mysql palīdzība ja ir alternatīvas gatavas būšū priecīgs dzirdēt :)

 

Paš cepts kods :)

$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];

$select = mysql_query("SELECT hosting_guests_ip,COUNT(hosting_guests_ip) FROM hosting_guests") or die(mysql_error());
if (mysql_numrows($select) > 0) 
{
while($test = mysql_fetch_array($select))
{
	echo 'Total Users Online '.$test['COUNT(hosting_guests_ip)'].'<br>';

	if ($test['COUNT(hosting_guests_ip)'] >= 1 OR $test['COUNT(hosting_guests_ip)'] <= 0) 
	{
		if ($ip == $test['hosting_guests_ip']) 
		{
			$tests = ("UPDATE hosting_guests SET hosting_guests_ip = '".$ip."' hosting_guests_browser = '".$browser."' ") or die(mysql_error());
		}
		elseif ($ip != $test['hosting_guests_ip'])
		{
			$tests = ("INSERT INTO hosting_guests (hosting_guests_ip,hosting_guests_browser) VALUES('".$ip."','".$browser."') ") or die(mysql_error());
		}
		mysql_query($tests);
		mysql_close($tests);
	}

}
}
else 
{
echo 'No user in db';
}

 

Problēmā itka sekojoša vis darbojas lieliski bet tiko lieta noiet lidz linux browseriem tad viņu ip liekas iekša bez limita respetivi var ielikt vienu Ip simtiem un vairāk reižu bet ar windows ip ir ok vismaz tā es novēroju lieta tāda ja kāds zin ko es atkal palaižu garām tad būšu priecīgs dzirdēt ieteikums piemērus vai jebko kas var palīdzēt vai arī apgaismot mani :)

 

šeit var pārbaudīt kodu darbībā Nospied Mani

Edited by Faks
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...