Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Updated Web Server v.2


Guest
 Share

Recommended Posts

> i would like to see that we can link this web server with mybb forum software  from what i  saw last time we was not able to do that 
>
> better interface maybe?

Hmm.  Well, I don't want to require anyone to have to have actual PHP installed to use it, but I could definitely build a nice forum system into it with live screen updates even if wanted.  I could even go as far as stuff like showing the live game chat in the webpage, and maybe even some kind of live image stream from a specific map or moving camera from the game itself–so many possibilities with this so don't be afraid to ask for extensive stuff I want to have fun with this ;)  And yes, it needs a big 'ol config section where the owner can manage things a lot easier and in more detail--I totally agree.  

If you absolutely needed to use phpmybb or something else that is already in PHP, you could just run apache 2.2 as your main web server, maybe even wamp or something if on windows, and just setup this extra utility we have here like this:  a rewrite rule in apache.conf to redirect any requests to whatever.myhost.com to the other webserver on a different port.  There is a special way to setup the subdomain in apache to redirect it to a different port and mask it as a sub domain.

The other aspect of this (which is maybe what you meant) is getting phpmybb to use the same usernames/password as this & the game.  I could make a php API on it where you could verify username/passwords via actual PHP (like inside the phpmybb code itself).  Is that what you need or?

And on the last item there about tutorials--when I get a new version ready & available, I can post a youtube video or something on how to set it all up no prob.
Link to comment
Share on other sites

> Hmm.  Well, I don't want to require anyone to have to have actual PHP installed to use it, but I could definitely build a nice forum system into it with live screen updates even if wanted.  I could even go as far as stuff like showing the live game chat in the webpage, and maybe even some kind of live image stream from a specific map or moving camera from the game itself–so many possibilities with this so don't be afraid to ask for extensive stuff I want to have fun with this ;)  And yes, it needs a big 'ol config section where the owner can manage things a lot easier and in more detail--I totally agree.  
>
>  
>
> If you absolutely needed to use phpmybb or something else that is already in PHP, you could just run apache 2.2 as your main web server, maybe even wamp or something if on windows, and just setup this extra utility we have here like this:  a rewrite rule in apache.conf to redirect any requests to whatever.myhost.com to the other webserver on a different port.  There is a special way to setup the subdomain in apache to redirect it to a different port and mask it as a sub domain.
>
>  
>
> The other aspect of this (which is maybe what you meant) is getting phpmybb to use the same usernames/password as this & the game.  I could make a php API on it where you could verify username/passwords via actual PHP (like inside the phpmybb code itself).  Is that what you need or?

sounds good i also like  live game chat and image stream  idea   :D but there should be option so we can turn off live stream   if server dont have good host
Link to comment
Share on other sites

> The users web browsers think it's php.  What it really is–a vb socket daemon that acts like a web browser.  It's a socket array that listens for connections on port 80 or whatever, then I just have a function that the requested URL gets thrown into along with any post or get variable info, its a big SELECT CASE statement that determines what do to at that point & usually sends something back or the contents of a file, perform tasks, etc.  It's kind of like PHP, but your using VB instead of PHP, directly in the 'web servers' code.  By doing it that way the purpose of the program is hard coded but still able to do more than PHP could, such as working with the account files for EO server.  There is also some sections of code that deal with things like request and output web headers, and a very specific way of dealing with packet splitting to act  as a web server or proxy.  There are also a bunch of "php" in the working directory, these are files that this thing uses, and inside of each is just html, and the program needs these because they are like.. the parts of the web output that the admin can modify--files acting as variables basically.

So basically like this? 

1. Request from PHP script on webbrowser to the game server.
2. Game server gets the request and complies the neccessary stuff.
3. Php script then proccess the stuff and displays it.

Or in other word PHP is connected to VB6? I would love to have a look in the source and learn a lot more.
Link to comment
Share on other sites

