NOTA: Si necesitas ayuda en español contactáme. And sorry if my english is too bad.
Skype: yaeldd
- FOR ADMINS: I consider this like a release because i fully made this code and i'm adding files with that code to this thread, if you think is wrong section and title please change it to the correct.
- All the links to other threads/documents/sites i will post here, are made by their respective writers, i'm not taking credit for they work, i'm just linking to the info i think its needed to understand how this release/tutorial work.
- You need to have a working PHP version.
- This SQL connections work with ODBC tunneling, you should not to worry if you have the correct PHP version or SQLSRV extension for it, but you should to enable the ODBC into your PHP installation/instance, you should to search for info if you want to know more about this, for enabling extensions tutorial CLICK HERE
This is my first release/tutorial, please be sweet with your criticisms.
I've read a lot of explanations about how the OdinRestServer work and all those says, and in fact, the port for having it working should be the "80" port, due to this port is the WEB server port, you could wish to have both working, Rest Server and Web Server, you could simply change the port where your Web Server is listening the incoming connections but the users who visit your web should to write in the URL the port you are using, example: http://myurl.com:8080
And that is what you won't to do anymore, right?
Well i found a solution for this, i should to specify this substitute only has been tested for working with the client login successfully, at the moment the client ask to the web server if the received token is valid or not, you could find more info about how the full login (with full i mean to from launcher to client) system work here:
Original info posted by @NextIdea on this thread: NextIdea commnet saying the info...
Thread made by bruna157
The request to the Rest Server from Login Server is something like this:
/user/v1/getInfo?realm=fiesta&token=Jaeru&sig=510ca3d4b2ac0e05cbe9dec0aa0c1e8061d4dfdcdedd630c6a3813e9bb8e00cc
Remember that when you set up your Server there is one step where you should to edit your "hosts" file (Windows System file you can find in: X:\Windows\System32\drivers\etc directory, where "X" mean you Local Hard Drive/Local Disk), this step say that you should to add a line with the "stubedore.t" domain redirecting it to your server IP, example:
127.0.0.1 stubedore.t
This was a step really required for the Login Server not for Rest Server (due to that is the Login Server "who ask" for that URL), then, the full URL to get the answer is:
stubedore.t/user/v1/getInfo?realm=fiesta&token=Jaeru&sig=510ca3d4b2ac0e05cbe9dec0aa0c1e8061d4dfdcdedd630c6a3813e9bb8e00cc
Or in other words (adding the web "http" protocol):
http://stubedore.t/user/v1/getInfo?r...3813e9bb8e00cc
And the expected answer from it is something like this:
{"token_age":0,"user_id":1,"login":"Jaeru","user_role":"user","blocked":false}
We will make a "script" that will allow your normal Web Server to do that, but like you can see in the request, the Login Server ask for a certain URL:
http://stubedore.t/user/v1/getInfo?realm=fiesta&token=Jaeru&sig=510ca3d4b2ac0e05cbe9dec0aa0c1e8061d4dfdcdedd630c6a3813e9bb8e00cc
If you already added the line to the "hosts" file you can continue.
- Then the first step is creating that URL in our web server, this step will depend of where your Web Root documents are saved in your Hard Disk, example:
C:\WebDocsDir\user\v1\
And there you should to create a file without extension with the name "getInfo"
Maybe you are asking yourself: "And how the hell will be read this file without extension?", what make us go to the next step.- If in your Web Root directory you already have a file named ".htaccess" then you just open that file and add this lines:
*If you don't have any file with that name you will notice you can't simply make a new one due to the OS limitations, in this case you can download files that are in the link provided at the end of this release/tutorial or in the attached files.Code:<FilesMatch "^[^\.]+$"> ForceType application/x-httpd-php </FilesMatch>
This will force your IIS/Apache/WebServer to read all the documents without extension like PHP Files.- Now that you added those lines, you should to go to the "getInfo" info file and edit it with any Text Editor (I recommend to use Notepad++, its Freeee!!, use Google to get it). In that file you will add the next lines of code and replace corresponding data by your own:
NAME\SQLINSTANCE: You will replace this with your computer and SQL instance data, by example: JAERU-PC\SQLEXPRESS
DBUsername: Replace this with your SQL username, by example: sa
DBPassword: Replace this with your SQL password, by example: 123456
PHP Code:<?PHP
$conexion_acc = "DRIVER={SQL Server};SERVER=NAME\SQLINSTANCE;DATABASE=OdinAccounts";
$con_user = "DBUsername";
$con_pass = "DBPassword";
/* ### Establish an ODBC connection with the DataBase or show a message in case of error ### */
$conexion_rest = ODBC_CONNECT( $conexion_acc, $con_user, $con_pass ) OR DIE ('Error trying to connect to the database.');
IF(ISSET($_GET['realm']) AND ISSET($_GET['token']) AND ISSET($_GET['sig'])) {
$Realm = $_GET['realm'];
$Token = $_GET['token'];
$Sig = $_GET['sig'];
/* ### Returning the answer ### */
$query_lft = "SELECT tAccounts.nEMID, tAccounts.sUsername FROM tAccounts, tTokens WHERE tAccounts.nEMID = tTokens.nEMID AND tTokens.sToken = '$Token'";
$query_lft_exec = ODBC_EXEC($conexion_rest, $query_lft);
IF(ODBC_NUM_ROWS($query_lft_exec) != 1) {
ECHO 'NoToken: '.$Token;
}
ELSE {
$Result = ODBC_FETCH_ARRAY($query_lft_exec);
ECHO '{"token_age":0,"user_id":'.$Result['nEMID'].',"login":"'.$Result['sUsername'].'","user_role":"user","blocked":false}';
}
}
ELSE {
ECHO 'NO DATA FOUND!<BR />All or some of the required data was not received correctly or is undefined.';
}
/* ### Closing ODBC connection ### */
ODBC_CLOSE($conexion_rest);
?>
And that's all!!!
Try to connect to your server using your login like normally you do (.BAT file or Launcher) with the RestServer stopped and you will see that this works.
Please if you like this Release/Tutorial Support us on facebook: Aeolus Network Facebook Page
Special thanks to Tronic due to was him who give me the idea to make this, he doesn't helped me to code it, he just gave me the idea, maybe i don't like him anymore because he deleted to me from Skype contact but i have not rancor against him.
Thank you for reading.
DOWNLOAD FILES: MEGA - Replace your OdinRestServer!
- - EDITED - -
Well the next file, is fully released by: @Gruntilda (I'm just posting the info).... this make me look like dumbass but i think is the main reason of this release....
- - EDITED - -
After a lot of negative comments about the security and functions issues in my code i had a new idea and then i said "LET'S TRY".....
I discovered you could use OdinRestServer in other port, this will help you a lot because you are not making "security" issues and this way you avoid the "free access to the databases" in the first script I post, and this way, you will have too working your "Premium Inventory"...
to get this working, do the same steps than before, but in step 3 replace that code by this one:
Where (stubedore.t:8080) 8080 is the new port where you are running your rest server, and do the same for the requested URL for the itemPurchases and all those things, maybe you are asking yoursefl: "How the f***k will i have that URL?" (rhetoric question for noobs - including meCode:<?PHP IF(ISSET($_GET['realm']) AND ISSET($_GET['token']) AND ISSET($_GET['sig'])) { $Realm = $_GET['realm']; $Token = $_GET['token']; $Sig = $_GET['sig']; ECHO '<META http-equiv="refresh" content="0;URL=stubedore.t:8080/user/v1/getInfo?realm='.$Realm.'&token='.$Token.'&sig='.$Sig.'">'; } ELSE { ECHO 'NO DATA FOUND!<BR />All or some of the required data was not received correctly or is undefined.'; } ?>-)
Well you can get it from the LogFile ("Requests.txt") from RestServer folder (if you have questions add me on the skype given at top of this thread), Or for advanced users, you can download the release that @Gruntilda made... look for the "RestClient.cs" class into the project (OdinRestServer source) and there are all the possible requests that the RestServer could Receive, made the "URL" for each one and replace the code by the requested, EXAMPLE:
URLs AND PARAMETERS:
FOR TOKEN VERIFICATION:
Request Example: GET /user/v1/getInfo?realm=fiesta&token=Jaeru&sig=510ca3d4b2ac0e05cbe9dec0aa0c1e8061d4dfdcdedd630c6a3813e9bb8e00cc HTTP/1.1
DATA: /user/v1/getInfo - And parameters: realm, token and sig.
FOR PREMIUM INVENTORY REVIEW:
Request Example: GET /store/v1/getPurchasedItems?realm=fiesta&outsparkID=2&sig=0eb36846bef4fc313893c9d8717c46b91ba385961601296d2fd9255969aa9a0a HTTP/1.1
DATA: /store/v1/getPurchasedItems - And parameters: realm, outsparkID and sig... ETC, ETC.... you will check all the URLs and create the corresponding folders on your Web Server:
Examples:
For tokens: C:\WebServerRoot\user\v1\getInfo.php
For premium inventory: C:\WebServerRoot\store\v1\getPurchasedItems.php
For now this is just working for token, bu i will found a way to make it to with the other 2 URL!!
And on each one you will recover the correct parameters (realm, fiesta, outsparkID, etc) and send it to the new port of your rest server like the new example... and all its done ;)
Have fun and remember support us on Facebook: Aeolus Network Facebook Page and like the thread.... have great developing!!....




-)
Reply With Quote![[Release]USE YOUR RestServer in Other Port!!!](http://ragezone.com/hyper728.png)

