Author Topic: Bit of PHP fun  (Read 1870 times)

Offline saquivor

  • BFF
  • ***
  • Posts: 110
    • View Profile
Bit of PHP fun
« on: May 13, 2007, 01:19:33 PM »
I was looking at coffee mud today and was impressed by how mud interacts with objects in real time. So decided to play with PHP sockets to see if I could do something silmilar :)

Well here is a rough early script that does show the potential of php! So phase 2 of my tool will use php. I am sure you can all see how this script could be extended to do some really fun stuff!

Current script assumes you have already created user and will log on and send a message on newbie channel if it exists.

Connection will time out after property shown in script and via php.ini default_socket_timeout = 60

Enjoy,

Saquivor

Code: [Select]
<?php
$host
="localhost" ;
$port=6680;
$timeout=30;
$sk=fsockopen($host,$port,$errnum,$errstr,$timeout) ;
if (!
is_resource($sk)) {
    exit(
"connection fail: ".$errnum." ".$errstr) ;
} else {
fputs($sk"username\n") ;
fputs($sk"password\n") ;

fputs($sk"newbie I am a php bot test\n") ;
    
$dati="" ;
    while (!
feof($sk)) {
        
$dati.= fgets ($sk1024);
    }
}
fclose($sk) ;
echo(
$dati) ;
?>