diff --git a/bin/uce_fastcgi.debug.linux.bin b/bin/uce_fastcgi.debug.linux.bin index 2cf63bd..21af37e 100755 Binary files a/bin/uce_fastcgi.debug.linux.bin and b/bin/uce_fastcgi.debug.linux.bin differ diff --git a/scripts/compile b/scripts/compile index 8cd3c84..3c24b24 100755 --- a/scripts/compile +++ b/scripts/compile @@ -17,6 +17,8 @@ SO_FN="$5" mkdir -p "$DEST_DIR" > /dev/null 2>&1 +export CPLUS_INCLUDE_PATH="${CPLUS_INCLUDE_PATH:+${CPLUS_INCLUDE_PATH}:}$SRC_DIR" + BUILDMODE="debug" OPT_FLAG="O0" diff --git a/src/lib/compiler.h b/src/lib/compiler.h index 698f131..9986810 100644 --- a/src/lib/compiler.h +++ b/src/lib/compiler.h @@ -254,7 +254,11 @@ SharedUnit* get_shared_unit(string file_name) void invoke(string file_name) { - printf("(i) invoke(%s)\n", file_name.c_str()); + if(file_name[0] != '/') + { + file_name = expand_path(file_name); + } + //printf("(i) invoke(%s)\n", file_name.c_str()); auto su = get_shared_unit(file_name); if(!su) { diff --git a/src/lib/datastructures.h b/src/lib/datastructures.h index d64ab47..027cc25 100644 --- a/src/lib/datastructures.h +++ b/src/lib/datastructures.h @@ -10,6 +10,18 @@ string var_dump(StringMap map, string prefix = "", string postfix = "\n") return(result); } +string var_dump(StringList map, string prefix = "", string postfix = "\n") +{ + string result = ""; + + for (u32 i = 0; i < map.size(); i++) + { + result.append(prefix + map[i] + postfix); + } + + return(result); +} + u8 char_to_u8(char input) { if(input >= '0' && input <= '9') @@ -26,6 +38,15 @@ u8 hex_to_u8(string src) return(char_to_u8(src[0])*16 + char_to_u8(src[1])); } +template string to_hex(ITYPE w, size_t hex_len = sizeof(ITYPE)<<1) +{ + static const char* digits = "0123456789ABCDEF"; + string rc(hex_len,'0'); + for (size_t i=0, j=(hex_len-1)*4 ; i>j) & 0x0f]; + return(rc); +} + string trim(string raw) { u32 len = raw.length(); @@ -47,22 +68,24 @@ StringList explode(string str, string delim = "\n") StringList result; int start = 0; int end = str.find(delim); - while (end != -1) + while (end != string::npos) { - result.push_back(str.substr(start, end - start)); + result.push_back(str.substr(start, end - start)); start = end + delim.size(); end = str.find(delim, start); } result.push_back(str.substr(start, end - start)); + return(result); } string implode(StringList l, string delim = "\n") { string result; - for(string &s : l) + for(u32 i = 0; i < l.size(); i++) { - if(result.length() > 0) - result.append(delim+s); + string s = l[i]; + if(i > 0) + result.append(delim); result.append(s); } return(result); diff --git a/src/lib/settings.h b/src/lib/settings.h deleted file mode 100644 index c1419a7..0000000 --- a/src/lib/settings.h +++ /dev/null @@ -1,12 +0,0 @@ -struct ServerSettings { - - string BIN_DIRECTORY = "work"; - string COMPILE_SCRIPT = "scripts/compile"; - string LIT_ESC = "3d5b5_1"; - string CONTENT_TYPE = "text/html; charset=utf-8"; - string SOCKET_PATH = "/run/uce.sock"; - string TMP_UPLOAD = "/tmp"; - string COMPILER_SYS_PATH = ""; - u32 LISTEN_PORT = 9993; - -}; diff --git a/src/lib/sys.h b/src/lib/sys.h index 935c2f4..99e7fe8 100644 --- a/src/lib/sys.h +++ b/src/lib/sys.h @@ -49,12 +49,21 @@ $ U+0024 Dollar sign Parameter expansion string basename(string fn) { - return(trim(shell_exec("basename "+shell_escape(fn)))); + string result; + while(fn.length() > 0) + result = nibble("/", fn); + //printf("basename(%s) %s\n", fn.c_str(), result.c_str()); + return(result); } string dirname(string fn) { - return(trim(shell_exec("dirname "+shell_escape(fn)))); + string result; + auto seg = explode(fn, "/"); + seg.pop_back(); + result = implode(seg, "/"); + //printf("dirname(%s) %s seg#%i\n", fn.c_str(), result.c_str(), seg.size()); + return(result); } bool file_exists(string path) @@ -109,7 +118,7 @@ time_t file_mtime(string file_name) struct stat info; if (stat(file_name.c_str(), &info) != 0) { - printf("file_mtime(%s) error\n", file_name.c_str()); + return(0); } else { @@ -121,3 +130,15 @@ void unlink(string file_name) { remove(file_name.c_str()); } + +string expand_path(string path) +{ + string result; + char buf[PATH_MAX]; + char *res = realpath(path.c_str(), buf); + if(res) + { + result.append(res); + } + return(result); +} diff --git a/src/lib/time.h b/src/lib/time.h index 9d493e7..b9f5fa2 100644 --- a/src/lib/time.h +++ b/src/lib/time.h @@ -13,8 +13,10 @@ string date(string format = "", u64 timestamp = 0) { string ts; string fmt; - if(timestamp > 0) ts = string("-d '@")+to_string(timestamp)+"'"; - if(format != "") fmt = string("+'"+format+"'"); + if(timestamp > 0) + ts = string("-d '@")+to_string(timestamp)+"'"; + if(format != "") + fmt = string("+'"+format+"'"); return(trim(shell_exec("date "+ts+" "+fmt))); } @@ -22,12 +24,16 @@ string gmdate(string format = "", u64 timestamp = 0) { string ts; string fmt; - if(timestamp > 0) ts = string("'@")+to_string(timestamp)+"'"; - if(format != "") fmt = string("+'"+format+"'"); + if(timestamp > 0) + ts = string("-d '@")+to_string(timestamp)+"'"; + if(format == "RFC1123") + format = "%a, %d %b %Y %T GMT"; + if(format != "") + fmt = string("+'"+format+"'"); return(trim(shell_exec("date -u "+ts+" "+fmt))); } u64 parse_time(string time_string) { return(int_val(trim(shell_exec("date -u -d '"+time_string+"' +'%s'")))); -} \ No newline at end of file +} diff --git a/src/lib/types.h b/src/lib/types.h index ac28403..f91a630 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -2,7 +2,6 @@ #include #include #include -//#include #include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include typedef std::string string; @@ -36,17 +36,24 @@ typedef std::vector StringList; typedef void (*invoke_handler)(string file_name); -struct UploadedFile { - string file_name; - string tmp_name; - u32 size; -}; - struct Request; typedef void (*call_handler)(); typedef void (*request_handler)(Request* request); +struct ServerSettings { + + string BIN_DIRECTORY = "work"; + string COMPILE_SCRIPT = "scripts/compile"; + string LIT_ESC = "3d5b5_1"; + string CONTENT_TYPE = "text/html; charset=utf-8"; + string SOCKET_PATH = "/run/uce.sock"; + string TMP_UPLOAD = "/tmp"; + string COMPILER_SYS_PATH = ""; + u32 LISTEN_PORT = 9993; + +}; + struct SharedUnit { string file_name; @@ -78,3 +85,52 @@ struct SharedUnit { #include "dtree.h" +struct UploadedFile { + string file_name; + string tmp_name; + u32 size; +}; + +struct ServerState { + + std::map units; + ServerSettings config; + +} server_state; + +struct Request { + + ServerState* server_state; + + StringMap params; + StringMap get; + StringMap post; + StringMap cookies; + std::vector uploaded_files; + + StringMap header; + StringList set_cookies; + + std::string in; + std::string out; + std::string err; + + f64 time_init; + f64 time_start; + f64 time_end; + + void print(string s) + { + out.append(s); + } + +}; + +struct URI { + + StringMap query; + StringMap parts; + +}; + +typedef Request FastCGIRequest; diff --git a/src/lib/uce_gen.h b/src/lib/uce_gen.h index 8f7035b..aa70ca2 100644 --- a/src/lib/uce_gen.h +++ b/src/lib/uce_gen.h @@ -1,44 +1,10 @@ + + #include "types.h" -#include "settings.h" #include "datastructures.h" #include "sys.h" #include "time.h" -struct ServerState { - - std::map units; - ServerSettings config; - -} server_state; - -struct Request { - - ServerState* server_state; - - StringMap params; - StringMap get; - StringMap post; - std::vector uploaded_files; - - StringMap header; - - std::string in; - std::string out; - std::string err; - - f64 time_init; - f64 time_start; - f64 time_end; - - void print(string s) - { - out.append(s); - } - -}; - -typedef Request FastCGIRequest; - Request* context; #include "uri.h" diff --git a/src/lib/uri.h b/src/lib/uri.h index f3bd3a3..a4861ab 100644 --- a/src/lib/uri.h +++ b/src/lib/uri.h @@ -1,221 +1,4 @@ -struct URI { - StringMap query; - StringMap parts; - - static URI parse(string uri_string) - { - URI result; - - u8 state = 0; - string current = ""; - char expect = 0; - - result.parts["raw"] = uri_string; - - string part_names[] = { - "scheme", - "host", - "port", - "path", - "query", - "fragment", - }; - - if(uri_string[0] == '/') - state = 3; - - for (char &c: uri_string) - { - bool append_it = true; - - if(expect && expect != c) - { - result.parts["error"] = string("\'") + c + string("\' expected"); - result.parts["error_parsing"] = current; - result.parts["error_part"] = part_names[state]; - return(result); - } - expect = 0; - - switch(state) - { - case(0): // scheme - if(c == ':') - { - result.parts[part_names[state]] = current; - append_it = false; - current = ""; - state = 1; - } - break; - case(1): // host name - if(c == '/') - { - if(current == "") - { - append_it = false; - break; - } - result.parts[part_names[state]] = current; - append_it = false; - current = ""; - state = 3; - expect = '/'; - } - else if(c == ':') - { - result.parts[part_names[state]] = current; - append_it = false; - current = ""; - state = 2; - } - break; - case(2): // port - if(c == '/') - { - result.parts[part_names[state]] = current; - append_it = false; - current = ""; - state = 3; - expect = '/'; - } - break; - case(3): // path - if(c == '/' && current == "") - { - append_it = false; - break; - } - if(c == '?') - { - result.parts[part_names[state]] = current; - append_it = false; - current = ""; - state = 4; - } - break; - case(4): // query - if(c == '#') - { - result.parts[part_names[state]] = current; - append_it = false; - current = ""; - state = 5; - } - break; - } - - if(append_it) - current.append(1, c); - } - - result.parts[part_names[state]] = current; - - result.query = URI::parse_query(result.parts["query"]); - - return(result); - } - - static StringMap parse_query(string q) - { - StringMap result; - if(q.length() == 0) - return(result); - - bool is_key = true; - string key = ""; - string value = ""; - for (char &c: q) - { - if(c == '=') - { - is_key = !is_key; - } - else if(c == '&') - { - result[URI::decode(key)] = URI::decode(value); - key = ""; - value = ""; - is_key = true; - } - else if(is_key) - { - key.append(1, c); - } - else - { - value.append(1, c); - } - } - - result[URI::decode(key)] = URI::decode(value); - - return(result); - } - - static StringMap parse_multipart(string q, string boundary, std::vector& uploaded_files) - { - StringMap result; - - auto i = boundary.length(); - while(i < q.length()) - { - auto end_pos = q.find(boundary, i); - if(end_pos != string::npos) - { - string field = q.substr(i, end_pos - i); - nibble(":", field); - string ftype = trim(nibble(";", field)); - if(ftype == "form-data") - { - nibble("=\"", field); - string field_name = nibble("\"", field); - result[field_name] = field.substr(4, field.length()-6); - } - else if(ftype == "attachment") - { - nibble("=\"", field); - UploadedFile f; - f.tmp_name = context->server_state->config.TMP_UPLOAD + to_string(rand()); - f.file_name = nibble("\"", field); - string bin = field.substr(4, field.length()-6); - f.size = bin.length(); - file_put_contents(f.tmp_name, bin); - uploaded_files.push_back(f); - } - } - else - { - // we're done - end_pos = q.length(); - } - i = end_pos + boundary.length(); - } - - return(result); - } - - static string decode(string q) - { - string result; - for(u32 i = 0; i < q.length(); i++) - { - char c = q[i]; - if(c == '%' && q[i+1] != '%') - { - result.append(1, hex_to_u8(q.substr(i+1, 2))); - i += 2; - } - else - { - result.append(1, c); - } - } - return(result); - } - -}; string var_dump(URI uri, string prefix = "", string postfix = "\n") { @@ -226,3 +9,257 @@ string var_dump(URI uri, string prefix = "", string postfix = "\n") var_dump(uri.query, prefix+" ", postfix) ); } + +string uri_decode(string q) +{ + string result; + for(u32 i = 0; i < q.length(); i++) + { + char c = q[i]; + if(c == '%' && q[i+1] != '%') + { + result.append(1, hex_to_u8(q.substr(i+1, 2))); + i += 2; + } + else + { + result.append(1, c); + } + } + return(result); +} + +string uri_encode(string q) +{ + string result; + for(u32 i = 0; i < q.length(); i++) + { + char c = q[i]; + if(isalnum(c) || c == '~' || c == '.' || c == '_' || c == '-') + result.append(1, c); + else + { + result.append(1, '%'); + result.append(to_hex(c)); + } + } + return(result); +} + +StringMap parse_query(string q) +{ + StringMap result; + if(q.length() == 0) + return(result); + + bool is_key = true; + string key = ""; + string value = ""; + for (char &c: q) + { + if(c == '=') + { + is_key = !is_key; + } + else if(c == '&') + { + result[uri_decode(key)] = uri_decode(value); + key = ""; + value = ""; + is_key = true; + } + else if(is_key) + { + key.append(1, c); + } + else + { + value.append(1, c); + } + } + + result[uri_decode(key)] = uri_decode(value); + + return(result); +} + +StringMap parse_multipart(string q, string boundary, std::vector& uploaded_files) +{ + StringMap result; + + auto i = boundary.length(); + while(i < q.length()) + { + auto end_pos = q.find(boundary, i); + if(end_pos != string::npos) + { + string field = q.substr(i, end_pos - i); + nibble(":", field); + string ftype = trim(nibble(";", field)); + if(ftype == "form-data") + { + nibble("=\"", field); + string field_name = nibble("\"", field); + result[field_name] = field.substr(4, field.length()-6); + } + else if(ftype == "attachment") + { + nibble("=\"", field); + UploadedFile f; + f.tmp_name = context->server_state->config.TMP_UPLOAD + to_string(rand()); + f.file_name = nibble("\"", field); + string bin = field.substr(4, field.length()-6); + f.size = bin.length(); + file_put_contents(f.tmp_name, bin); + uploaded_files.push_back(f); + } + } + else + { + // we're done + end_pos = q.length(); + } + i = end_pos + boundary.length(); + } + + return(result); +} + +URI parse_uri(string uri_string) +{ + URI result; + + u8 state = 0; + string current = ""; + char expect = 0; + + result.parts["raw"] = uri_string; + + string part_names[] = { + "scheme", + "host", + "port", + "path", + "query", + "fragment", + }; + + if(uri_string[0] == '/') + state = 3; + + for (char &c: uri_string) + { + bool append_it = true; + + if(expect && expect != c) + { + result.parts["error"] = string("\'") + c + string("\' expected"); + result.parts["error_parsing"] = current; + result.parts["error_part"] = part_names[state]; + return(result); + } + expect = 0; + + switch(state) + { + case(0): // scheme + if(c == ':') + { + result.parts[part_names[state]] = current; + append_it = false; + current = ""; + state = 1; + } + break; + case(1): // host name + if(c == '/') + { + if(current == "") + { + append_it = false; + break; + } + result.parts[part_names[state]] = current; + append_it = false; + current = ""; + state = 3; + expect = '/'; + } + else if(c == ':') + { + result.parts[part_names[state]] = current; + append_it = false; + current = ""; + state = 2; + } + break; + case(2): // port + if(c == '/') + { + result.parts[part_names[state]] = current; + append_it = false; + current = ""; + state = 3; + expect = '/'; + } + break; + case(3): // path + if(c == '/' && current == "") + { + append_it = false; + break; + } + if(c == '?') + { + result.parts[part_names[state]] = current; + append_it = false; + current = ""; + state = 4; + } + break; + case(4): // query + if(c == '#') + { + result.parts[part_names[state]] = current; + append_it = false; + current = ""; + state = 5; + } + break; + } + + if(append_it) + current.append(1, c); + } + + result.parts[part_names[state]] = current; + + result.query = parse_query(result.parts["query"]); + + return(result); +} + +void set_cookie( + string name, string value = "", + u64 expires = 0, string path = "/", string domain = "", + bool secure = false, bool http_only = true) +{ + string cookie = "Set-Cookie: "; + cookie.append(uri_encode(name) + "=" + uri_encode(value)); + if(expires > 0) + cookie.append(string("; Expires=") + gmdate("RFC1123", expires)); + + context->set_cookies.push_back(cookie); +} + +StringMap parse_cookies(string cookie_string) +{ + StringMap result; + while(cookie_string.length() > 0) + { + string key = trim(nibble("=", cookie_string)); + string value = nibble(";", cookie_string); + result[key] = value; + } + return(result); +} diff --git a/src/linux_fastcgi.cpp b/src/linux_fastcgi.cpp index 64a57be..de27a35 100644 --- a/src/linux_fastcgi.cpp +++ b/src/linux_fastcgi.cpp @@ -43,7 +43,10 @@ int handle_complete(FastCGIRequest& request) { request.time_start = microtime(); request.header["Content-Type"] = context->server_state->config.CONTENT_TYPE; - request.get = URI::parse_query(request.params["QUERY_STRING"]); + request.get = parse_query(request.params["QUERY_STRING"]); + + if(request.params["HTTP_COOKIE"].length() > 0) + request.cookies = parse_cookies(request.params["HTTP_COOKIE"]); string ct_info = request.params["CONTENT_TYPE"]; string ct_type = nibble(";", ct_info); @@ -53,17 +56,20 @@ int handle_complete(FastCGIRequest& request) { if(ct_type == "multipart/form-data") { nibble("boundary=", ct_info); - request.post = URI::parse_multipart(request.in, string("--")+ct_info, request.uploaded_files); + request.post = parse_multipart(request.in, string("--")+ct_info, request.uploaded_files); } else { - request.post = URI::parse_query(request.in); + request.post = parse_query(request.in); } } invoke(request.params["SCRIPT_FILENAME"]); - string headers = var_dump(request.header, "", "\r\n") + "\r\n"; + string headers = + var_dump(request.header, "", "\r\n") + + var_dump(request.set_cookies, "", "\r\n") + + "\r\n"; request.out = headers + request.out; for( auto &f : request.uploaded_files) @@ -101,6 +107,9 @@ int main(int argc, char** argv) server.listen(server_state.config.SOCKET_PATH); chmod(server_state.config.SOCKET_PATH.c_str(), S_IRWXU | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + dirname(server_state.config.COMPILER_SYS_PATH); + basename(server_state.config.COMPILER_SYS_PATH); + //server.process(100); //server.process(); server.process_forever(); diff --git a/test/cookie.uce b/test/cookie.uce new file mode 100644 index 0000000..9201215 --- /dev/null +++ b/test/cookie.uce @@ -0,0 +1,27 @@ + + +RENDER() +{ + + <> + +

+ UCE Test: + Cookies +

+
cookies));
+
+		?>
+
set_cookies));
+
+		?>
+
params) ?>
+ + +} diff --git a/test/inc-test.cpp b/test/inc-test.cpp new file mode 100644 index 0000000..69d160f --- /dev/null +++ b/test/inc-test.cpp @@ -0,0 +1,4 @@ +void test_output() +{ + echo("hello from include!"); +} diff --git a/test/index.uce b/test/index.uce index b7f5db6..1a49299 100644 --- a/test/index.uce +++ b/test/index.uce @@ -3,7 +3,7 @@ RENDER() { - + <>

UCE Test: @@ -14,8 +14,10 @@ RENDER()
  • Form Post
  • Form Multipart Post
  • Working Directory
  • +
  • URI
  • +
  • Cookies
  • params) ?>
    - + } diff --git a/test/uri.uce b/test/uri.uce new file mode 100644 index 0000000..f46c890 --- /dev/null +++ b/test/uri.uce @@ -0,0 +1,28 @@ + + +RENDER() +{ + + <> + +

    + UCE Test: + URI +

    +
    +
    + + "/> +
    + Encode: post["uri_encode"]) ?> +
    + Decode: post["uri_encode"])) ?> +
    +
    + +
    +
    +
    params) ?>
    + + +} diff --git a/todo.txt b/todo.txt index 7665b60..2b27da9 100644 --- a/todo.txt +++ b/todo.txt @@ -5,7 +5,6 @@ Library - sha1 / md5 / meow - cache - json_encode / json_decode -- cookies - session - curl - random @@ -15,9 +14,8 @@ Library Bugs ================================= - shell_escape() -- include path -- preprocessor - - nested tags +- we crash on illegal paths +- you should not be able to invoke() outside of DOCUMENT_ROOT Framework diff --git a/workCode/uce.openfu.com/uce/test/hello.uce.cpp b/workCode/uce.openfu.com/uce/test/hello.uce.cpp new file mode 100644 index 0000000..c484046 --- /dev/null +++ b/workCode/uce.openfu.com/uce/test/hello.uce.cpp @@ -0,0 +1,191 @@ +#include "/Code/uce.openfu.com/uce/src/lib/uce_gen.h" + + +void show_stuff() +{ + //context->header["Content-Type"] = "text/plain"; + //echo(to_string(time())+"\n"); + + context->print(R"( + Mwahahaaha )");echo(html_escape( time() )); context->print(R"( +
    hello world: )");echo(html_escape( context->params["HTTP_HOST"] )); context->print(R"(
    +
    +Display the date using any or all of the following elements:
    +
    +%a: abbreviated day name (i.e. mon, tue, wed)
    +%A: full day name (i.e. Monday, Tuesday, Wednesday)
    +%b or %h: abbreviated month name (i.e. jan, feb, mar)
    +%B: full month name (January, February, March)
    +%c: locales date and time (full date and time)
    +%C: century - displays the first two numbers of the year (i.e 19 for 1999 and 20 for 2020)
    +%d: day of month (i.e. 01, 02, 03)
    +%D: same as M/D/Y (i.e. 04/20/16)
    +%e: day of month padded (i.e. ' 1', ' 2')
    +%F: full date, same as yyyy-mm-dd
    +%H: hour (00, 01, 02, 21, 22, 23)
    +%I: hour (1,2,3,10,11,12)
    +%j: day of year (i.e. 243)
    +%k: hour padded (i.e. '1' becomes ' 1'
    +%l: hour padded (12 hour clock)
    +%m: month number (1,2,3)
    +%M: minute (1,2,3,57,58,59)
    +%n: new line
    +%N: nanoseconds
    +%p: AM or PM
    +%P: like %p but lowercase (ironically)
    +%r: locales 12 hour clock time
    +%R: 24 hour version of hour and minute
    +%s: seconds since 1970-01-01 00:00:00
    +%S: second (01,02,03, 57, 58, 59)
    +%t: a tab
    +%T: time same as %H:%M:%S
    +%u: day of week (1 is Monday, 2 is Tuesday etc)
    +%U: week number of year (assuming Sunday as first day of the week)
    +%V: ISO week number with Monday as the first day of the week
    +%w: day of week (0 is Sunday)
    +%W: week number of the year with Monday as the first day of the week
    +%x: locales date representation (12/31/2015)
    +%X: locales time representation (14:44:44)
    +%y: last two digits of year
    +%Y: year
    +%z: numeric time zone (i.e. -0400)
    +%:z: numeric time zone as follows (i.e. -04:00)
    +%::z: numeric time zone as follows (i.e. -04:00:00)
    +%Z: alphabetic time zone abbreviation (GMT)
    +-: a single hyphen prevents zero padding
    +_: a single underscore pads with spaces
    +0: pads with zeroes
    +^: use uppercase if possible
    +#: use opposite case if possible
    +To display just the time use the following:
    +
    +date +%T
    +Alternatively, use the following:
    +
    +date +%H:%M:%S
    +Attach the date, as well, using the command:
    +
    +date +%d/%m/%Y%t%H:%M:%S
    +Alternatively, use the follow (since %T is equivalent to %H:%M:%S):
    +
    +date +$d/%m/%Y%t%T
    +The : and / characters are optional and can be whatever you want. For example:
    +
    +date +%dc%mc%Y
    +
    +outputs: 24c09c2020, if you wanted to use 'c' as a delimiter for some reason.
    +
    +Use any combination of the above switches after the plus symbol to output the date as you so wish. If you want to add spaces you can use quotes around the date.
    +
    +date +'%d/%m/%Y %H:%M:%S'
    +How to Show the UTC Date
    +View the UTC date for your computer using the following command:
    +
    +date -u
    +If you are in the UK you will notice that instead of showing "18:58:20" as the time it will show "17:58:20" as the time.
    +
    +How to Show the RFC Date
    +View the RFC date for your computer using the following command:
    +
    +date --rfc-2822
    +This displays the date in the following format:
    +
    +Wed, 20 Apr 2018 19:56:52 +0100
    +This flag is useful as it shows that you are an hour ahead of GMT.
    +
    +Some Useful Date Commands
    +Do you want to know the date next Monday? Try this:
    +
    +date -d "next Monday"
    +
    +At the point of writing this returns "Mon 25 Apr 00:00:00 BST 2016"
    +
    +The -d basically prints a date in the future or the past. So, you can use "next Monday" or "last Friday".
    +
    +Using the same command you can find out which day of the week your birthday or Christmas falls upon.
    +
    +date -d 12/25/2016
    +
    +The result is Sun Dec 25.
    +
    +Summary
    +It is worth checking out the manual page for the date command using the following command:
    +
    +man date
    +Was this page helpful?
    +
    +More from Lifewire
    +Businessman checking the time on his watch
    +How to Understand the Date and Time in Email Headers
    +Calendar next to an Apple keyboard
    +How to Change the Date and Time on a Mac Manually
    +Turning on automatic date and time settings in Windows 10.
    +Change the Date and Time Zone on Your Windows Laptop
    +People comparing the calendars on their iPhones
    +How to Change Date on iPhone
    +Woman walking with Black Friday shopping bag
    +What Is Black Friday?
    +Clock On White Wall
    +Find the Sent Timestamp on Gmail Messages
    +Homescreen with clock on Android
    +How to Change the Time on Android
    +Person taking a photo of a flower with a smartphone
    +How to Adjust the Date, Time, and Location of Photos in iOS 15
    +Dark office with many computers, one lit up
    +Understanding the Linux Command: Ar
    +A human hand pressing an old-fashioned alarm clock
    +Learn the Linux Command 'at'
    +Close-Up Of Thumbtack On Calendar Date
    +Using the DATE Function in Google Sheets
    +DATE function in Excel
    +How to Use the Excel DATE Function
    +Tux the penguin is the official Linux mascot.
    +Delete Files Using the Linux Command Line
    +Close-Up Of Clock Against Calendar
    +Serial Number and Serial Date in Excel
    +Person running Linux sleep command for 20 seconds on a laptop
    +How to Use the Linux Sleep Command to Pause a BASH Script
    +Cropped Hand Of Person Using Laptop By Alarm Clock At Table
    +Excel's Volatile NOW Function for the Date and Time
    +Lifewire
    +Tech for Humans
    +Follow Us
    +Subscribe to our newsletter and get tech’s top stories in 30 seconds.
    +Email Address
    +enter email
    +SUBMIT
    +News
    +Best Products
    +Mobile Phones
    +Computers
    +About Us
    +Advertise
    +Privacy Policy
    +Cookie Policy
    +Careers
    +Editorial Guidelines
    +Contact
    +Terms of Use
    +EU Privacy
    +California Privacy Notice
    +Lifewire is part of the Dotdash publishing family.
    +
    +		
    + )"); + +} + +RENDER() +{ + + context->print(R"( + +

    + UCE Test: + Index +

    + )"); show_stuff(); context->print(R"( +
    )");echo(html_escape(  var_dump(context->params)  )); context->print(R"(
    + )"); + +} diff --git a/workCode/uce.openfu.com/uce/test/index.uce.cpp b/workCode/uce.openfu.com/uce/test/index.uce.cpp new file mode 100644 index 0000000..75298c3 --- /dev/null +++ b/workCode/uce.openfu.com/uce/test/index.uce.cpp @@ -0,0 +1,22 @@ +#include "/Code/uce.openfu.com/uce/src/lib/uce_gen.h" + + +RENDER() +{ + + context->print(R"( + +

    + UCE Test: + Index +

    + +
    )");echo(html_escape(  var_dump(context->params)  )); context->print(R"(
    + )"); + +} diff --git a/workCode/uce.openfu.com/uce/test/post-multipart.uce.cpp b/workCode/uce.openfu.com/uce/test/post-multipart.uce.cpp new file mode 100644 index 0000000..4ed900c --- /dev/null +++ b/workCode/uce.openfu.com/uce/test/post-multipart.uce.cpp @@ -0,0 +1,48 @@ +#include "/Code/uce.openfu.com/uce/src/lib/uce_gen.h" + +void show_form() +{ + + context->print(R"(
    +
    + + post["fühld"] )); context->print(R"("/> +
    +
    + + +
    +
    + +
    +
    )"); + +} + +RENDER() +{ + + context->print(R"( + +

    + UCE Test: + Multipart-Encoded Form POST +

    + + )"); show_form(); context->print(R"( + +
    + +
    + + +
    )");echo(html_escape(  var_dump(context->post)  )); context->print(R"(
    + + +
    )");echo(html_escape(  context->in  )); context->print(R"(
    + + +
    )");echo(html_escape(  var_dump(context->params)  )); context->print(R"(
    + )"); + +} diff --git a/workCode/uce.openfu.com/uce/test/post.uce.cpp b/workCode/uce.openfu.com/uce/test/post.uce.cpp new file mode 100644 index 0000000..181c12a --- /dev/null +++ b/workCode/uce.openfu.com/uce/test/post.uce.cpp @@ -0,0 +1,44 @@ +#include "/Code/uce.openfu.com/uce/src/lib/uce_gen.h" + +void show_form() +{ + + context->print(R"(
    +
    + + post["field"] )); context->print(R"("/> +
    +
    + + +
    +
    + +
    +
    )"); + +} + +RENDER() +{ + + context->print(R"( + +

    + UCE Test: + Form POST +

    + + )"); show_form(); context->print(R"( + + +
    )");echo(html_escape(  var_dump(context->post)  )); context->print(R"(
    + + +
    )");echo(html_escape(  context->in  )); context->print(R"(
    + + +
    )");echo(html_escape(  var_dump(context->params)  )); context->print(R"(
    + )"); + +}