> So basically like this? 
>
> 1. Request from PHP script on webbrowser to the game server.
> 2. Game server gets the request and complies the neccessary stuff.
> 3. Php script then proccess the stuff and displays it.
>
> Or in other word PHP is connected to VB6? I would love to have a look in the source and learn a lot more.

Without trying to get too convoluted and explaining my master plan in complete detail just yet for this (lol), basically I decided today to make this thing a full fledged platform & server that will offer some cool things no other web server can do (that I know of).  I definitely got a really good & clean baseline of it going today.  There will be modules you can load into it to do all kinds of cool things.  Basically, there will be one for the EO3.0 server I will maintain to replace what we had for it before.  

You will be able to make modules very easily with VB6 actually.  Once I get this going a bit further with the first modules developed initially & some cool demos & a download of the first release of each of these things, I will post a video or something here.
Link to comment
Share on other sites

> A simple google search and I got lots of examples. Never thought it would be so simple. Thanks anyways.

Sorry, I wasn't trying to get off topic, If you have specific questions about code I can try to help, but there is so much going on here in my project I guess I didn't really understand what you we're asking me about specifically with the 3 questions you posted.  But essentially teh point is you can do anything you want with a VB6 webserver, not just PHP.   :)

Building a webserver in VB6 is not really that hard and there probably are a bunch of good examples out there already, however I had to spend a long time perfecting things on mine in order to get it to work well, like:

- The socket array and the code that handles opening and closing all the connections, AND renewing sockets when they become dead, a timeout system, etc. 

- Sending file contents never really worked great before, I figured why yesterday & fixed all that – it was the size of the chunks where I was pulling that data in before sending it out to that socket

- The packet splitter & understanding what to do with the headers

This will be open source, so you -will- eventually be able to see all of my code to that & the EO engine module for it.  It will be a lot cleaner and make alot more sense to other people, I don't want to confuse you with the messy code in old/beta versions of it (like what was posted here last year) honestly though.

You can also use the php.exe interpreter to process .php files through a custom VB webserver if it's installed if you want.
Link to comment
Share on other sites

> My really big question now is how do you actually decode the HTTP request and send back the data from the request?

Oh.  Well when a browser connects to the web server it sends a request string, looks something like this:

GET /test/ HTTP/1.1
Host: ##.###.##.##
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

So in your winsock array function that reads incoming data, you parse out the line with the word GET or POST in it.. use Mid$ or something to grab what's in between "GET" and "HTTP/1.1"

Then you end up with the requested filename.  If there was any GET or POST variable data (such as form information) on the request it would all be in this request string too.

HOST: line is the domain they contacted your server via, so if I had a domain pointing to this, the web servers domain name would show up under Host: but only if the user called it up that way through their browser.  I called it up by IP is why it shows an IP there.

You can send headers back directly at the very top of the 'blob of text' or 'string' controlling things to like expiry dates, redirection, etc, but most modern browsers don't require a header you can usually get away with just sending the data or contents of file, etc and closing the connection.  As soon as the connection for that item is closed it will appear loaded in the web browser.

You could serv up real files, even parse them certain ones with php.exe, or use 'virtual/fake' files by just setting up a Select Case statement in the 'request handler function' you make.. send back certain things based on request filenames, etc.

If you want to send binary files, simply use the function below in a line like this:

