h the folder "protect", then require auth if(memcmppgm2ram(cFile, (ROM void*)"protect", 7) == 0) return 0x00; // Authentication will be needed later // If the filename begins with the folder "snmp", then require auth if(memcmppgm2ram(cFile, (ROM void*)"snmp", 4) == 0) return 0x00; // Authentication will be needed later #if defined(HTTP_MPFS_UPLOAD_REQUIRES_AUTH) if(memcmppgm2ram(cFile, (ROM void*)"mpfsupload", 10) == 0) return 0x00; #endif // You can match additional strings here to password protect other files. // You could switch this and exclude files from authentication. // You could also always return 0x00 to require auth for all files. // You can return different values (0x00 to 0x79) to track "realms" for below. return 0x80; // No authentication required } #endif /***************************************************************************** Function: BYTE HTTPCheckAuth(BYTE* cUser, BYTE* cPass) Internal: See documentation in the TCP/IP Stack API or HTTP2.h for details. ***************************************************************************/ #if defined(HTTP_USE_AUTHENTICATION) BYTE HTTPCheckAuth(BYTE* cUser, BYTE* cPass) { if(strcmppgm2ram((char *)cUser,(ROM char *)"admin") == 0 && strcmppgm2ram((char *)cPass, (ROM char *)"microchip") == 0) return 0x80; // We accept this combination // You can add additional user/pass combos here. // If you return specific "realm" values above, you can base this // decision on what specific file or folder is being accessed. // You could return different values (0x80 to 0xff) to indicate // various users or groups, and base future processing decisions // in HTTPExecuteGet/Post or HTTPPrint callbacks on this value. return 0x00; // Provided user/pass is invalid } #endif /**************************************************************************** Section: GET Form Handlers ***************************************************************************/ /***************************************************************************** Function: HTTP_IO_RESULT HTTPExecuteGet(void) Internal: See documentation in the TCP/IP Stack API or HTTP2.h for details. ***************************************************************************/ HTTP_IO_RESULT HTTPExecuteGet(void) { BYTE *ptr; BYTE filename[20]; char buf [10]; // Defaultwert setzen StartZeit = 1262304000; // Load the file name // Make sure BYTE filename[] above is large enough for your longest name MPFSGetFilename(curHTTP.file, filename, 20); // Penis // If its the forms.htm page if(!memcmppgm2ram(filename, "forms.htm", 9)) { // Seek out each of the four LED strings, and if it exists set the LED states ptr = HTTPGetROMArg(curHTTP.data, (ROM BYTE *)"led4"); if(ptr) LED4_IO = (*ptr == '1'); ptr = HTTPGetROMArg(curHTTP.data, (ROM BYTE *)"led3"); if(ptr) LED3_IO = (*ptr == '1'); ptr = HTTPGetROMArg(curHTTP.data, (ROM BYTE *)"led2"); if(ptr) LED2_IO = (*ptr == '1'); ptr = HTTPGetROMArg(curHTTP.data, (ROM BYTE *)"led1"); if(ptr) LED1_IO = (*ptr == '1'); } else //------------------------------------------------------ // Ist die Datenübertragungsseite angesprochen worden ? //------------------------------------------------------ if(!memcmppgm2ram(filename, "daten.htm", 9)) { // Überbtragenes Argument auswerten, also die Startzeit der Datenübermittlung in UTC, damit nur die aktuellen Werte übermittelt werden müssen // Werbseite wird aufgerufen mit daten.htm?start=1262304000, also gewünschte UTC ptr = HTTPGetROMArg(curHTTP.data, (ROM BYTE *)"start"); if (ptr) StartZeit = atol (ptr); else StartZeit = 1262304000; // Varible enthält jetzt die gewünschte Zeit oder einen Defaultwert = 1.1.2010 00:00:00 Uhr // Mistkacke // Debugausgabe mit feindlicher Variablenübernahme putrsUART((ROM char*)"\r\Das kam : "); sprintf (buf, "%lX\n\r", StartZeit); putsUSART(buf); } // If it's the LED updater file else if(!memcmppgm2ram(filename, "cookies.htm", 11)) { // This is very simple. The names and values we want are already in // the data array. We just set the hasArgs value to indicate how many // name/value pairs we want stored as cookies. // To add the second cookie, just increment this value. // remember to also add a dynamic variable callback to control the printout. curHTTP.hasArgs = 0x01; } // If it's the LED updater file else if(!memcmppgm2ram(filename, "leds.cgi", 8)) { // Determine which LED to toggle ptr = HTTPGetROMArg(curHTTP.data, (ROM BYTE *)"led"); // Toggle the specified LED switch(*ptr) { case '1': LED1_IO ^= 1; break; case '2': LED2_IO ^= 1; break; case '3': LED3_IO ^= 1; break; case '4': LED4_IO ^= 1; break; case '5': LED5_IO ^= 1; break; case '6': LED6_IO ^= 1; break; case '7': LED7_IO ^= 1; break; } } // Defaultwert setzen if (StartZeit < 1262304000) StartZeit = 1262304000; return HTTP_IO_DONE; } /**************************************************************************** Section: POST Form Handlers ***************************************************************************/ #if defined(HTTP_USE_POST) /***************************************************************************** Function: HTTP_IO_RESULT HTTPExecutePost(void) Internal: See documentation in the TCP/IP Stack API or HTTP2.h for details. ***************************************************************************/ HTTP_IO_RESULT HTTPExecutePost(void) { // Resolve which function to use and pass along BYTE filename[20]; // Load the file name // Make sure BYTE filename[] above is large enough for your longest name MPFSGetFilename(curHTTP.file, filename, sizeof(filename)); #if defined(USE_LCD) if(!memcmppgm2ram(filename, "forms.htm", 9)) return HTTPPostLCD(); #endif #if defined(STACK_USE_HTTP_MD5_DEMO) if(!memcmppgm2ram(filename, "upload.htm", 10)) return HTTPPostMD5(); #endif #if defined(STACK_USE_HTTP_APP_RECONFIG) if(!memcmppgm2ram(filename, "protect/config.htm", 18)) return HTTPPostConfig(); #if defined(STACK_USE_SNMP_SERVER) else if(!memcmppgm2ram(filename, "snmp/snmpconfig.htm", 19)) return HTTPPostSNMPCommunity(); #endif #endif #if defined(STACK_USE_SMTP_CLIENT) if(!strcmppgm2ram((char*)filename, (ROM char*)"email/index.htm")) return HTTPPostEmail(); #endif #if defined(STACK_USE_DYNAMICDNS_CLIENT) if(!strcmppgm2ram((char*)filename, "dyndns/index.htm")) return HTTPPostDDNSConfig(); #endif return HTTP_IO_DONE; } /***************************************************************************** Function: static HTTP_IO_RESULT HTTPPostLCD(void) Summary: Processes the LCD form on forms.htm Description: Locates the 'lcd' parameter and uses it to update the text displayed on the board's LCD display. This function has four states. The first reads a name from the data string returned as part of the POST request. If a name cannot be found, it returns, asking for more data. Otherwise, if the name is expected, it reads the associated value and writes it to the LCD. If the name is not expected, the value is discarded and the next name parameter is read. In the case where the expected string is never found, this function will eventually return HTTP_IO_NEED_DATA when no data is left. In that case, the HTTP2 server will automatically trap the error and issue an Internal Server Error to the browser. Precondition: None Parameters: None Return Values: HTTP_IO_DONE - the parameter has been found and saved HTTP_IO_WAITING - the function is pausing to continue later HTTP_IO_NEED_DATA - data needed by this function has not yet arrived ***************************************************************************/ #if defined(USE_LCD) static HTTP_IO_RESULT HTTPPostLCD(void) { BYTE* cDest; #define SM_POST_LCD_READ_NAME (0u) #define SM_POST_LCD_READ_VALUE (1u) switch(curHTTP.smPost) { // Find the name case SM_POST_LCD_READ_NAME: // Read a name if(HTTPReadPostName(curHTTP.data, HTTP_MAX_DATA_LEN) == HTTP_READ_INCOMPLETE) return HTTP_IO_NEED_DATA; curHTTP.smPost = SM_POST_LCD_READ_VALUE; // No break...continue reading value // Found the value, so store the LCD and return case SM_POST_LCD_READ_VALUE: // If value is expected, read it to data buffer, // otherwise ignore it (by reading to NULL) if(!strcmppgm2ram((char*)curHTTP.data, (ROM char*)"lcd")) cDest = curHTTP.data; else cDest = NULL; // Read a value string if(HTTPReadPostValue(cDest, HTTP_MAX_DATA_LEN) == HTTP_READ_INCOMPLETE) return HTTP_IO_NEED_DATA; // If this was an unexpected value, look for a new name if(!cDest) { curHTTP.smPost = SM_POST_LCD_READ_NAME; break; } // Copy up to 32 characters to the LCD if(strlen((char*)cDest) < 32u) { memset(LCDText, ' ', 32); strcpy((char*)LCDText, (char*)cDest); } else { memcpy(LCDText, (void *)cDest, 32); } LCDUpdate(); // This is the only expected value, so callback is done strcpypgm2ram((char*)curHTTP.data, (ROM void*)"/forms.htm"); curHTTP.htt