-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLaunch.php
72 lines (59 loc) · 1.72 KB
/
Launch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Created by JetBrains PhpStorm.
* User: sekjun9878
* Date: 28/09/13
* Time: 3:04 PM
* To change this template use File | Settings | File Templates.
*/
require __DIR__ . '/SourceQuery/SourceQuery.class.php';
$Query = new SourceQuery( );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery :: SOURCE );
echo "----------------------------------------------------------------------\n";
echo "| PHP RCON Client v0.1 by sekjun9878\n";
echo "|\n";
echo "| Open Source under Creative Commons A-NC-SA 3.0 Unported License\n";
echo "| Thanks to xPaw for the Minecraft RCON Library for PHP!\n";
echo "----------------------------------------------------------------------\n";
$fp = fopen('php://stdin', 'r');
echo "Please enter the IP / Address of the server you wish to connect to.\n";
echo "IP> ";
$IP = trim(fgets($fp, 1024));
echo "Please enter the Port of the server you wish to connect to.\n";
echo "Port> ";
$Port = trim(fgets($fp, 1024));
try
{
$Query->Connect( $IP , $Port, SQ_TIMEOUT, SQ_ENGINE );
echo "Please enter the RCON Password of the server you wish to connect to.\n";
echo "RCON Password> ";
$RCONPassword = trim(fgets($fp, 1024));
$Query->setRconPassword($RCONPassword);
}
catch( Exception $e )
{
echo $e->getMessage( )."\n";
echo "Failed to connect to server. Exiting...\n";
exit(0);
}
$quit = false;
echo "Connected! Type '.' to quit.\n";
while (!$quit) {
echo "> ";
$next_line = fgets($fp, 1024); // read the special file to get the user input from keyboard
if (".\n" == $next_line) {
$quit = true;
} else {
try
{
echo $Query->Rcon(trim($next_line))."\n";
}
catch( Exception $e )
{
echo $e->getMessage( )."\n";
echo "Failed to send RCON Message.\n";
}
}
}
exit(0);