GithubHelp home page GithubHelp logo

Comments (11)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
Related topic on the PHP Desktop Forum:

"Interaction between PhpDesktop and .exe (throwing param)"
https://groups.google.com/d/topic/phpdesktop/nNLWpjofqvY/discussion

Original comment by [email protected] on 8 Aug 2013 at 11:49

  • Changed title: Set CGI environment variables through parameters passed to executable file
  • Changed state: Accepted

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
[deleted comment]

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
[deleted comment]

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
It might take me about three weeks to find some spare time, but if no one is on 
this particular issue I can take it.

Original comment by [email protected] on 13 Oct 2013 at 9:42

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
@approachfoundation.org : It might be a good solution if you can take it.
The solution we have choose is to write some parameters in the php.ini file.
But it's not the right way cause the process need to be re-start again when you 
want to use a variable.
So the problem is still alive

Original comment by [email protected] on 14 Oct 2013 at 7:47

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
Referring to http://cesanta.com/docs.html#docs/Options.md I thought this should 
work out. I haven't test this yet aside from grabbing the arguments, as I still 
haven't had much time, but thought I'd post this anyway. If it works for 
anyone, you might want to use the concept but get the value of lpstrCmdLine 
into StartWebServer through another context instead of by passing, or maybe 
just use an overload. 

Basically I just turn WinMain's lpstrCmdLine into an array, similar to argv in 
standard main or wmain, and place them in the string format Mongoose prefers. 
Ideally, you can find a better function than explode to parse CLI arguments, 
this one will not allow spaces in options but should do OK.

This is just a quick run through but it could be used to work up a proper 
version pretty quickly.

-Garet


Line #230 main.cpp:
if (!StartWebServer(lpstrCmdLine)) {

Line #38 web_server.cpp
bool StartWebServer(&LPTSTR WinArgsCLI) {}


Lines #105-#116 web_server.cpp
    const char* options[] = {
        "document_root", wwwDirectory.c_str(),
        "listening_ports", listening_ports.c_str(),
        "index_files", indexFiles.c_str(),
        "cgi_interpreter", cgiInterpreter.c_str(),
        "cgi_pattern", cgiPattern.c_str(),
        "cgi_environment", WinToMongooseArgsCLI(WinArgsCLI),
        NULL
    };
    mg_callbacks callbacks = {0};
    callbacks.log_message = &log_message;
    callbacks.end_request = &end_request;
    g_mongooseContext = mg_start(&callbacks, NULL, options);

.
.
.




Added functions for web_server.php:

string WinToMongooseArgsCLI(LPTSTR lpstrCmdLine)
{
    string MongooseArgsCLI = "";
    vector<string> WinArgsCLI=explode( lpstrCmdLine," ");
    for(unsigned int i=1,L=WorkWith.size();i<L;i+=2 ){        Mongoose_CLI_KeyValueList = Mongoose_CLI_KeyValueList + WorkWith[i-1] +"="+ WorkWith[i] + ((i>=L-2)?"":",");    }

    return MongooseArgsCLI;
}

vector<string> explode (const string &str, const string &delimiter)
{
    vector<string> arr;

    int strleng = str.length();
    int delleng = delimiter.length();
    if (delleng==0)
        return arr;//no change

    int i=0;
    int k=0;
    while( i<strleng ){
        int j=0;
        while (i+j<strleng && j<delleng && str[i+j]==delimiter[j])
            j++;
        if (j==delleng){    //found delimiter
            arr.push_back(  str.substr(k, i-k) );
            i+=delleng;
            k=i;
        }
        else{
            i++;
        }
    }
    arr.push_back(  str.substr(k, i-k) );
    return arr;
}

Original comment by [email protected] on 18 Oct 2013 at 6:30

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
I have successfully set the "cgi_environment" option in Mongoose to set the 
TMP, TEMP and TEMPDIR environment variables. See revision 89f4820f0bf1.

Original comment by [email protected] on 22 Jan 2014 at 4:05

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
CGI environment variables can now be passed to the phpdesktop executables.

See revision 07c81718f5a5.

See the CGIEnvironmentFromArgs wiki page:
https://code.google.com/p/phpdesktop/wiki/CGIEnvironmentFromArgs

Original comment by [email protected] on 22 Jan 2014 at 10:57

  • Changed state: Fixed

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
Revision 8091beb8d108 fixes problems with port conflicts. A random port is now 
assigned when port is set to 0. The CGI environment variables did not work when 
both instances of application where listening on the same port. Now with random 
port support this issue is solved.

Original comment by [email protected] on 25 Jan 2014 at 3:49

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
Chrome 31.4 and MSIE 1.12 released.

Original comment by [email protected] on 26 Jan 2014 at 1:24

from phpdesktop.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 27, 2024
Project will move to Github. Find this issue at the new address (soon): 
https://github.com/cztomczak/phpdesktop/issues/43

Original comment by [email protected] on 24 Aug 2015 at 3:20

from phpdesktop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.