Jump to content

How to use Remote Access


Guest chmuun

Recommended Posts

Hi,

I am a PHP developer and I'm trying to make a vote/donate script for mangos... The normal SQL Insertion method is too unstable... usually sends wrong items.

I've tried alot trying to log in from PUTTY to Mango's Remote Access on my own server... But it always says WRONG password... Even though my password is correct

Please help

Thank you

Link to comment
Share on other sites

I'm unsure exactly what your asking for, but it sounds like your looking for a way to interface PHP with MaNGOS?

Before SOAP was implemented I used PHP's fopen,fread,fwrite and communicated with mangos through RA via 127.0.0.1:3443

This worked for the most part however you need to write data to RA, then wait, then read, then write some more and repeat, I used something similar to

$fsk = @fsockopen("127.0.0.1",3443);
usleep(20000);
echo fread($fsk,64);

fwrite($fsk,"[b]username[/b]\\r\\n");
usleep(20000);
fread($fsk,64);

fwrite($fsk,"[b]password[/b]\\r\\n");
usleep(20000);
fread($fsk,64);

fwrite($fsk,"[b]server info[/b]\\r\\n"); // replace "server info" with the mangos command to execute
usleep(25000);
echo fread($fsk,1024);

However this is very slow, inefficient, and doesn't always work

With PHP-SOAP you can do the following, just make sure SOAP is enabled in your mangos.conf file

$remote_soap = array("127.0.0.1", "7878", "[b]username[/b]", "[b]password[/b]"); // use your own username and password
$client = new SoapClient(NULL,array("location" => "http://".$remote_soap[0].":".$remote_soap[1]."/","uri" => "urn:MaNGOS","style" => SOAP_RPC,"login" => $remote_soap[2],"password" => $remote_soap[3]));

$command = "[b]server info[/b]"; // Replace "server info" with the mangos command to execute

$result = $client->executeCommand(new SoapParam($command, "command"));
echo $result;

Link to comment
Share on other sites

Welcome to the Cataclysmic Domination Funserver, Be sure to vote for us every 12 hours and receive great voting rewards at REMOVED LINK! You can also donate and be rewarded by many donation items! Username: Password: -Wrong pass. Password:

THis is what i always get... -Wrong pass. It works on the server and on the website but never on RA

Link to comment
Share on other sites

Well I tried to recreate your problem of getting a wrong password, but i was unable to do so.

I did try out my php-fopen-RA code, last time i used RA with PHP was before it was rewritten in revision 9466

After revision 9466, RA is allowed to have more than one connection at a time, so if your running a current version this is not your problem.

Also I've noticed that the delay I encountered prior to 9466 is no longer there, for the most part, so my original PHP code using fopen can now be written as

You still need to read after every write, but the usleep()'s are no longer needed

<?php
$fsk = @fsockopen("127.0.0.1",3443);
echo fread($fsk,64);

fwrite($fsk,"[b]username[/b]\\n");    //your username/adminname
fread($fsk,64);

fwrite($fsk,"[b]password[/b]\\n"); // Your user/admins's password
fread($fsk,64);

// This is where you could use the "send items #playername "#subject" "#text" itemid1[:count]" command
// ex: "send items [b]user1[/b] \\"You Won in the Lottery/Giveaway\\" \\"Congratz [b]user1[/b], You won in the daily giveaway/lottery. You have received [b][item][/b]\\" [b]itemid1[/b]:1"
fwrite($fsk,"[b]server info[/b]\\n"); // replace "server info" with the mangos command to execute
echo fread($fsk,1024);

fwrite($fsk,"quit\\n");
echo fread($fsk,1024);
?>

The above returns the following for me

Welcome to the Massive Network Game Object Server.
Username: MaNGOS/0.16.0 (* * Revision 10074 - *) for FreeBSD_x32 (little-endian)
Using script library: ScriptDev2 (for MaNGOS 9832+) Revision [1718] 2010-06-17 02:09:04 (Unix)
Using World DB: UDB 0.12.0 (391) for MaNGOS 9999 with SD2 SQL for rev. 1702
Using creature EventAI: ACID 3.0.4 - Final Release for Mangos (3.3.2 Client)
Online players: 0 (max: 2) Queued players: 0 (max: 0)
Server uptime: 11 Hour(s) 1 Minute(s) 52 Second(s).
mangos>

And although brunogcar stated both DB and Script must have the Username in upper case, I think this may only be true for the DB.. I log into RA/SOAP using lowercase, and the scripts that I wrote in my first post worked with lowercase just fine.

If you can provide the exact code your using for your script, just replace private data, I'll see what it does on my server.

Other stuff that could be helpful would be your MaNGOS version and PHP version

Link to comment
Share on other sites

indeed what i said isnt true anymore, used to be, just tested to make sure,

i havent been following mangos closely lately, but if nothing changed mangos (if i remember correctly thats how client send username) still expect usernames to be stored in uppercase

Link to comment
Share on other sites

OK Thanks Guys... THe solution is USERNAME must be in uppercase in both... Script and Database... Thanx to brunogcar

I'm making this script for my server only... It is a very powerful script and i dont like to use other's creations because it doesn't meets my requirements... The script is a whole system so i couldn't use it anyways.

I'm gonna use SOAP cuz RA isn't useful for big servers.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use