deviss Posted May 26, 2012 Share Posted May 26, 2012 Hello I've been trying to find a way on making this work for mysql but it's over my powers I got a php script that connects through soap and registers an account inside a sql database lib.php <?php /* * Copyright (C) 2011 mooege project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** * LibMooege class that connect Mooege's web-services and communicate with them. * Requires php_soap extension to be activated. */ class LibMooege { /** * Is connected to mooege web-services? * @var type $connected */ var $connected=false; /** * Mooege web-services address * @var type $servicesAddress */ var $servicesAddress; /** * SOAP client for Core service. * @var type SOAPClient */ var $core; /** * SOAP client for MooNet service. * @var type SOAPClient */ var $moonet; /** * SOAP client for GS service. * @var type $gs */ var $gameserver; /** * SOAP client for accounts service * @var type $accounts. */ var $accounts; /** * Creates a new instance of the LibMooege class. * @param type $address - Base address for mooege web-services. * @param type $port - Port for mooege web-services. * @param type $default_timeout - Default timeout value for connecting soap services. */ public function __construct($address = "http://localhost", $port = 9000, $default_timeout = 5) { $this->servicesAddress="$address:$port"; $this->CreateSOAPClients($default_timeout); } /** * Creates soap-clients used for communicating mooege web-services. */ private function CreateSOAPClients($timeout) { try { $this->core = new SoapClient($this->servicesAddress.'/Core?wsdl', array( 'connection_timeout' => $timeout)); $this->moonet = new SoapClient($this->servicesAddress.'/MooNet?wsdl', array( 'connection_timeout' => $timeout)); $this->gameserver = new SoapClient($this->servicesAddress.'/GS?wsdl', array( 'connection_timeout' => $timeout)); $this->accounts = new SoapClient($this->servicesAddress.'/Accounts?wsdl', array( 'connection_timeout' => $timeout)); $this->connected=true; } catch(Exception $e) { $this->connected=false; } } /** * Returns mooege version. * @return type string */ public function Version() { if(!$this->connected) return "N/A"; try { $response=$this->core->Version(); } catch(Exception $e) { return "N/A"; } return $response->VersionResult; } /** * Returns uptime statistics for mooege. * @return type string */ public function Uptime() { if(!$this->connected) return "N/A"; try { $response=$this->core->Uptime(); } catch(Exception $e) { return "N/A"; } return $response->UptimeResult; } /** * Returns true if MooNet is online. * @return type bool */ public function IsMooNetServerOnline() { if(!$this->connected) return false; try { $response=$this->moonet->Ping(); } catch(Exception $e) { return false; } return $response->PingResult; } /** * Returns count of online players. * @return type int */ public function OnlinePlayerCount() { if(!$this->connected) return -1; try { $response = $this->moonet->OnlinePlayersCount(); } catch(Exception $e) { return -1; } return $response->OnlinePlayersCountResult; } /** * Returns list of online players. * @return type array. */ public function OnlinePlayersList() { if(!$this->connected) return array(); try { $response = $this->moonet->OnlinePlayersList(); } catch(Exception $e) { return array(); } if(property_exists($response->OnlinePlayersListResult, "string")) return $response->OnlinePlayersListResult->string; else return $response->OnlinePlayersListResult; } /** * Returns true if game-server is online. * @return type bool */ public function IsGameServerOnline() { if(!$this->connected) return false; try { $response=$this->gameserver->Ping(); } catch(Exception $e) { return false; } return $response->PingResult; } /** * Creates a new account over mooege database. * Returns true if the call was successful, false otherwhise. * @param type $email * @param type $password * @return type bool */ public function CreateAccount($email, $password, $battleTag) { if(!$this->connected) return false; try { $response=$this->accounts->CreateAccount(array('email' => $email, 'password' => $password, 'battleTag' => $battleTag)); } catch(Exception $e) { return false; } return $response->CreateAccountResult; } public function ChangePassword($email, $password) { if(!$this->connected) return false; return $response=$this->accounts->ChangePassword(array('email' => $email, 'password' => $password)); } /** * Returns true if an account exists for given email address, false otherwise. * @param type $email * @return type bool */ public function AccountExists($email) { if(!$this->connected) return false; try { $response=$this->accounts->AccountExists(array('email' => $email)); } catch(Exception $e) { return false; } return $response->AccountExistsResult; } /** * Returns true if password is correct, false otherwise. * @param type $email * @param type $password * @return type bool */ public function VerifyPassword($email, $password) { if(!$this->connected) return false; try { $response=$this->accounts->VerifyPassword(array('email' => $email, 'password' => $password)); } catch(Exception $e) { return false; } return $response->VerifyPasswordResult; } /** * Returns count of total accounts. * @return type int */ public function TotalAccounts() { if(!$this->connected) return -1; try { $response = $this->accounts->TotalAccounts(); } catch(Exception $e) { return -1; } return $response->TotalAccountsResult; } /** * Returns count of total toons. * @return type int */ public function TotalToons() { if(!$this->connected) return -1; try { $response = $this->accounts->TotalToons(); } catch(Exception $e) { return -1; } return $response->TotalToonsResult; } } ?> register.php <?php /* * Copyright (C) 2011 mooege project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ include "lib/LibMooege.php"; $email=''; $password=''; // See if request contains email & password. if(array_key_exists('email', $_REQUEST)) $email=$_REQUEST['email']; if(array_key_exists('password', $_REQUEST)) $password=$_REQUEST['password']; if(array_key_exists('battleTag', $_REQUEST)) $battleTag=$_REQUEST['battleTag']; if(empty($email) || empty($password)) // if email or password is empty. print_account_form(); // print the login form. else if(empty($battleTag)) print_account_form(); else create_account($email, $password, $battleTag); // try loging using given credentals. function create_account($email, $password, $battleTag) { $mooege=new LibMooege("http://localhost", 9000); // change this line to match your configuration. if(!$mooege->connected) // check if we have a succesfull connection there. die("Can not connect to mooege!"); $exists=$mooege->AccountExists($email); if($exists) die("An account already exists for email address: $email!"); $created=$mooege->CreateAccount($email,$password,$battleTag); if($created) echo "Account created successfully!"; else echo "Error creating account!"; } ?> <? /** * Prints login form. */ function print_account_form() { ?> <div style="width: 300px; border: 1px solid black; padding: 10px;"> mooege login <form method="POST" action="register.php"> E-mail:      <input type="text" name="email" size="16" value=""/><br /> Password: <input type="password" name="password" size="16" /><br /> BattleTag: <input type="text" name="battleTag" size="16" /><br /> <div align="center"> <p><input type="submit" value="Create" /></p> </div> </form> </div> <? } ?> the MYSQL table where it stores email, pass, etc has this structure DROP TABLE IF EXISTS `dbaccount`; CREATE TABLE `dbaccount` ( `Id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `Email` varchar(255) DEFAULT NULL, `Salt` tinyblob, `PasswordVerifier` blob, `BattleTagName` varchar(255) DEFAULT NULL, `HashCode` int(11) DEFAULT NULL, `UserLevel` varchar(255) DEFAULT NULL, `LastOnline` bigint(20) DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; Anyone is kind enough to help me out with a working converted php script from soap to mysql table i've posted? Thanks in advance Quote Link to comment Share on other sites More sharing options...
deviss Posted May 26, 2012 Author Share Posted May 26, 2012 I can't seem to use EDIT button anymore This is the dump of dbaccount table /* Navicat MySQL Data Transfer Source Server : localhost Source Server Version : 50141 Source Host : localhost:3306 Source Database : d3db Target Server Type : MYSQL Target Server Version : 50141 File Encoding : 65001 Date: 2012-05-26 16:38:41 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `dbaccount` -- ---------------------------- DROP TABLE IF EXISTS `dbaccount`; CREATE TABLE `dbaccount` ( `Id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `Email` varchar(255) DEFAULT NULL, `Salt` tinyblob, `PasswordVerifier` blob, `BattleTagName` varchar(255) DEFAULT NULL, `HashCode` int(11) DEFAULT NULL, `UserLevel` varchar(255) DEFAULT NULL, `LastOnline` bigint(20) DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; -- ---------------------------- -- Records of dbaccount -- ---------------------------- INSERT INTO `dbaccount` VALUES ('1', 'test@', 0x7680CD02A285D4171A99BCDF4DBB259D490AB7088E420E100597C85E39EC86F2, 0x27560FA3B2936D90E393029A7BF54DE2AFD08DC52F6E8C4A5BB78B00C278D9A62B28B66E2E71815D108AF043E827CEDC67BBF45E6901C313BB8882D777E99BC7DD53581A9AD22A25BA8EFD19F31A03C23B661F64FCDE3A75577AD5A9DF76D6FD026CB26677382054EB50D203DC690B775D6D8EA005537702205FF1619947022B, 'test', '851', 'Admin', '0'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.