|
@@ -165,7 +165,6 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t er
|
|
{
|
|
{
|
|
char *data;
|
|
char *data;
|
|
struct http_state *hs;
|
|
struct http_state *hs;
|
|
- struct fs_file file = {0, 0};
|
|
|
|
char buf[150];
|
|
char buf[150];
|
|
|
|
|
|
hs = arg;
|
|
hs = arg;
|
|
@@ -487,7 +486,6 @@ static int fs_open(char *name, struct fs_file *file)
|
|
*/
|
|
*/
|
|
void HTTP_Init()
|
|
void HTTP_Init()
|
|
{
|
|
{
|
|
-
|
|
|
|
struct tcp_pcb *pcb;
|
|
struct tcp_pcb *pcb;
|
|
|
|
|
|
pcb = tcp_new();
|
|
pcb = tcp_new();
|
|
@@ -555,9 +553,8 @@ int HTTP_InfoPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBuf
|
|
|
|
|
|
int HTTP_HistoryPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut)
|
|
int HTTP_HistoryPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut)
|
|
{
|
|
{
|
|
- uint8_t i, valueLen = 0;
|
|
|
|
|
|
+ uint8_t valueLen = 0;
|
|
char value[20];
|
|
char value[20];
|
|
- uint32_t nbytes = 0;
|
|
|
|
|
|
|
|
(void)lenBufIn;
|
|
(void)lenBufIn;
|
|
|
|
|
|
@@ -609,9 +606,8 @@ int HTTP_HistoryPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *len
|
|
|
|
|
|
int HTTP_UpsHistoryPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut)
|
|
int HTTP_UpsHistoryPage(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut)
|
|
{
|
|
{
|
|
- uint8_t i, valueLen = 0;
|
|
|
|
|
|
+ uint8_t valueLen = 0;
|
|
char value[20];
|
|
char value[20];
|
|
- uint32_t nbytes = 0;
|
|
|
|
|
|
|
|
(void)lenBufIn;
|
|
(void)lenBufIn;
|
|
|
|
|
|
@@ -1005,13 +1001,6 @@ void HTTP_UPSshutdown(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *le
|
|
*/
|
|
*/
|
|
void HTTP_ConfirmBootPwd(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut)
|
|
void HTTP_ConfirmBootPwd(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut)
|
|
{
|
|
{
|
|
- char tempStr[50];
|
|
|
|
- strncpy(tempStr, bufIn, 50);
|
|
|
|
- char value[20];
|
|
|
|
- uint8_t valueLen;
|
|
|
|
-
|
|
|
|
- memset(value, 0, 20);
|
|
|
|
-
|
|
|
|
/* Запускаем задачу отложенной перезагрузки. Контроллер должен успеть
|
|
/* Запускаем задачу отложенной перезагрузки. Контроллер должен успеть
|
|
отправить ответ серверу о статусе пароля */
|
|
отправить ответ серверу о статусе пароля */
|
|
HTTP_StartResetTask(true);
|
|
HTTP_StartResetTask(true);
|
|
@@ -1032,7 +1021,7 @@ int HTTP_ConfirmWebPwd(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *l
|
|
char tempStr[50];
|
|
char tempStr[50];
|
|
char login[20];
|
|
char login[20];
|
|
char password[20];
|
|
char password[20];
|
|
- uint8_t valueLen, user_id;
|
|
|
|
|
|
+ uint8_t valueLen, user_id = 0xff;
|
|
char *strPtr = 0;
|
|
char *strPtr = 0;
|
|
char WebPassword[MAX_WEB_PASSWD_LEN];
|
|
char WebPassword[MAX_WEB_PASSWD_LEN];
|
|
char WebLogin[MAX_WEB_LOGIN_LEN];
|
|
char WebLogin[MAX_WEB_LOGIN_LEN];
|
|
@@ -1261,6 +1250,7 @@ uint8_t GetCookieValue(char *inStr, char *paramName, char *paramValue, uint8_t *
|
|
{
|
|
{
|
|
char *beginValue = 0;
|
|
char *beginValue = 0;
|
|
char *endValue = 0;
|
|
char *endValue = 0;
|
|
|
|
+ char *endValueTemp = 0;
|
|
int len = 0;
|
|
int len = 0;
|
|
char *strPtr = 0;
|
|
char *strPtr = 0;
|
|
|
|
|
|
@@ -1270,6 +1260,9 @@ uint8_t GetCookieValue(char *inStr, char *paramName, char *paramValue, uint8_t *
|
|
{
|
|
{
|
|
beginValue = strpbrk(strPtr,"=");
|
|
beginValue = strpbrk(strPtr,"=");
|
|
endValue = strpbrk(strPtr,";");
|
|
endValue = strpbrk(strPtr,";");
|
|
|
|
+ endValueTemp = strpbrk(strPtr,"\r");
|
|
|
|
+ if(endValueTemp != 0 && endValueTemp < endValue)
|
|
|
|
+ endValue = endValueTemp;
|
|
if (endValue == 0)
|
|
if (endValue == 0)
|
|
endValue = strpbrk(strPtr,"\n");
|
|
endValue = strpbrk(strPtr,"\n");
|
|
len = endValue - beginValue - 1;
|
|
len = endValue - beginValue - 1;
|
|
@@ -1543,18 +1536,11 @@ struct fs_file file = {0, 0};
|
|
//
|
|
//
|
|
void Cockie(void)
|
|
void Cockie(void)
|
|
{
|
|
{
|
|
- char* endPtr;
|
|
|
|
- uint32_t len;
|
|
|
|
receiveBuf[receivedBufLen] = '\0';
|
|
receiveBuf[receivedBufLen] = '\0';
|
|
//printf("receive %s \r\n", receiveBuf);
|
|
//printf("receive %s \r\n", receiveBuf);
|
|
// Get cookie "uname" value
|
|
// Get cookie "uname" value
|
|
memset(CookieBuf, 0, sizeof(CookieBuf));
|
|
memset(CookieBuf, 0, sizeof(CookieBuf));
|
|
CookiePtr = strstr(receiveBuf, "uname=");
|
|
CookiePtr = strstr(receiveBuf, "uname=");
|
|
- endPtr = strstr(CookiePtr, "\r");
|
|
|
|
- len = (endPtr - CookiePtr)+2;
|
|
|
|
- if(len < 50)
|
|
|
|
- strncpy(CookieBuf, CookiePtr,len);
|
|
|
|
- else
|
|
|
|
strncpy(CookieBuf, CookiePtr, 50);
|
|
strncpy(CookieBuf, CookiePtr, 50);
|
|
|
|
|
|
//printf("********CookieBuf1= %s\r\n", CookieBuf);
|
|
//printf("********CookieBuf1= %s\r\n", CookieBuf);
|
|
@@ -1566,10 +1552,7 @@ void Cockie(void)
|
|
memset(CookieBuf, 0, sizeof(CookieBuf));
|
|
memset(CookieBuf, 0, sizeof(CookieBuf));
|
|
// Get cookie "id" value
|
|
// Get cookie "id" value
|
|
CookiePtr = strstr(receiveBuf, " id=");
|
|
CookiePtr = strstr(receiveBuf, " id=");
|
|
- if(len < 50)
|
|
|
|
- strncpy(CookieBuf, CookiePtr,len);
|
|
|
|
- else
|
|
|
|
- strncpy(CookieBuf, CookiePtr, 50);
|
|
|
|
|
|
+ strncpy(CookieBuf, CookiePtr, 50);
|
|
|
|
|
|
//printf("********CookieBuf1= %s\r\n", CookieBuf);
|
|
//printf("********CookieBuf1= %s\r\n", CookieBuf);
|
|
memset(id, 0, MAX_WEB_COOKIE_LEN);
|
|
memset(id, 0, MAX_WEB_COOKIE_LEN);
|
|
@@ -1997,69 +1980,7 @@ char* AuthenticatedTrueRoutine(uint16_t* sendLen)
|
|
char *DataOffset;
|
|
char *DataOffset;
|
|
char *ptr;
|
|
char *ptr;
|
|
|
|
|
|
- /* if (strncmp(receiveBuf, "GET /main.css", 13) == 0) // +
|
|
|
|
- {
|
|
|
|
- fs_open("/main.css", &file);
|
|
|
|
- *sendLen = file.len;
|
|
|
|
- return file.data;
|
|
|
|
- }
|
|
|
|
- else if (strncmp(receiveBuf, "GET /rotek.png", 14) == 0) // +
|
|
|
|
- {
|
|
|
|
- fs_open("/rotek.png", &file);
|
|
|
|
- *sendLen = file.len;
|
|
|
|
- return file.data;
|
|
|
|
- }
|
|
|
|
- else if (strncmp(receiveBuf, "GET /favicon.ico", 16) == 0) // ?
|
|
|
|
- {
|
|
|
|
- fs_open("/favicon.ico", &file);
|
|
|
|
- *sendLen = file.len;
|
|
|
|
- return file.data;
|
|
|
|
- }
|
|
|
|
- else if (strncmp(receiveBuf, "GET /main.js", 12) == 0) // +
|
|
|
|
- {
|
|
|
|
- fs_open("/main.js", &file);
|
|
|
|
- *sendLen = file.len;
|
|
|
|
- return file.data;
|
|
|
|
- }
|
|
|
|
- else if (strncmp(receiveBuf, "GET /role.js", 12) == 0)
|
|
|
|
- {
|
|
|
|
- fs_open("/role.js", &file);
|
|
|
|
- *sendLen = file.len;
|
|
|
|
- return file.data;
|
|
|
|
- }
|
|
|
|
- else if (strncmp(receiveBuf, "GET /settings.html", 18) == 0) // +
|
|
|
|
- {
|
|
|
|
- HTTP_UpdateUserLoginTime(user_id);
|
|
|
|
- if (seclevel == 0)
|
|
|
|
- fs_open("/settings.html", &file);
|
|
|
|
- else
|
|
|
|
- fs_open("/index.html", &file);
|
|
|
|
-
|
|
|
|
- *sendLen = file.len;
|
|
|
|
- return file.data;
|
|
|
|
- }
|
|
|
|
- else if (strncmp(receiveBuf, "GET /info.html", 14) == 0) // +
|
|
|
|
- {
|
|
|
|
- HTTP_UpdateUserLoginTime(user_id);
|
|
|
|
- fs_open("/info.html", &file);
|
|
|
|
- *sendLen = file.len;
|
|
|
|
- return file.data;
|
|
|
|
- }
|
|
|
|
- else if (strncmp(receiveBuf, "GET /history.html", 17) == 0)
|
|
|
|
- {
|
|
|
|
- HTTP_UpdateUserLoginTime(user_id);
|
|
|
|
- fs_open("/history.html", &file);
|
|
|
|
- *sendLen = file.len;
|
|
|
|
- return file.data;
|
|
|
|
- }
|
|
|
|
- else if (strncmp(receiveBuf, "GET /ups_history.html", 21) == 0)
|
|
|
|
- {
|
|
|
|
- HTTP_UpdateUserLoginTime(user_id);
|
|
|
|
- fs_open("/ups_history.html", &file);
|
|
|
|
- *sendLen = file.len;
|
|
|
|
- return file.data;
|
|
|
|
- }
|
|
|
|
- else*/ if (strncmp(receiveBuf, "GET /getJson.cgi", 16) == 0) // +
|
|
|
|
|
|
+ if (strncmp(receiveBuf, "GET /getJson.cgi", 16) == 0) // +
|
|
{
|
|
{
|
|
HTTP_GetParamsPage1(sendBuf);
|
|
HTTP_GetParamsPage1(sendBuf);
|
|
*sendLen = strlen(sendBuf);
|
|
*sendLen = strlen(sendBuf);
|
|
@@ -2563,14 +2484,8 @@ char* send_file(char *filename, char *pnonmatch, struct fs_file *file, uint16_t
|
|
DBG printf(sendBuf);
|
|
DBG printf(sendBuf);
|
|
*Len = strlen(sendBuf);
|
|
*Len = strlen(sendBuf);
|
|
return sendBuf;
|
|
return sendBuf;
|
|
- //hs->file = sendBuf;
|
|
|
|
- //hs->left = strlen(sendBuf);
|
|
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- /* Send file */
|
|
|
|
- //DBG printf("%s\r\n\r\n", filename);
|
|
|
|
- //hs->file = file->data;
|
|
|
|
- //hs->left = file->len;
|
|
|
|
*Len = file->len;
|
|
*Len = file->len;
|
|
return file->data;
|
|
return file->data;
|
|
}
|
|
}
|
|
@@ -2654,7 +2569,6 @@ bool GetFileName(char *inStr, char *fileName, uint8_t *fileNameLen)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|