PHP Script not sending info to external IP + SMF username usage

ntg

New Member
Messages
1
Reaction score
0
Points
0
Hi there webdevs!

I ran into a problem:
I've got a php script which allowes a user to send information from the script to an external server/ip.
In this case, this is a promotion on a minecraft server.
So this is the script I've got:
$HOST = "IP Here"; //the ip of the bukkit server, removed ip on purpose
$password = "Pass here"; //removed pass on purpose
$user = $_POST["minecraftID"];
$sock = socket_create(AF_INET, SOCK_STREAM, 0)
or die("error: could not create socket\n");
$succ = socket_connect($sock, $HOST, 4445)
or die("error: could not connect to host\n");
socket_write($sock, $command = md5($password)."<Password>", strlen($command) + 1)
or die("error: failed to write to socket\n");
socket_write($sock, $command = "/Command/ExecuteConsoleCommand:pex user " . $user . " setgroup Gamer;", strlen($command) + 1)
or die("error: failed to write to socket\n");

Now it gives an error at the connection of the website to the server, at the line where it says "$succ = socket_connect($sock, $HOST, 4445)".

It says that it is unable to connect to the server.

Do you have any idea on fixing this?
And do you know how to use the username of SMF instead of "minecraftID" in this script?
(so when the user is logged in it uses their SMF username instead of "minecraftID")
Thanks for the help!
 
Top