This little mod will replace WebWoW’s in built RA mail system (Remote Access, which uses telnet). It will change it to a fully SOAP compatible version. This will replace both the admins “send mail” and users “vote shop” features. I created this little hack so the WebWoW In-game mail would use SOAP as it just seems more logical (and more easily secured!).
Having recently switched back to version 3.6.3 of the WebWoW CMS (using the web creator v1), I tried to sort out a few issues with the default setup. The latest version just doesn’t seem ready yet. I had problems sending in-game mail with the older version of WebWoW. I’d disabled Remote Access in MangOS as the port being opened didn’t seem necessary.
Didn’t like the way telnet was forced instead of a web interface, so I replaced the telnet mail system.
The only error I saw was “Remote Login Problem:”, apparently caused by incorrect settings. I knew the problem was remote access so I patched the system to use SOAP.
I have edited the mail system in WebWoW so it can be used to send anything including money, items, support tickets, postcards, and more. So getting it working was top of my list of things to do!
Below is how to get it working:
- Enable SOAP in your mangosd.conf file
- Open: includes/core/mangos_sendmail.php
- Replace the sendmail function, below:
function sendmail($playername,$playerguid, $subject, $text, $item, $shopid=0, $money=0, $realmid='1') //returns, IMPORTANT: do not remove <!-- success --> if success { global $server,$ra_user,$ra_pass,$db,$a_user,$se_c,$realm; $playername = clean_string($playername); $subject = preg_replace( "/[^A-Za-z0-9]/", "", clean_string($subject)); //no whitespaces $item = preg_replace( "/[^0-9]/", "", $item); //item id $realmid = preg_replace( "/[^0-9]/", "", $realmid); //item id if ($item<>'') $item = " ".$item; $text = clean_string($text); $money= preg_replace( "/[^0-9]/", "", $money); $telnet = fsockopen($server, $realm[$realmid]['port_ra'], $error, $error_str, 3); if($telnet) { fgets($telnet,1024); // Motd fputs($telnet, $ra_user."\n"); sleep(3); //fgets($telnet,1024); // PASS fputs($telnet, $ra_pass."\n"); sleep(3); $remote_login = fgets($telnet,1024); if(strstr($remote_login, "Logged in.")) { if ($item<>'' && $item<>'0')//send item { //sendmail to RA console fputs($telnet, ".send items ".$playername." \"".$subject."\" \"".$text."\"".$item."\n"); $easf=time(); $mailtext="Mail with item sent! No money was sent."; } elseif ($money>'0' && $money<>'')//send money { fputs($telnet, ".send money ".$playername." \"".$subject."\" \"".$text."\" ".$money."\n"); $moneytext="Mail with money sent! No item was sent."; } else //send letter { fputs($telnet, ".send mail ".$playername." \"".$subject."\" \"".$text."\"\n"); $moneytext="Normal Mail sent!"; } //check database if actuall item is there //WebsiteVoteShopREFXXXXXXX ->this is unique $check=$db->query("SELECT * FROM mail WHERE receiver = '".$playerguid."' AND subject ='".$subject."' LIMIT 1")or die(mysql_error()); if(mysql_num_rows($check)=='0') $status="Recheck script (just to make sure mail is actually sent):<br><br><center><iframe style='width:96%; height:100px' src='./include/core/mangos_iframe_mailcheck.php?shopid=".$shopid."&reciver=".$playerguid."&subject=".$subject."&realmid=".$realmid."&shash=".sha1($a_user['id'].$playerguid.$subject.$se_c.$shopid)."'><a href='./include/core/mangos_iframe_mailcheck.php?shopid=".$shopid."&reciver=".$playerguid."&subject=".$subject."&realmid=".$realmid."&shash=".sha1($a_user['id'].$playerguid.$subject.$se_c.$shopid)."'>Check here if your mail is here.</a></iframe></center>"; return "<!-- success --><span class=\"colorgood\">".$mailtext.$moneytext."<br></span><br>".$status; } else return "<span class=\"colorbad\">Remote Login Problem: ".$remote_login."</span><br>Used login: ".$ra_user; fclose($telnet); } else return "<span class=\"colorbad\">MaNGOS server is offline, you must do this when server is online.</span>"; }
With the following function:
function sendmail($playername,$playerguid, $subject, $text, $item, $shopid=0, $money=0, $realmid='1') //returns, IMPORTANT: do not remove <!-- success --> if success { global $server,$ra_user,$ra_pass,$db,$a_user,$se_c,$realm; $playername = clean_string($playername); $subject = preg_replace( "/[^A-Za-z0-9]/", "", clean_string($subject)); //no whitespaces $item = preg_replace( "/[^0-9]/", "", $item); //item id $realmid = preg_replace( "/[^0-9]/", "", $realmid); //item id if ($item<>'') $item = " ".$item; $text = clean_string($text); $money = preg_replace( "/[^0-9]/", "", $money); $username = 'GMNAME'; $password = 'GMPASS'; $host = "localhost"; $soapport = 7878; if ($item<>'' && $item<>'0') //send item { $command = 'send items '.$playername.' "'.$subject.'" "'.$text.'" '.$item.''; $moneytext = "<strong>Your reward has been sent.</strong> Please check your mailbox in game!"; $client = new SoapClient(NULL, array( "location" => "http://$host:$soapport/", "uri" => "urn:MaNGOS", "style" => SOAP_RPC, 'login' => $username, 'password' => $password )); try { $result = $client->executeCommand(new SoapParam($command, "command")); return "<!-- success --><span class=\"colorgood\">".$mailtext.$moneytext."<br /></span><br />".$status; } catch (Exception $e) { echo "Command failed! Reason:<br />\n"; echo $e->getMessage(); } } elseif ($money>'0' && $money<>'')//send money { $command = 'send money '.$playername.' "'.$subject.'" "'.$text.'" '.$money.''; $client = new SoapClient(NULL, array( "location" => "http://$host:$soapport/", "uri" => "urn:MaNGOS", "style" => SOAP_RPC, 'login' => $username, 'password' => $password )); try { $result = $client->executeCommand(new SoapParam($command, "command")); $moneytext = "<strong>Your money has been sent.</strong> Please check your mailbox in game!"; } catch (Exception $e) { $moneytext = "Failed to send any money. <br />Please contact support!"; } } else //send mail { $command = 'send mail '.$playername.' "'.$subject.'" "'.$text.'"'; $client = new SoapClient(NULL, array( "location" => "http://$host:$soapport/", "uri" => "urn:MaNGOS", "style" => SOAP_RPC, 'login' => $username, 'password' => $password )); try { $result = $client->executeCommand(new SoapParam($command, "command")); $moneytext = "<strong>Your mail was sent.</strong> Please check your mailbox in game!"; } catch (Exception $e) { $moneytext = "Failed to send your mail. <br />Please contact support!"; } } $check=$db->query("SELECT * FROM mail WHERE receiver = '".$playerguid."' AND subject ='".$subject."' LIMIT 1")or die(mysql_error()); if(mysql_num_rows($check)=='0') { $status="Rechecking, just to make sure mail is actually sent:<br><br><center><iframe style='width:96%; height:100px' src='./include/core/mangos_iframe_mailcheck.php?shopid=".$shopid."&reciver=".$playerguid."&subject=".$subject."&realmid=".$realmid."&shash=".sha1($a_user['id'].$playerguid.$subject.$se_c.$shopid)."'><a href='./include/core/mangos_iframe_mailcheck.php?shopid=".$shopid."&reciver=".$playerguid."&subject=".$subject."&realmid=".$realmid."&shash=".sha1($a_user['id'].$playerguid.$subject.$se_c.$shopid)."'>Check here if your mail is here.</a></iframe></center>"; return "<!-- success --><span class=\"colorgood\">".$mailtext.$moneytext."<br></span><br>".$status; } else return "<span class=\"colorbad\">Mail Problem: ".$remote_login."</span><br>Used login: ".$ra_user; }
Change the username, password, host, and port (in the code above):
$username = 'GMNAME'; $password = 'GMPASS'; $host = "localhost"; $soapport = 7878;
To a relevant account with admin access and you’re all set. This modification will allow you to use SOAP instead of the default RA (Remote Access) and should work exactly the same.
Leave a Reply