Skip to content

Commit

Permalink
whatever i changed
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchy- committed Dec 7, 2014
1 parent 2cc4cef commit b9c5624
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ircd/cmd/cmd_join.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function cmd_join($client_index,$items)
{
global $nicks;
global $channels;
$nick=client_nick($client_index)
$nick=client_nick($client_index);
if ($nick===False)
{
return;
Expand All @@ -41,7 +41,7 @@ function cmd_join($client_index,$items)
$ident_prefix=$nicks[strtolower($nick)]["connection"]["ident_prefix"];
$msg=":".$nick."!".$ident_prefix.$username."@".$hostname." JOIN ".$chan;
$msg="*** JOIN MESSAGE RECEIVED FROM $addr";
do_reply($client,$msg);
do_reply($client_index,$msg);
}

#####################################################################################################
Expand Down
19 changes: 11 additions & 8 deletions ircd/ircd.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
return;
}
$clients=array($server);
echo "CRUTCHY IRCD\n";
echo "listening...\n";
while (True)
{
Expand All @@ -62,12 +63,11 @@
{
$client=socket_accept($server);
$clients[]=$client;
$client_index=array_search($client,$clients);
$addr="";
if (socket_getpeername($client,$addr)==True)
{
echo "connected to remote address $addr\n";
on_connect($connections,$client,$addr);
}
socket_getpeername($client,$addr);
echo "connected to remote address $addr\n";
on_connect($client_index);
$n=count($clients)-1;
socket_write($client,"successfully connected to server\nthere are $n clients connected\n");
$key=array_search($server,$read);
Expand Down Expand Up @@ -107,10 +107,13 @@
unset($clients[$client_index]);
break;
}
foreach ($clients as $client_index => $client_socket)
foreach ($clients as $client_index => $socket)
{
socket_close($clients[$client_index]);
unset($clients[$client_index]);
if ($clients[$client_index]<>$server)
{
socket_close($clients[$client_index]);
unset($clients[$client_index]);
}
}
break 2;
}
Expand Down
7 changes: 3 additions & 4 deletions ircd/ircd_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

function connection_index($client_index,$suppress_error=False)
{
global $clients;
global $connections;
foreach ($connections as $index => $data)
{
if ($connections[$index]["client"]===$clients[$client_index])
if ($connections[$index]["client_index"]==$client_index)
{
return $index;
}
Expand Down Expand Up @@ -50,7 +49,7 @@ function client_nick($client_index,$suppress_error=False)
global $connections;
global $nicks;
$connection_index=connection_index($client_index,$suppress_error);
if ($key===False)
if ($connection_index===False)
{
return False;
}
Expand Down Expand Up @@ -115,7 +114,7 @@ function on_connect($client_index)
$connection["addr"]=$addr;
$connection["connect_timestamp"]=microtime(True);
$connections[]=$connection;
send_to_all("*** CLIENT CONNECTED: $addr");
broadcast("*** CLIENT CONNECTED: $addr");
}
else
{
Expand Down

0 comments on commit b9c5624

Please sign in to comment.