| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/qdent/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if(!socket_bind($sock,0,$argv[1])){
printMessage("Couldn't bind socket");
exit;
}
socket_set_nonblock($sock);
$clients = array();
$clients = array($sock);
$c = array();
$wait=1;
$users = array();
while (true) {
usleep($wait);
// create a copy, so $clients doesn't get modified by socket_select()
$read = array($sock);
$write = array();
$except = NULL;
$buf="";
// get a list of all the clients that have data to be read from
// if there are no clients with data, go to next iteration
if (socket_select($read, $write, $except, 0) < 1){
$wait = 100;
continue;
}
$wait = 1;
$from = '';
$port = 0;
socket_recvfrom($sock, $buf, 1024, 0, $from, $port);
echo "Received $buf from remote address $from and remote port $port and got: " .$buf. PHP_EOL;
$data = explode("|",trim($buf));
switch($data[0]){
case 1:
$users[count($users)] = array('ip' => $from, 'port'=>$port, 'name'=>$data[1]);
break;
case 2:
for($i=0;$i<count($users);$i++){
if($users[$i]['name']==$data[1]){
$buf = $users[$i]['ip']."|".$users[$i]['port'];
echo "Sending ".$buf.PHP_EOL;
socket_sendto($sock, $buf, strlen($buf), 0, $from, $port);
break;
}
}
break;
}
}
// close the listening socket
socket_close($sock);
<body>
</body>
</html>