Serving-PHP - WeOnlyDo Software example code



All

wodCrypt (12)
wodSSH (10)
wodSFTP (23)
wodSSHServer (1)
wodSSHTunnel (11)
wodSSHpackage
wodSFTPdll

wodSSH.NET (10)
wodSFTP.NET (24)
wodFtpDLX.NET (22)
wodWebServer.NET (10)

wodAppUpdate (13)
wodHttpDLX (8)
wodFtpDLX (22)
wodTelnetDLX
wodFTPServer (3)
wodWebServer (10)
wodVPN
wodXMPP (13)
All ** [Visual Basic] ** [C#] ** [VB.NET] **

Serving PHP Pages
VB code
Option Explicit
Dim WithEvents Http1 As wodWebServerCom

Private Sub Form_Load()
    Set Http1 = New wodWebServerCom
    
    On Error Resume Next
    Http1.Port = 80
    
    ' Let's start the server
    Http1.Start
    If Err Then
        MsgBox "There was an error: " & Err.Description, vbOKOnly, "Error"
    End If
End Sub

' CGIStart event is triggered when CGI Application is actually started
Private Sub Http1_CGIStart(ByVal User As WODWEBSERVERCOMLib.IWebUser, ByVal FullPath As String, ByVal Environment As WODWEBSERVERCOMLib.IWebHeaders)
    Environment.Add "REDIRECT_STATUS", "200"
    Debug.Print Environment.ToString
End Sub

' Let's call the CGI application
Private Sub Http1_RequestDone(ByVal User As WODWEBSERVERCOMLib.IWebUser)
    Dim docPath As String
    docPath = """" & App.Path & "\" & User.Request.PageName & """"
    User.Response.CGIExecute "C:\php\php.exe " & docPath
    User.Response.StatusCode = 200
End Sub
VB.Net code
Option Explicit
Dim WithEvents Http1 As WODWEBSERVERCOMLib.wodWebServerCom

Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
    Http1 = New WODWEBSERVERCOMLib.wodWebServerCom

    On Error Resume Next
    Http1.Port = 80

    ' Let's start the server
    Http1.Start()
    If Err.Number Then
        MsgBox("There was an error: " & Err.Description, MsgBoxStyle.OkOnly, "Error")
    End If
End Sub

' CGIStart event is triggered when CGI Application is actually started
Private Sub Http1_CGIStart(ByVal User As WODWEBSERVERCOMLib.IWebUser, ByVal FullPath As String, ByVal Environment As WODWEBSERVERCOMLib.IWebHeaders)
    Environment.Add("REDIRECT_STATUS", "200")
    Debug.Print(Environment.ToString)
End Sub

' Let's call the CGI application
Private Sub Http1_RequestDone(ByVal User As WODWEBSERVERCOMLib.IWebUser)
    Dim docPath As String
    docPath = """" & My.Application.Info.DirectoryPath & "\" & User.Request.PageName & """"
    User.Response.CGIExecute("C:\php\php.exe " & docPath)
    User.Response.StatusCode = 200
End Sub
C# code
private WODWEBSERVERCOMLib.wodWebServerCom Http1;
private void Form1_Load(object sender, EventArgs e)
{
    Http1 = new WODWEBSERVERCOMLib.wodWebServerCom();

    Http1.RequestDone += new WODWEBSERVERCOMLib._IwodWebServerComEvents_RequestDoneEventHandler(Http1_RequestDone);
    Http1.CGIStart += new WODWEBSERVERCOMLib._IwodWebServerComEvents_CGIStartEventHandler(Http1_CGIStart);

    Http1.Port = 80;

    // Let's start the server
    try
    {
        Http1.Start();
    }
    catch (System.Exception ex)
    {
        MessageBox.Show("There was an error: " + ex.Message);
    }
}

// CGIStart event is triggered when CGI Application is actually started
void Http1_CGIStart(WODWEBSERVERCOMLib.WebUser User, string FullPath, WODWEBSERVERCOMLib.WebHeaders Environment)
{
    Environment.Add("REDIRECT_STATUS", "200");
    Console.Write(Environment.ToString());
}

// Let's call the CGI application
void Http1_RequestDone(WODWEBSERVERCOMLib.WebUser User)
{
    String docPath;
    docPath = Application.StartupPath + "\\" + User.Request.PageName;
    User.Response.CGIExecute("C:\\php\\php.exe \"" + docPath + "\"", null, null);
    User.Response.StatusCode = WODWEBSERVERCOMLib.StatusCodes.OK;
}