parent
314239842e
commit
28a170faa3
File diff suppressed because one or more lines are too long
@ -0,0 +1,21 @@ |
||||
<?php |
||||
|
||||
/* This script is run on demand to generate JS version of tr() */ |
||||
|
||||
require_once __DIR__ . '/base.php'; |
||||
|
||||
$selected = [ |
||||
'wifi.connected_ip_is', |
||||
'wifi.not_conn', |
||||
]; |
||||
|
||||
$out = []; |
||||
foreach ($selected as $key) { |
||||
$out[$key] = $_messages[$key]; |
||||
} |
||||
|
||||
file_put_contents(__DIR__. '/jssrc/lang.js', |
||||
"// Generated from PHP locale file\n" . |
||||
'var _tr = ' . json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE) . ";\n\n" . |
||||
"function tr(key) { return _tr[key] || '?'+key+'?'; }\n" |
||||
); |
@ -0,0 +1,7 @@ |
||||
// Generated from PHP locale file
|
||||
var _tr = { |
||||
"wifi.connected_ip_is": "Connected, IP is ", |
||||
"wifi.not_conn": "Not connected." |
||||
}; |
||||
|
||||
function tr(key) { return _tr[key] || '?'+key+'?'; } |
@ -0,0 +1,74 @@ |
||||
/*
|
||||
Cgi/template routines for configuring non-wifi settings |
||||
*/ |
||||
|
||||
#include <esp8266.h> |
||||
#include "cgi_persist.h" |
||||
#include "persist.h" |
||||
#include "helpers.h" |
||||
|
||||
#define SET_REDIR_SUC "/cfg/admin" |
||||
|
||||
static bool ICACHE_FLASH_ATTR |
||||
verify_admin_pw(const char *pw) |
||||
{ |
||||
// This is not really for security, but to prevent someone who
|
||||
// shouldn't touch those settings from fucking it up.
|
||||
return streq(pw, STR(ADMIN_PASSWORD)); // the PW comes from the makefile
|
||||
} |
||||
|
||||
httpd_cgi_state ICACHE_FLASH_ATTR |
||||
cgiPersistWriteDefaults(HttpdConnData *connData) |
||||
{ |
||||
char buff[50]; |
||||
|
||||
if (connData->conn == NULL) { |
||||
//Connection aborted. Clean up.
|
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
|
||||
// width and height must always go together so we can do max size validation
|
||||
if (GET_ARG("pw")) { |
||||
dbg("Entered password for admin: %s", buff); |
||||
if (verify_admin_pw(buff)) { |
||||
dbg("pw is OK"); |
||||
|
||||
persist_set_as_default(); |
||||
|
||||
httpdRedirect(connData, SET_REDIR_SUC); |
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
// if pw failed, show the same error as if it's wrong
|
||||
} |
||||
|
||||
httpdRedirect(connData, SET_REDIR_SUC "?err=Password"); // this will show in the "validation errors" box
|
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
|
||||
|
||||
httpd_cgi_state ICACHE_FLASH_ATTR |
||||
cgiPersistRestoreDefaults(HttpdConnData *connData) |
||||
{ |
||||
if (connData->conn == NULL) { |
||||
//Connection aborted. Clean up.
|
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
|
||||
persist_restore_default(); |
||||
httpdRedirect(connData, SET_REDIR_SUC); |
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
|
||||
httpd_cgi_state ICACHE_FLASH_ATTR |
||||
cgiPersistRestoreHard(HttpdConnData *connData) |
||||
{ |
||||
if (connData->conn == NULL) { |
||||
//Connection aborted. Clean up.
|
||||
return HTTPD_CGI_DONE; |
||||
} |
||||
|
||||
persist_restore_hard_default(); |
||||
|
||||
httpdRedirect(connData, SET_REDIR_SUC); |
||||
return HTTPD_CGI_DONE; |
||||
} |
@ -0,0 +1,10 @@ |
||||
#ifndef CGIPERSIST_H |
||||
#define CGIPERSIST_H |
||||
|
||||
#include "httpd.h" |
||||
|
||||
httpd_cgi_state cgiPersistWriteDefaults(HttpdConnData *connData); |
||||
httpd_cgi_state cgiPersistRestoreDefaults(HttpdConnData *connData); |
||||
httpd_cgi_state cgiPersistRestoreHard(HttpdConnData *connData); |
||||
|
||||
#endif |
Loading…
Reference in new issue