bug fixes
This commit is contained in:
@@ -145,7 +145,7 @@ int handlePOSTRequest(int socket, struct HTTPRequest *r, SSL *ssl) {
|
||||
}
|
||||
|
||||
if (r->requestConType != NULL) {
|
||||
if (!strcmp(r->requestConType, "application/x-www-form-utlencoded") == 0) {
|
||||
if (!(strcmp(r->requestConType, "application/x-www-form-utlencoded") == 0)) {
|
||||
printDebug("Application From Selected");
|
||||
} else {
|
||||
printDebug("Content will likely get parsed wrong");
|
||||
|
||||
21
src/utils.c
21
src/utils.c
@@ -24,7 +24,7 @@ int PrintLog(unsigned char *message) {
|
||||
|
||||
if (!strcmp(WEB_ROOT_DIR, "/var/www/html/")) {
|
||||
FILE *fp;
|
||||
fp = fopen("/var/log/seaweb/log", "w");
|
||||
fp = fopen("/var/log/seaweb/log", "a");
|
||||
fprintf(fp, "[Log] %02d/%02d/%d %02d:%02d:%02d - %s\n", (now->tm_mon + 1), now->tm_mday,
|
||||
(now->tm_year + 1900), now->tm_hour, now->tm_min, now->tm_sec, message);
|
||||
fclose(fp);
|
||||
@@ -81,7 +81,11 @@ char *php_cgi(char *sPath, struct HTTPRequest *r) {
|
||||
putenv(conLenString);
|
||||
putenv("CONTENT_TYPE=application/x-www-form-urlencoded");
|
||||
queryString = malloc(r->requestBodyLen + 24);
|
||||
sprintf(queryString, "QUERY_STRING=%s", r->requestBody);
|
||||
if (r->requestBodyLen != 0) {
|
||||
sprintf(queryString, "QUERY_STRING=%s", r->requestBody);
|
||||
} else {
|
||||
sprintf(queryString, "QUERY_STRING=");
|
||||
}
|
||||
putenv(queryString);
|
||||
|
||||
// Starting fork to pipe stdin into php-cgi
|
||||
@@ -99,15 +103,20 @@ char *php_cgi(char *sPath, struct HTTPRequest *r) {
|
||||
} else if (pid < 0) { // Error forking
|
||||
printDebug("Error in stdin php frok");
|
||||
} else { // Parent fork
|
||||
close(phpPipe[1]);
|
||||
close(phpPipe2[1]);
|
||||
dup2(phpPipe2[0], STDIN_FILENO);
|
||||
execl("/usr/bin/php-cgi", "php-cgi", NULL);
|
||||
}
|
||||
} else {
|
||||
queryString = malloc(strlen(r->requestVars) + 24);
|
||||
sprintf(queryString, "QUERY_STRING=%s", r->requestVars);
|
||||
putenv(queryString);
|
||||
putenv("REQUEST_METHOD=GET");
|
||||
if (r->requestVars != NULL) {
|
||||
queryString = malloc(strlen(r->requestVars) + 24);
|
||||
sprintf(queryString, "QUERY_STRING=%s", r->requestVars);
|
||||
} else {
|
||||
queryString = malloc(24);
|
||||
sprintf(queryString, "QUERY_STRING=");
|
||||
}
|
||||
putenv(queryString);
|
||||
execl("/usr/bin/php-cgi", "php-cgi", NULL);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
Reference in New Issue
Block a user