sango Posted December 28, 2006 Share Posted December 28, 2006 alright guys..i need a simple help hereright now, im hosting a gameserver, the players are connected on 5 different portsi want to make a php script which shows how many players are online currently.so, how to make the script which adds up all the players on the 5 ports?ports are 1234 1235 1236 1237 1238 Link to comment https://forums.phpfreaks.com/topic/32067-how-to-show-online-players-by-connected-ports-help-pls/ Share on other sites More sharing options...
drifter Posted December 28, 2006 Share Posted December 28, 2006 I would probably have it log a DB entry every time someone connects to the server and then read the count from the DB. Not sure if there is another way Link to comment https://forums.phpfreaks.com/topic/32067-how-to-show-online-players-by-connected-ports-help-pls/#findComment-148906 Share on other sites More sharing options...
sango Posted December 28, 2006 Author Share Posted December 28, 2006 this is from netstat -n cmd218.212.16.144:55901 58.182.121.251:22938 ESTABLISHED218.212.16.144:55901 121.6.38.32:1225 ESTABLISHED218.212.16.144:55901 200.109.29.190:1805 ESTABLISHED218.212.16.144:55901 201.252.106.219:3893 ESTABLISHED218.212.16.144:55901 202.156.20.146:1773 ESTABLISHED218.212.16.144:55901 202.156.44.183:1352 ESTABLISHED218.212.16.144:55901 202.156.149.71:1572 ESTABLISHED218.212.16.144:55901 202.156.173.239:1824 ESTABLISHED218.212.16.144:55901 202.156.185.145:1110 ESTABLISHED218.212.16.144:55901 218.186.153.117:1925 ESTABLISHEDfor example there are 10 connections for port 55901thus it will show 10 players are connectedi want to do this also for 5 different ports Link to comment https://forums.phpfreaks.com/topic/32067-how-to-show-online-players-by-connected-ports-help-pls/#findComment-148934 Share on other sites More sharing options...
sango Posted December 28, 2006 Author Share Posted December 28, 2006 help pls add my msn [email protected] Link to comment https://forums.phpfreaks.com/topic/32067-how-to-show-online-players-by-connected-ports-help-pls/#findComment-148960 Share on other sites More sharing options...
sango Posted December 29, 2006 Author Share Posted December 29, 2006 bump Link to comment https://forums.phpfreaks.com/topic/32067-how-to-show-online-players-by-connected-ports-help-pls/#findComment-149150 Share on other sites More sharing options...
corbin Posted December 29, 2006 Share Posted December 29, 2006 You could pass a command to CMD like netstat -n | find "ESTABLISHED" then explode that apart and check if the local port is port 1234 and if it is increment a variable...Not gonna come up with the code for you, but thats how you could do it... Link to comment https://forums.phpfreaks.com/topic/32067-how-to-show-online-players-by-connected-ports-help-pls/#findComment-149152 Share on other sites More sharing options...
sango Posted December 29, 2006 Author Share Posted December 29, 2006 but i know nothing about php coding...im very sad nowpls help me Link to comment https://forums.phpfreaks.com/topic/32067-how-to-show-online-players-by-connected-ports-help-pls/#findComment-149254 Share on other sites More sharing options...
sango Posted December 29, 2006 Author Share Posted December 29, 2006 bump Link to comment https://forums.phpfreaks.com/topic/32067-how-to-show-online-players-by-connected-ports-help-pls/#findComment-149283 Share on other sites More sharing options...
trq Posted December 29, 2006 Share Posted December 29, 2006 You could try this, but I havent (can't) tested it.[code]<?php $ports = array('1234', '1235', '1236', '1237', '1238'); $total = 0; foreach ($ports as $port) { $total += shell_exec("netstat | grep $port | wc -l"); } echo $total;?>[/code]Im also not sure how reliable that might be but it should give you the idea. Most of the work is done within the shell, not really php. Link to comment https://forums.phpfreaks.com/topic/32067-how-to-show-online-players-by-connected-ports-help-pls/#findComment-149285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.