Skip to content

Commit

Permalink
Merge pull request #21 from rekmus/nodepp_3_2_0
Browse files Browse the repository at this point in the history
Node++ 3.2
  • Loading branch information
rekmus authored Apr 23, 2024
2 parents 070df5f + edf9c83 commit ea42bba
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/npp.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ typedef char bool;
macros
-------------------------------------------------------------------------- */

#define NPP_VERSION "3.1.0"
#define NPP_VERSION "3.2.0"


#ifndef FALSE
Expand Down Expand Up @@ -1787,6 +1787,9 @@ extern int G_ASYNCId;
extern int G_ASYNCSvcProcesses;
extern int G_ASYNCDefTimeout;
extern int G_callHTTPTimeout;
#ifdef NPP_PHP
extern char G_phpPathWindows[256];
#endif

/* end of config params */

Expand Down
51 changes: 50 additions & 1 deletion lib/npp_eng_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -2994,6 +2994,10 @@ static bool init(int argc, char **argv)

ALWAYS(" callHTTPTimeout = %d", G_callHTTPTimeout);

#ifdef NPP_PHP
ALWAYS(" phpPathWindows = %s", G_phpPathWindows);
#endif

ALWAYS("");
ALWAYS_LINE_LONG;
ALWAYS("");
Expand Down Expand Up @@ -5067,6 +5071,48 @@ static void process_php()

char cmd[4096];

#ifdef _WIN32

STRM_BEGIN(cmd);

if ( NPP_CONN_IS_PAYLOAD(G_connections[G_ci].flags) && G_connections[G_ci].clen > 0 && G_connections[G_ci].clen < 3072 )
{
STRM("echo \"%s\" | ", npp_filter_qs(G_connections[G_ci].in_data));
}

STRM("set REDIRECT_STATUS=CGI ");
STRM("& set SCRIPT_FILENAME=%s/res/%s ", G_appdir, G_connections[G_ci].uri_no_qs);
STRM("& set REQUEST_METHOD=%s ", G_connections[G_ci].method);

#ifdef NPP_PHP_ALL_COOKIES
if ( G_connections[G_ci].in_cookie[0] )
STRM("& set \"HTTP_COOKIE=%s\" ", npp_filter_cookie(G_connections[G_ci].in_cookie));
#else
if ( G_connections[G_ci].php_sessid[0] )
STRM("& set \"HTTP_COOKIE=PHPSESSID=%s\" ", npp_filter_strict(G_connections[G_ci].php_sessid));
#endif

if ( REQ_GET && qs && *(qs+1) != EOS )
{
STRM("& set \"QUERY_STRING=%s\" ", npp_filter_qs(qs+1));
STRM("& set CONTENT_LENGTH=%d ", strlen(qs+1));
STRM("& set CONTENT_TYPE=application/www-form-urlencoded ");
}
else if ( NPP_CONN_IS_PAYLOAD(G_connections[G_ci].flags) && G_connections[G_ci].clen > 0 && G_connections[G_ci].clen < 3072 )
{
STRM("& set CONTENT_LENGTH=%d ", G_connections[G_ci].clen);

if ( G_connections[G_ci].in_ctypestr[0] )
STRM("& set CONTENT_TYPE=%s ", G_connections[G_ci].in_ctypestr);
else
STRM("& set CONTENT_TYPE=application/www-form-urlencoded ");
}

STRM("| %s\\php-cgi", G_phpPathWindows);
STRM_END;

#else /* Linux */

STRM_BEGIN(cmd);

if ( NPP_CONN_IS_PAYLOAD(G_connections[G_ci].flags) && G_connections[G_ci].clen > 0 && G_connections[G_ci].clen < 3072 )
Expand All @@ -5078,10 +5124,11 @@ static void process_php()
STRM("SCRIPT_FILENAME=%s/res/%s ", G_appdir, G_connections[G_ci].uri_no_qs);
STRM("REQUEST_METHOD=%s ", G_connections[G_ci].method);

if ( G_connections[G_ci].in_cookie[0] )
#ifdef NPP_PHP_ALL_COOKIES
if ( G_connections[G_ci].in_cookie[0] )
STRM("HTTP_COOKIE=\"%s\" ", npp_filter_cookie(G_connections[G_ci].in_cookie));
#else
if ( G_connections[G_ci].php_sessid[0] )
STRM("HTTP_COOKIE=\"PHPSESSID=%s\" ", npp_filter_strict(G_connections[G_ci].php_sessid));
#endif

Expand All @@ -5104,6 +5151,8 @@ static void process_php()
STRM("php-cgi");
STRM_END;

#endif /* _WIN32 */

DBG("Executing [%s]...", cmd);

FILE *pipe = popen(cmd, "r");
Expand Down
29 changes: 29 additions & 0 deletions lib/npp_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ char G_call_http_content_type[NPP_MAX_VALUE_LEN+1];
int G_call_http_res_len=0;
int G_qs_len=0;

#ifdef NPP_PHP
char G_phpPathWindows[256]="C:\\php";
#endif


/* locals */

Expand Down Expand Up @@ -10510,6 +10514,10 @@ void npp_lib_read_conf(bool first)
#endif

G_callHTTPTimeout = CALL_HTTP_DEFAULT_TIMEOUT;

#ifdef NPP_PHP
strcpy(G_phpPathWindows, "C:\\php");
#endif
}

/* -------------------------------------------------- */
Expand Down Expand Up @@ -10804,6 +10812,27 @@ void npp_lib_read_conf(bool first)
}
}

/* -------------------------------------------------- */
/* PHP path on Windows */

#ifdef NPP_PHP

if ( first )
{
npp_read_param_str("phpPathWindows", G_phpPathWindows);
}
else /* npp_reload_conf */
{
char tmp_phpPathWindows[256]="";

npp_read_param_str("phpPathWindows", tmp_phpPathWindows);

if ( strcmp(tmp_phpPathWindows, G_phpPathWindows) != 0 )
strcpy(G_phpPathWindows, tmp_phpPathWindows);
}

#endif /* NPP_PHP */

#endif /* NPP_APP */

/* -------------------------------------------------- */
Expand Down

0 comments on commit ea42bba

Please sign in to comment.