Winsock1(indexnum).SendData  SendFileContents(App.path & "\www\" strRequestFilename, indexnum)

Here is the function:

```
Public Function SendFileContents(ByVal file_name As String, idx As Integer) As String
'experiment with this number throughout this sub for speed adjustments: 4, its in 5 spots
Dim CharNo As Long, Char As String * 4
Dim FileNo As Long, FileSize As Long
Dim Buffer As String

FileNo = FreeFile ' Get next available file number.
Open file_name For Binary Access Read Shared As #FileNo
FileSize = LOF(FileNo) ' Determine how large the file is (in bytes).
Buffer = Space$(FileSize) ' Set our buffer (string) to that length.

' The length of the string (Buffer) determines how many bytes are read...
Get #FileNo, , Buffer ' Grab a chunk of data from the file.
Close #FileNo

' Display the results, either as one big chunk or 256 bytes at a time.
'If TreatAsText Then
' SendData buffer, idx
'Else
For CharNo = 1 To FileSize Step 4
Char = Mid(Buffer, CharNo, 4)
'lngBytesSec = lngBytesSec + 4
'lngBytesTransed = lngBytesTransed + 4
'lngMBSTransed = (lngBytesTransed \ 1024) \ 1024

SendData Char, idx
DoEvents
Next
'End If
End Function

```

Hope that helps.
Link to comment
Share on other sites

```
Private Sub Winsock1_DataArrival(index As Integer, ByVal bytesTotal As Long)
Winsock1(index).GetData strData(index), vbString

If Mid(strData(index), 1, 3) = "GET" Then
strAddress(index) = Mid$(strData(index), InStr(1, strData(index), "GET") + 4, InStr(1, strData(index), "HTTP/") - 6)
strReqType = "[GET]"
ElseIf Mid(strData(index), 1, 4) = "POST" Then
strAddress(index) = Mid$(strData(index), InStr(1, strData(index), "POST") + 5, InStr(1, strData(index), "HTTP/") - 6)
booPostNotGet = True
strReqType = "[post]"
End If

List1.AddItem "(" & index & ")" & strReqType & ": " & strAddress(index)

Select Case Mid$(LCase$(Trim(strAddress(index))), InStr(1, LCase$(Trim(strAddress(index))), "/"))
Case "/"
'list root directory
Case "/fakefile.php"
'send contents of fake file, basically we are listening for fake files or 'aliases' before
'real stuff dealt with in the next Else statement
Case Else
'check if the requested file exists & list file contents if it does.. filename is in strAddress(index)
End Select

Winsock1(index).Close
End Sub

These are only sections of my DataArrival sub just to give you a realy basic version of what it should look like.   You still need parts that deal with reading filenames and sub directories of everything in your www directory based on where you currently browsing in order to have a browsable filesystem feature, etc.

You also need to utilize the GetFileContents sub here however you want too.  

I made this extremely stripped down version of this sub for you just for understanding purposes , I don't know if there are any bugs or typos in it as like I said I pieced it together for you.

[/post]
```
Link to comment
Share on other sites

I have been working on a new file system handling section, new interface, massive code cleanup, and converting all the sections of code in the old EO version into a module you just load into NEWT to get what we had before, then I will enhance it massively with features once I get to that point.

Things like a graphic camera into the EO game, a quest system for EO, etc can be developed & maintained as individual modules for it.  Hoping this works out well I have a good feeling about it though.  The nice part about doing it this way is it keeps things organized, and you could use modules for as many game server solutions as you need in one instance of newt.

Here is what it looks like right now:

![](http://i.imgur.com/9Z6jidq.png)

![](http://imgur.com/DO5UK82.png)
Link to comment
Share on other sites

> I have been working on a new file system handling section, new interface, massive code cleanup, and converting all the sections of code in the old EO version into a module you just load into NEWT to get what we had before, then I will enhance it massively with features once I get to that point.
>
>  
>
> Things like a graphic camera into the EO game, a quest system for EO, etc can be developed & maintained as individual modules for it.  Hoping this works out well I have a good feeling about it though.  The nice part about doing it this way is it keeps things organized, and you could use modules for as many game server solutions as you need in one instance of newt.
>
>  
>
> Here is what it looks like right now:
>
>  
>
> ![](http://i.imgur.com/9Z6jidq.png)
>
>  
>
> ![](http://imgur.com/DO5UK82.png)

looks good :D
Link to comment
Share on other sites

> You can send headers back directly at the very top of the 'blob of text' or 'string' controlling things to like expiry dates, redirection, etc, but most modern browsers don't require a header you can usually get away with just sending the data or contents of file, etc and closing the connection.  As soon as the connection for that item is closed it will appear loaded in the web browser.
>
> You could serv up real files, even parse them certain ones with php.exe, or use 'virtual/fake' files by just setting up a Select Case statement in the 'request handler function' you make.. send back certain things based on request filenames, etc.

So if the webserver is to send data to the browser will the header be identical or will it be the same. 

And the data sent would just be a wall of HTML and stuff or parsed php files right? 

Thanks for the big wall of text. I actually really liked that
Link to comment
Share on other sites

Answer to…

First question.. The header sent back to the browser with the text or file contents is not necessary at all I have found out.  It IS best practice to send a proper one back though before the data though.   Things like the MIME type need to be filled out properly, and the cache expire date etc.   But like I said I have had success on just not sending a header back at all just sending the raw data its expecting  :P

Second question.. Yep.

No problem.  ;)
Link to comment
Share on other sites

> Answer to…
>
>  
>
> First question.. The header sent back to the browser with the text or file contents is not necessary at all I have found out.  It IS best practice to send a proper one back though before the data though.   Things like the MIME type need to be filled out properly, and the cache expire date etc.   But like I said I have had success on just not sending a header back at all just sending the raw data its expecting   :P
>
>  
>
> Second question.. Yep.
>
>  
>
> No problem.   ;)

How do I compile a PHP script from the webserver? I tried just running the php.exe but I have no Idea how to get the output.
Link to comment
Share on other sites

> How do I compile a PHP script from the webserver? I tried just running the php.exe but I have no Idea how to get the output.

Lol, first of all, I am very confused about the Bauer effect going on here today.   What the heck is that about? Lol.  Anyways, You will need to run php.exe using the VB shell function & pass your said php code into the command line as a parameter or pipe it to a file if it is a blob of html/php/whatever.  Then you need to capture the output, probably by piping it into a different file with a random/temp filename and then reading that file by vb when its done.

Another way might be to try this activex I just found:

[http://www.codeproject.com/Articles/10283/PHP-Executed-From-ActiveX ](http://www.codeproject.com/Articles/10283/PHP-Executed-From-ActiveX%C2%A0)
Link to comment
Share on other sites

  • 4 weeks later...
I haven't forgot about you guys, just alot going on right now.  

@abhi2011:  Sorry, I wasn't very clear in answering your last question I just now realized.  ^^

So, in your shell function where your calling php.exe… try something like this:

```

Shell "c:\phppath\php.exe " & strPhpCodeToExecute & " >phpoutput.txt", vbHide
```
It should work.. might need option flags on php.exe too depending on the version and what your trying to do, but this allows you to give some code to convert to html, and the html output contained in a file.  You can then access it by doing just a simple binary or text input section of code, just use something like this to read the php parsed output back into your app (for example):

```

dim ffile as variant, strfinalinput as string, strinpstr1 as string
ffile = FreeFile
Open app.path & "\phpoutput.txt" for input as #ffile
    do while not eof(ffile)
        Input #ffile, , strinpstr1
        strfinalinput = strfinalinput & strinpstr1
    loop
close #ffile

kill app.path & "\phpoutput.txt"
msgbox strfinalinput

```
etc..

You can make that a double >> to append to the output filename, so if your parsing multiple sections of code into one output file, use that but the first blob in the final output needs to obviously be a single > pipe to start it as a blank file.

You could use vbNormalFocus or vbMinimized as your window focus option there too to start with for debugging purposes.

The parts that interest me the most about this, is once you get the mime types all under control and figure out how to send images across… then you realize you can grab complete control of 'animated gif output'   .. basically throw anything you can render up in VB into a control like that or even better movie type streams.. alot to experiment with at this point but.. yeah.  : )   Could be something idk yet for sure..
Link to comment
Share on other sites

> I wouldn't buy this cause it isn't properly advertised for what I would want from something like this. Basically, you need to work on your presentation skills cause no on is going to shell out cash for something which looks shady.

pretty sure the original author is going to make this opensource
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...