C:\Documents and Settings\Dygear\Desktop\PHPInSim>php InSim.php
Listen socket created!
Binded to listen socket!
Send socket created!
Conneceted to send socket!
¶☻☺ 0.5Y S2 ♦ ∟♣ Ç?Ç♀ ☺ ♣ KY1 ☺♦♥ (
☺ SimFIA : InSim ∟♣ Ç?Ç♫ ☺ ♣ KY1 ☺♦♥ §ê♂ Tr
ack loaded
∟♣ Ç?ÇN ☺☺ ♣ KY1 ☺L§ ☺
I♠^1(E^7AGL^4E)^7Dygear Dygear BF1 BMWSauber_NH-16 ♥♥♥♥ ☺ $$ ☺☺
∟◄ ♣ ☺ KY1 ☺# · ▲ u ****∟♣ Ç?üN♥☺☺☺ ☺ ♣ KY1
☺♦♥ ►↓ ☺ΣH ΣH ☺ ♦♥ ¶↑ ☺2¢ 2¢ ☺ I♠ ►↓ ☺Ä+ └╞ ☺ ♦♥ ¶↑ ☺░| Γ↨☺ ☻
I♠ ►↓ ☺╩+ ¼C☺ ☺ ♦♥ ¶↑ ☺d} Fò☺ ♥ I♠ ♦♥ ►↓ ☺└+ ♠┴☺ ☺ ¶↑ ☺~| ─◄☻ ♦
I♠ ♦♥ ►↓ ☺$, Φ=☻ ☺ ¶↑ ☺2} ÷Ä☻ ♣ I♠ ¶" ☺÷Ä☻ ~| ♣ I♠∟♣ Ç?üN♥☺☺☺
☺☺ ♣ KY1 ☺T# ☺Dygear ^1(E^7AGL^4E)^7Dygear Dygear BF1 ÷Ä
☻ ~| ☻ ♣ I♠ ☺ ê♂ ^1(E^7AGL^4E)^7Dygear^8 finished
♦♥ ☺
☺☻
Yeah, I know, it's kinda dirty and raw for the moment. But it works, it's open source, it's for everyone to use and I will continue work on it.
If anyone wants to post this code to the LFS Wiki on how to connect to InSim with PHP5, please do.
<?php
php
/*
** @package PHPInSim.
** @since 2008-02-23 17:10 EST.
** @author Mark 'Dygear' Tomlin.
** @license MIT License (http://opensource.org/licenses/mit-license.php).
** @copyright Copyright (C) 2008, Mark 'Dygear' Tomlin.
** @version 0.2.1
*/
$InSim = new InSim();
class InSim {
private $skIn;
private $skOt;
private $time;
function __construct($AdminPass = '', $Address = '127.0.0.1', $Port = 29999, $PreFixChar = '!') {
// Socket In;
if ($this->skIn = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP)) {
echo('Listen socket created!' . PHP_EOL);
if (socket_bind($this->skIn, $Address, $Port + 1))
echo('Binded to listen socket!' . PHP_EOL);
else
die('Could not bind to listen socket, address or port!' . PHP_EOL);
}
else
die('Could not create listen socket!' . PHP_EOL);
// Socket Out;
if ($this->skOt = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP)) {
echo('Send socket created!' . PHP_EOL);
if (socket_connect($this->skOt, $Address, $Port))
echo('Conneceted to send socket!' . PHP_EOL);
else
die('Could not connect to send socket, address or port!' . PHP_EOL);
}
else
die('Could not create send socket!');
// Connect To InSim;
$this->send(pack('CCCxSSxCSa16a16', 44, 1, 1, $Port + 1, 4 | 8, 36, 0, $AdminPass, 'phpInSim'));
$this->main();
}
function send($packet) {
return socket_write($this->skOt, $packet, strlen($packet));
}
function main() {
while (TRUE) {
// Keep Alive;
if (time() > $this->time) {
$this->send(pack('CCCC', 4, 3, 0, 0));
$this->time = time() + 30;
}
// Get Packet;
if ($data = $this->recv()) {
print_r($data);
}
}
}
function recv() {
return socket_read($this->skIn, 256, PHP_BINARY_READ);
}
function __destruct() {
$this->send(pack('CCCC', 4, 3, 0, 2));
}
}
?>