Compare commits

..
17 Commits
Author SHA1 Message Date
brad ArantandClaude Opus 5.5 2847ce5fa7 Add jetc --lint-sql to find <sql> that pastes values (phase 2)
Implements phase 2 of docs/design-sql-bound-parameters.md. jetc --lint-sql
[--strict] <file|dir>... lists each <sql> whose statement contains a $[...]
or #[...] reference instead of a <bind>, with file:line and where each value
comes from. Row values ($[.col], $[session.col], $[?N], $[#]) are only
reported with --strict. References in <bind>, <if>, <set> and the other
attribute-only tags, <comment> and |> <| are skipped. A custom tag defined
as <sql><container></sql> (barant.com's <showtable>) is checked at each use.
Exit status is 0 for none found, 1 for findings, 2 for an unreadable path.

- jetc/JetLint.*: the scanner; jetc.cpp: the option
- build scripts and runbindtests.sh: link JetLint.cpp
- tests/runlinttests.sh and tests/lintsql/: fixtures and expected output
- docs: worklist for the local copies of both sites, design doc status,
  manual note on the lint

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 20:29:28 -08:00
brad ArantandClaude Opus 5.5 fd81bb877f Document <bind> and bound parameters in the user manual
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 20:22:50 -08:00
brad ArantandClaude Opus 5.5 cfdb3cbf57 Avoid a trigraph warning in the SqlBind unit test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 20:22:03 -08:00
brad ArantandClaude Opus 5.5 3c6411c16e Error on unterminated tags instead of looping forever
The Tag constructor's attribute loop made no progress at end of data, so
a tag that never closed - such as <set value="a\"> with its closing quote
escaped - hung jet-2.0. Throw "unterminated <name> tag." at end of data,
and "unterminated value for X in <name>." when an attribute value's
closing quote is missing.

Needs CoreUtils with the getTokenExclude fix for <set value="a\\">.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 19:57:51 -08:00
brad ArantandClaude Opus 5.5 a18d1358b0 Add <bind> bound parameters for <sql> (phase 1)
Implements phase 1 of docs/design-sql-bound-parameters.md: <bind> supplies
the value for the next ? placeholder of the enclosing <sql>, with typed
validation (int, decimal, date, datetime, bool, ident with allow list),
null="empty", and refusal to change the connection character set.

- SqlBind.*: MySQL-free placeholder scanning and binding logic
- __bind.*, __sql, __mysql: runtime wiring
- Tag.cpp, jetc/JetParser.cpp: bind is a void tag in both
- jetc/JetCodegen: emit sized ZString literals for text holding a NUL,
  which previously truncated the compiled page
- tests: unit tests, end-to-end test against MySQL (interpreted and
  jetc-compiled), and the generator for the binary test page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 19:55:23 -08:00
brad Arant 9fae14eb96 Merge branch 'fix-missing-libssl-link' 2026-11-20 19:37:33 -08:00
Brad ArantandClaude Opus 5.5 ec3e40b71a Add ltrim and rtrim expression functions
ltrim(x) removes leading blanks and rtrim(x) removes trailing blanks,
using the same characters trim removes (space, tab, newline). rtrim
counts by index so an all-blank value becomes empty. The manual now
documents trim, ltrim and rtrim with examples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 15:07:33 +00:00
Brad ArantandClaude Opus 5.5 5f9a53aba2 Fix nested tags hiding a marker right after their close
Tag::ifNested(in) returned false after skipping a nested same-name tag
(or, for if/while/until/ifrow, a nested one of the others), so both
callers also nextChar()ed and skipped the first character after it.
A marker right after the nested close was never seen: </if></if> lost
the outer end and swallowed the rest of the content, </if><else> lost
the else, and </try><catch> lost the outer catch, so an error raised
inside an inner catch block vanished silently. Return true instead.

Tested with the jet CLI (old vs new on 15 cases) and a test server on
port 8443: all 87 pages on both sites render the same apart from blank
lines, and nested try/catch tests pass on the live site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 02:18:39 +00:00
Brad ArantandClaude Opus 5.5 fdcb2b43a9 Keep <catch> attributes so <catch name="err"> stores the error
The split-tag scanner skipped the attributes on <catch ...>, so
<catch name="err"> never stored the error text and every caught error
read as "". Keep them in Tag::splitKeywords, and have <try> use the
catch tag's name and scope when the try tag itself has no name.

Tested live on barant.com: <catch name> and <try name> both store the
error, including scope="session" and single-quoted attributes; the
catch block still runs; no error leaves the name unset; nested tries
catch body errors at the right level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 01:51:04 +00:00
Brad ArantandClaude Opus 5.5 08462ca996 Add scope="session" to <set>; replace setenv with it
<set name="x" value="..." scope="session"> now writes x to the session
file (any name, no @ prefix); values are still read with $[@x].
storeVariable passes the scope through instead of repeating the
global/local/parent checks for each value source.

Convert every <setenv> use on barant-site and qualityiron-site to a
plain <set> plus a scope="session" <set>, which keeps same-request
$[name] reads working, and remove setenv from both SESSIONCTL.tag
copies (sessionctl is deprecated for session management).

Document session variables and the set tag scopes in the Jet manual.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 01:46:36 +00:00
Brad ArantandClaude Sonnet 5 867ace3cb3 Give jetc a dedicated, fully inert <comment> handler at compile time
<comment> had no special-case in jetc's compiler at all - it fell
through to parseFallback(), the generic unknown-tag path, which hunts
for a tag's own closing tag via scanBody()/skipQuotedValue(), the same
quote-aware, backslash-escape-interpreting scanning real Jet attribute
syntax needs. A comment containing an explanatory " sequence (a JSON
example in prose, say) or a literal <else>/<if>-looking word - both
already confirmed, separately, to corrupt jetc when they turn up
inside a JS // comment - hit the exact same corruption here too, just
triggered from inside a <comment> block instead.

Added skipCommentTag(), which only tracks same-tag-name nesting depth
via the existing case-insensitive matchTagOpen/matchTagClose and
otherwise ignores every character - no quote tracking, no other-tag
recognition, nothing a comment's own body could ever trip over. Wired
into parseNodes() alongside the other recognized top-level tags;
unlike those, it pushes no node at all; the comment contributes
nothing to the compiled output, matching the runtime interpreters own
__comment behavior but now safe at compile time too.

Verified directly: a scratch .jet with five <comment> blocks (plain,
a bare quote, a backslash-quote JSON example, literal <else>/<if>
text, and nested comments with their own quotes) all compiled clean
and left zero trace in the generated code, with the <if> immediately
following them compiling correctly too - confirming nothing after a
tricky comment gets corrupted either.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-10 16:49:53 +00:00
Brad ArantandClaude Sonnet 5 b8f7793773 Add global music player, invoicing/payment system, account subpages, mail account admin, and the qualityiron.vegas Jet 2.0 port
Jet interpreter (Tag.cpp, __call.cpp, __imap*.cpp/h, __smtpsend.cpp/h,
__imapemptyfolder.cpp/h - new): assorted parser/tag fixes found across
this work - a stray literal-tag-in-comment and backslash-quote parser
corruption class, a dangling-pointer fix, a __call.cpp fd leak, IMAP
folder-management tags, multi-account/per-host IMAP support, and a
smtpsend Message-ID fix.

barant.com site (jetc/barant-site/):
- A site-wide persistent music player (header band, playlist/queue,
  stereo FFT EQ, session-persisted state) fed by new library/
  ianslibrary/music song-list subpages.
- /account split into info/phones/invoices subpages; a full invoicing
  and Square payment system (create/edit/copy/pay/email invoice);
  admin invoice management and mail-account management subpages.
- /services split into overview/hosting/siptrunking/documents
  subpages, retiring the old standalone pages.
- SIPPHONE.tag: a Jet 2.0 WebRTC softphone tag.
- main.css/spa.js/email.js: the SPA loading indicator, the music
  player band styling, and assorted fixes accumulated alongside this
  work.

qualityiron-site/: the qualityiron.vegas job/contractor/customer/
document management app, ported from its original Jet 1.4 codebase to
Jet 2.0 as barant.coms APIServers second multi-tenant site.

wcwc/wcwc.jet: the WCWC site Jet source (wcwc.jtc build output not
included).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-06 17:42:01 +00:00
Brad ArantandClaude Sonnet 5 905fbafa5a Fix <sql> silent-failure bug; split /vst into overview + subpage; misc site fixes
- __mysql.cpp: <sql> never checked mysql_real_query's own return code,
  so a genuine query failure was indistinguishable from "ran fine, zero
  rows" - <try>/<catch> around a failing <sql> never actually caught
  anything anywhere. Now throws on a real failure.
- spa.js: dynamically re-injected scripts now run in true sequential
  order (wait for each external script's load event before running the
  next), fixing checkout's Square card field never building on the
  first client-side navigation to /checkout (only after a refresh) -
  async=false alone only orders multiple external scripts relative to
  each other, it doesn't delay a plain inline sibling.
- /vst split into a real overview + /vst/modular1 subpage with a left
  menu, reusing opensource.page's existing subpage-tier pattern
  (opensource.menu/main.css's submenuitem-active highlighting, and
  several other subpage-tier retirements, were already finished earlier
  this session but never committed - included here too).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-13 15:14:25 +00:00
brad ArantandClaude Sonnet 5 9d965bfd1a Fix jet-2.0 link failure: add missing -lssl
The __imap tag (added for the /email webmail client) calls real
SSL_CTX_*/SSL_connect() functions, which live in libssl - not libcrypto
(a separate, lower-level library providing only crypto primitives).
compile only ever linked -lcrypto, so a build from a completely fresh
checkout fails at the final link step:

  __imap.o: undefined reference to symbol 'SSL_CTX_free@@OPENSSL_3.0.0'

Reproduced building fresh on a brand-new server (nothing else installed
yet) rather than an incremental rebuild against an already-linked
jet-2.0, which is presumably why this went unnoticed - barant.com's own
production jet-2.0 was likely last linked before __imap needed real SSL
session functions, or was patched by hand at the time without this fix
landing in the committed script.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-08 21:32:48 -07:00
Brad Arant 46ef67b735 Bump email.js cache-buster for pagination change 2026-09-07 04:20:53 +00:00
Brad Arant 41fbf0b7d9 Add pagination to the email list (was hardcoded to newest 50, no way to see older mail)
listMessages() only ever fetched everything then kept the newest
limit (default 50) messages, with no offset parameter and no way for
the client to know how many messages existed beyond what it was
shown - older mail was completely unreachable through the webmail UI.

__imap::listMessages() now takes an offset (counted back from the
newest message) and returns {"total":N,"messages":[...]} instead of
a bare array, so the client can page backward/forward and know when
it has reached either end. __imaplist tag and /email/list both pass
offset through; /email/search is unchanged (search results are not
paginated). email.js tracks currentOffset (reset alongside
currentFolder/currentUid at every existing reset site), and renders
Prev/Next controls next to the unread count showing the current
1-based range and total.
2026-09-07 04:20:42 +00:00
Brad Arant dcfe2a667c Restyle htmleditor.page to match site theme, remove email disconnect button
htmleditor.page previously used hardcoded blue/gray Windows-95-era
inline styles (#678, #abc, #808080, #def) totally disconnected from
the site current dark/gold Bond theme (main.css --bond-* variables) -
this is what showed up as "the old page with the blue stylesheet"
when opening a file to edit. Restyled the window chrome, toolbar,
title bar, and buttons to use the same custom properties/.button
class the rest of the site uses; left the #mainpage content-preview
canvas white since it renders the actual page being edited.

email.js: removed the Disconnect button/handler and its unused icon
from the email toolbar per request. Bumped its cache-buster in
admin-email.subpage.
2026-09-07 04:09:12 +00:00
473 changed files with 18473 additions and 794 deletions

No files matched your search

+31 -1
View File
@@ -225,7 +225,37 @@ namespace jet {
if(in.ifNext(")")) {
string = parm1.string.trim();
} else
throw coreutils::Exception("Expecting ) at end of TRIM expression.");
throw coreutils::Exception("Expecting ) at end of TRIM expression.");
} else if(in.ifNextIgnoreCase("LTRIM")) {
// Leading blanks only - the same characters TRIM removes (space,
// tab, newline).
if(!in.ifNext("("))
throw coreutils::Exception("Expecting ( for LTRIM parameters.");
Operand parm1(in, tag);
if(in.ifNext(")")) {
const char *data = parm1.string.getData();
int len = parm1.string.getLength();
int start = 0;
while((start < len) && ((data[start] == ' ') || (data[start] == '\t') || (data[start] == '\n')))
++start;
string = parm1.string.substring(start, len - start);
} else
throw coreutils::Exception("Expecting ) at end of LTRIM expression.");
} else if(in.ifNextIgnoreCase("RTRIM")) {
// Trailing blanks only. Counted by index rather than with
// trimTrailingWhitespace(), which stops one character short and
// would leave " " for an all-blank value.
if(!in.ifNext("("))
throw coreutils::Exception("Expecting ( for RTRIM parameters.");
Operand parm1(in, tag);
if(in.ifNext(")")) {
const char *data = parm1.string.getData();
int len = parm1.string.getLength();
while((len > 0) && ((data[len - 1] == ' ') || (data[len - 1] == '\t') || (data[len - 1] == '\n')))
--len;
string = parm1.string.substring(0, len);
} else
throw coreutils::Exception("Expecting ) at end of RTRIM expression.");
} else if(in.ifNextIgnoreCase("TOUPPER")) {
if(!in.ifNext("("))
throw coreutils::Exception("Expecting ( for TOUPPER parameters.");
+305
View File
@@ -0,0 +1,305 @@
#include "SqlBind.h"
#include "Exception.h"
#include <cctype>
namespace jet {
namespace {
std::string lower(std::string s) {
for(char &c : s) c = (char)std::tolower((unsigned char)c);
return s;
}
std::string trim(const std::string &s) {
size_t b = 0, e = s.size();
while(b < e && std::isspace((unsigned char)s[b])) ++b;
while(e > b && std::isspace((unsigned char)s[e - 1])) --e;
return s.substr(b, e - b);
}
std::string where(int position) {
return "bind " + std::to_string(position) + ": ";
}
bool allDigits(const std::string &s, size_t from, size_t to) {
if(from >= to) return false;
for(size_t i = from; i < to; ++i)
if(!std::isdigit((unsigned char)s[i])) return false;
return true;
}
// ^-?[0-9]{1,maxDigits}$
bool isInteger(const std::string &s, size_t maxDigits) {
size_t start = (!s.empty() && s[0] == '-') ? 1 : 0;
size_t digits = s.size() - start;
return digits >= 1 && digits <= maxDigits && allDigits(s, start, s.size());
}
// ^-?[0-9]{1,30}(\.[0-9]{1,30})?$
bool isDecimal(const std::string &s) {
size_t dot = s.find('.');
if(dot == std::string::npos) return isInteger(s, 30);
std::string frac = s.substr(dot + 1);
return isInteger(s.substr(0, dot), 30) && frac.size() >= 1 && frac.size() <= 30 && allDigits(frac, 0, frac.size());
}
int num(const std::string &s, size_t at, size_t len) {
return std::stoi(s.substr(at, len));
}
// YYYY-MM-DD with a real month and day range.
bool isDate(const std::string &s) {
if(s.size() != 10 || s[4] != '-' || s[7] != '-') return false;
if(!allDigits(s, 0, 4) || !allDigits(s, 5, 7) || !allDigits(s, 8, 10)) return false;
int month = num(s, 5, 2), day = num(s, 8, 2);
return month >= 1 && month <= 12 && day >= 1 && day <= 31;
}
// YYYY-MM-DD HH:MM or YYYY-MM-DD HH:MM:SS
bool isDateTime(const std::string &s) {
if(s.size() != 16 && s.size() != 19) return false;
if(!isDate(s.substr(0, 10)) || s[10] != ' ' || s[13] != ':') return false;
if(!allDigits(s, 11, 13) || !allDigits(s, 14, 16)) return false;
if(num(s, 11, 2) > 23 || num(s, 14, 2) > 59) return false;
if(s.size() == 19) {
if(s[16] != ':' || !allDigits(s, 17, 19) || num(s, 17, 2) > 59) return false;
}
return true;
}
// Walks query and calls onPlaceholder(index) for every '?' that is
// outside '...', "...", `...`, -- / # line comments and /* */
// comments. With NO_BACKSLASH_ESCAPES off, a backslash escapes the
// next character inside '...' and "..."; with it on, it doesn't.
// A doubled quote ('', "", ``) is an escaped quote in every mode.
template<typename F>
void scan(const std::string &q, bool noBackslashEscapes, F onPlaceholder) {
size_t i = 0, n = q.size();
while(i < n) {
char c = q[i];
if(c == '\'' || c == '"' || c == '`') {
char quote = c;
++i;
while(i < n) {
if(quote != '`' && !noBackslashEscapes && q[i] == '\\') { i += 2; continue; }
if(q[i] == quote) {
if(i + 1 < n && q[i + 1] == quote) { i += 2; continue; }
++i;
break;
}
++i;
}
continue;
}
if(c == '#' || (c == '-' && i + 1 < n && q[i + 1] == '-' &&
(i + 2 >= n || (unsigned char)q[i + 2] <= ' '))) {
while(i < n && q[i] != '\n') ++i;
continue;
}
if(c == '/' && i + 1 < n && q[i + 1] == '*') {
size_t end = q.find("*/", i + 2);
i = (end == std::string::npos) ? n : end + 2;
continue;
}
if(c == '?') onPlaceholder(i);
++i;
}
}
// Lowercased words ([a-z0-9_@.$]) outside quotes and comments.
std::vector<std::string> words(const std::string &q) {
std::vector<std::string> out;
std::string cur;
size_t i = 0, n = q.size();
auto flush = [&]() { if(!cur.empty()) { out.push_back(lower(cur)); cur.clear(); } };
while(i < n) {
char c = q[i];
if(c == '\'' || c == '"' || c == '`') {
flush();
char quote = c;
++i;
while(i < n) {
if(quote != '`' && q[i] == '\\') { i += 2; continue; }
if(q[i] == quote) {
if(i + 1 < n && q[i + 1] == quote) { i += 2; continue; }
++i;
break;
}
++i;
}
out.push_back("'"); // a literal stands between words
continue;
}
if(c == '#' || (c == '-' && i + 1 < n && q[i + 1] == '-' &&
(i + 2 >= n || (unsigned char)q[i + 2] <= ' '))) {
flush();
while(i < n && q[i] != '\n') ++i;
continue;
}
if(c == '/' && i + 1 < n && q[i + 1] == '*') {
flush();
size_t end = q.find("*/", i + 2);
i = (end == std::string::npos) ? n : end + 2;
continue;
}
if(std::isalnum((unsigned char)c) || c == '_' || c == '@' || c == '.' || c == '$')
cur += c;
else
flush();
++i;
}
flush();
return out;
}
}
BoundValue makeBoundValue(const std::string &value,
const std::string &typeIn,
const std::string &nullModeIn,
bool hasAllow,
const std::string &allow,
int position) {
std::string type = typeIn.empty() ? "string" : lower(trim(typeIn));
std::string nullMode = lower(trim(nullModeIn));
if(nullMode != "" && nullMode != "empty")
throw coreutils::Exception(where(position) + "null must be \"empty\".");
if(hasAllow && type != "ident")
throw coreutils::Exception(where(position) + "allow is only valid with type=\"ident\".");
BoundValue b;
if(nullMode == "empty" && value.empty()) {
b.kind = BoundValue::SQLNULL;
return b;
}
if(type == "string") {
b.kind = BoundValue::QUOTED;
b.text = value;
} else if(type == "int") {
if(!isInteger(value, 19))
throw coreutils::Exception(where(position) + "value is not a valid int.");
b.kind = BoundValue::BARE;
b.text = value;
} else if(type == "decimal") {
if(!isDecimal(value))
throw coreutils::Exception(where(position) + "value is not a valid decimal.");
b.kind = BoundValue::BARE;
b.text = value;
} else if(type == "bool") {
std::string v = lower(value);
b.kind = BoundValue::BARE;
if(v == "1" || v == "true" || v == "yes")
b.text = "1";
else if(v == "0" || v == "false" || v == "no")
b.text = "0";
else
throw coreutils::Exception(where(position) + "value is not a valid bool.");
} else if(type == "date") {
if(!isDate(value))
throw coreutils::Exception(where(position) + "value is not a valid date (YYYY-MM-DD).");
b.kind = BoundValue::QUOTED;
b.text = value;
} else if(type == "datetime") {
if(!isDateTime(value))
throw coreutils::Exception(where(position) + "value is not a valid datetime (YYYY-MM-DD HH:MM[:SS]).");
b.kind = BoundValue::QUOTED;
b.text = value;
} else if(type == "ident") {
if(!hasAllow)
throw coreutils::Exception(where(position) + "type=\"ident\" requires an allow list.");
// Match case-insensitively, but emit the allow list's own spelling:
// what reaches the query always comes from the page, never the request.
std::string match;
bool found = false;
size_t start = 0;
while(start <= allow.size()) {
size_t comma = allow.find(',', start);
if(comma == std::string::npos) comma = allow.size();
std::string entry = trim(allow.substr(start, comma - start));
if(!entry.empty() && lower(entry) == lower(value)) {
match = entry;
found = true;
break;
}
start = comma + 1;
}
if(!found)
throw coreutils::Exception(where(position) + "value is not in the allow list.");
b.kind = BoundValue::BARE;
std::string m = lower(match);
if(m == "asc" || m == "desc") {
b.text = (m == "asc") ? "ASC" : "DESC";
} else {
b.text = "`";
for(char c : match) {
if(c == '`') b.text += '`';
b.text += c;
}
b.text += "`";
}
} else
throw coreutils::Exception(where(position) + "unknown type \"" + type + "\".");
return b;
}
size_t countPlaceholders(const std::string &query, bool noBackslashEscapes) {
size_t count = 0;
scan(query, noBackslashEscapes, [&](size_t) { ++count; });
return count;
}
std::string bindPlaceholders(const std::string &query,
const std::vector<BoundValue> &values,
bool noBackslashEscapes,
const std::function<std::string(const std::string &)> &quoteEscape) {
std::vector<size_t> at;
scan(query, noBackslashEscapes, [&](size_t i) { at.push_back(i); });
if(at.size() != values.size())
throw coreutils::Exception("sql: " + std::to_string(at.size()) + " placeholders but " +
std::to_string(values.size()) + " bind values");
std::string out;
out.reserve(query.size() + 32 * values.size());
size_t last = 0;
for(size_t k = 0; k < at.size(); ++k) {
out.append(query, last, at[k] - last);
const BoundValue &v = values[k];
if(v.kind == BoundValue::SQLNULL)
out += "NULL";
else if(v.kind == BoundValue::BARE)
out += v.text;
else {
out += '\'';
out += quoteEscape(v.text);
out += '\'';
}
last = at[k] + 1;
}
out.append(query, last, std::string::npos);
return out;
}
bool isCharsetChange(const std::string &query) {
std::vector<std::string> w = words(query);
if(w.empty() || w[0] != "set")
return false;
for(size_t i = 1; i < w.size(); ++i) {
const std::string &x = w[i];
if(x == "names" || x == "charset")
return true;
if(x == "character" && i + 1 < w.size() && w[i + 1] == "set")
return true;
// character_set_client, @@character_set_client, @@session.character_set_client, ...
for(const char *var : {"character_set_client", "character_set_connection", "collation_connection"}) {
std::string v(var);
if(x.size() >= v.size() && x.compare(x.size() - v.size(), v.size(), v) == 0)
return true;
}
}
return false;
}
}
+64
View File
@@ -0,0 +1,64 @@
#ifndef __SqlBind_h__
#define __SqlBind_h__
#include <functional>
#include <string>
#include <vector>
// Bound parameters for <sql> - see docs/design-sql-bound-parameters.md.
//
// Everything here is plain string logic with no MySQL or Tag dependency,
// so it can be unit tested on its own (tests/sqlbind_test.cpp). __bind
// builds BoundValues with makeBoundValue(); __sql substitutes them into
// the rendered query with bindPlaceholders(), passing in the connection's
// own escaping function.
namespace jet {
struct BoundValue {
enum Kind {
SQLNULL, // emitted as NULL
BARE, // already validated (int/decimal/bool/ASC/DESC/`ident`) - emitted as is
QUOTED // escaped with the connection's escaper and wrapped in '...'
};
Kind kind = QUOTED;
std::string text;
};
// Validates value against type and returns how it must be emitted.
// position is the 1-based bind number, used only in error messages.
// Error messages never contain the value itself (it may be a password).
// type: string (default if empty), int, decimal, bool, date, datetime, ident
// nullMode: "" (bind '' for an empty value) or "empty" (bind NULL)
// allow: comma list of permitted identifiers - required for ident,
// not allowed on any other type
BoundValue makeBoundValue(const std::string &value,
const std::string &type,
const std::string &nullMode,
bool hasAllow,
const std::string &allow,
int position);
// Number of '?' placeholders in query that are outside string literals,
// backtick identifiers and comments.
size_t countPlaceholders(const std::string &query, bool noBackslashEscapes);
// Replaces each placeholder (as counted above) with the matching bound
// value, in order. Throws if the placeholder and value counts differ.
// quoteEscape escapes the body of a single-quoted string literal (no
// surrounding quotes) for the actual connection.
std::string bindPlaceholders(const std::string &query,
const std::vector<BoundValue> &values,
bool noBackslashEscapes,
const std::function<std::string(const std::string &)> &quoteEscape);
// True for a SET statement that changes the connection character set
// (SET NAMES, SET CHARACTER SET, SET CHARSET, or an assignment to
// character_set_client / character_set_connection / collation_connection).
// Changing it after connect makes client-side escaping and server-side
// parsing disagree, so <sql> refuses these.
bool isCharsetChange(const std::string &query);
}
#endif
+123 -45
View File
@@ -6,11 +6,13 @@
#include "Global.h"
#include "__mysql.h"
#include "__sql.h"
#include "__bind.h"
#include "__imap.h"
#include "__imaplist.h"
#include "__imapmessage.h"
#include "__imapflag.h"
#include "__imapdelete.h"
#include "__imapemptyfolder.h"
#include "__imapmove.h"
#include "__imapfolders.h"
#include "__imapsearch.h"
@@ -64,6 +66,10 @@ namespace jet {
bool finished = false;
while(!finished) {
in.skipWhitespace();
// Nothing below makes progress at end of data, so a tag that
// never closes would otherwise loop here forever.
if(in.eod())
throw coreutils::Exception("unterminated <" + name.str() + "> tag.");
if(in.ifNext(">")) {
// jet-1.4's real parser knew which built-ins never take
// a body (its own "void element" list) - real 1.4
@@ -87,7 +93,7 @@ namespace jet {
(nameLower == "cookie") || (nameLower == "header") ||
(nameLower == "read") || (nameLower == "write") ||
(nameLower == "call") || (nameLower == "system") ||
(nameLower == "dump");
(nameLower == "dump") || (nameLower == "bind");
// A CUSTOM tag (not one of jet's own built-ins above)
// written bare, with no explicit close, is genuinely
// ambiguous: is a real body coming (scan for
@@ -154,7 +160,8 @@ namespace jet {
keywords[keywordName] = in.getTokenExclude(dq ? "\"" : "'");
else
throw coreutils::Exception("keyword name must be unique for tag.");
in.ifNext(dq ? "\"" : "'");
if(!in.ifNext(dq ? "\"" : "'"))
throw coreutils::Exception("unterminated value for " + keywordName.str() + " in <" + name.str() + ">.");
} else if(keywordName.getLength() > 0) {
// Unquoted attribute value (e.g. TYPE=NE, SCOPE=LOCAL - real
// 1.4 content throughout). Neither quote style matched, but
@@ -215,9 +222,40 @@ namespace jet {
// matches the same unconsumed <catch> on every subsequent
// iteration forever. Build the real expected delimiter
// from splitTagName itself so it works for any split tag.
coreutils::MString splitOpenTag;
splitOpenTag << "<" << splitTagName << ">";
in.ifNextIgnoreCase(splitOpenTag);
in.ifNext("<");
in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
while(!in.eod()) {
in.skipWhitespace();
if(in.ifNext(">"))
break;
else if(coreutils::ZString attrName = in.getTokenExclude("="); attrName.getLength() != 0) {
bool dq = in.ifNext("=\"");
bool sq = !dq && in.ifNext("='");
if(dq || sq) {
// Keep the attribute (e.g. <catch name="err">) - it used
// to be skipped and dropped, so <catch name=...> never
// stored the error and every caught error read as "".
char *valueStart = in.getCursor();
while(1) {
char *valueEnd = in.getCursor();
if(in.ifNext(dq ? "\"" : "'")) {
splitKeywords[coreutils::MString(attrName)] = coreutils::MString(coreutils::ZString(valueStart, valueEnd - valueStart));
break;
}
in.nextChar();
}
} else {
in.nextChar();
while(!in.eod()) {
char c = in.charAt(0);
if(c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '>' || c == '/')
break;
in.nextChar();
}
}
} else
break;
}
start = in.getCursor();
} else if(ifNested(in)) {
} else
@@ -462,6 +500,9 @@ namespace jet {
} else if(ifTagName(in, "sql")) {
__sql _sql(in, out, global, this, local);
continue;
} else if(ifTagName(in, "bind")) {
__bind _bind(in, out, global, this, local);
continue;
} else if(ifTagName(in, "imap")) {
__imap _imap(in, out, global, this, local);
continue;
@@ -477,6 +518,9 @@ namespace jet {
} else if(ifTagName(in, "imapdelete")) {
__imapdelete _imapdelete(in, out, global, this, local);
continue;
} else if(ifTagName(in, "imapemptyfolder")) {
__imapemptyfolder _imapemptyfolder(in, out, global, this, local);
continue;
} else if(ifTagName(in, "imapmove")) {
__imapmove _imapmove(in, out, global, this, local);
continue;
@@ -737,16 +781,53 @@ namespace jet {
bool Tag::ifSplitTagName(coreutils::ZString &in) {
in.push();
if(in.ifNext("<"))
if(coreutils::MString(in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_")).toLower() == coreutils::MString(splitTagName).toLower()) {
if(in.ifNext(">"))
in.pop();
return true;
}
if(in.ifNext("<")) {
if(coreutils::MString(in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_")).toLower() == coreutils::MString(splitTagName).toLower()) {
// Tolerate attributes on the split-tag marker itself (e.g.
// <try>'s own <catch name="_imaperr">) rather than requiring
// '>' to land immediately after the tag name - every
// splitTagName="else" caller writes a bare <else> so this
// never mattered for them, but <catch name="..."> is the
// universal convention everywhere it's used. Previously this
// whole check was a single unbraced
// if(...){in.pop();return true;} where the missing braces
// meant "return true" executed unconditionally, leaving the
// cursor in a half-advanced, never-popped state on the
// attributed-tag path - confirmed live via a real /email/list
// failure whose caught error text leaked
// "name=\"_imaperr\">" into the JSON response.
while(!in.eod()) {
in.skipWhitespace();
if(in.ifNext(">")) {
in.pop();
return true;
} else if(in.getTokenExclude("=").getLength() != 0) {
bool dq = in.ifNext("=\"");
bool sq = !dq && in.ifNext("='");
if(dq || sq) {
while(1) {
if(in.ifNext(dq ? "\"" : "'"))
break;
in.nextChar();
}
} else {
in.nextChar();
while(!in.eod()) {
char c = in.charAt(0);
if(c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '>' || c == '/')
break;
in.nextChar();
}
}
} else
break;
}
}
}
in.pop();
return false;
}
int Tag::skipBlankLine(coreutils::ZString in) {
ZString temp = in.getTokenInclude(" \t");
if(ifNext("\n"))
@@ -840,7 +921,12 @@ namespace jet {
}
if(hasContainer)
scanContainer(in);
return false;
// true: the cursor is already past the nested tag. Returning false
// made both callers also nextChar(), skipping the first character
// after it - so a marker right after the nested close (</if></if>,
// </if><else>, </try><catch>) was never seen and the outer tag
// lost its own end or split.
return true;
}
// Same-name match failed - if THIS tag itself is one of the
// splitTagName="else" conditionals (if/while/until/ifrow), a
@@ -860,7 +946,7 @@ namespace jet {
if(splitTagName == "else") {
for(int i = 0; i < elseSplitTagNameCount; i++) {
if(ifNested(in, elseSplitTagNames[i]))
break;
return true;
}
}
return false;
@@ -1189,6 +1275,17 @@ namespace jet {
(*global.sessionFile)[sessionName] = value;
return;
}
if(coreutils::MString(scope).toLower() == "session") {
// <set name="x" scope="session"> - the supported way to write a
// session variable (sessionctl's <setenv> and the "@name" prefix
// above are deprecated). Any name, no '@'. Copied into its own
// MString for the same JString::locate() reason as above.
coreutils::MString sessionName(variable);
if(global.sessionFile == NULL)
throw coreutils::Exception("scope=\"session\" requested but no session is active (missing sessiondir keyword, or cgi mode is off).");
(*global.sessionFile)[sessionName] = value;
return;
}
if((scope == "global") || (scope == ""))
global.variables[variable] = value;
else if(scope == "local") {
@@ -1244,38 +1341,19 @@ namespace jet {
}
void Tag::storeVariable(coreutils::ZString variable) {
if(keywordDefined("expr")) {
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
assignVariable(variable, Operand(keywords["expr"], *this).string, "global");
else if(resolveKeyword("scope").toLower() == "local")
assignVariable(variable, Operand(keywords["expr"], *this).string, "local");
else if(resolveKeyword("scope").toLower() == "parent")
assignVariable(variable, Operand(keywords["expr"], *this).string, "parent");
} else if(hasContainer) {
coreutils::MString scope("global");
if(keywordDefined("scope"))
scope = resolveKeyword("scope").toLower();
if(keywordDefined("expr"))
assignVariable(variable, Operand(keywords["expr"], *this).string, scope);
else if(hasContainer) {
processContainer(container);
if(evaluate) {
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
assignVariable(variable, out, "global");
else if(resolveKeyword("scope").toLower() == "local")
assignVariable(variable, out, "local");
else if(resolveKeyword("scope").toLower() == "parent")
assignVariable(variable, out, "parent");
} else {
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
assignVariable(variable, container, "global");
else if(resolveKeyword("scope").toLower() == "local")
assignVariable(variable, container, "local");
else if(resolveKeyword("scope").toLower() == "parent")
assignVariable(variable, container, "parent");
}
} else {
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
assignVariable(variable, resolveKeyword("value"), "global");
else if(resolveKeyword("scope").toLower() == "local")
assignVariable(variable, resolveKeyword("value"), "local");
else if(resolveKeyword("scope").toLower() == "parent")
assignVariable(variable, resolveKeyword("value"), "parent");
}
if(evaluate)
assignVariable(variable, out, scope);
else
assignVariable(variable, container, scope);
} else
assignVariable(variable, resolveKeyword("value"), scope);
}
coreutils::MString Tag::processModifier(coreutils::MString &value, coreutils::MString &modifier) {
+6
View File
@@ -139,6 +139,12 @@ namespace jet {
void scanContainerNamed(coreutils::ZString &in, const char *tagName);
coreutils::MString processModifier(coreutils::MString &value, coreutils::MString &modifier);
public:
// The split tag's own attributes (raw, unresolved) - e.g. <try>'s
// <catch name="err">, so __trytag can bind the error to that name.
// Last member on purpose: adding it changes no other member's offset.
std::map<coreutils::MString, coreutils::MString> splitKeywords;
};
}
+29
View File
@@ -0,0 +1,29 @@
#include "__bind.h"
#include "__sql.h"
#include "Exception.h"
#include "SqlBind.h"
namespace jet {
__bind::__bind(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
output = false;
// Nearest enclosing <sql>, through any <if>/<for>/etc. in between.
__sql *sql = NULL;
for(Tag *scope = parent; scope && !sql; scope = scope->parent)
sql = dynamic_cast<__sql *>(scope);
if(!sql)
throw coreutils::Exception("bind must be inside sql.");
if(!keywordDefined("value"))
throw coreutils::Exception("bind must have a value.");
std::string value = resolveKeyword("value").str();
std::string type = keywordDefined("type") ? resolveKeyword("type").str() : "";
std::string nullMode = keywordDefined("null") ? resolveKeyword("null").str() : "";
bool hasAllow = keywordDefined("allow");
std::string allow = hasAllow ? resolveKeyword("allow").str() : "";
sql->addBind(makeBoundValue(value, type, nullMode, hasAllow, allow, (int)sql->bindCount() + 1));
}
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef ____bind_h__
#define ____bind_h__
#include "Tag.h"
namespace jet {
// <bind value="..." [type="..."] [null="empty"] [allow="a,b"]> - supplies
// the value for the next '?' placeholder of the enclosing <sql>. Always
// void (no closing tag) and produces no output. See
// docs/design-sql-bound-parameters.md.
class __bind : public Tag {
public:
__bind(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
};
}
#endif
+73 -26
View File
@@ -7,13 +7,15 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <cerrno>
#include <cstring>
#include <filesystem>
namespace jet {
__call::__call(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
if(hasContainer && keywordDefined("input"))
throw coreutils::Exception("call tag cannot have both input keyword and have a container.");
throw coreutils::Exception("call tag cannot have both input keyword and have a container.");
if(!keywordDefined("pgm"))
throw coreutils::Exception("pgm keyword must be specified.");
for(ix = 0; ix < 50; ++ix)
@@ -35,48 +37,93 @@ namespace jet {
} else
break;
}
pipe(fdo);
// pipe()/fork() both used to go unchecked here - on failure (most
// realistically pipe() hitting the process's open-file-descriptor
// limit, see below) fdo[] is left holding whatever garbage was
// already on the stack/in this member array, and every use of it
// after this point (close(), read(), and - for a failed fork() -
// waitpid(-1, ...), which has the special POSIX meaning "wait for
// ANY child" rather than "wait for none") operates on that garbage
// or on an unrelated process instead of safely no-oping. That's a
// real, confirmed mechanism for exactly the kind of sporadic
// memory corruption this codebase has seen: closing/reading a
// stale fd that coincidentally matches another subsystem's live
// socket, or reaping a concurrent request's own child out from
// under it.
if(pipe(fdo) != 0)
throw coreutils::Exception("call: pipe() failed - " + std::string(strerror(errno)), __FILE__, __LINE__, 500);
pid = fork();
if(pid < 0) {
close(fdo[0]);
close(fdo[1]);
throw coreutils::Exception("call: fork() failed - " + std::string(strerror(errno)), __FILE__, __LINE__, 500);
}
if(pid == 0) {
close(fdo[0]);
dup2(fdo[1], 1);
if(hasContainer) {
pipe(fdi);
if(fork() == 0) {
close(fdi[0]);
write(fdi[1], container.getData(), container.getLength());
close(fdi[1]);
exit(0);
if(hasContainer) {
if(pipe(fdi) == 0) {
pid_t innerPid = fork();
if(innerPid == 0) {
close(fdi[0]);
write(fdi[1], container.getData(), container.getLength());
close(fdi[1]);
_exit(0);
} else if(innerPid > 0) {
close(fdi[1]);
dup2(fdi[0], 0);
close(fdi[0]);
} else {
close(fdi[0]);
close(fdi[1]);
}
}
close(fdi[1]);
dup2(fdi[0], 0);
} else if(keywordDefined("input")) {
coreutils::MString input(resolveKeyword("input"));
pipe(fdi);
if(fork() == 0) {
close(fdi[0]);
write(fdi[1], input.getData(), input.getLength());
close(fdi[1]);
exit(0);
if(pipe(fdi) == 0) {
pid_t innerPid = fork();
if(innerPid == 0) {
close(fdi[0]);
write(fdi[1], input.getData(), input.getLength());
close(fdi[1]);
_exit(0);
} else if(innerPid > 0) {
close(fdi[1]);
dup2(fdi[0], 0);
close(fdi[0]);
} else {
close(fdi[0]);
close(fdi[1]);
}
}
close(fdi[1]);
dup2(fdi[0], 0);
}
rc = execvpe(argv[0], argv, global.envp);
close(fdo[1]);
exit(errno);
_exit(errno);
}
close(fdo[1]);
if(keywordDefined("name")) {
coreutils::MString value;
value.read(fdo[0]);
storeVariable(resolveKeyword("name"), value, resolveKeyword("scope"));
} else
out.read(fdo[0]);
} else
out.read(fdo[0]);
// fdo[0] (the read end, still open in this - the parent - process)
// was never closed here before, leaking one file descriptor on
// every single <call> invocation for the life of the process.
// Harmless-looking for an occasional <call>, but <call> is used
// throughout this codebase (jq/curl parsing, mailcreate, this
// session's own per-line-item JS-escaping on the invoice editor,
// which alone can issue a double-digit number of calls per page
// load) - repeated, routine use was slowly accumulating leaked
// fds for as long as this process stayed up, eventually hitting
// the real open-files limit and turning into exactly the pipe()
// failures (and the undefined behavior above) this fix addresses.
close(fdo[0]);
waitpid(pid, &status, 0);
if(keywordDefined("error")) {
if(keywordDefined("error")) {
global.variables[resolveKeyword("error")] = (status >> 8 & 255);
}
}
}
}
+47 -14
View File
@@ -559,8 +559,15 @@ namespace jet {
coreutils::MString passwordVal = resolveKeyword("password");
coreutils::JFile config(configPath);
std::string host = config.getString("host");
long port = (long)config.getNumber("port");
// host/port keywords override the config file's own values when
// present - lets a caller reuse one config file (still needed for
// caCertificate/smtpPort) across many accounts that each live on
// a different mail server, rather than requiring a separate config
// file per server. Every existing caller omits these keywords, so
// behavior is unchanged for them - config's own host/port is still
// the only thing read in that case.
std::string host = keywordDefined("host") ? resolveKeyword("host").str() : config.getString("host");
long port = keywordDefined("port") ? strtol(resolveKeyword("port").str().c_str(), nullptr, 10) : (long)config.getNumber("port");
if (port <= 0)
port = 993;
@@ -832,7 +839,7 @@ namespace jet {
return extractLiteralAt(fetchLine, braceEnd);
}
coreutils::MString __imap::listMessages(const std::string &folder, int limit) {
coreutils::MString __imap::listMessages(const std::string &folder, int limit, int offset) {
if (!selectFolderIfNeeded(folder))
throw coreutils::Exception("imap: could not select folder " + folder, __FILE__, __LINE__, 502);
@@ -843,22 +850,30 @@ namespace jet {
throw coreutils::Exception("imap: FETCH failed", __FILE__, __LINE__, 502);
std::vector<std::string> items = parseSummaryLines(lines);
int total = (int)items.size();
// Keep only the newest `limit` - UIDs are assigned in strictly
// ascending delivery order (see MailFolder.h, BARANTMail, built
// earlier this session), so the tail of this UID-ascending list
// is the newest mail.
if ((int)items.size() > limit)
items.erase(items.begin(), items.end() - limit);
std::reverse(items.begin(), items.end());
// items is UID-ascending (oldest-first) - UIDs are assigned in
// strictly ascending delivery order (see MailFolder.h, BARANTMail,
// built earlier this session), so the tail is the newest mail.
// `offset` counts back from the newest message (0 = the very
// newest), so the page is the `limit`-wide slice ending `offset`
// messages from the end.
int end = total - offset;
if (end < 0)
end = 0;
int start = end - limit;
if (start < 0)
start = 0;
std::vector<std::string> page(items.begin() + start, items.begin() + end);
std::reverse(page.begin(), page.end());
std::string json = "[";
for (size_t i = 0; i < items.size(); ++i) {
std::string json = "{\"total\":" + std::to_string(total) + ",\"messages\":[";
for (size_t i = 0; i < page.size(); ++i) {
if (i)
json += ",";
json += items[i];
json += page[i];
}
json += "]";
json += "]}";
return coreutils::MString(json);
}
@@ -1026,6 +1041,24 @@ namespace jet {
return coreutils::MString(std::string("{\"ok\":") + (ok ? "true" : "false") + "}");
}
coreutils::MString __imap::emptyFolder(const std::string &folder) {
if (!selectFolderIfNeeded(folder))
throw coreutils::Exception("imap: could not select folder " + folder, __FILE__, __LINE__, 502);
std::string tag = nextTag();
sendLine(tag + " UID STORE 1:* +FLAGS (\\Deleted)");
auto lines = readUntilTagged(tag);
bool ok1 = taggedOk(lines, tag);
std::string tag2 = nextTag();
sendLine(tag2 + " EXPUNGE");
auto lines2 = readUntilTagged(tag2);
bool ok2 = taggedOk(lines2, tag2);
bool ok = ok1 && ok2;
return coreutils::MString(std::string("{\"ok\":") + (ok ? "true" : "false") + "}");
}
// BARANTMail (see __IMAP_COPY.cpp) implements COPY but not the
// RFC 6851 MOVE extension - not surprising, since the whole point
// of that extension was standardizing what every real-world client
+12 -1
View File
@@ -55,12 +55,23 @@ namespace jet {
// just write whatever this returns straight into their own `out`,
// the same one-call-does-everything shape __sql's query() call
// has relative to <sql>.
coreutils::MString listMessages(const std::string &folder, int limit);
/// offset counts back from the newest message (0 = the newest
/// page); the returned JSON is {"total":N,"messages":[...]}.
coreutils::MString listMessages(const std::string &folder, int limit, int offset);
coreutils::MString searchMessages(const std::string &folder, const std::string &query);
coreutils::MString fetchMessage(const std::string &folder, uint32_t uid);
coreutils::MString setFlag(const std::string &folder, uint32_t uid, const std::string &flag, bool add);
coreutils::MString deleteMessage(const std::string &folder, uint32_t uid);
coreutils::MString moveMessage(const std::string &folder, uint32_t uid, const std::string &destFolder);
// Permanently empties an entire folder - every message, not one at
// a time. "1:*" is IMAP's standard UID-range syntax for "every UID
// in the selected mailbox" (well-defined and a no-op, not an error,
// on an already-empty folder - verified directly against
// BARANTMail rather than assumed from the RFC), so this is a
// single mark-all-deleted STORE plus one EXPUNGE, not a loop over
// deleteMessage() - the whole point is one IMAP round trip instead
// of one per message.
coreutils::MString emptyFolder(const std::string &folder);
coreutils::MString folderCounts();
coreutils::MString sessionId;
+43 -19
View File
@@ -37,8 +37,8 @@ namespace jet {
return s.substr(start, end - start + 1);
}
std::vector<std::pair<std::string, std::string>> __imapaccounts::decodeList(const std::string &encodedRaw) {
std::vector<std::pair<std::string, std::string>> entries;
std::vector<__imapaccounts::Account> __imapaccounts::decodeList(const std::string &encodedRaw) {
std::vector<Account> entries;
coreutils::Base64 base64;
// The list value round-trips through <eval>/<set> template
// captures, which include whatever whitespace/newlines surround
@@ -56,26 +56,35 @@ namespace jet {
entry = trimWhitespace(entry);
if (entry.empty())
continue;
size_t colon = entry.find(':');
if (colon == std::string::npos)
size_t colon1 = entry.find(':');
if (colon1 == std::string::npos)
continue;
std::string userB64 = trimWhitespace(entry.substr(0, colon));
std::string passB64 = trimWhitespace(entry.substr(colon + 1));
std::string user = base64.decode(userB64).str();
std::string password = base64.decode(passB64).str();
entries.push_back(std::make_pair(user, password));
size_t colon2 = entry.find(':', colon1 + 1);
if (colon2 == std::string::npos)
continue;
std::string hostB64 = trimWhitespace(entry.substr(0, colon1));
std::string userB64 = trimWhitespace(entry.substr(colon1 + 1, colon2 - colon1 - 1));
std::string passB64 = trimWhitespace(entry.substr(colon2 + 1));
Account account;
account.host = base64.decode(hostB64).str();
account.user = base64.decode(userB64).str();
account.password = base64.decode(passB64).str();
entries.push_back(account);
}
return entries;
}
std::string __imapaccounts::encodeList(const std::vector<std::pair<std::string, std::string>> &entries) {
std::string __imapaccounts::encodeList(const std::vector<Account> &entries) {
coreutils::Base64 base64;
std::string result;
for (size_t i = 0; i < entries.size(); i++) {
if (i > 0)
result += ";";
std::string user = entries[i].first;
std::string password = entries[i].second;
std::string host = entries[i].host;
std::string user = entries[i].user;
std::string password = entries[i].password;
result += base64.encode(host).str();
result += ":";
result += base64.encode(user).str();
result += ":";
result += base64.encode(password).str();
@@ -90,20 +99,25 @@ namespace jet {
auto entries = decodeList(listStr);
if (action == "add") {
std::string host = trimWhitespace(resolveKeyword("host").str());
std::string user = trimWhitespace(resolveKeyword("user").str());
std::string password = trimWhitespace(resolveKeyword("password").str());
for (size_t i = 0; i < entries.size(); i++) {
if (entries[i].first == user) {
if (entries[i].user == user) {
entries.erase(entries.begin() + (long)i);
break;
}
}
entries.push_back(std::make_pair(user, password));
Account account;
account.host = host;
account.user = user;
account.password = password;
entries.push_back(account);
out = coreutils::MString(encodeList(entries));
} else if (action == "remove") {
std::string user = trimWhitespace(resolveKeyword("user").str());
for (size_t i = 0; i < entries.size(); i++) {
if (entries[i].first == user) {
if (entries[i].user == user) {
entries.erase(entries.begin() + (long)i);
break;
}
@@ -113,21 +127,31 @@ namespace jet {
std::string user = trimWhitespace(resolveKeyword("user").str());
std::string password;
for (size_t i = 0; i < entries.size(); i++) {
if (entries[i].first == user) {
password = entries[i].second;
if (entries[i].user == user) {
password = entries[i].password;
break;
}
}
out = coreutils::MString(password);
} else if (action == "gethost") {
std::string user = trimWhitespace(resolveKeyword("user").str());
std::string host;
for (size_t i = 0; i < entries.size(); i++) {
if (entries[i].user == user) {
host = entries[i].host;
break;
}
}
out = coreutils::MString(host);
} else if (action == "firstuser") {
out = coreutils::MString(entries.empty() ? std::string() : entries[0].first);
out = coreutils::MString(entries.empty() ? std::string() : entries[0].user);
} else if (action == "list") {
std::string active = resolveKeyword("active").str();
std::string json = "{\"accounts\":[";
for (size_t i = 0; i < entries.size(); i++) {
if (i > 0)
json += ",";
json += "\"" + jsonEscape(entries[i].first) + "\"";
json += "\"" + jsonEscape(entries[i].user) + "\"";
}
json += "],\"active\":\"" + jsonEscape(active) + "\"}";
out = coreutils::MString(json);
+24 -13
View File
@@ -11,8 +11,8 @@
namespace jet {
///
/// <imapaccounts action="add|remove|getpassword|firstuser|list"
/// list="$[@_imap_accounts]" user="..." password="...">
/// <imapaccounts action="add|remove|getpassword|gethost|firstuser|list"
/// list="$[@_imap_accounts]" host="..." user="..." password="...">
///
/// Pure list-transform tag (no session-variable access of its own,
/// no IMAP connection) that manages the multi-account list webmail
@@ -23,34 +23,45 @@ namespace jet {
/// touches Global's session-variable map directly).
///
/// The list's own on-the-wire encoding (semicolon-separated
/// "base64(user):base64(password)" entries) is private to this tag -
/// callers only ever pass the whole `list` value back in verbatim
/// and use the returned value the same way, so the choice of
/// delimiter can't collide with any real username or password
/// character.
/// "base64(host):base64(user):base64(password)" entries) is private
/// to this tag - callers only ever pass the whole `list` value back
/// in verbatim and use the returned value the same way, so the
/// choice of delimiter can't collide with any real username or
/// password character. Each account can live on its own IMAP server
/// (see the <imap>/<imaplist>/etc. tags' own optional host/port
/// keywords), not just the one fixed host in email.cfg.
///
/// action="add": upserts user/password (removing any existing entry
/// for the same user first, so reconnecting with a changed password
/// updates it) - returns the updated encoded list.
/// action="add": upserts host/user/password (removing any existing
/// entry for the same user first, so reconnecting with a changed
/// password or server updates it) - returns the updated encoded list.
/// action="remove": drops the entry for user, if present - returns
/// the updated encoded list.
/// action="getpassword": returns the stored password for user, or
/// an empty string if not present.
/// action="gethost": returns the stored host for user, or an empty
/// string if not present.
/// action="firstuser": returns the first entry's username, or an
/// empty string if the list is empty.
/// action="list": returns JSON ({"accounts":[...],"active":"..."})
/// - the one client-facing action; "active" echoes the `active`
/// keyword (typically $[@_imap_user]) back verbatim so the sidebar
/// can highlight the current one, and never includes any password.
/// can highlight the current one, and never includes any password or
/// host (unchanged shape from before per-account hosts existed -
/// nothing client-side needs the host to switch between already-
/// connected accounts).
///
class __imapaccounts : public Tag {
struct Account {
std::string host, user, password;
};
public:
__imapaccounts(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
private:
static std::vector<std::pair<std::string, std::string>> decodeList(const std::string &encoded);
static std::string encodeList(const std::vector<std::pair<std::string, std::string>> &entries);
static std::vector<Account> decodeList(const std::string &encoded);
static std::string encodeList(const std::vector<Account> &entries);
static std::string jsonEscape(const std::string &s);
};
+26
View File
@@ -0,0 +1,26 @@
#include "__imapemptyfolder.h"
#include "Exception.h"
#include "__imap.h"
namespace jet {
__imapemptyfolder::__imapemptyfolder(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
coreutils::MString sessionId = resolveKeyword("sessionid");
if (!global.imapSessionExists(sessionId))
throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502);
// Unlike __imapdelete (one message - low blast radius even on a
// wrong default), this permanently destroys an entire folder's
// contents - no silent "defaults to INBOX" here. A missing/blank
// folder attribute is refused outright rather than risked.
if (!keywordDefined("folder"))
throw coreutils::Exception("imapemptyfolder tag must have folder defined.", __FILE__, __LINE__, 400);
std::string folder = resolveKeyword("folder").str();
if (folder.empty())
throw coreutils::Exception("imapemptyfolder tag must have folder defined.", __FILE__, __LINE__, 400);
out = global.getImapSession(sessionId)->emptyFolder(folder);
}
}
+26
View File
@@ -0,0 +1,26 @@
#ifndef ____imapemptyfolder_h__
# define ____imapemptyfolder_h__
# include "Tag.h"
namespace jet {
///
/// <imapemptyfolder sessionid="" folder="Trash">
///
/// Self-closing tag - permanently deletes every message in the given
/// folder (mark-all-\Deleted + one EXPUNGE, not a per-message loop),
/// writes {"ok":true|false} into `out`. See __imaplist.h's doc
/// comment for how `out` reaches the real response body.
///
class __imapemptyfolder : public Tag {
public:
__imapemptyfolder(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
};
}
#endif
+6 -1
View File
@@ -20,7 +20,12 @@ namespace jet {
if (limit <= 0)
limit = 50;
out = global.getImapSession(sessionId)->listMessages(folder, limit);
std::string offsetStr = resolveKeyword("offset").str();
int offset = offsetStr.empty() ? 0 : atoi(offsetStr.c_str());
if (offset < 0)
offset = 0;
out = global.getImapSession(sessionId)->listMessages(folder, limit, offset);
}
}
+29
View File
@@ -108,6 +108,10 @@ namespace jet {
if(!mysql) {
MYSQL *handle = mysql_init(NULL);
// Pin the connection character set so <bind>'s client-side
// escaping and the server's parsing always agree (<sql> refuses
// SET NAMES and friends for the same reason).
mysql_options(handle, MYSQL_SET_CHARSET_NAME, "utf8mb4");
mysql = mysql_real_connect(handle,
hostVal.c_str(),
userVal.c_str(),
@@ -157,6 +161,18 @@ namespace jet {
void __mysql::query(coreutils::MString query) {
int rc = mysql_real_query(mysql, query.getData(), query.getLength());
// rc was captured but never checked - a genuinely failed query
// (syntax error, constraint violation, etc.) fell straight into
// the result==NULL branch below, which is ALSO the normal path
// for a successful non-SELECT statement (INSERT/UPDATE/DELETE
// have no result set to store either). That made every SQL error
// in the whole codebase silently indistinguishable from "ran fine,
// no rows" - <try>/<catch> around a failing <sql> never caught
// anything, since no exception was ever thrown in the first place.
// Only rc (mysql_real_query's own success/failure signal) can
// actually tell the two cases apart; result's nullness can't.
if(rc != 0)
throw coreutils::Exception(std::string("mysql query failed: ") + mysql_error(mysql));
result = mysql_store_result(mysql);
if(result) {
row = mysql_fetch_row(result);
@@ -195,6 +211,19 @@ namespace jet {
}
}
std::string __mysql::escapeString(const std::string &value) {
std::string to(value.size() * 2 + 1, '\0');
unsigned long len = mysql_real_escape_string_quote(mysql, to.data(), value.data(), value.size(), '\'');
if(len == (unsigned long)-1)
throw coreutils::Exception("sql: bind value could not be escaped.");
to.resize(len);
return to;
}
bool __mysql::noBackslashEscapes() {
return (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) != 0;
}
void __mysql::nextRow() {
row = mysql_fetch_row(result);
fieldLength = mysql_fetch_lengths(result);
+7
View File
@@ -21,6 +21,13 @@ namespace jet {
void nextRow();
bool hasRow();
coreutils::ZString getColumnValue(coreutils::ZString column);
// Body of a single-quoted SQL string literal for this connection
// (mysql_real_escape_string_quote: uses the connection's character
// set and honours NO_BACKSLASH_ESCAPES). Used by <bind>.
std::string escapeString(const std::string &value);
// True while the session's sql_mode includes NO_BACKSLASH_ESCAPES.
bool noBackslashEscapes();
private:
// Explicitly initialized - result/row/fieldLength were otherwise
+23
View File
@@ -10,6 +10,8 @@
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <sstream>
namespace jet {
@@ -88,10 +90,31 @@ namespace jet {
return std::string(buf);
}
// RFC 5322 3.6.4: Message-ID "SHOULD be present" - in practice
// several real receivers (confirmed live: Gmail) now hard-reject
// anything missing one ("550 5.7.1 Messages missing a valid
// Message-ID header are not accepted") rather than just marking it
// down, so this isn't optional in practice. Domain part is the
// sender's own domain (everything after '@' in `from`), matching
// RFC 5322's own recommendation that it be a name under the
// generating system's control - falls back to the literal `from`
// string in the (should-never-happen) case it has no '@' at all.
std::string __smtpsend::generateMessageId(const std::string &from) {
size_t at = from.find('@');
std::string domainPart = (at == std::string::npos) ? from : from.substr(at + 1);
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
std::ostringstream idStream;
idStream << ts.tv_sec << "." << std::setfill('0') << std::setw(9) << ts.tv_nsec
<< "." << rand() << "@" << domainPart;
return idStream.str();
}
std::string __smtpsend::buildMessage(const std::string &from, const std::string &to,
const std::string &subject, const std::string &html) {
std::string msg;
msg += "Date: " + rfc2822Date() + "\r\n";
msg += "Message-ID: <" + generateMessageId(from) + ">\r\n";
msg += "From: " + from + "\r\n";
msg += "To: " + to + "\r\n";
msg += "Subject: " + subject + "\r\n";
+1
View File
@@ -58,6 +58,7 @@ namespace jet {
static std::string base64Encode(const std::string &s);
static std::string rfc2822Date();
static std::string generateMessageId(const std::string &from);
// Builds the full RFC 5322 message (headers + dot-stuffed body)
// handed to SMTP's DATA command.
static std::string buildMessage(const std::string &from, const std::string &to,
+15 -1
View File
@@ -26,7 +26,21 @@ namespace jet {
if(!global.sessionExists(sessionId))
throw coreutils::Exception("sessionid does not exist.");
processContainer(container);
global.getSession(sessionId)->query(out);
__mysql *session = global.getSession(sessionId);
// No <bind> inside: the query runs exactly as rendered, with no '?'
// replacement at all, so existing queries containing a literal '?'
// are unaffected. See docs/design-sql-bound-parameters.md.
if(binds.empty()) {
if(isCharsetChange(out.str()))
throw coreutils::Exception("sql: changing the connection character set is not allowed.");
session->query(out);
return;
}
std::string bound = bindPlaceholders(out.str(), binds, session->noBackslashEscapes(),
[session](const std::string &s) { return session->escapeString(s); });
if(isCharsetChange(bound))
throw coreutils::Exception("sql: changing the connection character set is not allowed.");
session->query(coreutils::MString(bound));
}
}
+13 -4
View File
@@ -2,16 +2,25 @@
#define ____sql_h__
#include "Tag.h"
#include "SqlBind.h"
#include <vector>
namespace jet {
class __sql : public Tag {
public:
__sql(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
// Called by each <bind> inside this <sql> while its body renders.
void addBind(BoundValue value) { binds.push_back(std::move(value)); }
size_t bindCount() const { return binds.size(); }
private:
std::vector<BoundValue> binds;
};
}
#endif
+4
View File
@@ -30,9 +30,13 @@ namespace jet {
// without this a caught mid-render failure would leave partial
// try-block output mixed in ahead of the catch block's own.
out = "";
// <try name="err"> or <catch name="err"> (the usual form).
if(keywordDefined("name"))
storeVariable(resolveKeyword("name"), errorText,
keywordDefined("scope") ? resolveKeyword("scope") : "global");
else if(splitKeywords.count("name"))
storeVariable(splitKeywords["name"], errorText,
splitKeywords.count("scope") ? coreutils::ZString(splitKeywords["scope"]) : coreutils::ZString("global"));
if(hasContainer2)
processContainer(container2);
}
+1 -1
View File
@@ -18,7 +18,7 @@ done
wait
echo -n "Building executable jet-2.0..."
g++ -g -o jet-2.0 $list -std=c++23 -L../CoreUtils -lCoreUtils -lmysqlclient -lcrypto
g++ -g -o jet-2.0 $list -std=c++23 -L../CoreUtils -lCoreUtils -lmysqlclient -lssl -lcrypto
if [ $? = '0' ]
then
echo "OK"
BIN
View File
Binary file not shown.
+168 -6
View File
@@ -95,9 +95,12 @@ specifying the scope of global.
\item Keyword - within a tag's container we may access the keyword
values specified on the containing tag.
\item Environment -
\item Session - values stored in the session file with the set tag and
a scope of session. They persist across requests from the same browser.
\item CGI Variables -
\item Environment -
\item CGI Variables -
\end{itemize}
@@ -120,6 +123,32 @@ the container where they are defined. Some containers may not be
capable of storing local variables (i.e. set tag) and are inheriting
the local scope from their parent tag.
\section{Session Variables}
Session variables are stored in the session file for the current
session and remain available to later requests from the same browser.
Session control must be enabled (see Session Control).
A session variable is written with the set tag and a scope of
session:
\begin{verbatim}
<set name="_login_id" value="$[login_id]" scope="session">
\end{verbatim}
The name can be any variable name. It does not need an @ prefix.
Session variables are read with the \$[@name] syntax, for example
\$[@\_login\_id].
Setting a session variable does not also set a global variable of
the same name. When the same request needs to read the value as
\$[name], set it with both scopes:
\begin{verbatim}
<set name="_login_id" value="$[login_id]">
<set name="_login_id" value="$[login_id]" scope="session">
\end{verbatim}
\section{Keyword Variables}
Keyword variables are set when they are specified on a containing tag.
@@ -234,6 +263,15 @@ the second parameter from the parameter passed as the first parameter.
If the number of characters to return is greater than the length of
the first parameter then the entire parameter is returned.
\subsection{ltrim}
Use the ltrim function to remove the leading blanks (spaces, tabs and
newlines) from a value. Trailing blanks are kept.
\begin{verbatim}
ltrim(' abc ') returns 'abc '
\end{verbatim}
\subsection{reverse}
\subsection{right}
@@ -241,7 +279,16 @@ the first parameter then the entire parameter is returned.
\subsection{round}
Use the round function to round a numeric value to the specified
number of digits after the decimal point.
number of digits after the decimal point.
\subsection{rtrim}
Use the rtrim function to remove the trailing blanks (spaces, tabs and
newlines) from a value. Leading blanks are kept.
\begin{verbatim}
rtrim(' abc ') returns ' abc'
\end{verbatim}
\subsection{substring}
@@ -254,6 +301,13 @@ the value as a string.
\subsection{trim}
Use the trim function to remove the blanks (spaces, tabs and newlines)
from both ends of a value. See also ltrim and rtrim.
\begin{verbatim}
trim(' abc ') returns 'abc'
\end{verbatim}
\subsection{expr}
Use the expr function to parse the string contents contained in the expr string.
@@ -299,8 +353,16 @@ into the directory named after the token. Captured session data will
become available to future requests coming into the server and made
available through the variable formats for the session.
The <set> tag will also have an additional scope value that can be
used to store the value in the session. This is scope="session".
Under APIServer, session control is enabled for a site by its
sessionDir setting in the server configuration instead of the <jet>
tag.
Use the <set> tag with scope="session" to store a value in the
session, and \$[@name] to read it back (see Session Variables).
The session tags in SESSIONCTL.tag are deprecated for session
management. Its setenv tag has been removed, and the startsession and
endsession tags are no longer provided. Use scope="session" instead.
@@ -315,6 +377,82 @@ variable parsing. This sequence is |> this is not parsed or resolved
and is different from the <exclude /> tag as exclude may be further
parsed if output is again evaluated.
\section{bind}
Use the bind tag inside an sql tag to supply the value for a ?
placeholder in the statement. Each bind fills the next ? in order. The
value is escaped or checked before it reaches the server, so whatever
it contains can never change the meaning of the statement. Use bind for
every value that comes from a request, a cookie or a session instead of
writing \$[name] into the statement text.
The bind tag has no closing tag and produces no output. It must be
inside an sql tag, although it may be inside other tags (if, for and so
on) within that sql tag.
\begin{verbatim}
<sql>select id, name from users where email=? and status=?
<bind value="$[email]">
<bind value="ACTIVE">
</sql>
\end{verbatim}
The attributes are:
value - the value to bind. Required. Any expression or variable
reference may be used here.
type - how the value is checked and sent. The values are:
\begin{itemize}
\item string - the default. Quoted and escaped.
\item int - a whole number of up to 19 digits, optionally negative.
Sent without quotes.
\item decimal - a number with an optional fraction, for example
-12.50. Sent without quotes.
\item bool - 1, true, yes, 0, false or no (any case). Sent as 1 or 0.
\item date - YYYY-MM-DD.
\item datetime - YYYY-MM-DD HH:MM or YYYY-MM-DD HH:MM:SS.
\item ident - a column or table name, or a sort direction, for the
places SQL cannot take a value (ORDER BY and so on). Requires the allow
attribute. Names are sent in backticks; ASC and DESC are sent as they
are.
\end{itemize}
null - set to empty to send SQL NULL when the value is empty. Without
it an empty value is sent as an empty string (and is an error for int,
decimal, bool, date and datetime).
allow - for type="ident" only. A comma separated list of the values
that are permitted. Any other value is an error.
\begin{verbatim}
<sql>select * from products order by ? ?
<bind value="$[sort]" type="ident" allow="name,price,created">
<bind value="$[dir]" type="ident" allow="ASC,DESC">
</sql>
\end{verbatim}
A ? inside a quoted string, a backtick name or a comment in the
statement is not a placeholder. An sql tag that contains no bind tags
is run exactly as written, so a ? in it is left alone.
These are errors, and can be caught with try/catch: a value that does
not fit its type, an ident that is not in the allow list, a bind
outside an sql tag, a bind with no value, an unknown type, and a
statement whose number of ? placeholders differs from its number of
bind tags. The error text never contains the bound value itself.
To find the sql tags that still write values into the statement text,
run the jet compiler's lint over a site:
\begin{verbatim}
jetc --lint-sql /path/to/site
\end{verbatim}
It prints the file and line of each one, with the variables it uses.
Add \texttt{-{}-strict} to include values from the rows of an earlier query.
\section{call}
Use the call tag to evoke an executable file from a jet script.
@@ -488,7 +626,16 @@ value
container
scope
scope - where the variable is stored. The values are:
\begin{itemize}
\item global - the default. Available to all logic for the rest of the
request.
\item local - available only within the container where it is set.
\item parent - stored in the scope of the enclosing tag.
\item session - stored in the session file and kept across requests.
Requires session control. See Session Variables.
\end{itemize}
\section{sql}
@@ -499,6 +646,21 @@ As long as sql statements are executed within the same mysql
containing tag then the same mysql session is used for each sql
statement.
Values that come from a request, a cookie or a session should be
passed with bind tags and ? placeholders rather than written into the
statement text. See the bind tag.
\begin{verbatim}
<sql>delete from cart_item where session_uuid=? and sku=?
<bind value="$[_session_id]">
<bind value="$[sku]">
</sql>
\end{verbatim}
A statement that changes the connection character set (SET NAMES, SET
CHARACTER SET and similar) is refused. The connection always uses
utf8mb4.
The attributes are:
sessionid
+238
View File
@@ -0,0 +1,238 @@
# Design: bound parameters for `<sql>`
**Status:** phases 1 and 2 implemented (2026-11-20) · **Author:** Brad Arant (drafted with Claude) · **Date:** 2026-10-23
**Applies to:** JetCore (`__sql`, `__mysql`, `Tag.cpp` tag dispatch, `jetc` parser/codegen)
## 1. The problem
`<sql>` builds its query by rendering its body as text, then sending the finished
string to MySQL:
```cpp
// __sql.cpp today
processContainer(container); // every $[...] substituted as plain text
global.getSession(sessionId)->query(out); // mysql_real_query(the whole string)
```
So a request value lands *inside the SQL text*:
```html
<sql>select id from users where email='$[email]' and secret='$[password]'</sql>
```
With `email = x' or '1'='1' -- ` that becomes a different query. There is no
escaping function in Jet, so this is the only way to write a query, and it's
unsafe everywhere a value comes from a request. Numeric positions are worse:
`where id=$[id]` has no quotes, so even escaping wouldn't help (`id = 1 or 1=1`).
Measured on 2026-10-23 (`<sql>` blocks whose body contains a request/session
value other than `$[.column]`, `$[_login_id]` or `$[_session_id]`):
| Site | `<sql>` blocks | with values pasted in | files |
|---|---:|---:|---:|
| barant.com | 152 | 117 | 64 |
| ClockPlanet | 94 | 83 | 35 |
Roughly 80% of all queries. Login, signup, cart, checkout and admin pages are
all in that set.
## 2. Goals
1. A way to pass values to `<sql>` that **can never change the query's meaning**,
whatever they contain.
2. **No change to how results are read** - `<ifrow>`, `<whilerow>`, `$[.column]`,
`$[?N]`, `$[#]` keep working exactly as today.
3. Easy, mechanical migration of existing pages; old pages keep running until migrated.
4. A path to *enforcing* it, so new unsafe queries can't be written by accident.
Non-goals: an ORM, query builders, or changing `<database>`/`<mysql>` connection handling.
## 3. Proposed syntax
Placeholders are `?` in the query; values come from `<bind>` tags inside the
`<sql>`, in order:
```html
<sql>
select id, name from users where email=? and status=?
<bind value="$[email]">
<bind value="ACTIVE">
</sql>
```
`<bind>` attributes:
| attribute | meaning |
|---|---|
| `value` | the value (any Jet expression - `$[...]` is fine here, that's the point) |
| `type` | `string` (default), `int`, `decimal`, `bool`, `date`, `datetime`, `ident` |
| `null` | `empty` = bind SQL `NULL` when the value is empty (default: bind `''`) |
| `allow` | for `type="ident"` only: comma list of permitted identifiers |
Type behaviour (a value that doesn't fit throws a catchable Jet exception -
`<try>`/`<catch>` works, see §6):
- `string` - quoted and escaped (§4).
- `int` - must match `^-?[0-9]{1,19}$`; emitted bare. This fixes the unquoted
`where id=$[id]` case.
- `decimal` - must match `^-?[0-9]{1,30}(\.[0-9]{1,30})?$`; emitted bare.
- `bool` - `1/0/true/false/yes/no` → `1`/`0`.
- `date` / `datetime` - must parse as `YYYY-MM-DD` / `YYYY-MM-DD HH:MM[:SS]`; quoted.
- `ident` - for the things SQL can't parameterise (column in `ORDER BY`, a sort
direction, a table name). The value must be in `allow` or it throws; emitted
backtick-quoted (`ASC`/`DESC` emitted bare). Example:
```html
<sql>select * from products order by ? ?
<bind value="$[sort]" type="ident" allow="name,price,created">
<bind value="$[dir]" type="ident" allow="ASC,DESC">
</sql>
```
Why `<bind>` and not `<param>`: `param` is an HTML element (inside `<object>`),
and `jetc`'s void-tag list treats it as HTML. A Jet-only name avoids any ambiguity.
Why positional `?` and not named (`:email`): `?` is what MySQL and every SQL
library uses, it needs no new attribute-name syntax in the parser, and the
`<bind>` lines sit right under the query so the order is easy to read. Named
binds can be added later without breaking this (§9).
## 4. How it works
### Emulated binding (recommended for phase 1)
`__sql` collects the `<bind>` values while its body renders, then replaces each
`?` that is **outside** a string literal, backtick identifier or comment with the
bound value, rendered safely - and only then calls `query()` as today.
- Strings are escaped with `mysql_real_escape_string_quote(mysql, to, from, len, '\'')`
and wrapped in single quotes. This uses the *connection's* character set and
respects `NO_BACKSLASH_ESCAPES`, which plain `mysql_real_escape_string` doesn't.
- The connection's character set is pinned at connect time
(`mysql_options(MYSQL_SET_CHARSET_NAME, "utf8mb4")` in `__mysql`), so escaping
and server parsing always agree. `<sql>` refuses a `SET NAMES`/`SET CHARACTER SET`
statement (the classic way to make escaping and parsing disagree).
- Number of `?` must equal number of `<bind>`s, otherwise throw
`"sql: 3 placeholders but 2 bind values"`.
This is the same approach PHP's PDO uses by default. Its big advantage here:
**the result path doesn't change at all** - `query()` still runs
`mysql_real_query` and `mysql_store_result`, so `MYSQL_ROW`, `getColumnValue()`,
`<ifrow>`, `<whilerow>` and the column-index map are untouched.
### Why not real server-side prepared statements (yet)
`mysql_stmt_*` returns rows through typed bind buffers, not `MYSQL_ROW`, so
`getColumnValue()`, `$[?N]`, `$[#]` and the field-index map would all need a
second implementation, and some statements (multi-statements, some DDL) can't be
prepared. That's a bigger change for no extra safety over correct emulation.
It stays open as a later option (§9), behind the same `<bind>` syntax, so pages
written now won't need touching again.
### Code shape
- **New** `__bind.h/.cpp`: on construction, find the nearest enclosing `__sql`
(walk `parent` with `dynamic_cast<__sql*>`; throw `"bind must be inside sql"`
if none), resolve `value`/`type`/`null`/`allow`, validate per type, and call
`sql->addBind(...)`. Produces no output.
- **`__sql`**: a `std::vector<BoundValue>` member and `addBind()`. After
`processContainer(container)`, run `bindPlaceholders(out)` - a small scanner
that tracks `'...'` (with `''` and `\'`), `"..."`, `` `...` ``, `-- `, `#` and
`/* */` so `?` inside them is left alone - then `query(result)`.
- **`__mysql`**: `escapeString(const MString&)` wrapper around
`mysql_real_escape_string_quote`; pin `utf8mb4` at connect.
- **`Tag.cpp`**: add `ifTagName(in, "bind")` next to `sql` (line ~494).
- **`jetc` `JetParser.cpp`**: add `"bind"` to the Jet void-tag list (it has no
closing tag); **`JetCodegen.cpp`**: emit `__bind` like the other tags.
Estimated size: ~200 lines plus tests.
## 5. Existing pages: nothing breaks
A `<sql>` with no `<bind>` runs exactly as today - no `?` replacement at all,
so existing queries containing a literal `?` are unaffected. Migration is
page by page:
```html
<!-- before -->
<sql>select * from users where email="$[email]" and status="CONFIRM"</sql>
<!-- after -->
<sql>select * from users where email=? and status="CONFIRM"
<bind value="$[email]">
</sql>
<!-- before: unquoted number, injectable even with escaping -->
<sql>delete from cart_item where session_uuid='$[_session_id]' and sku='$[sku]'</sql>
<!-- after -->
<sql>delete from cart_item where session_uuid=? and sku=?
<bind value="$[_session_id]">
<bind value="$[sku]">
</sql>
```
## 6. Errors
- Bad `<bind>` value (wrong type, ident not allowed), placeholder/bind count
mismatch, `<bind>` outside `<sql>`: throw `coreutils::Exception` with a clear
message, caught by `<try>`/`<catch>` like the MySQL errors fixed on 2026-09-13.
- The exception text never includes the bound value itself (it may be a password).
## 7. Enforcement
Once pages are migrated, make the unsafe form an error instead of a habit:
1. **`jetc --lint-sql`** - lists every `<sql>` whose body contains `$[...]`
other than `$[.column]` (row values from an outer query), with file:line.
This is the migration worklist (§8) and a CI check.
As implemented (`jetc/JetLint.cpp`): `jetc --lint-sql [--strict] <file|dir>...`
scans every file under the given paths. It reports `$[...]` and local
`#[...]` references, with the kind of each (`global`, `cgi`, `session`,
`env`, `keyword`, `local`). Row values (`$[.col]`, `$[session.col]`,
`$[?N]`, `$[#]`, `$[?#]`) are not reported unless `--strict` is given.
References in the attributes of `<bind>`, `<if>`, `<else>`, `<ifrow>`,
`<while>`, `<whilerow>`, `<until>`, `<for>` and `<set>` are not reported,
since those never become statement text; nor is anything inside
`<comment>` or `|> <|`. A custom tag defined as `<sql ...><container></sql>`
(barant.com's `<showtable>`) takes its statement from the caller's content,
so each use of it is checked like an `<sql>`. Exit status: 0 nothing found,
1 findings, 2 a path could not be read. Tests: `tests/runlinttests.sh`.
2. **Per-site strict mode** - an APIServer site setting
`"sqlInterpolation": "warn" | "error"`. In `error` mode `<sql>` refuses to run
if its body substituted any `$[...]` except `$[.column]`; `warn` logs it.
Default `warn` for existing sites, `error` for new ones.
3. **Escape hatch** - `<sql raw="yes">` for the rare trusted dynamic SQL
(generated by the site itself, never from input), so it's visible in review
and greppable.
## 8. Migration plan
| Phase | What | Notes |
|---|---|---|
| 1 | Implement `<bind>`, escaping, utf8mb4 pinning, tests | JetCore only; no page changes. Done 2026-11-20 |
| 2 | `jetc --lint-sql`; run on both sites | produces the worklist (≈200 queries). Done 2026-11-20 on the local copies: see [sql-lint-worklist.md](sql-lint-worklist.md) |
| 3 | Convert the high-risk pages first | login/signup/password reset, cart/checkout/payment (`pp.jet`), admin procs, ClockPlanet `mobile_api.jet` and auth |
| 4 | Convert the rest; turn on `warn` | logs show anything missed |
| 5 | Switch both sites to `error` | unsafe queries can no longer ship |
Phase 3 is the one that matters most for security and is a few days' work;
each conversion is mechanical and testable page by page.
## 9. Later
- Named binds: `where email=:email` + `<bind name="email" value="...">`.
- Real prepared statements (`mysql_stmt_*`) behind the same `<bind>` syntax.
- The companion fix for output: HTML-escape `$[...]` by default with an explicit
raw form - the same "safe unless you say otherwise" rule for the other half of
the injection problem (cross-site scripting).
## 10. Tests
- Every type: valid values bind correctly; invalid values throw.
- Injection strings (`' or '1'='1`, `\'`, multibyte sequences such as `0xbf27`,
`--`, `;`, NUL bytes) are stored and read back byte-for-byte unchanged.
- `?` inside `'...'`, `"..."`, `` `...` ``, `--`, `#` and `/* */` is never replaced.
- Placeholder/bind count mismatch throws; `<bind>` outside `<sql>` throws.
- A `<sql>` with no binds produces exactly the same query text as before.
- `<ifrow>`/`<whilerow>`/`$[.col]`/`$[?N]`/`$[#]` behave identically on bound queries.
- `NO_BACKSLASH_ESCAPES` on and off.
+166
View File
@@ -0,0 +1,166 @@
# `<sql>` migration worklist
Output of `jetc --lint-sql` (phase 2 of [design-sql-bound-parameters.md](design-sql-bound-parameters.md)),
generated 2026-11-20 from the copies of the two sites in `~/Development`.
Each line is a `<sql>` (or a use of a custom tag that wraps one, such as
barant.com's `<showtable>`) whose statement pastes in a variable instead of
using `<bind>`. The kind in brackets is where the value comes from: `global`
includes request parameters, `cgi` is a POST body field, `session` is
`$[@name]`, `local` is `#[name]`.
These local copies are not the whole of either live site. ClockPlanet in
particular has only billing and a few site pages here (no `mobile_api.jet`), so
rerun the lint on the live site trees for the full list:
```
jetc --lint-sql /path/to/site
```
Phase 3 starts with login/signup/password reset, cart/checkout/payment and
admin procs (see the design doc §8).
## barant.com (`JetCore/jetc/barant-site`)
```
./src/SIPPHONE.tag:178: <sql> pastes $[_login_id] (global)
./src/account-info.subpage:3: <sql> pastes $[_login_id] (global)
./src/account-info.subpage:14: <sql> pastes $[_login_id] (global)
./src/account-info.subpage:28: <sql> pastes $[_login_id] (global)
./src/account-info.subpage:54: <sql> pastes $[_login_id] (global)
./src/account-invoices.subpage:3: <sql> pastes $[@_invoice_id] (session)
./src/account-invoices.subpage:14: <showtable> (wraps sql) pastes $[_login_id] (global)
./src/accountconfirm.page:14: <sql> pastes $[uuid] (global)
./src/accountconfirm.page:15: <sql> pastes $[uuid] (global)
./src/accountconfirm.page:16: <sql> pastes $[id] (global)
./src/add_track.page:10: <sql> pastes $[collection_id] (global)
./src/add_track.proc:5: <sql> pastes $[login_id] (global), $[collection_id] (global), $[name] (global), $[artist] (global), $[description] (global), $[price] (global), $[filedata_binary] (global)
./src/addtasknote.page:12: <sql> pastes $[_task_id] (global)
./src/addtasknote.proc:3: <sql> pastes $[_task_id] (global), $[_login_id] (global), $[noteb] (global), $[task_status_id] (global)
./src/addtocart.proc:1: <sql> pastes $[_session_id] (global), $[sku] (global)
./src/addtocart.proc:4: <sql> pastes $[_session_id] (global), $[sku] (global), $[qty] (global)
./src/admin-mailaccounts.subpage:19: <sql> pastes $[@_login_id] (session)
./src/barant.tag:70: <sql> pastes #[table] (local), #[where] (local), #[sortfield] (local)
./src/cart.menu:2: <sql> pastes $[_session_id] (global)
./src/cart.page:17: <sql> pastes $[_session_id] (global)
./src/cart.page:34: <sql> pastes $[_session_id] (global)
./src/cart.page:67: <sql> pastes $[_session_id] (global)
./src/changeprojecticon.proc:3: <sql> pastes $[datax] (global)
./src/changeprojecticon.proc:9: <sql> pastes $[image_id] (global), $[_project_id] (global)
./src/checkout.page:65: <sql> pastes $[_session_id] (global)
./src/checkout.page:75: <sql> pastes $[_session_id] (global)
./src/copy_invoice.jet:14: <sql> pastes $[source_invoice_id] (global)
./src/copy_invoice.jet:19: <sql> pastes $[new_invoice_id] (global), $[source_invoice_id] (global)
./src/create_invoice.jet:14: <sql> pastes $[user_id] (global)
./src/createaccount.proc:17: <sql> pastes $[email:0] (global)
./src/createaccount.proc:28: <sql> pastes $[name] (global), $[company_name] (global), $[email] (global), $[password] (global)
./src/createaccount.proc:46: <sql> pastes $[id] (global), $[link] (global)
./src/createproject.proc:2: <sql> pastes $[_login_id] (global), $[text] (global), $[description] (global)
./src/createreleasetarget.proc:4: <sql> pastes $[_project_id] (global), $[release] (global), $[descriptionx] (global)
./src/createrequest.proc:4: <sql> pastes $[_project_id] (global), $[_login_id] (global), $[priority] (global), $[release_id] (global), $[textx] (global), $[descriptionx] (global)
./src/createtask.proc:5: <sql> pastes $[_request_id] (global), $[_login_id] (global), $[textx] (global), $[descriptionx] (global)
./src/deleterequest.proc:3: <sql> pastes $[_request_id] (global)
./src/documents.jet:2: <sql> pastes $[id] (global), $[@_login_id] (session)
./src/documents_api.jet:17: <sql> pastes $[@_login_id] (session), $[name] (global)
./src/documents_api.jet:29: <sql> pastes $[id] (global), $[@_login_id] (session)
./src/documents_api.jet:31: <sql> pastes $[id] (global), $[@_login_id] (session)
./src/documents_api.jet:43: <sql> pastes $[@_login_id] (session)
./src/documents_delete.proc:4: <sql> pastes $[delete_id] (global), $[@_login_id] (session)
./src/documents_delete.proc:6: <sql> pastes $[delete_id] (global), $[@_login_id] (session)
./src/documents_upload.proc:4: <sql> pastes $[@_login_id] (session), $[name] (global)
./src/editinvoice.page:180: <sql> pastes $[@_invoice_id] (session)
./src/editinvoice.page:234: <sql> pastes $[@_invoice_id] (session)
./src/editproduct.page:8: <sql> pastes $[_product_sku] (global)
./src/editrequest.page:7: <sql> pastes $[_request_id] (global)
./src/edittask.page:12: <sql> pastes $[_task_id] (global)
./src/invoice.method:1: <sql> pastes $[@_invoice_id] (session)
./src/invoice.method:28: <sql> pastes $[@_invoice_id] (session)
./src/invoice.method:51: <sql> pastes $[@_invoice_id] (session)
./src/invoices.menu:2: <sql> pastes $[_user_id] (global)
./src/login.method:1: <sql> pastes $[login_email] (global), $[login_password] (global)
./src/login.method:16: <sql> pastes $[login_id] (global)
./src/login.method:17: <sql> pastes $[login_id] (global)
./src/mailaccounts.jet:25: <sql> pastes $[@_login_id] (session), $[mail_email] (global), $[mail_host] (global), $[mail_password] (global)
./src/mailaccounts.jet:38: <sql> pastes $[account_id] (global), $[@_login_id] (session)
./src/make_invoice.method:5: <sql> pastes $[_session_id] (global)
./src/make_invoice.method:47: <sql> pastes $[_login_id] (global), $[total] (global)
./src/make_invoice.method:62: <sql> pastes $[invoice_id] (global), $[total] (global), $[card_brand] (global), $[last_4_digits] (global), $[exp_month] (global), $[exp_year] (global), $[payment_id] (global), $[tranonce] (global)
./src/make_invoice.method:74: <sql> pastes $[_session_id] (global)
./src/make_invoice.method:81: <sql> pastes $[invoice_id] (global)
./src/make_invoice.method:96: <sql> pastes $[license] (global)
./src/make_invoice.method:97: <sql> pastes $[_login_id] (global), $[invoice_id] (global), $[license] (global), $[key] (global)
./src/make_invoice.method:110: <sql> pastes $[_session_id] (global)
./src/memberhometemplate.temp:25: <sql> pastes $[login_id] (global)
./src/menu.bar:18: <sql> pastes $[_session_id] (global)
./src/musicianhome.page:13: <sql> pastes $[login_id] (global)
./src/musicianhome.page:35: <sql> pastes $[login_id] (global)
./src/myprojects.page:15: <showtable> (wraps sql) pastes $[_login_id] (global)
./src/myworklist.page:10: <showtable> (wraps sql) pastes $[_login_id] (global)
./src/newcollection.proc:11: <sql> pastes $[login_id] (global), $[name] (global), $[artist] (global), $[description] (global), $[price] (global)
./src/payinvoice.page:7: <sql> pastes $[_invoice_id] (global)
./src/phones.section:1: <sql> pastes $[@_login_id] (session)
./src/phones.section:9: <showtable> (wraps sql) pastes $[@_login_id] (session)
./src/processorder.proc:4: <sql> pastes $[_login_id] (global)
./src/processorder.proc:7: <sql> pastes $[_session_id] (global)
./src/processorder.proc:12: <sql> pastes $[invoice_id] (global)
./src/processorder.proc:27: <sql> pastes $[license] (global)
./src/processorder.proc:28: <sql> pastes $[_login_id] (global), $[invoice_id] (global), $[license] (global), $[key] (global)
./src/processorder.proc:41: <sql> pastes $[_session_id] (global)
./src/project.page:16: <sql> pastes $[_project_id] (global)
./src/project.page:37: <showtable> (wraps sql) pastes $[_project_id] (global)
./src/project.tag:3: <sql> pastes $[_project_id] (global)
./src/projects.menu:1: <sql> pastes $[_login_id] (global)
./src/projman.bar:15: <sql> pastes $[_session_id] (global)
./src/registermusician.proc:2: <sql> pastes $[login_id] (global)
./src/removecartitem.proc:1: <sql> pastes $[_session_id] (global), $[sku] (global)
./src/removefromcart.proc:1: <sql> pastes $[_session_id] (global)
./src/request.page:12: <sql> pastes $[_request_id] (global)
./src/request.page:43: <showtable> (wraps sql) pastes $[_request_id] (global)
./src/selectproject.proc:2: <sql> pastes $[project_id] (global)
./src/selecttask.proc:2: <sql> pastes $[task_id] (global)
./src/send_invoice_email.method:5: <sql> pastes $[_send_invoice_id] (global)
./src/task.page:12: <sql> pastes $[_request_id] (global)
./src/task.page:35: <sql> pastes $[_task_id] (global)
./src/taskassignresource.page:15: <sql> pastes $[_task_id] (global)
./src/taskassignresource.proc:5: <sql> pastes $[_task_id] (global), $[user_id] (global), $[estimate_hours] (global)
./src/update_invoice.proc:3: <sql> pastes $[@_invoice_id] (session)
./src/update_invoice.proc:5: <sql> pastes $[@_invoice_id] (session), $[sku$[ix]] (global), $[quantity$[ix]] (global), $[description$[ix]] (global), $[textarea$[ix]] (global), $[price$[ix]] (global), $[total$[ix]] (global), $[tax_amount$[ix]] (global), $[type$[ix]] (global)
./src/update_invoice.proc:8: <sql> pastes $[invoice_total] (global), $[user_id] (global), $[@_invoice_id] (session)
./src/update_product.proc:2: <sql> pastes $[type] (global), $[description] (global), $[text] (global), $[price] (global), $[image] (global), $[_product_sku] (global)
./src/updatecartqty.proc:2: <sql> pastes $[_session_id] (global), $[sku] (global)
./src/updatecartqty.proc:4: <sql> pastes $[qty] (global), $[_session_id] (global), $[sku] (global)
./src/updaterequest.proc:6: <sql> pastes $[textx] (global), $[descriptionx] (global), $[priority] (global), $[owner_id] (global), $[release_id] (global), $[_request_id] (global)
./src/upload_modular1_1_preset.proc:5: <sql> pastes $[title] (global), $[textx] (global), $[preset_datax] (global), $[audio_samplex] (global)
lint-sql: 108 of 139 <sql> blocks (and uses of tags that wrap <sql>) paste values into the statement, in 64 of 76 files (global 174, local 3, session 22)
```
## ClockPlanet (`~/Development/ClockPlanet`)
```
./billing/account.page:9: <sql> pastes $[_acct_bid] (global)
./billing/account.page:46: <sql> pastes $[_acct_bid] (global), $[_acct_req] (global)
./billing/account.page:157: <sql> pastes $[_acct_bid] (global)
./billing/account.page:159: <sql> pastes $[_acct_bid] (global)
./billing/billing_api.jet:28: <sql> pastes $[_mail_key] (global)
./billing/billing_api.jet:50: <sql> pastes $[_mail_key] (global)
./billing/billing_api.jet:53: <sql> pastes $[_notice_business] (global)
./billing/dobilling_pay.proc:16: <sql> pastes $[_bp_bid] (global)
./billing/dobilling_settings.proc:7: <sql> pastes $[_bs_bid] (global), $[_bs_low] (global), $[_bs_rep] (global)
./billing/dobilling_settings.proc:14: <sql> pastes $[_bs_low] (global), $[_bs_rep] (global), $[_bs_bid] (global)
./billing/doemployee_add.proc:6: <sql> pastes $[@_login_business_id] (session), $[name] (global), $[role] (global), $[phone] (global), $[mode] (global), $[invitecode] (global)
./billing/invoice.method:1: <sql> pastes $[_cp_invoice_id] (global)
./billing/invoice.method:33: <sql> pastes $[_cp_invoice_id] (global)
./billing/invoice.method:52: <sql> pastes $[_cp_invoice_id] (global)
./billing/send_invoice_email.method:3: <sql> pastes $[_send_invoice_id] (global)
./site-live/billing-current.txt:10: <sql> pastes $[_acct_bid] (global)
./site-live/billing-current.txt:49: <sql> pastes $[_acct_bid] (global), $[_acct_req] (global)
./site-live/billing-current.txt:114: <sql> pastes $[_acct_bid] (global)
./site-live/billing-current.txt:116: <sql> pastes $[_acct_bid] (global)
./site-live/billing-current.txt:252: <sql> pastes $[_mail_key] (global)
./site-live/billing-current.txt:272: <sql> pastes $[_mail_key] (global)
./site-live/billing-current.txt:275: <sql> pastes $[_notice_business] (global)
./site-live/billing-current.txt:313: <sql> pastes $[@_login_business_id] (session), $[name] (global), $[role] (global), $[phone] (global), $[mode] (global), $[invitecode] (global)
./site-live/sites.page:12: <sql> pastes $[@_login_business_id] (session)
./site-live/sites.page:32: <sql> pastes $[@_login_business_id] (session)
./site-live/sites.page:36: <sql> pastes $[@_login_business_id] (session)
lint-sql: 26 of 28 <sql> blocks paste values into the statement, in 9 of 10 files (global 37, session 5)
```
+10 -3
View File
@@ -32,6 +32,13 @@ namespace jetc {
return r;
}
std::string Codegen::zstr(const std::string &raw) {
// A plain C string literal stops at its first NUL, so text holding
// one (raw bytes in a page) has to carry its length explicitly.
if (raw.find('\0') == std::string::npos) return cstr(raw);
return "coreutils::ZString(" + cstr(raw) + ", " + std::to_string(raw.size()) + ")";
}
const char *Codegen::staticTypeOp(const std::string &type, const char *rc) {
// type is known at compile time (a literal attribute value, not a
// runtime expression) so the comparison operator is picked once here
@@ -59,7 +66,7 @@ namespace jetc {
case NodeKind::TEXT: {
if (n->text.empty()) break;
target << I << "out << " << cstr(n->text) << ";\n";
target << I << "out << " << zstr(n->text) << ";\n";
break;
}
@@ -166,7 +173,7 @@ namespace jetc {
}
case NodeKind::FALLBACK: {
target << I << "{ coreutils::ZString span(" << cstr(n->rawSpan) << "); scope.interpretSpan(span, out); }\n";
target << I << "{ coreutils::ZString span(" << zstr(n->rawSpan) << "); scope.interpretSpan(span, out); }\n";
break;
}
@@ -213,7 +220,7 @@ namespace jetc {
// correctness fallback: any invocation this compiler doesn't
// itself recognize - e.g. reached through content this pass
// never compiled - still resolves it exactly as it always has).
target << I << "{ coreutils::ZString span(" << cstr(n->rawSpan) << "); scope.interpretSpan(span, out); }\n";
target << I << "{ coreutils::ZString span(" << zstr(n->rawSpan) << "); scope.interpretSpan(span, out); }\n";
if (compiledOk) {
// The registration into compiledTags right after is the only
// new behavior beyond the raw registration above - a pure
+1
View File
@@ -86,6 +86,7 @@ namespace jetc {
void emitNode(const NodePtr &n, int indent, std::ostringstream &target);
static std::string ind(int indent);
static std::string cstr(const std::string &raw); // C++ string-literal escape
static std::string zstr(const std::string &raw); // same, as a sized ZString if it holds a NUL
static const char *staticTypeOp(const std::string &type, const char *rcVar);
};
+322
View File
@@ -0,0 +1,322 @@
#include "JetLint.h"
#include <algorithm>
#include <cctype>
#include <filesystem>
#include <fstream>
#include <map>
#include <sstream>
// See JetLint.h. This is a plain text scan of the page source rather than a
// use of jetc's Parser: the parser keeps no line numbers, compiles some
// content into fallback spans, and stops at the first error, while a lint
// run over a whole site has to report every <sql> in every file.
namespace jetc {
namespace {
bool startsWithNoCase(const std::string &s, size_t pos, const char *word) {
for (size_t i = 0; word[i]; ++i)
if (pos + i >= s.size() || std::tolower((unsigned char)s[pos + i]) != word[i]) return false;
return true;
}
bool isTagEndChar(char c) {
return c == '>' || c == '/' || std::isspace((unsigned char)c);
}
// "<name" at pos, followed by whitespace, '>' or '/'.
bool isOpenTag(const std::string &s, size_t pos, const std::string &name) {
if (s[pos] != '<' || !startsWithNoCase(s, pos + 1, name.c_str())) return false;
size_t after = pos + 1 + name.size();
return after < s.size() && isTagEndChar(s[after]);
}
// "</name" + optional whitespace + ">" at pos. Returns the position
// after the '>', or npos.
size_t closeTagEnd(const std::string &s, size_t pos, const std::string &name) {
if (s.compare(pos, 2, "</") != 0 || !startsWithNoCase(s, pos + 2, name.c_str())) return std::string::npos;
size_t i = pos + 2 + name.size();
while (i < s.size() && std::isspace((unsigned char)s[i])) ++i;
return (i < s.size() && s[i] == '>') ? i + 1 : std::string::npos;
}
// pos is at '<'. Returns the position of the '>' ending the opening
// tag, skipping quoted attribute values, or npos.
size_t openTagEnd(const std::string &s, size_t pos) {
char quote = 0;
for (size_t i = pos + 1; i < s.size(); ++i) {
char c = s[i];
if (quote) { if (c == quote) quote = 0; }
else if (c == '"' || c == '\'') quote = c;
else if (c == '>') return i;
}
return std::string::npos;
}
// pos is at "$[" or "#[". Returns the position after the matching
// ']' (nested references included), or npos.
size_t refEnd(const std::string &s, size_t pos) {
int depth = 0;
for (size_t i = pos; i < s.size(); ++i) {
if ((s[i] == '$' || s[i] == '#') && i + 1 < s.size() && s[i + 1] == '[') { ++depth; ++i; }
else if (s[i] == ']' && --depth == 0) return i + 1;
}
return std::string::npos;
}
// What a reference reads from, from its type designator (see
// Tag::getVariable). "row" is a column of an earlier query.
std::string refKind(const std::string &ref) {
if (ref[0] == '#') return "local";
char d = ref.size() > 2 ? ref[2] : 0;
switch (d) {
case ':': return "cgi";
case '@': return "session";
case '&': return "env";
case '%': return "keyword";
case '!': return "global";
case '.': case '?': case '#': return "row";
}
// $[session.column] - a dot outside any nested reference.
int depth = 0;
for (size_t i = 2; i + 1 < ref.size(); ++i) {
if (ref[i] == '[') ++depth;
else if (ref[i] == ']') --depth;
else if (ref[i] == '.' && depth == 0) return "row";
}
return "global";
}
int lineAt(const std::string &s, size_t pos) {
return 1 + (int)std::count(s.begin(), s.begin() + pos, '\n');
}
// Tags inside a <sql> whose attributes never become statement text:
// <bind> passes its value safely, and the rest only decide what the
// body renders.
const char *const attributeOnlyTags[] = {
"bind", "if", "else", "ifrow", "while", "whilerow", "until", "for", "set",
};
}
void lintSqlText(const std::string &file, const std::string &s, bool strict,
const std::vector<std::string> &wrappers,
std::vector<LintFinding> &findings, LintStats &stats) {
std::vector<std::string> names{"sql"};
names.insert(names.end(), wrappers.begin(), wrappers.end());
bool counted = false;
size_t pos = 0;
while ((pos = s.find('<', pos)) != std::string::npos) {
std::string name;
for (const auto &n : names)
if (isOpenTag(s, pos, n)) { name = n; break; }
if (name.empty()) { ++pos; continue; }
if (!counted) { ++stats.files; counted = true; }
++stats.sqlBlocks;
size_t tagStart = pos;
size_t gt = openTagEnd(s, pos);
if (gt == std::string::npos) break;
pos = gt + 1;
if (s[gt - 1] == '/') continue; // <sql ... /> has no statement
LintFinding finding{file, lineAt(s, tagStart), name, {}};
int depth = 1;
size_t i = pos;
while (i < s.size()) {
size_t end;
if (s[i] == '<') {
if ((end = closeTagEnd(s, i, name)) != std::string::npos) {
i = end;
if (--depth == 0) break;
continue;
}
if (isOpenTag(s, i, name)) {
// A nested block of the same tag is its own block; it is
// reported when the outer scan reaches it.
++depth;
size_t e = openTagEnd(s, i);
i = (e == std::string::npos) ? s.size() : e + 1;
continue;
}
if (isOpenTag(s, i, "comment")) {
size_t c = s.find("</comment>", i);
i = (c == std::string::npos) ? s.size() : c + 10;
continue;
}
bool skipped = false;
for (const char *tag : attributeOnlyTags)
if (isOpenTag(s, i, tag)) {
size_t e = openTagEnd(s, i);
i = (e == std::string::npos) ? s.size() : e + 1;
skipped = true;
break;
}
if (skipped) continue;
} else if (s.compare(i, 2, "|>") == 0) {
// |> ... <| is never parsed, so nothing in it is a reference.
size_t c = s.find("<|", i + 2);
i = (c == std::string::npos) ? s.size() : c + 2;
continue;
} else if ((s[i] == '$' || s[i] == '#') && i + 1 < s.size() && s[i + 1] == '[') {
end = refEnd(s, i);
if (end == std::string::npos) end = s.size();
LintRef ref{s.substr(i, end - i), ""};
ref.kind = refKind(ref.text);
i = end;
if (ref.kind == "row" && !strict) continue;
bool seen = false;
for (auto &r : finding.refs) seen = seen || r.text == ref.text;
if (!seen) finding.refs.push_back(ref);
continue;
}
++i;
}
if (!finding.refs.empty()) {
++stats.flaggedBlocks;
findings.push_back(finding);
}
// Carry on from the end of this <sql>'s opening tag, not its body,
// so a nested <sql> is still counted and checked.
}
}
namespace {
bool fileMentions(const std::string &text, const std::vector<std::string> &names) {
for (size_t p = 0; (p = text.find('<', p)) != std::string::npos; ++p)
for (const auto &n : names)
if (isOpenTag(text, p, n)) return true;
return false;
}
bool readFile(const std::string &path, std::string &text) {
std::ifstream in(path, std::ios::binary);
if (!in) return false;
std::ostringstream ss;
ss << in.rdbuf();
text = ss.str();
return true;
}
}
void findSqlWrappers(const std::string &s, std::vector<std::string> &wrappers) {
for (size_t pos = 0; (pos = s.find('<', pos)) != std::string::npos; ++pos) {
if (!isOpenTag(s, pos, "tag")) continue;
size_t gt = openTagEnd(s, pos);
if (gt == std::string::npos) return;
std::string open = s.substr(pos, gt - pos);
// name="X" (or name='X')
std::string lower = open;
for (auto &c : lower) c = (char)std::tolower((unsigned char)c);
size_t n = lower.find("name=");
if (n == std::string::npos || n + 5 >= open.size()) continue;
char q = open[n + 5];
if (q != '"' && q != '\'') continue;
size_t e = open.find(q, n + 6);
if (e == std::string::npos) continue;
std::string name = open.substr(n + 6, e - n - 6);
// Tag names match without regard to case (isOpenTag lowercases).
for (auto &c : name) c = (char)std::tolower((unsigned char)c);
size_t close = std::string::npos;
for (size_t c = gt; (c = s.find("</", c)) != std::string::npos; ++c)
if (closeTagEnd(s, c, "tag") != std::string::npos) { close = c; break; }
std::string body = s.substr(gt + 1, (close == std::string::npos ? s.size() : close) - gt - 1);
// An <sql> in the definition whose statement is the caller's content.
for (size_t p = 0; (p = body.find('<', p)) != std::string::npos; ++p) {
if (!isOpenTag(body, p, "sql")) continue;
size_t bgt = openTagEnd(body, p);
if (bgt == std::string::npos) break;
size_t end = std::string::npos;
for (size_t c = bgt; (c = body.find("</", c)) != std::string::npos; ++c)
if (closeTagEnd(body, c, "sql") != std::string::npos) { end = c; break; }
std::string stmt = body.substr(bgt + 1, (end == std::string::npos ? body.size() : end) - bgt - 1);
bool hasContainer = false;
for (size_t c = 0; (c = stmt.find('<', c)) != std::string::npos; ++c)
hasContainer = hasContainer || isOpenTag(stmt, c, "container");
if (hasContainer && !name.empty() &&
std::find(wrappers.begin(), wrappers.end(), name) == wrappers.end()) {
wrappers.push_back(name);
break;
}
}
}
}
int lintSql(const std::vector<std::string> &paths, bool strict, std::ostream &out, std::ostream &err) {
namespace fs = std::filesystem;
std::vector<std::string> files;
bool error = false;
for (const auto &p : paths) {
std::error_code ec;
if (fs::is_directory(p, ec)) {
std::vector<std::string> found;
for (auto it = fs::recursive_directory_iterator(p, fs::directory_options::skip_permission_denied, ec);
it != fs::recursive_directory_iterator(); it.increment(ec)) {
if (ec) break;
std::string name = it->path().filename().string();
if (it->is_directory(ec) && !name.empty() && name[0] == '.') { it.disable_recursion_pending(); continue; }
if (it->is_regular_file(ec)) found.push_back(it->path().string());
}
std::sort(found.begin(), found.end());
files.insert(files.end(), found.begin(), found.end());
} else if (fs::is_regular_file(p, ec)) {
files.push_back(p);
} else {
err << "jetc: cannot open " << p << std::endl;
error = true;
}
}
// Two passes: a custom tag defined anywhere in the scanned files as
// <sql ...><container></sql> takes its statement from the caller's
// content, so each use of it is checked like an <sql>.
std::vector<std::string> texts(files.size());
std::vector<bool> readOk(files.size(), false);
std::vector<std::string> wrappers;
for (size_t i = 0; i < files.size(); ++i) {
if (!readFile(files[i], texts[i])) { err << "jetc: cannot read " << files[i] << std::endl; error = true; continue; }
readOk[i] = true;
findSqlWrappers(texts[i], wrappers);
}
std::vector<std::string> names{"sql"};
names.insert(names.end(), wrappers.begin(), wrappers.end());
std::vector<LintFinding> findings;
LintStats stats;
for (size_t i = 0; i < files.size(); ++i) {
if (!readOk[i] || !fileMentions(texts[i], names)) continue;
lintSqlText(files[i], texts[i], strict, wrappers, findings, stats);
}
std::map<std::string, int> byKind;
std::map<std::string, bool> flaggedFiles;
for (const auto &f : findings) {
flaggedFiles[f.file] = true;
out << f.file << ":" << f.line << ": <" << f.tag << ">"
<< (f.tag == "sql" ? "" : " (wraps sql)") << " pastes ";
for (size_t i = 0; i < f.refs.size(); ++i) {
out << (i ? ", " : "") << f.refs[i].text << " (" << f.refs[i].kind << ")";
++byKind[f.refs[i].kind];
}
out << "\n";
}
out << "lint-sql: " << stats.flaggedBlocks << " of " << stats.sqlBlocks
<< " <sql> blocks" << (wrappers.empty() ? "" : " (and uses of tags that wrap <sql>)")
<< " paste values into the statement, in " << flaggedFiles.size()
<< " of " << stats.files << " files";
if (!byKind.empty()) {
out << " (";
bool first = true;
for (auto &[kind, n] : byKind) { out << (first ? "" : ", ") << kind << " " << n; first = false; }
out << ")";
}
out << std::endl;
if (error) return 2;
return findings.empty() ? 0 : 1;
}
}
+57
View File
@@ -0,0 +1,57 @@
#ifndef __JetLint_h__
#define __JetLint_h__
#include <string>
#include <vector>
#include <ostream>
// jetc --lint-sql: phase 2 of docs/design-sql-bound-parameters.md.
//
// Lists every <sql> whose body pastes a variable into the statement text
// ($[...] or #[...]) instead of passing it with <bind>. These are the
// queries to migrate. A value from a row of an earlier query
// ($[.column], $[session.column], $[?N], $[#]) is not reported, as the
// design doc specifies, unless strict is set.
namespace jetc {
struct LintRef {
std::string text; // the reference as written, e.g. "$[:email]"
std::string kind; // cgi, global, local, session, env, keyword, row, ...
};
struct LintFinding {
std::string file;
int line; // line of the <sql tag
std::string tag; // "sql", or a custom tag that wraps <sql><container></sql>
std::vector<LintRef> refs;
};
struct LintStats {
int files = 0; // files that contain at least one <sql>
int sqlBlocks = 0;
int flaggedBlocks = 0;
};
// Scans one file's text. Appends to findings and stats.
// wrappers: custom tag names whose uses count as <sql> (see
// findSqlWrappers).
void lintSqlText(const std::string &file, const std::string &text, bool strict,
const std::vector<std::string> &wrappers,
std::vector<LintFinding> &findings, LintStats &stats);
// Adds to wrappers each custom tag defined in text (<tag name="X">)
// whose definition runs the caller's content as its statement:
// <sql ...><container></sql>.
void findSqlWrappers(const std::string &text, std::vector<std::string> &wrappers);
// Scans files and directories (recursively; every regular file,
// whatever its extension). Tag definitions are collected from all of
// them first, so a wrapper defined in one file is found in all.
// Prints one line per finding and a summary. Returns 0 when nothing is found, 1 when something is,
// 2 on an error (unreadable path).
int lintSql(const std::vector<std::string> &paths, bool strict, std::ostream &out, std::ostream &err);
}
#endif
+48
View File
@@ -83,6 +83,11 @@ namespace jetc {
// otherwise), it was previously miscategorized as void.
"set", "include", "cookie", "header", "read", "write",
"call", "system", "dump",
// <bind> (see __bind.cpp) supplies one <sql> placeholder value
// and never has a closing tag - without this a bare
// <bind value="..."> outside a <sql> span would scan forward
// for a "</bind>" that doesn't exist.
"bind",
// <container> (see parseContainerSlot/Tag::renderContainer) -
// real content always writes it as a bare marker with no
// separate closing tag, even when it carries its own
@@ -162,6 +167,48 @@ namespace jetc {
}
}
// Advances p from '<' of "<comment" (any case - matchTagOpen already
// confirmed the match before this is called) past the whole
// <comment>...</comment> construct, including any nested <comment>
// tags, counted the same case-insensitive way everything else in this
// file matches tag names. Deliberately does NOT call skipOpenTag/
// skipQuotedValue/skipEmbeddedTag or any other quote- or tag-aware
// scanning on the body text - a comment containing an explanatory '"'
// or '\"' (about the code itself, say) previously fell through to
// parseFallback()'s generic path, which DOES apply those rules while
// hunting for this same closing tag, and silently mislocated it
// exactly like the already-documented JS-comment-corrupts-jetc bug
// class, just triggered from inside a <comment> instead of a //
// comment. This only ever advances past '<'/'>' boundaries it
// recognizes as comment open/close - nothing inside can affect it.
void Parser::skipCommentTag(size_t &p) {
p += 8; // "<comment" (8 chars regardless of case)
bool selfClosing = false;
while (p < s.size() && s[p] != '>') {
if (s[p] == '/' && p + 1 < s.size() && s[p + 1] == '>') selfClosing = true;
p++;
}
if (p < s.size()) p++; // past '>'
if (selfClosing) return;
int depth = 1;
while (p < s.size()) {
if (matchTagOpen("comment", p)) {
depth++;
p++;
continue;
}
if (matchTagClose("comment", p)) {
p += 2; // "</"
while (p < s.size() && isNameChar(s[p])) p++;
if (p < s.size() && s[p] == '>') p++;
depth--;
if (depth == 0) return;
continue;
}
p++;
}
}
bool Parser::skipOpenTag(size_t &p) {
p++; // '<'
while (p < s.size() && isNameChar(s[p])) p++;
@@ -555,6 +602,7 @@ namespace jetc {
continue;
}
if (matchTagOpen("container", pos)) { flush(); nodes.push_back(parseContainerSlot()); continue; }
if (matchTagOpen("comment", pos)) { flush(); skipCommentTag(pos); continue; }
if (topLevel && matchTagOpen("tag", pos)) { flush(); nodes.push_back(parseTagDef()); continue; }
flush();
nodes.push_back(parseFallback());
+9
View File
@@ -61,6 +61,15 @@ namespace jetc {
void skipQuotedValue(size_t &p);
void skipEmbeddedTag(size_t &p);
// <comment>...</comment> must be fully inert regardless of what's
// inside it - unlike the generic parseFallback/scanBody path this
// tag used to fall through to (which applies the same quote/
// backslash-escape and nested-tag scanning real Jet syntax needs),
// this tracks only same-tag-name nesting depth via matchTagOpen/
// matchTagClose and otherwise ignores every character. See its own
// definition for the quote-corruption bug this specifically closes.
void skipCommentTag(size_t &p);
std::map<std::string, std::string> parseAttrs(bool &hasContainer);
// Scans forward from bodyStart (just after the opening tag's '>') for
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 510 KiB

+137 -34
View File
@@ -24,12 +24,6 @@
'<path d="M20 11a8 8 0 0 0-14.6-4.4M4 4v5h5"/>' +
'<path d="M4 13a8 8 0 0 0 14.6 4.4M20 20v-5h-5"/>' +
'</svg>',
disconnect:
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' +
'<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>' +
'<path d="M16 17l5-5-5-5"/>' +
'<path d="M21 12H9"/>' +
'</svg>',
flag:
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' +
'<path d="M5 3v18"/>' +
@@ -41,6 +35,21 @@
'<path d="M9 7V4h6v3"/>' +
'<path d="M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"/>' +
'<path d="M10 11v6M14 11v6"/>' +
'</svg>',
pagePrev:
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' +
'<path d="M15 18l-6-6 6-6"/>' +
'</svg>',
pageNext:
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' +
'<path d="M9 18l6-6-6-6"/>' +
'</svg>',
emptyFolder:
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' +
'<path d="M4 7h16"/>' +
'<path d="M9 7V4h6v3"/>' +
'<path d="M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"/>' +
'<path d="M9.5 12.5l5 5M14.5 12.5l-5 5"/>' +
'</svg>'
};
@@ -55,6 +64,19 @@
// showing search results instead (see performSearch()/clearSearch()
// and loadMessageList()'s own branch on this).
var currentSearchQuery = null;
// How many newest-first messages /email/list has already skipped -
// 0 is the newest page. Must match LIST_LIMIT server-side (email.jet
// defaults "limit" to 50 too) so a page is exactly one "limit"
// worth of messages. Reset to 0 everywhere currentFolder/currentUid
// already get reset (folder switch, search, account switch) - a
// stale offset from one folder/account applied to another would
// silently skip or duplicate messages.
var currentOffset = 0;
var LIST_LIMIT = 50;
// Total message count the server reported for the CURRENT page's
// folder/query, used only to enable/disable the Next button -
// updated every time updateListCount() runs.
var currentTotal = 0;
// The array last handed to renderMessageList() - kept so openMessage()
// can flip a single message's .seen flag locally and recompute the
// toolbar's unread/total count without a round trip.
@@ -76,6 +98,7 @@
return;
currentFolder = folder;
currentUid = null;
currentOffset = 0;
// A folder click always means "show me this folder, plain" - drops
// out of search mode even if the folder didn't actually change,
// which is exactly how a user would expect to back out of a
@@ -93,6 +116,15 @@
var links = document.querySelectorAll('.email-folder-link');
for (var i = 0; i < links.length; i++)
links[i].classList.toggle('email-folder-selected', links[i].getAttribute('data-folder') === currentFolder);
// Only Spam/Trash ever offer this - emptying Inbox (or any future
// folder) as a single destructive click isn't something any real
// mail client exposes, and the server enforces the exact same
// Spam/Trash-only allowlist independently (see email.jet) - this is
// just keeping the button from ever being visible somewhere it
// would 400 anyway, not the actual safety boundary.
var emptyBtn = document.getElementById('email-empty-folder-btn');
if (emptyBtn)
emptyBtn.hidden = (currentFolder !== 'Spam' && currentFolder !== 'Trash');
}
function escapeHtml(s) {
@@ -135,14 +167,15 @@
'<div id="email-toolbar">' +
'<span id="email-connected-as">' + escapeHtml(userEmail) + '</span>' +
'<span id="email-list-count"></span>' +
'<span id="email-pagination"></span>' +
'<span id="email-toolbar-actions">' +
'<span id="email-search-box">' +
'<input type="text" id="email-search-input" placeholder="Search mail&hellip;">' +
'<button type="button" id="email-search-btn" class="icon-btn" title="Search">' + ICONS.search + '</button>' +
'</span>' +
'<button type="button" id="email-compose-btn" class="icon-btn" title="New Mail">' + ICONS.compose + '</button>' +
'<button type="button" id="email-empty-folder-btn" class="icon-btn" title="Permanently empty this folder" hidden>' + ICONS.emptyFolder + '</button>' +
'<button type="button" id="email-refresh-btn" class="icon-btn" title="Refresh">' + ICONS.refresh + '</button>' +
'<button type="button" id="email-disconnect-btn" class="icon-btn" title="Disconnect">' + ICONS.disconnect + '</button>' +
'</span>' +
'</div>' +
'<div id="email-layout">' +
@@ -202,23 +235,7 @@
document.getElementById('email-refresh-btn').addEventListener('click', function() {
loadMessageList();
});
document.getElementById('email-disconnect-btn').addEventListener('click', function() {
// Disconnecting only ever drops the ACTIVE account now (see
// /email/disconnect's own doc comment in email.jet) - if another
// already-connected account remains, res.active names it and the
// view just switches there instead of falling back to the
// connect form.
post('/email/disconnect', {}).then(function(res) {
if (res.active) {
resetViewForActiveAccount(res.active);
} else {
currentFolder = 'Inbox';
currentUid = null;
syncActiveFolder();
showConnectForm();
}
});
});
document.getElementById('email-empty-folder-btn').addEventListener('click', emptyCurrentFolder);
// Matches sender, subject, or body content in whatever folder is
// currently open (see __imap.cpp's searchMessages()) - an empty
@@ -231,6 +248,7 @@
var query = input.value.trim();
currentSearchQuery = query === '' ? null : query;
currentUid = null;
currentOffset = 0;
document.getElementById('email-reading-pane').innerHTML =
'<div id="email-empty-state">Select a message to read it.</div>';
loadMessageList();
@@ -258,10 +276,51 @@
countEl.textContent = '(' + unread + '/' + messages.length + ')';
}
function renderMessageList(messages) {
// total === null means "not paginated" (search results, or nothing
// loaded yet) - hides the whole control rather than showing a
// meaningless "1-0 of null". Otherwise renders the current page's
// 1-based range and enables Prev/Next based on currentOffset/total,
// matching how far a click on either button would actually move.
function updatePaginationControls(total) {
var el = document.getElementById('email-pagination');
if (!el)
return;
currentTotal = total || 0;
if (total === null || total === 0) {
el.innerHTML = '';
return;
}
var rangeStart = total === 0 ? 0 : currentOffset + 1;
var rangeEnd = Math.min(currentOffset + LIST_LIMIT, total);
var atStart = currentOffset <= 0;
var atEnd = currentOffset + LIST_LIMIT >= total;
el.innerHTML =
'<button type="button" id="email-page-prev" class="icon-btn"' + (atStart ? ' disabled' : '') + ' title="Newer messages">' + ICONS.pagePrev + '</button>' +
'<span id="email-page-range">' + rangeStart + '–' + rangeEnd + ' of ' + total + '</span>' +
'<button type="button" id="email-page-next" class="icon-btn"' + (atEnd ? ' disabled' : '') + ' title="Older messages">' + ICONS.pageNext + '</button>';
var prevBtn = document.getElementById('email-page-prev');
var nextBtn = document.getElementById('email-page-next');
if (prevBtn) prevBtn.addEventListener('click', function() {
if (currentOffset <= 0)
return;
currentOffset = Math.max(0, currentOffset - LIST_LIMIT);
currentUid = null;
loadMessageList();
});
if (nextBtn) nextBtn.addEventListener('click', function() {
if (currentOffset + LIST_LIMIT >= currentTotal)
return;
currentOffset += LIST_LIMIT;
currentUid = null;
loadMessageList();
});
}
function renderMessageList(messages, total) {
var list = document.getElementById('email-list');
currentMessages = messages;
updateListCount(messages);
updatePaginationControls(total === undefined ? null : total);
if (!messages.length) {
list.innerHTML = '<div id="email-empty-state">No messages.</div>';
return;
@@ -403,6 +462,38 @@
});
}
// Permanently deletes every message in the CURRENT folder (only ever
// reachable while viewing Spam or Trash - see syncActiveFolder()'s own
// button-visibility gate, and email.jet's independent server-side
// allowlist, which is the real enforcement). Unlike trashMessage()
// there's no undo, no "move somewhere" - a real, human-readable confirm()
// is the whole safety net here, matching how Gmail/Outlook both gate
// "Empty Trash now" behind exactly one extra click and nothing fancier.
function emptyCurrentFolder() {
if (currentFolder !== 'Spam' && currentFolder !== 'Trash')
return;
if (!window.confirm('Permanently delete every message in ' + currentFolder + '? This cannot be undone.'))
return;
var btn = document.getElementById('email-empty-folder-btn');
if (btn) btn.disabled = true;
post('/email/emptyfolder', { folder: currentFolder })
.then(function(res) {
if (btn) btn.disabled = false;
if (!res.ok) {
window.alert(res.error || 'Could not empty the folder.');
return;
}
currentUid = null;
document.getElementById('email-reading-pane').innerHTML =
'<div id="email-empty-state">Select a message to read it.</div>';
loadMessageList();
})
.catch(function() {
if (btn) btn.disabled = false;
window.alert('Empty-folder request failed.');
});
}
// Same fade-out/fetch-concurrently/fade-in shape as openMessage() and
// spa.js's own navigate() - every list refresh (folder switch,
// refresh button) gets the same smooth transition instead of a flash
@@ -421,10 +512,11 @@
// (see __imap.cpp's shared parseSummaryLines()), so this is the
// only place that needs to know search mode even exists -
// renderMessageList() below has no idea which one produced what
// it's rendering.
// it's rendering. Search isn't paginated (offset/limit only apply
// to the plain listing) - a search result set is returned in full.
var request = currentSearchQuery
? post('/email/search', { folder: currentFolder, query: currentSearchQuery })
: post('/email/list', { folder: currentFolder });
: post('/email/list', { folder: currentFolder, offset: currentOffset, limit: LIST_LIMIT });
return Promise.all([
request,
skipFade ? true : delay(180)
@@ -433,8 +525,10 @@
var res = results[0];
if (!res.ok && res.error)
list.innerHTML = '<div id="email-empty-state">' + escapeHtml(res.error) + '</div>';
else if (currentSearchQuery)
renderMessageList(Array.isArray(res) ? res : [], null);
else
renderMessageList(Array.isArray(res) ? res : []);
renderMessageList(Array.isArray(res.messages) ? res.messages : [], res.total || 0);
// Every place that reloads the list (connect, folder switch,
// refresh, post-trash) is a place the unseen counts next to
// each folder name could plausibly have changed too - one
@@ -444,8 +538,10 @@
if (!skipFade)
list.classList.remove('email-fading');
})
.catch(function() {
list.innerHTML = '<div id="email-empty-state">Could not load messages.</div>';
.catch(function(err) {
console.error('loadMessageList failed:', err);
list.innerHTML = '<div id="email-empty-state">Could not load messages' +
(err && err.message ? ': ' + escapeHtml(err.message) : '.') + '</div>';
if (!skipFade)
list.classList.remove('email-fading');
});
@@ -462,8 +558,10 @@
// cosmetic problem, not worth surfacing as a user-visible failure.
function loadFolderCounts() {
post('/email/folders', {}).then(function(res) {
if (res.error)
if (res.error) {
console.error('loadFolderCounts server error:', res.error);
return;
}
var folders = ['Inbox', 'Spam', 'Trash'];
for (var i = 0; i < folders.length; i++) {
var f = folders[i];
@@ -471,7 +569,9 @@
if (span && res[f])
span.textContent = res[f].messages > 0 ? (res[f].unseen + '/' + res[f].messages) : '';
}
}).catch(function() {});
}).catch(function(err) {
console.error('loadFolderCounts failed:', err);
});
}
function loadAccounts() {
@@ -506,6 +606,7 @@
function resetViewForActiveAccount(user) {
currentFolder = 'Inbox';
currentUid = null;
currentOffset = 0;
currentSearchQuery = null;
var searchInput = document.getElementById('email-search-input');
if (searchInput) searchInput.value = '';
@@ -711,8 +812,10 @@
}
pane.classList.remove('email-fading');
})
.catch(function() {
pane.innerHTML = '<div id="email-empty-state">Could not load message.</div>';
.catch(function(err) {
console.error('openMessage failed:', err);
pane.innerHTML = '<div id="email-empty-state">Could not load message' +
(err && err.message ? ': ' + escapeHtml(err.message) : '.') + '</div>';
pane.classList.remove('email-fading');
});
}
+537 -4
View File
@@ -13,16 +13,16 @@
@font-face {
font-family: avenir;
src: url('https://barant.com/fonts/AvenirLTStd-Light.ttf');
src: url('https://barant.com/assets/AvenirLTStd-Light.ttf');
}
@font-face {
font-family: source;
src: url('https://barant.com/fonts/jackinput.TTF');
src: url('https://barant.com/assets/jackinput.TTF');
}
@font-face {
font-family: exo2;
src: url('https://barant.com/fonts/Exo2-RegularCondensed.otf');
src: url('https://barant.com/assets/Exo2-RegularCondensed.otf');
}
:root {
@@ -283,7 +283,7 @@ textarea.fieldinputerror {
background: linear-gradient(180deg, #131318, #0d0d10);
border-radius: 5px 5px 0px 0px;
border-bottom: 1px solid var(--bond-line);
max-height: 80px;
max-height: 125px;
}
.entryform {
background: #232330;
@@ -365,6 +365,43 @@ textarea.fieldinputerror {
transition: color 0.2s ease, border-color 0.2s ease;
}
/* Every entry in a page's own sidebar submenu (e.g. opensource.menu's
list of subpages) shares this same box model - selected and
unselected alike - so the only thing that changes when an item
becomes active is its background/border, never its box size or the
position of its own text. Giving only the active item padding/margin
(the original approach) made its text visibly shift the moment it
was selected, since the unselected items sat flush with none. */
#panelmenu a {
display: block;
padding: 2px 6px;
margin: 2px 0;
}
/* The currently-active entry - a background highlight rather than
baritemselected's "raised tab" treatment, since these are plain
links stacked in a list, not tabs sitting on a bar edge. Applied
server-side (see opensource.menu) by comparing each linkbutton's own
subpage against $[SUBPAGE] - spa.js also applies it instantly client-
side on click (see its #panelmenu click listener) and then
re-confirms it from the server's own #_spa_panelmenu markup once the
fetch resolves, so this stays correct either way. */
.submenuitem-active {
background: var(--bond-panel-2);
color: var(--bond-gold-bright) !important;
border-radius: 3px;
box-shadow: inset 0 0 0 1px var(--bond-gold);
}
/* Every menu entry's own markup is <linkbutton...></linkbutton><br> - that
<br> was needed to force a line break after an inline link, but every
entry is display:block now (its own implicit line break), so the
trailing <br> doubles up into a blank line for every item, not just
the active one. */
#panelmenu a + br {
display: none;
}
.panel {
background: var(--bond-panel);
margin: 10px;
@@ -843,3 +880,499 @@ textarea.fieldinputerror {
.filemgr-progress-fill { height: 100%; width: 0%; background: var(--bond-gold-bright); transition: width 0.15s ease; }
.filemgr-item.filemgr-done .filemgr-progress-fill { background: #6c6; }
.filemgr-item.filemgr-failed .filemgr-progress-fill { background: #c66; }
/* Fades in during an SPA navigation fetch - lives outside #content (a
content.innerHTML swap would just wipe it out otherwise), positioned
relative to the viewport rather than the resizable content column so
dragging #panelmenu-resizer narrower/wider never throws its centering
off. The transition duration alone (no separate timer) is what keeps
a fast load from ever showing it at a noticeable opacity before the
class comes back off. */
.spa-loading-indicator {
position: fixed;
top: 90px;
left: 50%;
transform: translateX(-50%);
color: var(--bond-text-dim);
font-size: 10pt;
letter-spacing: 1px;
opacity: 0;
transition: opacity 0.6s ease;
pointer-events: none;
z-index: 500;
}
.spa-loading-indicator.spa-loading-visible {
opacity: 1;
}
/* Fades in during an SPA navigation fetch - lives outside #content (a
content.innerHTML swap would just wipe it out otherwise), positioned
relative to the viewport rather than the resizable content column so
dragging #panelmenu-resizer narrower/wider never throws its centering
off. The transition duration alone (no separate timer) is what keeps
a fast load from ever showing it at a noticeable opacity before the
class comes back off. */
.spa-loading-indicator {
position: fixed;
top: 90px;
left: 50%;
transform: translateX(-50%);
color: var(--bond-text-dim);
font-size: 10pt;
letter-spacing: 1px;
opacity: 0;
transition: opacity 0.6s ease;
pointer-events: none;
z-index: 500;
}
.spa-loading-indicator.spa-loading-visible {
opacity: 1;
}
/* Keeps the music/library/ianslibrary subpages pinned to the browser
window's height (footer always visible, no whole-page scroll) while
the song list itself scrolls internally - the exact same pattern
already proven for the email app's own message list
(.pageclass:has(#email-app)), just scoped to this marker instead and
adapted for <sectionframe>'s own heading-then-contents structure
(the heading needs to stay a fixed size above the scrolling list,
not get swept into the same scroll region). height:100% has to be
set explicitly at every level down to .music-song-list itself -
percentage heights only resolve against an ancestor with its own
definite height, and a plain block element's default is auto, which
does not count, so skipping any one level here would silently break
the whole chain. #main-subpage (main.page's generic per-subpage
wrapper, between #content and .sectionframe) is exactly that kind of
skip - missing it let .sectionframe's height:100% resolve to auto,
so .music-song-list sized itself to its full content height instead
of a scrollable box, and the overflow got clipped by .pageclass's
own overflow:hidden with no scrollbar to show for it. */
.pageclass:has(.music-song-list) {
height: calc(100vh - 150px);
overflow: hidden;
}
#content:has(.music-song-list) {
height: 100%;
overflow: hidden;
}
#main-subpage:has(.music-song-list) {
height: 100%;
overflow: hidden;
}
.sectionframe:has(.music-song-list) {
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
box-sizing: border-box;
}
.sectionframe:has(.music-song-list) .sectionframecontents {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
.music-song-list {
flex: 1;
min-height: 0;
overflow-y: auto;
}
/* Fades in during an SPA navigation fetch - lives outside #content (a
content.innerHTML swap would just wipe it out otherwise), positioned
relative to the viewport rather than the resizable content column so
dragging #panelmenu-resizer narrower/wider never throws its centering
off. The transition duration alone (no separate timer) is what keeps
a fast load from ever showing it at a noticeable opacity before the
class comes back off. */
.spa-loading-indicator {
position: fixed;
top: 90px;
left: 50%;
transform: translateX(-50%);
color: var(--bond-text-dim);
font-size: 10pt;
letter-spacing: 1px;
opacity: 0;
transition: opacity 0.6s ease;
pointer-events: none;
z-index: 500;
}
.spa-loading-indicator.spa-loading-visible {
opacity: 1;
}
/* Global persistent music player band - slides open only while playing */
.globalplayer-band {
max-height: 0;
overflow: hidden;
display: flex;
align-items: center;
gap: 10px;
background: var(--bond-panel);
border-bottom: 1pt solid var(--bond-line);
padding: 0 16px;
box-sizing: border-box;
transition: max-height 0.3s ease, padding 0.3s ease;
}
.globalplayer-band.globalplayer-open {
max-height: 54px;
padding: 10px 16px;
}
.globalplayer-title {
position: relative;
flex: 1;
/* A flex item's default min-width is its content's own min-content
size, not 0 - without this, a long song name would force the whole
LCD panel wider (squeezing the volume slider/buttons) rather than
actually truncating against the space it is given. */
min-width: 0;
display: flex;
flex-direction: column;
justify-content: center;
background: #000;
border: 1px solid #333;
border-radius: 4px;
padding: 4px 10px;
box-sizing: border-box;
box-shadow: inset 0 0 8px rgba(26,143,196,0.12), inset 0 2px 4px rgba(0,0,0,0.8);
}
.globalplayer-duration {
position: absolute;
top: 4px;
right: 8px;
font-family: 'Consolas', 'Courier New', monospace;
font-size: 10pt;
color: #1a8fc4;
text-shadow: 0 0 4px rgba(26,143,196,0.7);
opacity: 0.85;
}
.globalplayer-random-indicator {
position: absolute;
top: 20px;
right: 8px;
font-family: 'Consolas', 'Courier New', monospace;
font-size: 7pt;
letter-spacing: 1px;
color: #1a8fc4;
text-shadow: 0 0 4px rgba(26,143,196,0.7);
opacity: 0.85;
display: none;
}
.globalplayer-random-indicator.globalplayer-random-indicator-visible {
display: block;
}
.globalplayer-title-text {
font-family: 'Consolas', 'Courier New', monospace;
font-size: 20pt;
line-height: 1.1;
color: #1a8fc4;
text-shadow: 0 0 5px rgba(26,143,196,0.8), 0 0 1px rgba(26,143,196,0.9);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.globalplayer-progress {
position: relative;
height: 8px;
width: 100%;
background: rgba(26,143,196,0.15);
border-radius: 4px;
margin-top: 4px;
box-sizing: border-box;
cursor: pointer;
touch-action: none;
}
.globalplayer-progress-fill {
height: 100%;
width: 0%;
background: #1a8fc4;
border-radius: 4px 0 0 4px;
box-shadow: 0 0 4px rgba(26,143,196,0.8);
transition: width 0.2s linear;
pointer-events: none;
}
.globalplayer-progress-handle {
position: absolute;
top: 50%;
left: 0%;
width: 12px;
height: 12px;
border-radius: 50%;
background: radial-gradient(circle at 35% 30%, #fff6d0 0%, #d4af37 55%, #6b5313 100%);
border: 1px solid #5a4410;
box-shadow: 0 1px 3px rgba(0,0,0,0.7);
transform: translate(-50%, -50%);
transition: left 0.2s linear;
pointer-events: none;
}
.globalplayer-progress.globalplayer-progress-dragging .globalplayer-progress-fill,
.globalplayer-progress.globalplayer-progress-dragging .globalplayer-progress-handle {
transition: none;
}
/* Square, touch-tone-style buttons for the player band - same dished
gold-on-black look as the sipphone tag's dialpad keys. */
.globalplayer-btn {
flex-shrink: 0;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 8px;
background: radial-gradient(circle at 50% 50%, #8a6a22 0%, #b8903a 32%, #d4af37 55%, #ecce79 80%, #fff6d0 100%);
border: 1px solid #5a4410;
box-shadow:
0 2px 0 #4a3a0f,
0 3px 5px rgba(0,0,0,0.5),
inset 0 3px 5px rgba(0,0,0,0.45),
inset 0 -1px 1px rgba(255,255,255,0.5);
color: #3a2d05;
cursor: pointer;
transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.globalplayer-btn svg { width: 16px; height: 16px; }
.globalplayer-btn:active {
transform: translateY(2px);
box-shadow:
inset 0 4px 8px rgba(0,0,0,0.6),
inset 0 -1px 1px rgba(255,255,255,0.3);
}
.globalplayer-btn-text {
width: auto;
padding: 0 12px;
font-size: 10px;
font-weight: bold;
letter-spacing: 1px;
white-space: nowrap;
}
/* Stereo FFT-style bar graph - left channel above the midline, right
channel below it, drawn directly onto a small canvas. */
.globalplayer-eq {
flex-shrink: 0;
width: 60px;
height: 32px;
background: #000;
border: 1px solid #333;
border-radius: 4px;
}
/* Playlist dropdown - its own independent sliding strip directly below
the player band, NOT nested inside it: the band's own overflow:hidden
(needed for its slide animation) would otherwise clip anything
positioned to pop out below it, which is why this was invisible
before despite the open/close class toggling correctly in JS. */
.globalplayer-queue {
max-height: 0;
overflow: hidden;
background: var(--bond-panel-2);
border-bottom: 1pt solid var(--bond-line);
transition: max-height 0.25s ease;
}
.globalplayer-queue.globalplayer-queue-open {
max-height: 240px;
overflow-y: auto;
}
.globalplayer-queue-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin: 6px 10px;
padding: 8px 14px;
border: 1px solid var(--bond-line);
border-radius: 8px;
background: rgba(255,255,255,0.03);
color: var(--bond-text-dim);
}
.globalplayer-queue-name {
font-size: 18pt;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.globalplayer-queue-left {
display: flex;
align-items: center;
gap: 8px;
flex: 1;
min-width: 0;
}
.globalplayer-queue-handle {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
color: var(--bond-text-dim);
cursor: grab;
}
.globalplayer-queue-handle svg {
width: 14px;
height: 14px;
}
.globalplayer-queue-item.globalplayer-queue-dragging {
opacity: 0.4;
}
.globalplayer-queue-item.globalplayer-queue-dragover {
border-top: 2px solid var(--bond-gold-bright);
}
.globalplayer-queue-right {
flex-shrink: 0;
display: flex;
align-items: center;
gap: 8px;
}
.globalplayer-queue-duration {
flex-shrink: 0;
font-size: 9pt;
opacity: 0.75;
}
.globalplayer-queue-remove {
flex-shrink: 0;
display: inline-flex;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
padding: 0;
margin: 0;
border-radius: 6px;
border: 1px solid var(--bond-line);
background: linear-gradient(180deg, #1c1c24, #131318);
color: var(--bond-text-dim);
cursor: pointer;
transition: box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.globalplayer-queue-remove svg {
width: 12px;
height: 12px;
display: block;
}
.globalplayer-queue-remove:hover {
border-color: var(--bond-red);
color: var(--bond-red);
box-shadow: 0 0 0.5em rgba(161,58,58,0.35);
background: linear-gradient(180deg, #24242e, #1a1a20);
}
.globalplayer-queue-item.globalplayer-queue-current {
color: var(--bond-gold-bright);
font-weight: 600;
border-color: var(--bond-gold);
background: rgba(212,175,55,0.08);
}
/* Tactile feedback for clicking a song to queue it: an immediate flash
on the row, plus a lasting checkmark so it is clear at a glance which
songs are already in the queue. */
/* Scoped to the name span, not the row itself: the row is a flex
container with justify-content:space-between, and a ::before on it
directly becomes its own flex item - with 3 items instead of 2, the
name ends up looking centered between the checkmark and the duration/
remove group instead of staying left-aligned. Putting it on the name
span keeps it as ordinary inline content inside that one flex item. */
.song-queued .music-song-name::before {
content: "\2713 ";
color: var(--bond-gold-bright);
}
.song-queued-flash {
animation: songQueuedFlash 0.6s ease;
}
@keyframes songQueuedFlash {
0% { background: var(--bond-gold-bright); color: var(--bond-bg); }
100% { background: transparent; }
}
/* Song-picker rows (music/jukebox subpages) - same boxed, rounded-corner
look as the playlist dropdown's own entries, for visual consistency
between "songs you can pick" and "what's in the queue". */
.music-song-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
margin: 4px 0;
padding: 5px 10px;
border: 1px solid var(--bond-line);
border-radius: 8px;
background: rgba(255,255,255,0.03);
color: var(--bond-text-dim);
cursor: pointer;
}
.music-song-row:hover {
border-color: var(--bond-gold);
background: rgba(255,255,255,0.06);
}
.music-song-name {
font-size: 12pt;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.music-song-duration {
flex-shrink: 0;
font-size: 8pt;
opacity: 0.75;
}
/* Volume slider - a small gold knob riding a thin gold-tinted track */
.globalplayer-volume {
-webkit-appearance: none;
appearance: none;
flex-shrink: 0;
width: 70px;
height: 4px;
border-radius: 2px;
background: var(--bond-line);
outline: none;
cursor: pointer;
}
.globalplayer-volume::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 14px;
height: 14px;
border-radius: 50%;
background: radial-gradient(circle at 35% 30%, #fff6d0 0%, #d4af37 55%, #6b5313 100%);
border: 1px solid #5a4410;
box-shadow: 0 1px 2px rgba(0,0,0,0.6);
cursor: pointer;
}
.globalplayer-volume::-moz-range-track {
height: 4px;
border-radius: 2px;
background: var(--bond-line);
}
.globalplayer-volume::-moz-range-thumb {
width: 14px;
height: 14px;
border-radius: 50%;
background: radial-gradient(circle at 35% 30%, #fff6d0 0%, #d4af37 55%, #6b5313 100%);
border: 1px solid #5a4410;
box-shadow: 0 1px 2px rgba(0,0,0,0.6);
cursor: pointer;
}
+60 -8
View File
@@ -1,6 +1,7 @@
(function() {
var content = document.getElementById('content');
var form = document.getElementById('mainform');
var loadingIndicator = document.getElementById('spa-loading-indicator');
// Lives outside #content (a sibling in the persistent shell, next to
// the menu bar/form) - a fragment swap never touches it on its own,
// so a per-page side menu would otherwise stay frozen on whichever
@@ -127,19 +128,43 @@
// a client-side SPA swap (e.g. clicking "Check Out") instead of a
// full reload; only worked by accident on a fresh /checkout load.
// Re-creating each script element makes the browser actually run
// it. async=false on src="" ones preserves normal in-order
// execution (dynamically-inserted external scripts default to
// async otherwise), matching how a real page load would run them.
// it. A prior fix set async=false on src="" ones, but that only
// orders MULTIPLE external scripts relative to each other - it
// does nothing to delay a plain inline script sitting right after
// one, which still runs immediately on insertion regardless of a
// sibling's in-flight fetch. checkout.page is exactly that shape
// (an external Square SDK <script src> immediately followed by an
// inline script calling Square.payments(...)): on a client-side
// SPA swap the inline script ran before Square had actually
// finished downloading, throwing "Square is not defined" inside an
// async function with no visible catch, leaving the card container
// permanently empty - reported as "checkout's card field doesn't
// build the first time, only after a refresh" (a real full page
// load's parser-inserted <script src> blocks until loaded before
// the next tag runs, which a dynamically re-created one does not
// do on its own). Fixed by actually waiting for each external
// script's load/error event before moving on to the next one,
// rather than trusting async=false's narrower ordering guarantee -
// reproduced the failure and confirmed the fix against a real
// artificially-delayed script load before deploying.
var scripts = content.querySelectorAll('script');
for (var i = 0; i < scripts.length; i++) {
var old = scripts[i];
var scriptList = [];
for (var i = 0; i < scripts.length; i++) scriptList.push(scripts[i]);
(function runScript(index) {
if (index >= scriptList.length) return;
var old = scriptList[index];
var fresh = document.createElement('script');
for (var j = 0; j < old.attributes.length; j++)
fresh.setAttribute(old.attributes[j].name, old.attributes[j].value);
if (fresh.src) fresh.async = false;
fresh.textContent = old.textContent;
old.parentNode.replaceChild(fresh, old);
}
if (fresh.src) {
fresh.onload = fresh.onerror = function() { runScript(index + 1); };
old.parentNode.replaceChild(fresh, old);
} else {
old.parentNode.replaceChild(fresh, old);
runScript(index + 1);
}
})(0);
// #_spa_panelmenu carries the CURRENT page's own side-menu markup
// (mainpagetemplate.jet renders it into every fragment response
// specifically so this can pull it out) - extracted from the
@@ -196,6 +221,12 @@
function navigate(url, push) {
var sep = url.indexOf('?') === -1 ? '?' : '&';
content.classList.add('spa-fading');
// Opacity transition alone (see the CSS) means a fetch that resolves
// quickly never gets the indicator past a barely-visible opacity
// before this removes the class again - exactly the "do not flash
// this for a fast load" behavior wanted, with no separate delay
// timer needed to achieve it.
if (loadingIndicator) loadingIndicator.classList.add('spa-loading-visible');
Promise.all([
fetch(url + sep + '_fragment=1', { credentials: 'same-origin' }).then(function(r) { return r.text(); }),
delay(180)
@@ -209,6 +240,7 @@
syncActiveTab(finalUrl.split('?')[0]);
}
content.classList.remove('spa-fading');
if (loadingIndicator) loadingIndicator.classList.remove('spa-loading-visible');
});
}
@@ -230,6 +262,7 @@
var subpage = fd.get('SUBPAGE') || '';
var url = formPrefix + '/' + page + (subpage ? '/' + subpage : '');
content.classList.add('spa-fading');
if (loadingIndicator) loadingIndicator.classList.add('spa-loading-visible');
Promise.all([
fetch(url + '?_fragment=1', {
method: 'POST',
@@ -247,6 +280,7 @@
syncActiveTab(finalUrl.split('?')[0]);
}
content.classList.remove('spa-fading');
if (loadingIndicator) loadingIndicator.classList.remove('spa-loading-visible');
});
});
}
@@ -255,6 +289,24 @@
navigate(window.location.pathname + window.location.search, false);
});
// Instant visual feedback on a side-menu click - without this, the
// active-item highlight only updated once applyResponse() swapped in
// the new #_spa_panelmenu markup after the fetch finished, which read
// as unresponsive (the click did nothing visible until the whole
// subpage had already loaded). That server-rendered swap is still the
// authoritative source of truth and will correct this on arrival (e.g.
// if a click ends up redirected somewhere else entirely), so this is
// purely an optimistic bridge, not a second source of truth.
if (panelMenu) {
panelMenu.addEventListener('click', function(e) {
var a = e.target.closest('a');
if (!a || !panelMenu.contains(a)) return;
var current = panelMenu.querySelector('.submenuitem-active');
if (current) current.classList.remove('submenuitem-active');
a.classList.add('submenuitem-active');
});
}
// Drag-to-resize for the side menu (#panelmenu) against the main
// content column - the resizer bar (#panelmenu-resizer) lives in the
// persistent shell right alongside panelMenu itself (see its own
-6
View File
@@ -113,12 +113,6 @@
document.forms[0].requestSubmit();">&nbsp;<CONTAINER>&nbsp;</BUTTON>
</TAG>
<tag name="setenv" keywords="name">
<eval name="_envvalue" scope="local"><container></eval>
<set name="#[name]" value="#[_envvalue]">
<set name="@#[name]" value="#[_envvalue]">
</tag>
<tag name="clearenv" keywords="name">
<set name="#[name]" value="">
<set name="@#[name]" value="">
+421
View File
@@ -0,0 +1,421 @@
<tag name="sipphone">
<style>
.sipphone-bond {
width: 360px;
margin: 10px 0 24px 0;
padding: 14px;
border-radius: 16px;
background: linear-gradient(160deg, #1a1a1a 0%, #060606 60%, #000 100%);
border: 1px solid #000;
box-shadow:
0 0 0 2px #2a2a2a,
0 0 0 3px #b8860b,
0 10px 30px rgba(0,0,0,0.6),
inset 0 1px 0 rgba(255,255,255,0.05);
font-family: 'Segoe UI', Arial, sans-serif;
color: #d4af37;
}
.sipphone-bond .sipphone-brand {
text-align: center;
font-size: 10px;
letter-spacing: 4px;
color: #d4af37;
text-shadow: 0 0 6px rgba(212,175,55,0.6);
margin-bottom: 6px;
}
.sipphone-bond .sipphone-lcd {
background: #000;
border: 2px solid #333;
border-radius: 4px;
padding: 8px 10px;
margin-bottom: 10px;
font-family: 'Consolas', 'Courier New', monospace;
color: #39ff6a;
text-shadow: 0 0 5px rgba(57,255,106,0.8), 0 0 1px rgba(57,255,106,0.9);
font-size: 13px;
line-height: 1.5;
min-height: 56px;
box-shadow: inset 0 0 12px rgba(57,255,106,0.15), inset 0 2px 6px rgba(0,0,0,0.8);
position: relative;
overflow: hidden;
}
.sipphone-bond .sipphone-lcd::before {
content: "";
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: repeating-linear-gradient(
to bottom,
rgba(0,0,0,0.15) 0px,
rgba(0,0,0,0.15) 1px,
transparent 1px,
transparent 3px
);
pointer-events: none;
}
.sipphone-bond .sipphone-lcd-line1 { font-size: 30px; font-weight: bold; line-height: 1.2; }
.sipphone-bond .sipphone-lcd-line2 { opacity: 0.85; }
.sipphone-bond .sipphone-video-wrap {
position: relative;
width: 100%;
height: 180px;
background: #000;
border: 1px solid #333;
border-radius: 4px;
margin-bottom: 10px;
overflow: hidden;
display: none;
}
.sipphone-bond .sipphone-video-wrap.active { display: block; }
.sipphone-bond .sipphone-remote-video {
width: 100%;
height: 100%;
object-fit: cover;
background: #000;
}
.sipphone-bond .sipphone-local-video {
position: absolute;
width: 72px;
height: 54px;
right: 6px;
bottom: 6px;
border: 1px solid #d4af37;
border-radius: 3px;
object-fit: cover;
background: #111;
}
.sipphone-bond .sipphone-dialpad {
display: grid;
grid-template-columns: repeat(3, 44px);
justify-content: center;
gap: 8px;
margin-bottom: 10px;
}
.sipphone-bond .sipphone-key {
user-select: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border-radius: 8px;
font-size: 16px;
font-weight: bold;
color: #3a2d05;
background: radial-gradient(circle at 50% 50%, #8a6a22 0%, #b8903a 32%, #d4af37 55%, #ecce79 80%, #fff6d0 100%);
border: 1px solid #5a4410;
box-shadow:
0 2px 0 #4a3a0f,
0 4px 6px rgba(0,0,0,0.6),
inset 0 3px 5px rgba(0,0,0,0.45),
inset 0 -1px 1px rgba(255,255,255,0.5);
transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.sipphone-bond .sipphone-key:active {
transform: translateY(2px);
box-shadow:
inset 0 4px 8px rgba(0,0,0,0.6),
inset 0 -1px 1px rgba(255,255,255,0.3);
}
.sipphone-bond .sipphone-controls {
display: flex;
gap: 8px;
}
.sipphone-bond .sipphone-btn {
flex: 1;
cursor: pointer;
text-align: center;
padding: 9px 0;
border-radius: 8px;
font-size: 12px;
font-weight: bold;
letter-spacing: 1px;
color: #3a2d05;
background: linear-gradient(180deg, #f3d77a 0%, #d4af37 45%, #9c7a1f 100%);
border: 1px solid #5a4410;
box-shadow: 0 2px 0 #4a3a0f, 0 4px 8px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.7);
}
.sipphone-bond .sipphone-btn.sipphone-hangup {
background: linear-gradient(180deg, #e06666 0%, #a30000 60%, #6b0000 100%);
color: #2a0000;
border-color: #3a0000;
}
.sipphone-bond .sipphone-btn:active {
transform: translateY(2px);
box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}
.sipphone-bond .sipphone-btn.sipphone-btn-disabled {
cursor: default;
opacity: 0.35;
filter: grayscale(70%);
box-shadow: none;
pointer-events: none;
}
.sipphone-bond .sipphone-lcd-status-offline {
color: #ff3b3b;
text-shadow: 0 0 6px rgba(255,59,59,0.8);
}
.sipphone-bond .sipphone-status-dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 6px;
background: #666;
box-shadow: 0 0 4px #666;
}
.sipphone-bond .sipphone-status-dot.reg {
background: #39ff6a;
box-shadow: 0 0 6px #39ff6a;
}
.sipphone-bond .sipphone-status-dot.incall {
background: #ffcc00;
box-shadow: 0 0 6px #ffcc00;
}
</style>
<sql>select id, exten, secret from phones.extensions where user_id=$[_login_id] and secret is not null</sql>
<ifrow>
<whilerow>
<div class="sipphone-bond" id="sipphone-$[.id]"
data-sipphone-id="$[.id]"
data-sipphone-exten="$[.exten]"
data-sipphone-secret="$[.secret]"
data-sipphone-domain="barant.com"
data-sipphone-wss="wss://barant.com:8089/ws">
<div class="sipphone-brand">&#9670;&nbsp;B · A · R · A · N · T&nbsp;&#9670;</div>
<div class="sipphone-lcd">
<div class="sipphone-lcd-line1" data-role="lcd-line1">$[.exten]</div>
<div class="sipphone-lcd-line2" data-role="lcd-line2"><span class="sipphone-status-dot" data-role="status-dot"></span><span data-role="lcd-status">OFFLINE</span></div>
</div>
<div class="sipphone-video-wrap" data-role="video-wrap">
<video class="sipphone-remote-video" data-role="remote-video" autoplay playsinline></video>
<video class="sipphone-local-video" data-role="local-video" autoplay playsinline muted></video>
</div>
<div class="sipphone-dialpad" data-role="dialpad">
<div class="sipphone-key" data-digit="1">1</div>
<div class="sipphone-key" data-digit="2">2</div>
<div class="sipphone-key" data-digit="3">3</div>
<div class="sipphone-key" data-digit="4">4</div>
<div class="sipphone-key" data-digit="5">5</div>
<div class="sipphone-key" data-digit="6">6</div>
<div class="sipphone-key" data-digit="7">7</div>
<div class="sipphone-key" data-digit="8">8</div>
<div class="sipphone-key" data-digit="9">9</div>
<div class="sipphone-key" data-digit="*">*</div>
<div class="sipphone-key" data-digit="0">0</div>
<div class="sipphone-key" data-digit="#">#</div>
</div>
<div class="sipphone-controls">
<div class="sipphone-btn" data-role="call-hangup-btn">CALL</div>
<div class="sipphone-btn" data-role="video-toggle-btn">VIDEO: OFF</div>
</div>
</div>
</whilerow>
<script type="module">
import * as SIP from "https://cdn.jsdelivr.net/npm/sip.js@0.21.2/lib/index.min.js";
(function() {
function initSipPhone(root) {
var exten = root.dataset.sipphoneExten;
var secret = root.dataset.sipphoneSecret;
var domain = root.dataset.sipphoneDomain;
var wss = root.dataset.sipphoneWss;
var dialedDigits = "";
var currentSession = null;
var videoEnabled = false;
var isRegistered = false;
var previewStream = null;
var lcdLine1 = root.querySelector('[data-role="lcd-line1"]');
var lcdStatus = root.querySelector('[data-role="lcd-status"]');
var statusDot = root.querySelector('[data-role="status-dot"]');
var videoWrap = root.querySelector('[data-role="video-wrap"]');
var remoteVideo = root.querySelector('[data-role="remote-video"]');
var localVideo = root.querySelector('[data-role="local-video"]');
var callHangupBtn = root.querySelector('[data-role="call-hangup-btn"]');
var videoToggleBtn = root.querySelector('[data-role="video-toggle-btn"]');
function setLcd(line1, status, dotClass) {
if (line1 !== undefined) lcdLine1.textContent = line1;
if (status !== undefined) lcdStatus.textContent = status;
statusDot.className = "sipphone-status-dot" + (dotClass ? (" " + dotClass) : "");
}
function updateCallButton() {
if (currentSession) {
callHangupBtn.textContent = "END";
callHangupBtn.classList.add("sipphone-hangup");
callHangupBtn.classList.remove("sipphone-btn-disabled");
} else {
callHangupBtn.textContent = "CALL";
callHangupBtn.classList.remove("sipphone-hangup");
callHangupBtn.classList.toggle("sipphone-btn-disabled", !isRegistered || !dialedDigits);
}
lcdStatus.classList.toggle("sipphone-lcd-status-offline", !isRegistered);
}
var ua = new SIP.UserAgent({
uri: SIP.UserAgent.makeURI("sip:" + exten + "@" + domain),
transportOptions: { server: wss },
authorizationUsername: exten,
authorizationPassword: secret,
logLevel: "error",
delegate: {
onInvite: function(invitation) {
currentSession = invitation;
updateCallButton();
setLcd("INCOMING CALL", "RINGING", "incall");
attachSessionHandlers(invitation);
invitation.accept({
sessionDescriptionHandlerOptions: {
constraints: { audio: true, video: videoEnabled }
}
}).then(function() {
setLcd(exten, "IN CALL", "incall");
videoWrap.classList.add("active");
attachMedia(invitation);
});
}
}
});
var registerer = new SIP.Registerer(ua);
updateCallButton();
ua.start().then(function() {
return registerer.register();
}).then(function() {
isRegistered = true;
setLcd(exten, "READY", "reg");
updateCallButton();
}).catch(function() {
isRegistered = false;
setLcd(exten, "REG FAILED", "");
updateCallButton();
});
function stopPreview() {
if (previewStream) {
previewStream.getTracks().forEach(function(t) { t.stop(); });
previewStream = null;
}
}
function startPreview() {
if (previewStream || currentSession) return;
navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
if (!videoEnabled || currentSession) {
stream.getTracks().forEach(function(t) { t.stop(); });
return;
}
previewStream = stream;
localVideo.srcObject = stream;
videoWrap.classList.add("active");
}).catch(function() {
videoEnabled = false;
videoToggleBtn.textContent = "VIDEO: OFF";
});
}
function attachMedia(session) {
stopPreview();
var pc = session.sessionDescriptionHandler.peerConnection;
var remoteStream = new MediaStream();
pc.getReceivers().forEach(function(receiver) {
if (receiver.track) remoteStream.addTrack(receiver.track);
});
remoteVideo.srcObject = remoteStream;
var localStream = new MediaStream();
pc.getSenders().forEach(function(sender) {
if (sender.track) localStream.addTrack(sender.track);
});
localVideo.srcObject = localStream;
}
function attachSessionHandlers(session) {
session.stateChange.addListener(function(state) {
if (state === SIP.SessionState.Established) {
setLcd(undefined, "IN CALL", "incall");
videoWrap.classList.add("active");
attachMedia(session);
} else if (state === SIP.SessionState.Terminated) {
setLcd(exten, "READY", "reg");
videoWrap.classList.remove("active");
remoteVideo.srcObject = null;
localVideo.srcObject = null;
currentSession = null;
dialedDigits = "";
updateCallButton();
}
});
}
root.querySelectorAll('[data-digit]').forEach(function(key) {
key.addEventListener('click', function() {
var d = key.dataset.digit;
if (currentSession) {
currentSession.sessionDescriptionHandler.sendDtmf(d);
} else {
dialedDigits += d;
setLcd(dialedDigits || exten, dialedDigits ? "DIALING" : "READY", dialedDigits ? "" : "reg");
updateCallButton();
}
});
});
callHangupBtn.addEventListener('click', function() {
if (!currentSession) {
if (!dialedDigits || !isRegistered) return;
var target = SIP.UserAgent.makeURI("sip:" + dialedDigits + "@" + domain);
var inviter = new SIP.Inviter(ua, target, {
sessionDescriptionHandlerOptions: {
constraints: { audio: true, video: videoEnabled }
}
});
currentSession = inviter;
updateCallButton();
attachSessionHandlers(inviter);
setLcd(dialedDigits, "CALLING...", "incall");
inviter.invite();
} else {
if (currentSession.state === SIP.SessionState.Established) {
currentSession.bye();
} else if (currentSession instanceof SIP.Inviter) {
currentSession.cancel();
} else {
currentSession.reject();
}
}
});
videoToggleBtn.addEventListener('click', function() {
videoEnabled = !videoEnabled;
videoToggleBtn.textContent = "VIDEO: " + (videoEnabled ? "ON" : "OFF");
if (currentSession) return;
if (videoEnabled) {
startPreview();
} else {
stopPreview();
localVideo.srcObject = null;
videoWrap.classList.remove("active");
}
});
}
document.querySelectorAll('.sipphone-bond').forEach(initSipPhone);
})();
</script>
</ifrow>
</tag>
+83
View File
@@ -0,0 +1,83 @@
<sectionframe title="Account Information">
<sql>select * from users where id=$[_login_id]</sql>
<table>
<tr><th class="left">Name:</th><td class="right">$[.name]</td></tr>
<if value1="$[company_name]" value2="" type="ne">
<tr><th class="left">Company Name:</th><td class="right">$[.company_name]</td></tr>
</if>
<tr><th class="left">E-Mail:</th><td class="right">$[.email]</td></tr>
</table>
</sectionframe>
<sql>select * from user_messages where user_id=$[_login_id]</sql>$[sqlerror]
<ifrow>
<sectionframe title="Messages">
<table>
<whilerow>
<tr>
<td>$[.message]</td>
<td>$[.link]</td>
</tr>
</whilerow>
</table>
</sectionframe>
</ifrow>
<sql>select *
from virtual_machines
join products on virtual_machines.sku=products.sku
where user_id=$[_login_id]</sql>
<ifrow>
<sectionframe title="Virtual Machines">
<whilerow>
<div style="margin-bottom: 3px; border: 1pt solid #000; border-radius: 5px;">
<div style="float: left; padding: 2px 5px 0px 5px; vertical-align: middle; display: inline-block;"><img src="$[.image]" width="40"></div>
<div style="float: left; background: #ccf; width: 300px; padding: 0px 0px 0px 0px;"><span style="font-size: 7pt;">Ubuntu Server 22.04 LTE</span>
<br><span style="font-size: 9pt;"><b>barant.com</b></span>
<br><span style="font-size: 7pt;">IP:</span> <span style="font-size: 9pt; font-family: monospace;">74.80.233.78</span></div>
<div style="float: right; padding: 5px;"><img src="/assets/power_on.png" width="32"></div>
<div style="float: right; width: 90px; height: 48px; background: #444;"></div>
<div style="float: right; margin-right: 25px;">3 days 2:10:33<br><br>34% of 40.2GB</div>
<div style="clear: both;"></div>
</div>
</whilerow>
</sectionframe>
</ifrow>
<sql>select *
from files
join products on files.sku=products.sku
where user_id=$[_login_id]</sql>
<ifrow>
<sectionframe title="Downloadable Content">
<p>Content that has been purchased and can be downloaded is displayed
below. Click on the Download button to begin downloading your files.</p>
<whilerow>
<table style="margin: 3px;">
<tr>
<td>
<img src="$[.image]" width="50px"">
</td>
<td style="width: 300px; border: 1pt inset #888">
$[.description]
</td>
<td style="width: 300px;">
<div>$[license_name]</div><div>$[license_key]</div>
</td>
<td>
<a href="/downloadfile.cgi?sku=$[.sku]"><div class="button">Download</div></a>
</td>
</tr>
</table>
</whilerow>
</sectionframe>
</ifrow>
@@ -0,0 +1,18 @@
<sectionframe title="Invoices">
<if value1="$[@_invoice_id]" value2="" type="ne">
<sql>select user_id, status from invoices where id=$[@_invoice_id]</sql>
<ifrow>
<if expr="('$[.user_id]'='$[_login_id]') and ('$[.status]'='OPEN')">
<div style="margin-bottom: 16px;">
<include file="invoice.method">
<include file="payment.method">
</div>
</if>
</ifrow>
</if>
<div>
<showtable process="selectinvoice" name="invoice_id" value="X">
select id as X,id as 'Invoice ID',date_format(created, '%b %D %Y') as 'Date',amount as 'Amount',status as 'Status' from invoices where user_id=$[_login_id] order by created desc
</showtable>
</div>
</sectionframe>
@@ -0,0 +1,4 @@
<include file="phones.section">
<include file="SIPPHONE.tag">
<sipphone>
+17
View File
@@ -0,0 +1,17 @@
<sectionframe title="ACCOUNT">
<if value1="$[SUBPAGE]" value2="" type="eq">
<linkbutton page="account" class="submenuitem-active">ACCOUNT INFORMATION</linkbutton><br>
<else>
<linkbutton page="account">ACCOUNT INFORMATION</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="phones" type="eq">
<linkbutton page="account" subpage="phones" class="submenuitem-active">PHONES</linkbutton><br>
<else>
<linkbutton page="account" subpage="phones">PHONES</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="invoices" type="eq">
<linkbutton page="account" subpage="invoices" class="submenuitem-active">INVOICES</linkbutton><br>
<else>
<linkbutton page="account" subpage="invoices">INVOICES</linkbutton><br>
</if>
</sectionframe>
+11 -103
View File
@@ -4,108 +4,16 @@
<retain name="download_file">
<retain name="invoice_id">
<sectionframe title="Account Information">
<sql>select * from users where id=$[_login_id]</sql>
<table>
<tr><th class="left">Name:</th><td class="right">$[.name]</td></tr>
<if value1="$[company_name]" value2="" type="ne">
<tr><th class="left">Company Name:</th><td class="right">$[.company_name]</td></tr>
</if>
<tr><th class="left">E-Mail:</th><td class="right">$[.email]</td></tr>
</table>
</sectionframe>
<sql>select * from user_messages where user_id=$[_login_id]</sql>$[sqlerror]
<ifrow>
<sectionframe title="Messages">
<table>
<whilerow>
<tr>
<td>$[.message]</td>
<td>$[.link]</td>
</tr>
</whilerow>
</table>
</sectionframe>
</ifrow>
<sql>select *
from virtual_machines
join products on virtual_machines.sku=products.sku
where user_id=$[_login_id]</sql>
<ifrow>
<sectionframe title="Virtual Machines">
<whilerow>
<div style="margin-bottom: 3px; border: 1pt solid #000; border-radius: 5px;">
<div style="float: left; padding: 2px 5px 0px 5px; vertical-align: middle; display: inline-block;"><img src="$[.image]" width="40"></div>
<div style="float: left; background: #ccf; width: 300px; padding: 0px 0px 0px 0px;"><span style="font-size: 7pt;">Ubuntu Server 22.04 LTE</span>
<br><span style="font-size: 9pt;"><b>barant.com</b></span>
<br><span style="font-size: 7pt;">IP:</span> <span style="font-size: 9pt; font-family: monospace;">74.80.233.78</span></div>
<div style="float: right; padding: 5px;"><img src="/assets/power_on.png" width="32"></div>
<div style="float: right; width: 90px; height: 48px; background: #444;"></div>
<div style="float: right; margin-right: 25px;">3 days 2:10:33<br><br>34% of 40.2GB</div>
<div style="clear: both;"></div>
</div>
</whilerow>
</sectionframe>
</ifrow>
<include file="phones.section">
<sql>select *
from files
join products on files.sku=products.sku
where user_id=$[_login_id]</sql>
<ifrow>
<sectionframe title="Downloadable Content">
<p>Content that has been purchased and can be downloaded is displayed
below. Click on the Download button to begin downloading your files.</p>
<whilerow>
<table style="margin: 3px;">
<tr>
<td>
<img src="$[.image]" width="50px"">
</td>
<td style="width: 300px; border: 1pt inset #888">
$[.description]
</td>
<td style="width: 300px;">
<div>$[license_name]</div><div>$[license_key]</div>
</td>
<td>
<a href="/downloadfile.cgi?sku=$[.sku]"><div class="button">Download</div></a>
</td>
</tr>
</table>
</whilerow>
</sectionframe>
</ifrow>
<sectionframe title="Invoices">
<div style="display: flex;">
<div style="display: inline-block; padding: 0px 10px 0px 0px;">
<showtable process="selectinvoice" name="invoice_id" value="X">
select id as X,id as 'Invoice ID',date_format(created, '%b %D %Y') as 'Date',amount as 'Amount',status as 'Status' from invoices where user_id=$[_login_id]
</showtable>
</div>
<if value1="$[_invoice_id]" value2="" type="ne">
<div>
<include file="invoice.method">
<include file="payment.method">
</div>
</if>
</div>
</sectionframe>
<div id="account-subpage">
<if value1="$[SUBPAGE]" value2="" type="eq">
<include file="account-info.subpage">
<else>
<try>
<include file="account-$[SUBPAGE].subpage">
<catch>
<p>That account section doesn't exist.</p>
</try>
</if>
</div>
</contents>
</page>
+13 -1
View File
@@ -93,6 +93,16 @@
box-shadow: 0 0 0.4em rgba(197, 164, 90, 0.25);
transition: box-shadow 0.2s ease, background 0.2s ease, transform 0.1s ease;
}
/* .icon-btn's own display:inline-flex is a plain class selector -
same specificity as the browser's own [hidden]{display:none} UA
default, and an author rule always wins that tie regardless of
source order - confirmed as a real, previously-shipped bug on a
different site this same session (a hidden modal that stayed
visible for the exact same reason). Without this, the empty-folder
button's `hidden` attribute would be set correctly but silently
ignored, leaving it visible on every folder instead of only
Spam/Trash. */
.icon-btn[hidden] { display: none; }
.icon-btn svg { width: 16px; height: 16px; display: block; }
.icon-btn:hover {
box-shadow: 0 0 0.8em rgba(197, 164, 90, 0.5), 0 0 0.25em rgba(227, 196, 126, 0.55);
@@ -118,12 +128,14 @@
<div id="email-client">
<div id="email-toolbar">
<span id="email-connected-as">$[@_imap_user]</span><span id="email-list-count"></span>
<span id="email-pagination"></span>
<span id="email-toolbar-actions">
<span id="email-search-box">
<input type="text" id="email-search-input" placeholder="Search mail&hellip;">
<button type="button" id="email-search-btn" class="icon-btn" title="Search"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.35-4.35"/></svg></button>
</span>
<button type="button" id="email-compose-btn" class="icon-btn" title="New Mail"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6h13a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z"/><path d="M2.5 7.5 12 14l9.5-6.5"/><path d="M18.5 3.5v5M16 6h5"/></svg></button>
<button type="button" id="email-empty-folder-btn" class="icon-btn" title="Permanently empty this folder" hidden><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16"/><path d="M9 7V4h6v3"/><path d="M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"/><path d="M9.5 12.5l5 5M14.5 12.5l-5 5"/></svg></button>
<button type="button" id="email-refresh-btn" class="icon-btn" title="Refresh"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 11a8 8 0 0 0-14.6-4.4M4 4v5h5"/><path d="M4 13a8 8 0 0 0 14.6 4.4M20 20v-5h-5"/></svg></button>
<button type="button" id="email-disconnect-btn" class="icon-btn" title="Disconnect"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><path d="M16 17l5-5-5-5"/><path d="M21 12H9"/></svg></button>
</span>
@@ -135,4 +147,4 @@
</div>
</if>
</div>
<script src="/assets/email.js?v=20260905o"></script>
<script src="/assets/email.js?v=20260926a"></script>
@@ -0,0 +1,46 @@
<include file="invoice.method">
<br>
<linkbutton page="editinvoice"><div class="button">Edit Invoice</div></linkbutton>
<div style="margin-top: 10px; display: flex; align-items: center; gap: 6px;">
<input type="email" id="mail_invoice_email" placeholder="recipient@example.com" style="width: 220px;">
<button type="button" id="mail_invoice_btn" class="button">Mail Invoice</button>
<span id="mail_invoice_status" style="font-size: 12px; color: var(--bond-text-dim);"></span>
</div>
<script>
(function() {
var btn = document.getElementById('mail_invoice_btn');
var input = document.getElementById('mail_invoice_email');
var status = document.getElementById('mail_invoice_status');
if (!btn || !input || !status) return;
btn.addEventListener('click', function() {
var email = input.value.trim();
if (!email) {
status.textContent = 'Enter an e-mail address first.';
status.style.color = '#a13a3a';
return;
}
btn.disabled = true;
status.textContent = 'Sending…';
status.style.color = 'var(--bond-text-dim)';
fetch('/admin/mail-invoice', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ email: email }).toString()
}).then(function(r) { return r.json(); }).then(function(res) {
btn.disabled = false;
if (res.ok) {
status.textContent = 'Invoice emailed to ' + email + '.';
status.style.color = '#6fb8c9';
} else {
status.textContent = res.error || 'Could not send the invoice.';
status.style.color = '#a13a3a';
}
}).catch(function() {
btn.disabled = false;
status.textContent = 'Request failed. Please try again.';
status.style.color = '#a13a3a';
});
});
})();
</script>
+118 -3
View File
@@ -1,5 +1,120 @@
<retain name="invoice_id">
<h3>Invoices</h3>
<showtable page="admin_invoice" process="selectinvoice" name="invoice_id" value="X">
select invoices.id as X,invoices.id,user_id,name,invoices.created,amount,invoices.status from invoices join users on invoices.user_id=users.id
</showtable>
<div style="margin-bottom: 10px;">
<button type="button" id="new_invoice_toggle" class="button">+ Create New Invoice</button>
<div id="new_invoice_form" style="display: none; margin-top: 8px; align-items: center; gap: 6px;">
<select id="new_invoice_user">
<option value="">Select a customer&hellip;</option>
<sql>select id,name,email from users order by name</sql>
<whilerow>
<option value="$[.id]">$[.name] ($[.email])</option>
</whilerow>
</select>
<button type="button" id="new_invoice_create_btn" class="button">Create</button>
<span id="new_invoice_status" style="font-size: 12px; color: var(--bond-text-dim);"></span>
</div>
</div>
<span id="copy_invoice_status" style="font-size: 12px; color: var(--bond-text-dim);"></span>
<table>
<tr>
<th></th>
<th>id</th>
<th>user_id</th>
<th>name</th>
<th>created</th>
<th>amount</th>
<th>status</th>
<th></th>
</tr>
<sql>select invoices.id,user_id,name,invoices.created,amount,invoices.status from invoices join users on invoices.user_id=users.id</sql>
<whilerow>
<tr>
<td><linkbutton page="admin" subpage="invoice" process="selectinvoice" name="invoice_id" value="$[.id]" class="button">Open</linkbutton></td>
<td>$[.id]</td>
<td>$[.user_id]</td>
<td>$[.name]</td>
<td>$[.created]</td>
<td>$[.amount]</td>
<td>$[.status]</td>
<td><button type="button" class="button copy_invoice_btn" data-invoice-id="$[.id]">Copy</button></td>
</tr>
</whilerow>
</table>
<script>
(function() {
var toggle = document.getElementById('new_invoice_toggle');
var form = document.getElementById('new_invoice_form');
var userSelect = document.getElementById('new_invoice_user');
var createBtn = document.getElementById('new_invoice_create_btn');
var status = document.getElementById('new_invoice_status');
if (!toggle || !form || !userSelect || !createBtn || !status) return;
toggle.addEventListener('click', function() {
form.style.display = form.style.display === 'none' ? 'flex' : 'none';
});
createBtn.addEventListener('click', function() {
var userId = userSelect.value;
if (!userId) {
status.textContent = 'Please select a customer.';
status.style.color = '#a13a3a';
return;
}
createBtn.disabled = true;
status.textContent = 'Creating…';
status.style.color = 'var(--bond-text-dim)';
fetch('/admin/create-invoice', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ user_id: userId }).toString()
}).then(function(r) { return r.json(); }).then(function(res) {
if (res.ok) {
window.location.href = '/editinvoice';
} else {
createBtn.disabled = false;
status.textContent = res.error || 'Could not create the invoice.';
status.style.color = '#a13a3a';
}
}).catch(function() {
createBtn.disabled = false;
status.textContent = 'Request failed. Please try again.';
status.style.color = '#a13a3a';
});
});
var copyStatus = document.getElementById('copy_invoice_status');
document.querySelectorAll('.copy_invoice_btn').forEach(function(btn) {
btn.addEventListener('click', function() {
var sourceId = btn.getAttribute('data-invoice-id');
document.querySelectorAll('.copy_invoice_btn').forEach(function(b) { b.disabled = true; });
if (copyStatus) {
copyStatus.textContent = 'Copying…';
copyStatus.style.color = 'var(--bond-text-dim)';
}
fetch('/admin/copy-invoice', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ source_invoice_id: sourceId }).toString()
}).then(function(r) { return r.json(); }).then(function(res) {
if (res.ok) {
window.location.href = '/editinvoice';
} else {
document.querySelectorAll('.copy_invoice_btn').forEach(function(b) { b.disabled = false; });
if (copyStatus) {
copyStatus.textContent = res.error || 'Could not copy the invoice.';
copyStatus.style.color = '#a13a3a';
}
}
}).catch(function() {
document.querySelectorAll('.copy_invoice_btn').forEach(function(b) { b.disabled = false; });
if (copyStatus) {
copyStatus.textContent = 'Request failed. Please try again.';
copyStatus.style.color = '#a13a3a';
}
});
});
});
})();
</script>
@@ -0,0 +1,98 @@
<h3>Mail Accounts</h3>
<div style="margin-bottom: 10px;">
<button type="button" id="new_mailaccount_toggle" class="button">+ Add Mail Account</button>
<div id="new_mailaccount_form" style="display: none; margin-top: 8px; align-items: center; gap: 6px;">
<input type="text" id="new_mailaccount_host" placeholder="Mail Server" value="mail.barant.com">
<input type="text" id="new_mailaccount_email" placeholder="E-Mail Address">
<input type="password" id="new_mailaccount_password" placeholder="Password">
<button type="button" id="new_mailaccount_create_btn" class="button">Add</button>
<span id="new_mailaccount_status" style="font-size: 12px; color: var(--bond-text-dim);"></span>
</div>
</div>
<table>
<tr>
<th>E-Mail</th>
<th>Server</th>
<th>Added</th>
<th></th>
</tr>
<sql>select id,email,host,created from email_accounts where user_id=$[@_login_id] order by email</sql>
<whilerow>
<tr>
<td>$[.email]</td>
<td>$[.host]</td>
<td>$[.created]</td>
<td><button type="button" class="button remove_mailaccount_btn" data-account-id="$[.id]">Remove</button></td>
</tr>
</whilerow>
</table>
<p style="font-size: 12px; color: var(--bond-text-dim);">Saved accounts automatically reconnect the next time you log in.</p>
<script>
(function() {
var toggle = document.getElementById('new_mailaccount_toggle');
var form = document.getElementById('new_mailaccount_form');
var hostInput = document.getElementById('new_mailaccount_host');
var emailInput = document.getElementById('new_mailaccount_email');
var passwordInput = document.getElementById('new_mailaccount_password');
var createBtn = document.getElementById('new_mailaccount_create_btn');
var status = document.getElementById('new_mailaccount_status');
if (!toggle || !form || !hostInput || !emailInput || !passwordInput || !createBtn || !status) return;
toggle.addEventListener('click', function() {
form.style.display = form.style.display === 'none' ? 'flex' : 'none';
});
createBtn.addEventListener('click', function() {
var host = hostInput.value.trim();
var email = emailInput.value.trim();
var password = passwordInput.value;
if (!host || !email || !password) {
status.textContent = 'Please enter a mail server, e-mail address, and password.';
status.style.color = '#a13a3a';
return;
}
createBtn.disabled = true;
status.textContent = 'Connecting…';
status.style.color = 'var(--bond-text-dim)';
fetch('/admin/add-mail-account', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ mail_host: host, mail_email: email, mail_password: password }).toString()
}).then(function(r) { return r.json(); }).then(function(res) {
if (res.ok) {
window.location.href = '/admin/mailaccounts';
} else {
createBtn.disabled = false;
status.textContent = res.error || 'Could not add the account.';
status.style.color = '#a13a3a';
}
}).catch(function() {
createBtn.disabled = false;
status.textContent = 'Request failed. Please try again.';
status.style.color = '#a13a3a';
});
});
document.querySelectorAll('.remove_mailaccount_btn').forEach(function(btn) {
btn.addEventListener('click', function() {
var accountId = btn.getAttribute('data-account-id');
document.querySelectorAll('.remove_mailaccount_btn').forEach(function(b) { b.disabled = true; });
fetch('/admin/remove-mail-account', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ account_id: accountId }).toString()
}).then(function(r) { return r.json(); }).then(function(res) {
if (res.ok) {
window.location.href = '/admin/mailaccounts';
} else {
document.querySelectorAll('.remove_mailaccount_btn').forEach(function(b) { b.disabled = false; });
}
}).catch(function() {
document.querySelectorAll('.remove_mailaccount_btn').forEach(function(b) { b.disabled = false; });
});
});
});
})();
</script>
+25 -4
View File
@@ -1,8 +1,29 @@
<sectionframe title="ADMINISTRATIVE SUPPORT">
<linkbutton page="admin" subpage="email">EMAIL</linkbutton><br>
<linkbutton page="admin" subpage="invoices">INVOICES</linkbutton><br>
<linkbutton page="admin" subpage="products">PRODUCTS</linkbutton><br>
<linkbutton page="admin" subpage="users">USERS</linkbutton><br>
<if value1="$[SUBPAGE]" value2="email" type="eq">
<linkbutton page="admin" subpage="email" class="submenuitem-active">EMAIL</linkbutton><br>
<else>
<linkbutton page="admin" subpage="email">EMAIL</linkbutton><br>
</if>
<if expr="('$[SUBPAGE]'='invoices') or ('$[SUBPAGE]'='invoice')">
<linkbutton page="admin" subpage="invoices" class="submenuitem-active">INVOICES</linkbutton><br>
<else>
<linkbutton page="admin" subpage="invoices">INVOICES</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="products" type="eq">
<linkbutton page="admin" subpage="products" class="submenuitem-active">PRODUCTS</linkbutton><br>
<else>
<linkbutton page="admin" subpage="products">PRODUCTS</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="users" type="eq">
<linkbutton page="admin" subpage="users" class="submenuitem-active">USERS</linkbutton><br>
<else>
<linkbutton page="admin" subpage="users">USERS</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="mailaccounts" type="eq">
<linkbutton page="admin" subpage="mailaccounts" class="submenuitem-active">MAIL ACCOUNTS</linkbutton><br>
<else>
<linkbutton page="admin" subpage="mailaccounts">MAIL ACCOUNTS</linkbutton><br>
</if>
</sectionframe>
<if value1="$[SUBPAGE]" value2="email" type="eq">
<include file="email.menu">
+27 -3
View File
@@ -2,10 +2,18 @@
<title>ADMINISTRATION</title>
<contents>
<if value1="$[SUBPAGE]" value2="email" type="eq">
<include file="admin-email.subpage">
<if expr="('$[_login_type]'='user')">
<p>Requested page is not found.</p>
<else>
<include file="admin-email.subpage">
</if>
<else>
<if value1="$[SUBPAGE]" value2="newemail" type="eq">
<include file="admin-newemail.subpage">
<if expr="('$[_login_type]'='user')">
<p>Requested page is not found.</p>
<else>
<include file="admin-newemail.subpage">
</if>
<else>
<if value1="$[SUBPAGE]" value2="invoices" type="eq">
<if expr="('$[_login_type]'='user')">
@@ -14,6 +22,13 @@
<include file="admin-invoices.subpage">
</if>
<else>
<if value1="$[SUBPAGE]" value2="invoice" type="eq">
<if expr="('$[_login_type]'='user')">
<p>Requested page is not found.</p>
<else>
<include file="admin-invoice.subpage">
</if>
<else>
<if value1="$[SUBPAGE]" value2="users" type="eq">
<if expr="('$[_login_type]'='user')">
<p>Requested page is not found.</p>
@@ -28,18 +43,27 @@
<include file="admin-products.subpage">
</if>
<else>
<if expr="('$[_login_type]'='user')">
<if value1="$[SUBPAGE]" value2="mailaccounts" type="eq">
<if expr="('$[_login_type]'='user')">
<p>Requested page is not found.</p>
<else>
<include file="admin-mailaccounts.subpage">
</if>
<else>
<if expr="('$[_login_type]'='user')">
<p>Requested page is not found.</p>
<else>
<eval name="_menu">
<include file="adminmenu.section">
</eval>
<p>Select an item from the menu.</p>
</if>
</if>
</if>
</if>
</if>
</if>
</if>
</if>
</contents>
</page>
-11
View File
@@ -1,11 +0,0 @@
<page secure="yes" admin="true" loggedin="yes">
<title>INVOICE</title>
<contents>
<eval name="_menu">
<include file="adminmenu.section">
</eval>
<include file="invoice.method">
<br>
<linkbutton page="editinvoice"><div class="button">Edit Invoice</div></linkbutton>
</contents>
</page>
@@ -0,0 +1,14 @@
<page secure="yes" loggedin="yes" admin="true">
<title>ADMIN INVOICES</title>
<contents>
<eval name="_menu">
<include file="adminmenu.section">
</eval>
<retain name="invoice_id">
<h3>Invoices</h3>
<showtable page="admin_invoice" process="selectinvoice" name="invoice_id" value="X">
select invoices.id as X,invoices.id,user_id,name,invoices.created,amount,invoices.status from invoices join users on invoices.user_id=users.id
</showtable>
<br>
</contents>
</page>
+1 -1
View File
@@ -1,4 +1,4 @@
<sectionframe title="Admin Functions">
<div><linkbutton page="modular1_1_preset_admin">Modular 1 Presets</linkbutton></div>
<div><linkbutton page="admin_invoices">Invoices</linkbutton></div>
<div><linkbutton page="admin" subpage="invoices">Invoices</linkbutton></div>
</sectionframe>
@@ -0,0 +1,52 @@
<page>
<title>RCA1802 Micro-Controller Assembler/Emulator</title>
<contents>
<sectionframe title="RCA1802">
<h1>The RCA1802 Micro-Controller</h1>
<img src="/assets/rca1802chip.jpeg" align="right">
<p>Back in the 1970's RCA released a chip that was widely used in
satellites and other spacecraft to this day. It is a very simple
8-bit micro-controller with 16-bit addressibility enabling memory
access to 65,536 bytes of data.</p>
<p>The main chip is core to the COSMAC-ELF computers from the early period of
micro-controllers. Because of theyre reliability and lower clock
speeds the RCA1802 is a rugged controller for abusive environments.</p>
</sectionframe>
<sectionframe title="RCA1802 Assembler">
<p>The assembler allows the compilation of 1802 assembler language (as
defined in the chip's data reference manual) into a RAM file that is
65,536 bytes in size. This file can be loaded into the emulator which
can then be used to debug the code.</p>
<p>Output device 1 provides a console type display of ASCII characters
sent to it. Input device 1 is used to retrieve data from the keyboard
device.</p>
</sectionframe>
<sectionframe title="RCA1802 Emulator">
<img src="/assets/emu1802a.png" align="right" width="500">
<p>The 1802 emulator provides a fully functional RCA1802
micro-controller device complete with interupt handling and DMA
controls for memory access. Experiment with code structures and build
an associated kit that allows you to operate the software on real
hardware controllers.</p>
<p>The RAM for the device can be loaded from RAM file (.ram extension)
that contain 65,536 bytes of pre-assembled machine code created from
the assembler module.</p>
<p>The emulator has IDLE, RUN, STEP and DMA modes for easy code
visibility and manipulation.</p>
</sectionframe>
<sectionframe title="RCA1802 Computer Device">
We are working to provide a hardware kit for the controller device.
Current schematics are being layed out using Kicad. I have a full git
change environment going for the Kicad project as well as the source
code for the assembler and emulator components.
</sectionframe>
</contents>
</page>
+2 -2
View File
@@ -95,7 +95,7 @@
</if>
</tag>
<tag name="showtable" keywords="sessionid page process name value">
<tag name="showtable" keywords="sessionid page subpage process name value">
<sql sessionid="#[sessionid]"><container></sql>$[sqlerror]
<ifrow sessionid="#[sessionid]">
<table>
@@ -117,7 +117,7 @@
<set name="field" value="$[?$[index]]">
<if value1="$[field]" value2="X" type="eq">
<td>
<linkbutton page="#[page]" process="#[process]" name="#[name]" value="$[#[value]]" class="button">Open</linkbutton>
<linkbutton page="#[page]" subpage="#[subpage]" process="#[process]" name="#[name]" value="$[#[value]]" class="button">Open</linkbutton>
</td>
<else>
<if expr="substring('$[field]',1,1)!='_'">
@@ -0,0 +1,23 @@
<page>
<title>BARANTMAIL OPEN SOURCE PROJECT</title>
<contents>
<sectionframe title="BARANTMAIL OPEN SOURCE PROJECT">
<p>In the year 2000 I was extremely frustrated with the state of e-amil
systems available to Linux. Sendmail and q-mail were pretty much the two
mainstays. sendmail was prohibitively complex for the newly emerging
Internet method of using e-mail and q-mail was poorly maintained.</p>
<p>As a result, I embarked on a mission to write my own e-mail system that used
mysql as it's storage medium. I wanted to keep it simple and support
multiple users and domains with the simplest of configurations imaginable.
I also wanted a scalable multi-server capability.</p>
<p>The result is BARANTMAIL.</p>
<h2>Features</h2>
<p>Features of BARANTMAIL are:</p>
<ul>
<li>Fully compliant e-mail system.</li>
<li>Support for multiple domains.</li>
</ul>
<p></p>
</sectionframe>
</contents>
</page>
+29
View File
@@ -0,0 +1,29 @@
#api POST /admin/copy-invoice
<set name="host" value="localhost">
<set name="database" value="barant">
<set name="user" value="barant">
<set name="password" value="uversa1960">
<database name="$[database]" host="$[host]" user="$[user]" password="$[password]" sessionid="">
<header name="Content-Type" value="application/json">
<if value1="$[@_login_type]" value2="admin" type="ne">
{"ok":false,"error":"Not authorized."}
<else>
<if value1="$[source_invoice_id]" value2="" type="eq">
{"ok":false,"error":"Please select an invoice to copy."}
<else>
<sql>select * from invoices where id=$[source_invoice_id]</sql>
<ifrow>
<sql>insert into invoices set user_id=$[.user_id], created=now(), amount=$[.amount], status="OPEN"</sql>
<sql>select last_insert_id() as new_invoice_id</sql>
<set name="new_invoice_id" value="$[.new_invoice_id]">
<sql>insert into invoices_detail (invoice_id,sku,sku_suffix,quantity,description,text,price,total,tax_amount,type)
select $[new_invoice_id],sku,sku_suffix,quantity,description,text,price,total,tax_amount,type
from invoices_detail where invoice_id=$[source_invoice_id]</sql>
<set name="@_invoice_id" value="$[new_invoice_id]">
{"ok":true,"invoice_id":$[new_invoice_id]}
<else>
{"ok":false,"error":"Invoice not found."}
</ifrow>
</if>
</if>
</database>
+21
View File
@@ -0,0 +1,21 @@
#api POST /admin/create-invoice
<set name="host" value="localhost">
<set name="database" value="barant">
<set name="user" value="barant">
<set name="password" value="uversa1960">
<database name="$[database]" host="$[host]" user="$[user]" password="$[password]" sessionid="">
<header name="Content-Type" value="application/json">
<if value1="$[@_login_type]" value2="admin" type="ne">
{"ok":false,"error":"Not authorized."}
<else>
<if value1="$[user_id]" value2="" type="eq">
{"ok":false,"error":"Please select a user."}
<else>
<sql>insert into invoices set user_id=$[user_id], created=now(), amount=0.00, status="OPEN"</sql>
<sql>select last_insert_id() as new_invoice_id</sql>
<set name="new_invoice_id" value="$[.new_invoice_id]">
<set name="@_invoice_id" value="$[new_invoice_id]">
{"ok":true,"invoice_id":$[new_invoice_id]}
</if>
</if>
</database>
+1 -1
View File
@@ -1,7 +1,7 @@
<page>
<title>CRYSTAL</title>
<contents>
<setenv name="_menubar"></setenv>
<set name="_menubar" value=""><set name="_menubar" value="" scope="session">
<sectionframe title="Crystal - High Security Communications">
<p>Coming soon. High security communications apps for iPhone and
+113 -59
View File
@@ -3,9 +3,6 @@
<contents>
<database host="$[host]" name="$[database]" user="$[user]" password="$[password]" sessionid="1">
<script>
function checkDetail() {
document.getElementById('detail').style.display=(document.getElementById('sku').value=='***')?'block':'none';
}
function totalInvoice() {
const detail_section = document.getElementById('detail_section');
const totalsum = document.getElementById('totalsum');
@@ -13,10 +10,11 @@ function totalInvoice() {
var sum = 0;
var index = 0;
detail_section.childNodes.forEach((child) => {
if (!child.quantity_z) return;
child.quantity_z.setAttribute('name','quantity' + index);
child.sku_z.setAttribute('name','sku' + index);
child.description_z.setAttribute('name','description' + index);
child.textarea_z.setAttribute('name','textarea' + index);
child.textarea_z.setAttribute('name','textarea' + index);
child.detail_z.setAttribute('name','detail' + index);
child.price_z.setAttribute('name','price' + index);
child.taxAmount_z.setAttribute('name','tax_amount' + index);
@@ -31,16 +29,18 @@ function totalInvoice() {
}
function addLine(qty,skuid,descr,text,prc,tax,tot,typ) {
const lineItem = document.createElement('div');
lineItem.style.border = "padding: 3px;";
const lineItem = document.createElement('tr');
column1 = document.createElement('div');
column1.setAttribute('style','display: inline-block; margin-right: 5px;');
column1 = document.createElement('td');
column1.setAttribute('style','text-align: center; vertical-align: top; padding: 6px 4px; border-bottom: 1px solid #000;');
removeButton = document.createElement('button');
removeButton.setAttribute('type','button');
removeButton.setAttribute('class','button');
removeButton.setAttribute('style','padding: 1px 7px 2px 7px; font-size: 11pt; line-height: 1;');
removeButton.innerText = '-';
removeButton.addEventListener('click', function(e) {
document.getElementById('detail_section').removeChild(lineItem);
if (lineItem.detailRow) document.getElementById('detail_section').removeChild(lineItem.detailRow);
totalInvoice();
});
column1.appendChild(removeButton)
@@ -66,16 +66,15 @@ function addLine(qty,skuid,descr,text,prc,tax,tot,typ) {
lineItem.total_z = total;
lineItem.type_z = type;
column2 = document.createElement('div');
column2.setAttribute('style','display: inline-block; margin-right: 5px;');
column2 = document.createElement('td');
column2.setAttribute('style','width: 54px; vertical-align: top; padding: 6px 4px; border-bottom: 1px solid #000;');
quantity.setAttribute('type','text');
quantity.setAttribute('size','5');
quantity.setAttribute('maxlength','5');
quantity.setAttribute('style','width: 44px; text-align: center;');
quantity.setAttribute('name','quantity');
quantity.setAttribute('value',qty);
quantity.addEventListener('change',(e) => {
taxAmount.value = '0.00';
total.value = (quantity.value * sku.options[sku.selectedIndex].price).toFixed(2);
total.value = (quantity.value * sku.options[sku.selectedIndex].price).toFixed(2);
description.value = sku.options[sku.selectedIndex].description;
lineItem.total = total.value;
totalInvoice();
@@ -83,13 +82,14 @@ function addLine(qty,skuid,descr,text,prc,tax,tot,typ) {
column2.appendChild(quantity);
lineItem.appendChild(column2);
column3 = document.createElement('div');
column3.setAttribute('style','display: inline-block; margin-right: 5px;');
column3 = document.createElement('td');
column3.setAttribute('style','vertical-align: top; padding: 6px 4px; border-bottom: 1px solid #000;');
sku.setAttribute('name','sku');
sku.setAttribute('style','width: 100%;');
sku.detail = detail;
sku.addEventListener('change', (e) => {
sku.detail.style.display = sku.value == '***' ? 'block':'none';
price.value = sku.options[sku.selectedIndex].price;
price.value = sku.options[sku.selectedIndex].price;
taxAmount.value = '0.00';
total.value = (quantity.value * sku.options[sku.selectedIndex].price).toFixed(2);
lineItem.total = total.value;
@@ -99,13 +99,16 @@ function addLine(qty,skuid,descr,text,prc,tax,tot,typ) {
});
<sql sessionid="1">select * from product_list</sql>
<whilerow sessionid="1">
<call pgm="/bin/sh" arg1="-c" arg2="jq -R -s . | sed 's#/#\\/#g'" input="$[1.description]" name="product_description_js">
<call pgm="/bin/sh" arg1="-c" arg2="jq -R -s . | sed 's#/#\\/#g'" input="$[1.sku]" name="product_sku_js">
<call pgm="/bin/sh" arg1="-c" arg2="jq -R -s . | sed 's#/#\\/#g'" input="$[1.type]" name="product_type_js">
option = document.createElement('option');
option.setAttribute('value','$[1.sku]');
option.description = '$[1.description]';
option.typex = '$[1.type]';
option.setAttribute('value',$[product_sku_js]);
option.description = $[product_description_js];
option.typex = $[product_type_js];
option.price = '$[1.price]';
option.innerText = '$[1.description]';
if(skuid == '$[1.sku]') {
option.innerText = $[product_description_js];
if(skuid == $[product_sku_js]) {
option.selected = 'selected';
}
sku.appendChild(option);
@@ -121,47 +124,52 @@ function addLine(qty,skuid,descr,text,prc,tax,tot,typ) {
type.setAttribute('value', typ);
lineItem.appendChild(type);
column4 = document.createElement('div');
column4.setAttribute('style','display: inline-block; margin-right: 5px;');
column4 = document.createElement('td');
column4.setAttribute('style','width: 90px; vertical-align: top; padding: 6px 4px; border-bottom: 1px solid #000;');
price.setAttribute('type','text');
price.setAttribute('size','15');
price.setAttribute('maxlength','15');
price.setAttribute('style','width: 80px; text-align: right;');
price.setAttribute('name','price');
price.setAttribute('value',prc);
column4.appendChild(price);
lineItem.appendChild(column4);
column5 = document.createElement('div');
column5.setAttribute('style','display: inline-block; margin-right: 5px;');
column5 = document.createElement('td');
column5.setAttribute('style','width: 70px; vertical-align: top; padding: 6px 4px; border-bottom: 1px solid #000;');
taxAmount.setAttribute('type','text');
taxAmount.setAttribute('size','15');
taxAmount.setAttribute('maxlength','15');
taxAmount.setAttribute('style','width: 60px; text-align: right;');
taxAmount.setAttribute('name','tax_amount');
taxAmount.setAttribute('value',tax);
column5.appendChild(taxAmount);
lineItem.appendChild(column5);
column6 = document.createElement('div');
column6.setAttribute('style','display: inline-block;');
column6 = document.createElement('td');
column6.setAttribute('style','width: 90px; vertical-align: top; padding: 6px 4px; border-bottom: 1px solid #000;');
total.setAttribute('type','text');
total.setAttribute('size','15');
total.setAttribute('maxlength','15');
total.setAttribute('style','width: 80px; text-align: right;');
total.setAttribute('name','total');
total.setAttribute('value',tot);
column6.appendChild(total);
lineItem.appendChild(column6);
const detailRow = document.createElement('tr');
const detailCell = document.createElement('td');
detailCell.setAttribute('colspan','6');
detailCell.setAttribute('style','padding: 0 4px 6px 4px; border-bottom: 1px solid #000;');
textarea.setAttribute('name','textarea');
textarea.setAttribute('rows','5');
textarea.setAttribute('style','width: 100%; background: #101014; color: #e7e4dc; border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 2px; padding: 6px 8px; font-family: inherit; font-size: 14px;');
textarea.innerHTML = text;
CKEDITOR.replace(textarea);
detail.appendChild(textarea);
lineItem.appendChild(detail);
detailCell.appendChild(detail);
detailRow.appendChild(detailCell);
lineItem.detailRow = detailRow;
detail.style.display = sku.value == '***' ? 'block':'none';
lineItem.total = total.value;
document.getElementById('detail_section').appendChild(lineItem);
document.getElementById('detail_section').appendChild(lineItem);
document.getElementById('detail_section').appendChild(detailRow);
}
</script>
<input type="hidden" id="linecount" name="linecount">
@@ -169,37 +177,83 @@ function addLine(qty,skuid,descr,text,prc,tax,tot,typ) {
<eval name="_menu">
<include file="adminmenu.section">
</eval>
<h3>Invoice $[_invoice_id]</h3>
<sql>select * from invoices where id=$[_invoice_id]</sql>
<entryform>
<td>Account</td>
<td>
<select>
<sql sessionid="1">select * from users</sql>
<whilerow sessionid="1">
<option value="$[1.id]"
<if value1="$[.user_id]" value2="$[1.id]" type="eq">selected</if>
>$[1.name]</option>
</whilerow>
</select>
</td></tr>
<tr><td colspan="3">
<div id="detail_section"></div>
<sql>select * from invoices_detail where invoice_id=$[_invoice_id]</sql>
<sql>select i.id as invnumber,
u.name as name,
u.company_name as company_name,
u.email as email,
date_format(i.created,'%m/%e/%Y') as invdate,
i.status as status,
i.user_id as user_id
from invoices as i
join users as u on i.user_id=u.id
where i.id=$[@_invoice_id]</sql>
<ifrow>
<div style="width: 760px; max-width: 100%; margin: 0 auto; border: 1px solid rgba(197, 164, 90, 0.28); border-radius: 10px; padding: 20px; background: #0a0a0d; color: #e7e4dc; font-family: Arial, Helvetica, sans-serif; font-size: 14px;">
<table style="width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="0"><tr>
<td style="vertical-align: middle;"><img style="height: 90px; width: auto;" src="/assets/btglogo.png"></td>
<td style="vertical-align: middle; text-align: right; color: #c5a45a; letter-spacing: 0.5px;">
<div style="font-size: 24px; font-weight: 600;">Invoice: $[.invnumber]</div>
<div style="color: #8d8c92; font-size: 12px; margin-top: 4px;">$[.status]</div>
</td>
</tr></table>
<div style="height: 1px; background: rgba(197, 164, 90, 0.28); margin: 16px 0;"></div>
<table style="border-collapse: collapse; margin-bottom: 16px; font-size: 16px; width: 100%;" cellspacing="0" cellpadding="0">
<tr><td style="color: #8d8c92; text-align: right; padding: 3px 10px 3px 16px; border-bottom: 1px solid #000; width: 150px;">Account:</td>
<td style="padding: 3px 16px 3px 0; border-bottom: 1px solid #000;">
<select name="user_id" style="width: 100%; max-width: 360px;">
<sql sessionid="1">select * from users</sql>
<whilerow sessionid="1">
<option value="$[1.id]"
<if value1="$[.user_id]" value2="$[1.id]" type="eq">selected</if>
>$[1.name]</option>
</whilerow>
</select>
</td></tr>
<tr><td style="color: #8d8c92; text-align: right; padding: 3px 10px 3px 16px; border-bottom: 1px solid #000;">Company Name:</td><td style="color: #e7e4dc; text-align: left; padding: 3px 16px 3px 0; border-bottom: 1px solid #000;">$[.company_name]</td></tr>
<tr><td style="color: #8d8c92; text-align: right; padding: 3px 10px 3px 16px; border-bottom: 1px solid #000;">E-Mail:</td><td style="color: #e7e4dc; text-align: left; padding: 3px 16px 3px 0; border-bottom: 1px solid #000;">$[.email]</td></tr>
<tr><td style="color: #8d8c92; text-align: right; padding: 3px 10px 3px 16px;">Invoice Date:</td><td style="color: #e7e4dc; text-align: left; padding: 3px 16px 3px 0;">$[.invdate]</td></tr>
</table>
<table style="width: 100%; border-collapse: collapse; background: #16161c; border-radius: 6px;" cellspacing="0" cellpadding="0">
<thead>
<tr><td style="background-color: #1c1c24; color: #c5a45a; width: 54px; padding: 6px 4px; text-align: center; border-bottom: 1px solid #000;"></td>
<td style="background-color: #1c1c24; color: #c5a45a; width: 54px; padding: 6px 8px; text-align: center; border-bottom: 1px solid #000;">Qty</td>
<td style="background-color: #1c1c24; color: #c5a45a; padding: 6px 8px; border-bottom: 1px solid #000;">Item / Description</td>
<td style="background-color: #1c1c24; color: #c5a45a; width: 90px; padding: 6px 8px; text-align: center; border-bottom: 1px solid #000;">Unit Price</td>
<td style="background-color: #1c1c24; color: #c5a45a; width: 70px; padding: 6px 8px; text-align: center; border-bottom: 1px solid #000;">Tax</td>
<td style="background-color: #1c1c24; color: #c5a45a; width: 90px; padding: 6px 8px; text-align: center; border-bottom: 1px solid #000;">Amount</td>
</tr>
</thead>
<tbody id="detail_section"></tbody>
<tfoot>
<tr><td colspan="5" style="text-align: right; padding: 10px 8px; color: #e3c47e; font-weight: bold;">Invoice Total:</td>
<td id="totalsum" style="text-align: right; padding: 10px 8px; color: #e3c47e; font-weight: bold;"></td>
</tr>
</tfoot>
</table>
<sql>select * from invoices_detail where invoice_id=$[@_invoice_id]</sql>
<whilerow>
<call pgm="/bin/sh" arg1="-c" arg2="jq -R -s . | sed 's#/#\\/#g'" input="$[.sku]" name="detail_sku_js">
<call pgm="/bin/sh" arg1="-c" arg2="jq -R -s . | sed 's#/#\\/#g'" input="$[.description]" name="detail_description_js">
<call pgm="/bin/sh" arg1="-c" arg2="jq -R -s . | sed 's#/#\\/#g'" input="$[.text]" name="detail_text_js">
<call pgm="/bin/sh" arg1="-c" arg2="jq -R -s . | sed 's#/#\\/#g'" input="$[.type]" name="detail_type_js">
<script>
addLine('$[.quantity]','$[.sku]','$[.description]','$[.text]','$[.price]','$[.tax_amount]','$[.total]','$[.type]');
</script>
addLine('$[.quantity]',$[detail_sku_js],$[detail_description_js],$[detail_text_js],'$[.price]','$[.tax_amount]','$[.total]',$[detail_type_js]);
</script>
</whilerow>
<button type="button" onclick="addLine('1','','','','0.00','0.00','0.00','');">+</button>
<div id="totalsum" style="border: 1pt solid #000f; padding: 3px; width: 100px; text-align: right; float: right;"></div>
<div style="margin-top: 10px;">
<button type="button" class="button" onclick="addLine('1','','','','0.00','0.00','0.00','');">+ Add Line</button>
</div>
<script>
totalInvoice();
</script>
<buttonbay>
<buttonbay style="display: block; margin-top: 18px; text-align: right;">
<linkbutton process="update_invoice"><div class="button">Update Invoice</div></linkbutton>
</buttonbay>
</entryform>
</div>
<else>
<div style="width: 760px; max-width: 100%; margin: 40px auto; text-align: center; color: #8d8c92;">Invoice not found.</div>
</ifrow>
<br>
</database>
</contents>
+47 -23
View File
@@ -4,6 +4,7 @@
#api POST /email/message
#api POST /email/flag
#api POST /email/delete
#api POST /email/emptyfolder
#api POST /email/trash
#api POST /email/folders
#api POST /email/search
@@ -12,10 +13,15 @@
#api POST /email/switchaccount
<header name="Content-Type" value="application/json">
<if value1="$[REQUEST_URI]" value2="/email/connect" type="eq">
<if value1="$[host]" value2="" type="eq">
<set name="host" value="mail.barant.com">
</if>
<try>
<imap config="./email.cfg" user="$[user]" password="$[password]" sessionid="">
<eval name="_imap_accounts"><imapaccounts action="add" list="$[@_imap_accounts]" user="$[user]" password="$[password]"></imapaccounts></eval>
<imap config="./email.cfg" host="$[host]" user="$[user]" password="$[password]" sessionid="">
<eval name="_imap_accounts"><imapaccounts action="add" list="$[@_imap_accounts]" host="$[host]" user="$[user]" password="$[password]"></imapaccounts></eval>
<set name="@_imap_accounts" value="$[_imap_accounts]">
<set name="_imap_host" value="$[host]">
<set name="@_imap_host" value="$[host]">
<set name="_imap_user" value="$[user]">
<set name="@_imap_user" value="$[user]">
<set name="_imap_password" value="$[password]">
@@ -24,7 +30,6 @@
</imap>
<catch name="_imaperr">
{"ok":false,"error":"$[_imaperr]"}
</catch>
</try>
<else>
<if value1="$[REQUEST_URI]" value2="/email/disconnect" type="eq">
@@ -36,22 +41,25 @@
</if>
<eval name="_next_user"><imapaccounts action="firstuser" list="$[@_imap_accounts]"></imapaccounts></eval>
<if value1="$[_next_user]" value2="" type="eq">
<set name="@_imap_host" value="">
<set name="@_imap_user" value="">
<set name="@_imap_password" value="">
{"ok":true,"active":""}
<else>
<try>
<eval name="_next_host"><imapaccounts action="gethost" list="$[@_imap_accounts]" user="$[_next_user]"></imapaccounts></eval>
<eval name="_next_password"><imapaccounts action="getpassword" list="$[@_imap_accounts]" user="$[_next_user]"></imapaccounts></eval>
<imap config="./email.cfg" user="$[_next_user]" password="$[_next_password]" sessionid="">
<imap config="./email.cfg" host="$[_next_host]" user="$[_next_user]" password="$[_next_password]" sessionid="">
<set name="@_imap_host" value="$[_next_host]">
<set name="@_imap_user" value="$[_next_user]">
<set name="@_imap_password" value="$[_next_password]">
{"ok":true,"active":"$[_next_user]"}
</imap>
<catch name="_disconnecterr">
<set name="@_imap_host" value="">
<set name="@_imap_user" value="">
<set name="@_imap_password" value="">
{"ok":true,"active":""}
</catch>
</try>
</if>
<else>
@@ -63,75 +71,90 @@
</if>
<if value1="$[REQUEST_URI]" value2="/email/list" type="eq">
<try>
<imap config="./email.cfg" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imap config="./email.cfg" host="$[@_imap_host]" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<if value1="$[limit]" value2="" type="eq">
<set name="limit" value="50">
</if>
<imaplist sessionid="" folder="$[folder]" limit="$[limit]">
<imaplist sessionid="" folder="$[folder]" limit="$[limit]" offset="$[offset]">
</imap>
<catch name="_imaperr">
{"ok":false,"error":"$[_imaperr]"}
</catch>
</try>
<else>
<if value1="$[REQUEST_URI]" value2="/email/message" type="eq">
<try>
<imap config="./email.cfg" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imap config="./email.cfg" host="$[@_imap_host]" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imapmessage sessionid="" folder="$[folder]" uid="$[uid]">
</imap>
<catch name="_imaperr">
{"ok":false,"error":"$[_imaperr]"}
</catch>
</try>
<else>
<if value1="$[REQUEST_URI]" value2="/email/flag" type="eq">
<try>
<imap config="./email.cfg" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imap config="./email.cfg" host="$[@_imap_host]" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imapflag sessionid="" folder="$[folder]" uid="$[uid]" flag="$[flag]" set="$[set]">
</imap>
<catch name="_imaperr">
{"ok":false,"error":"$[_imaperr]"}
</catch>
</try>
<else>
<if value1="$[REQUEST_URI]" value2="/email/delete" type="eq">
<try>
<imap config="./email.cfg" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imap config="./email.cfg" host="$[@_imap_host]" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imapdelete sessionid="" folder="$[folder]" uid="$[uid]">
</imap>
<catch name="_imaperr">
{"ok":false,"error":"$[_imaperr]"}
</catch>
</try>
<else>
<if value1="$[REQUEST_URI]" value2="/email/emptyfolder" type="eq">
<if value1="$[folder]" value2="Spam" type="eq">
<set name="_emptyok" value="1">
<else>
<if value1="$[folder]" value2="Trash" type="eq">
<set name="_emptyok" value="1">
<else>
<set name="_emptyok" value="0">
</if>
</if>
<if value1="$[_emptyok]" value2="1" type="eq">
<try>
<imap config="./email.cfg" host="$[@_imap_host]" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imapemptyfolder sessionid="" folder="$[folder]">
</imap>
<catch name="_imaperr">
{"ok":false,"error":"$[_imaperr]"}
</try>
<else>
{"ok":false,"error":"Only the Spam and Trash folders can be emptied."}
</if>
<else>
<if value1="$[REQUEST_URI]" value2="/email/trash" type="eq">
<try>
<imap config="./email.cfg" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imap config="./email.cfg" host="$[@_imap_host]" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imapmove sessionid="" folder="$[folder]" uid="$[uid]" destfolder="Trash">
</imap>
<catch name="_imaperr">
{"ok":false,"error":"$[_imaperr]"}
</catch>
</try>
<else>
<if value1="$[REQUEST_URI]" value2="/email/folders" type="eq">
<try>
<imap config="./email.cfg" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imap config="./email.cfg" host="$[@_imap_host]" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imapfolders sessionid="">
</imap>
<catch name="_imaperr">
{"ok":false,"error":"$[_imaperr]"}
</catch>
</try>
<else>
<if value1="$[REQUEST_URI]" value2="/email/search" type="eq">
<try>
<imap config="./email.cfg" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imap config="./email.cfg" host="$[@_imap_host]" user="$[@_imap_user]" password="$[@_imap_password]" sessionid="">
<imapsearch sessionid="" folder="$[folder]" query="$[query]">
</imap>
<catch name="_imaperr">
{"ok":false,"error":"$[_imaperr]"}
</catch>
</try>
<else>
<if value1="$[REQUEST_URI]" value2="/email/send" type="eq">
@@ -139,7 +162,6 @@
<smtpsend config="./email.cfg" user="$[@_imap_user]" password="$[@_imap_password]" to="$[to]" subject="$[subject]" html="$[body]">
<catch name="_smtperr">
{"ok":false,"error":"$[_smtperr]"}
</catch>
</try>
<else>
<if value1="$[REQUEST_URI]" value2="/email/accounts" type="eq">
@@ -147,11 +169,13 @@
<else>
<if value1="$[REQUEST_URI]" value2="/email/switchaccount" type="eq">
<try>
<eval name="_switch_host"><imapaccounts action="gethost" list="$[@_imap_accounts]" user="$[user]"></imapaccounts></eval>
<eval name="_switch_password"><imapaccounts action="getpassword" list="$[@_imap_accounts]" user="$[user]"></imapaccounts></eval>
<if value1="$[_switch_password]" value2="" type="eq">
{"ok":false,"error":"That account is not connected."}
<else>
<imap config="./email.cfg" user="$[user]" password="$[_switch_password]" sessionid="">
<imap config="./email.cfg" host="$[_switch_host]" user="$[user]" password="$[_switch_password]" sessionid="">
<set name="@_imap_host" value="$[_switch_host]">
<set name="@_imap_user" value="$[user]">
<set name="@_imap_password" value="$[_switch_password]">
{"ok":true}
@@ -159,7 +183,6 @@
</if>
<catch name="_switcherr">
{"ok":false,"error":"$[_switcherr]"}
</catch>
</try>
<else>
{"ok":false,"error":"Unknown route."}
@@ -170,6 +193,7 @@
</if>
</if>
</if>
</if>
</if>
</if>
</if>
@@ -0,0 +1,128 @@
<page secure="yes" loggedin="yes">
<title>EMAIL</title>
<contents>
<style>
#email-connect-form { max-width: 360px; margin: 40px auto; }
#email-connect-form input { display: block; width: 100%; box-sizing: border-box; margin-bottom: 10px; padding: 6px; }
#email-connect-error { color: #a00; min-height: 1.2em; margin-bottom: 10px; }
#email-app { height: 100%; }
#email-client { display: flex; flex-direction: column; max-height: 100%; }
#email-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1pt solid var(--bond-line-soft); margin-bottom: 6px; }
#email-toolbar-actions { display: flex; align-items: center; gap: 6px; }
#email-search-box { display: flex; align-items: center; gap: 4px; margin-right: 6px; }
#email-search-input {
background: #101014; color: var(--bond-text);
border: 1px solid var(--bond-line-soft); border-radius: 4px;
padding: 4px 8px; font-size: 9pt; width: 150px;
}
#email-search-input:focus {
outline: none; border-color: var(--bond-gold-bright);
box-shadow: 0 0 0.6em rgba(197, 164, 90, 0.5), 0 0 0.2em rgba(227, 196, 126, 0.55);
}
#email-list-count { color: var(--bond-text-dim); font-size: 9pt; margin-left: 6px; }
#email-layout { display: flex; flex: 1; min-height: 0; }
#email-list { width: 340px; flex-shrink: 0; overflow-y: auto; border-right: 1pt solid var(--bond-line-soft); transition: opacity 0.18s ease; }
#email-reading-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 0 12px; transition: opacity 0.18s ease; }
.email-fading { opacity: 0; }
.email-row {
display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 13px;
border-bottom: 1pt solid var(--bond-line-soft); border-left: 3px solid transparent; cursor: pointer;
overflow: hidden;
transition: opacity 0.2s ease,
height 0.22s ease 0.2s, padding-top 0.22s ease 0.2s, padding-bottom 0.22s ease 0.2s,
margin-top 0.22s ease 0.2s, margin-bottom 0.22s ease 0.2s, border-width 0.22s ease 0.2s;
}
.email-row:hover { background: rgba(255, 255, 255, 0.05); }
.email-row.unread {
font-weight: bold;
background: rgba(197, 164, 90, 0.12);
box-shadow: inset 0 0 0 1px var(--bond-gold);
}
.email-row.selected { background: rgba(197, 164, 90, 0.16); border-left-color: var(--bond-gold); }
.email-row.selected:hover { background: rgba(197, 164, 90, 0.22); }
/* Per-row removal animation for the trash button (see trashMessage()
in email.js) - dissolves in place first (the opacity transition,
no delay), then collapses its own box to nothing (the delayed
height/padding/margin/border transitions kick in once the fade is
mostly done) so every row below it slides up smoothly to close the
gap, purely as a side effect of ordinary document-flow reflow - no
other row is touched, faded, or re-rendered to make that happen. */
.email-row.email-row-removing {
opacity: 0;
height: 0 !important;
padding-top: 0; padding-bottom: 0;
margin-top: 0; margin-bottom: 0;
border-width: 0;
}
.email-row-info { flex: 1; min-width: 0; }
.email-row .email-from { font-size: 10pt; }
.email-row .email-subject { font-size: 9pt; color: var(--bond-text-dim); }
.email-row .email-date { font-size: 8pt; color: var(--bond-text-dim); }
.email-row-trash-btn { flex-shrink: 0; width: 24px; height: 24px; opacity: 0.55; }
.email-row-trash-btn svg { width: 13px; height: 13px; }
.email-row-trash-btn:hover { opacity: 1; }
#email-reading-pane .email-header { border-bottom: 1pt solid var(--bond-line-soft); margin-bottom: 10px; padding-bottom: 10px; }
#email-reading-pane .email-body { white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word; font-family: monospace; font-size: 9pt; }
#email-reading-pane .email-body-frame { width: 100%; height: 520px; border: none; border-radius: 4px; background: #fff; }
#email-reading-pane .email-actions { margin-top: 10px; }
#email-empty-state { color: var(--bond-text-dim); padding: 20px; }
#email-folder-list { display: flex; flex-direction: column; }
.email-folder-link { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; margin-bottom: 2px; border-radius: 4px; text-decoration: none; color: inherit; }
.email-folder-link:hover { background: rgba(255,255,255,0.08); }
.email-folder-link.email-folder-selected { background: rgba(255,255,255,0.14); font-weight: bold; }
.email-folder-count { font-size: 8pt; padding: 1px 6px; border-radius: 8px; background: rgba(197, 164, 90, 0.25); color: var(--bond-gold-bright); }
.email-folder-count:empty { display: none; }
.icon-btn {
display: inline-flex; align-items: center; justify-content: center;
width: 30px; height: 30px; padding: 0; margin: 0; cursor: pointer;
border-radius: 6px; border: 1px solid var(--bond-gold);
background: linear-gradient(180deg, #1c1c24, #131318);
color: var(--bond-gold-bright);
box-shadow: 0 0 0.4em rgba(197, 164, 90, 0.25);
transition: box-shadow 0.2s ease, background 0.2s ease, transform 0.1s ease;
}
.icon-btn svg { width: 16px; height: 16px; display: block; }
.icon-btn:hover {
box-shadow: 0 0 0.8em rgba(197, 164, 90, 0.5), 0 0 0.25em rgba(227, 196, 126, 0.55);
background: linear-gradient(180deg, #24242e, #1a1a20);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn.icon-btn-active {
color: #131318;
background: linear-gradient(180deg, var(--bond-gold-bright), var(--bond-gold));
box-shadow: 0 0 0.7em rgba(197, 164, 90, 0.6);
}
</style>
<div id="email-app">
<if value1="$[@_imap_user]" value2="" type="eq">
<div id="email-connect-form">
<h3>Connect to Mailbox</h3>
<input type="text" id="email-user-input" placeholder="you@barant.com" autocomplete="username">
<input type="password" id="email-password-input" placeholder="Password" autocomplete="current-password">
<button type="button" id="email-connect-btn">Connect</button>
<div id="email-connect-error"></div>
</div>
<else>
<div id="email-client">
<div id="email-toolbar">
<span id="email-connected-as">$[@_imap_user]</span><span id="email-list-count"></span>
<span id="email-toolbar-actions">
<span id="email-search-box">
<input type="text" id="email-search-input" placeholder="Search mail&hellip;">
<button type="button" id="email-search-btn" class="icon-btn" title="Search"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.35-4.35"/></svg></button>
</span>
<button type="button" id="email-compose-btn" class="icon-btn" title="New Mail"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6h13a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z"/><path d="M2.5 7.5 12 14l9.5-6.5"/><path d="M18.5 3.5v5M16 6h5"/></svg></button>
<button type="button" id="email-refresh-btn" class="icon-btn" title="Refresh"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 11a8 8 0 0 0-14.6-4.4M4 4v5h5"/><path d="M4 13a8 8 0 0 0 14.6 4.4M20 20v-5h-5"/></svg></button>
<button type="button" id="email-disconnect-btn" class="icon-btn" title="Disconnect"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><path d="M16 17l5-5-5-5"/><path d="M21 12H9"/></svg></button>
</span>
</div>
<div id="email-layout">
<div id="email-list"></div>
<div id="email-reading-pane"><div id="email-empty-state">Select a message to read it.</div></div>
</div>
</div>
</if>
</div>
<script src="/assets/email.js?v=20260905m"></script>
</contents>
</page>
+29 -29
View File
@@ -49,22 +49,22 @@ $[filelist]
<div style="position: relative;">
<div id="window1" style="position: absolute; left: 0px; top: 0px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;"
<div id="window1" style="position: absolute; left: 0px; top: 0px; border: 1px solid var(--bond-line); display: inline-block; padding: 2px; background: var(--bond-panel); color: var(--bond-text);"
onmousemove="window_mousemove(this, event); return true;"
onmousedown="window_mousedown(this, event); return true;"
onmouseup="window_mouseup(this, event); return true;">
<div style="background-color: #678; height: 21px; padding: 2px 2px 2px 2px;">
<div style="float: left;"><b style="padding: 2px 8px;">$[letter_dir]/$[letter_file]</b></div>
<div style="float: left;"><button type="button" onclick="save(this.form);">SAVE</button></div>
<div style="float: left;"><button type="button" onclick="savenexit(this.form);">SAVE AND EXIT</button></div>
<div style="float: right;"><button type="button" onclick="exitnosave(this.form);">EXIT NO SAVE</button></div>
<div style="background: linear-gradient(180deg, #1c1c24, #101014); height: 21px; padding: 2px 2px 2px 2px;">
<div style="float: left;"><b style="padding: 2px 8px; color: var(--bond-gold-bright);">$[letter_dir]/$[letter_file]</b></div>
<div style="float: left;"><button type="button" class="button" onclick="save(this.form);">SAVE</button></div>
<div style="float: left;"><button type="button" class="button" onclick="savenexit(this.form);">SAVE AND EXIT</button></div>
<div style="float: right;"><button type="button" class="button" onclick="exitnosave(this.form);">EXIT NO SAVE</button></div>
</div>
<div style="background-color: #abc; padding: 0px 2px 6px 2px;">
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid #012; background-color: #def; cursor: pointer;" onclick="return do_undo();"><img width="18" src="/assets/htmleditor_undo.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid #012; background-color: #def; cursor: pointer;" onclick="return do_redo();"><img width="18" src="/assets/htmleditor_redo.png"></div>
<div style="background: var(--bond-bg-2); padding: 0px 2px 6px 2px;">
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid var(--bond-line); background-color: var(--bond-panel-2); cursor: pointer;" onclick="return do_undo();"><img width="18" src="/assets/htmleditor_undo.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid var(--bond-line); background-color: var(--bond-panel-2); cursor: pointer;" onclick="return do_redo();"><img width="18" src="/assets/htmleditor_redo.png"></div>
&nbsp;
<div style="display: inline-block; float: left; margin: 2px 0px 0px 0px;">
<select style="border: 1pt solid #123; border-radius: 3px; background-color: #def;" onchange="document.execCommand('formatBlock',false,this.value);return true;">
<select style="border: 1px solid var(--bond-line); border-radius: 3px; background-color: var(--bond-panel-2); color: var(--bond-text);" onchange="document.execCommand('formatBlock',false,this.value);return true;">
<option value="p">Paragraph</option>
<option value="h1">Heading 1</option>
<option value="h2">Heading 2</option>
@@ -72,13 +72,13 @@ onmouseup="window_mouseup(this, event); return true;">
<option value="pre">Monospace</option>
</select>
</div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 5px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid #012; background-color: #def; cursor: pointer;" onclick="document.execCommand('bold');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_bold.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid #012; background-color: #def; cursor: pointer;" onclick="document.execCommand('underline');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_underline.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 5px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid #012; background-color: #def; cursor: pointer;" onclick="document.execCommand('justifyLeft');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_jl.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid #012; background-color: #def; cursor: pointer;" onclick="document.execCommand('justifyCenter');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_jc.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid #012; background-color: #def; cursor: pointer;" onclick="document.execCommand('justifyRight');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_jr.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid #012; background-color: #def; cursor: pointer;" onclick="document.execCommand('justifyFull');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_jj.png"></div>
<div id="map" style="display: inline-block; color: #012; font-size: 10px;"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 5px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid var(--bond-line); background-color: var(--bond-panel-2); cursor: pointer;" onclick="document.execCommand('bold');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_bold.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid var(--bond-line); background-color: var(--bond-panel-2); cursor: pointer;" onclick="document.execCommand('underline');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_underline.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 5px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid var(--bond-line); background-color: var(--bond-panel-2); cursor: pointer;" onclick="document.execCommand('justifyLeft');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_jl.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid var(--bond-line); background-color: var(--bond-panel-2); cursor: pointer;" onclick="document.execCommand('justifyCenter');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_jc.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid var(--bond-line); background-color: var(--bond-panel-2); cursor: pointer;" onclick="document.execCommand('justifyRight');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_jr.png"></div>
<div style="float: left; display: inline-block; margin: 2px 2px 2px 0px; border-radius: 3px; width: 18px; height: 18px; border: 1px solid var(--bond-line); background-color: var(--bond-panel-2); cursor: pointer;" onclick="document.execCommand('justifyFull');return true;"><img width="14" style="padding: 2px;" src="/assets/htmleditor_jj.png"></div>
<div id="map" style="display: inline-block; color: var(--bond-text-dim); font-size: 10px;"></div>
</div>
<div id="mainpage"
@@ -93,16 +93,16 @@ onmouseup="window_mouseup(this, event); return true;">
<div id="window3" style="position:absolute; top: 235px; left: 1010px;
border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;">
border: 1px solid var(--bond-line); display: inline-block; padding: 2px; background: var(--bond-panel); color: var(--bond-text);">
<span>Options</span>
<span style="color: var(--bond-gold-bright);">Options</span>
<div style="width: 320px; color: #000000; border: 1px solid black; position: relative; background: #ffffff;">
<div style="width: 320px; color: var(--bond-text); border: 1px solid var(--bond-line); position: relative; background: var(--bond-bg-2);">
<div id="controls">
<input type="checkbox" name="grid" onchange="showGrid = this.checked; drawGrid(); return true;"><span style="font-size: 12px; margin-bottom: 2px;">Show Grid</span><br>
<input type="checkbox" name="snaptogrid" onchange="snapToGrid = this.checked; return true;"><span style="font-size: 12px; margin-bottom: 2px;">Snap To Grid</span><br>
<span style="font-size: 12px; margin-bottom: 2px;">Grid Size: </span><input type="text" name="gridsize" id="gridsize" style="width: 20px;" size="3" onchange="gridSize = parseInt(this.value); drawGrid(); return true;"><br>
<span style="font-size: 12px; margin-bottom: 2px;">Grid Size: </span><input type="text" name="gridsize" id="gridsize" class="fieldinput" style="width: 20px;" size="3" onchange="gridSize = parseInt(this.value); drawGrid(); return true;"><br>
</div>
<div id="itemparameters" style="font-size: 12px;"></div>
@@ -116,27 +116,27 @@ onmouseup="window_mouseup(this, event); return true;">
<div id="window2" style="position:absolute; top: 0px; left: 1010px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;">
<span>Toolbar</span>
<div id="toolbar" style="overflow-y: auto; width: 200px; height: 300px; border: 1px solid black; position: relative; background: #ffffff;">
<div id="window2" style="position:absolute; top: 0px; left: 1010px; border: 1px solid var(--bond-line); display: inline-block; padding: 2px; background: var(--bond-panel); color: var(--bond-text);">
<span style="color: var(--bond-gold-bright);">Toolbar</span>
<div id="toolbar" style="overflow-y: auto; width: 200px; height: 300px; border: 1px solid var(--bond-line); position: relative; background: var(--bond-bg-2);">
</div>
</div>
<div id="window4" style="position:absolute; top: 860px; left: 0px;
border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;">
border: 1px solid var(--bond-line); display: inline-block; padding: 2px; background: var(--bond-panel); color: var(--bond-text);">
<span>Images</span>
<span style="color: var(--bond-gold-bright);">Images</span>
<div style="width: 1000px; height: 300px; color: #000000; border: 1px solid black; position: relative; background: #ffffff;">
<div style="width: 1000px; height: 300px; color: var(--bond-text); border: 1px solid var(--bond-line); position: relative; background: var(--bond-bg-2);">
<div id="controls" style="overflow-y: scroll; max-height: 275px; padding: 3px;">
<div style="display: inline-block;">
<div style="width: 100px; height: 100px; border: 1px solid #000; margin: 5px 0px 5px 5px; background-image: url('/assets/htmleditor_drinkwise_logo.png'); background-size: contain; background-repeat: no-repeat; cursor: pointer;" onmousedown="newImage('htmleditor_drinkwise_logo.png', event); return true;"></div>
<div style="width: 100px; height: 100px; border: 1px solid var(--bond-line); margin: 5px 0px 5px 5px; background-image: url('/assets/htmleditor_drinkwise_logo.png'); background-size: contain; background-repeat: no-repeat; cursor: pointer;" onmousedown="newImage('htmleditor_drinkwise_logo.png', event); return true;"></div>
<div style="font-size: 8px;">drinkwise_logo.png</div>
</div>
<div style="display: inline-block;">
<div style="width: 100px; height: 100px; border: 1px solid #000; margin: 5px 0px 5px 5px; background-image: url('/assets/htmleditor_dwbackground.png'); background-size: contain; background-repeat: no-repeat; cursor: pointer;" onmousedown="newImage('htmleditor_dwbackground.png', event); return true;"></div>
<div style="width: 100px; height: 100px; border: 1px solid var(--bond-line); margin: 5px 0px 5px 5px; background-image: url('/assets/htmleditor_dwbackground.png'); background-size: contain; background-repeat: no-repeat; cursor: pointer;" onmousedown="newImage('htmleditor_dwbackground.png', event); return true;"></div>
<div style="font-size: 8px;">dwbackground.png</div>
</div>
</div>
+38 -39
View File
@@ -5,54 +5,53 @@
date_format(i.created,'%m/%e/%Y') as invdate,
i.status as status,
i.amount as amount
from invoices as i
from invoices as i
join users as u on i.user_id=u.id
where i.id=$[_invoice_id]</sql>
where i.id=$[@_invoice_id]</sql>
<set name="amount" value="$[.amount]">
<div style="width: 500px; border: 1pt solid #000; padding: 3px; background: #fff;">
<div><div style="display: inline-block;"><img style="width: 300px;" src="/assets/invoice_logo.png"></div>
<div style="display: flex; float: right; align-items: center;">
Invoice: $[.invnumber] $[.status]
</div>
</div>
<div style="background: #eee;">
<div>Name: $[.name]</div>
<div>Company Name: $[.company_name]</div>
<div>E-Mail $[.email]</div>
<div>Invoice Date: $[.invdate]</div>
</div>
<div style="background: #ddd;">
<sql>select * from invoices_detail where invoice_id=$[_invoice_id]</sql>
<table style="border: 0px;" cellspacing="0">
<tr><td style="background-color: #888; color: #fff; width: 50px; padding:3px; text-align: center; border: 1pt solid #ddd;">Qty</td>
<td style="background-color: #888; color: #fff; width: 400px; padding: 3px; border: 1pt solid #ddd;">Description</td>
<td style="background-color: #888; color: #fff; width: 60px; padding: 3px; text-align: center; border: 1pt solid #ddd;">Unit Price</td>
<td style="background-color: #888; color: #fff; width: 60px; padding: 3px; text-align: center; border: 1pt solid #ddd;">Amount</td>
<set name="invoicestatus" value="$[.status]">
<div style="width: 600px; max-width: 100%; margin: 0 auto; border: 1px solid rgba(197, 164, 90, 0.28); border-radius: 10px; padding: 20px; background: #0a0a0d; color: #e7e4dc; font-family: Arial, Helvetica, sans-serif; font-size: 14px;">
<table style="width: 100%; border-collapse: collapse;" cellspacing="0" cellpadding="0"><tr>
<td style="vertical-align: middle;"><img style="height: 90px; width: auto;" src="https://barant.com/assets/btglogo.png"></td>
<td style="vertical-align: middle; text-align: right; color: #c5a45a; letter-spacing: 0.5px;">
<div style="font-size: 24px; font-weight: 600;">Invoice: $[.invnumber]</div>
<div style="color: #8d8c92; font-size: 12px; margin-top: 4px;">$[.status]</div>
</td>
</tr></table>
<div style="height: 1px; background: rgba(197, 164, 90, 0.28); margin: 16px 0;"></div>
<table style="border-collapse: collapse; margin-bottom: 16px; font-size: 16px;" cellspacing="0" cellpadding="0">
<tr><td style="color: #8d8c92; text-align: right; padding: 3px 10px 3px 16px; border-bottom: 1px solid #000;">Name:</td><td style="color: #e7e4dc; text-align: left; padding: 3px 16px 3px 0; border-bottom: 1px solid #000;">$[.name]</td></tr>
<tr><td style="color: #8d8c92; text-align: right; padding: 3px 10px 3px 16px; border-bottom: 1px solid #000;">Company Name:</td><td style="color: #e7e4dc; text-align: left; padding: 3px 16px 3px 0; border-bottom: 1px solid #000;">$[.company_name]</td></tr>
<tr><td style="color: #8d8c92; text-align: right; padding: 3px 10px 3px 16px; border-bottom: 1px solid #000;">E-Mail:</td><td style="color: #e7e4dc; text-align: left; padding: 3px 16px 3px 0; border-bottom: 1px solid #000;">$[.email]</td></tr>
<tr><td style="color: #8d8c92; text-align: right; padding: 3px 10px 3px 16px;">Invoice Date:</td><td style="color: #e7e4dc; text-align: left; padding: 3px 16px 3px 0;">$[.invdate]</td></tr>
</table>
<sql>select * from invoices_detail where invoice_id=$[@_invoice_id]</sql>
<table style="width: 100%; border-collapse: collapse; background: #16161c; border-radius: 6px;" cellspacing="0" cellpadding="0">
<tr><td style="background-color: #1c1c24; color: #c5a45a; width: 50px; padding: 6px 8px; text-align: center; border-bottom: 1px solid #000;">Qty</td>
<td style="background-color: #1c1c24; color: #c5a45a; width: 400px; padding: 6px 8px; border-bottom: 1px solid #000;">Description</td>
<td style="background-color: #1c1c24; color: #c5a45a; width: 60px; padding: 6px 8px; text-align: center; border-bottom: 1px solid #000;">Unit Price</td>
<td style="background-color: #1c1c24; color: #c5a45a; width: 60px; padding: 6px 8px; text-align: center; border-bottom: 1px solid #000;">Amount</td>
</tr>
<whilerow>
<tr><td style="width: 50px; vertical-align: top; text-align: center; border: 1pt solid #ddd;">
<tr><td style="width: 50px; vertical-align: top; text-align: center; color: #e7e4dc; padding: 6px 8px; border-bottom: 1px solid #000;">
<if value1="$[.sku]" value2="***" type="ne">$[quantity]</if></td>
<td style="width: 400px; border: 1pt solid #ddd;">
<td style="width: 400px; vertical-align: top; color: #e7e4dc; padding: 6px 8px; border-bottom: 1px solid #000;">
<if value1="$[.sku]" value2="***" type="ne">$[description]<br></if>
$[text]</td>
<td style="width: 60px; vertical-align: top; text-align: right; border: 1pt solid #ddd;">
<td style="width: 60px; vertical-align: top; text-align: right; color: #e7e4dc; padding: 6px 8px; border-bottom: 1px solid #000;">
<if value1="$[.sku]" value2="***" type="ne">$[price]</if></td>
<td style="width: 60px; vertical-align: top; text-align: right; border: 1pt solid #ddd;">$[total]</td>
<td style="width: 60px; vertical-align: top; text-align: right; color: #e7e4dc; padding: 6px 8px; border-bottom: 1px solid #000;">$[total]</td>
</tr>
</whilerow>
<tr><td style="width: 50px; border: 0pt solid #000;"></td>
<td style="width: 400px; text-align: right; border: 0pt solid #000;" colspan="2">Invoice Total:</td>
<td style="width: 60px; text-align: right; border: 1pt solid #000;">$[amount]</td>
<tr><td style="width: 50px;"></td>
<td style="width: 400px; text-align: right; padding: 10px 8px; color: #e3c47e; font-weight: bold;" colspan="2">Invoice Total:</td>
<td style="width: 60px; text-align: right; padding: 10px 8px; color: #e3c47e; font-weight: bold;">$[amount]</td>
</tr>
<tr><td colspan="4" style="width: 50px; border: 0pt solid #000;"><hr></td>
</tr>
<sql>select * from payments where invoice_id=$[_invoice_id]</sql>
<whilerow>
<tr><td style="width: 50px; border: 0pt solid #000;"></td>
<td colspan="2" style="width: 400px; text-align: right; border: 0pt solid #000;">Credit Card: $[.card_brand] ending in $[.last_4_digits] expires on $[.exp_month]/$[.exp_year]</td>
<td style="width: 60px; text-align: right; border: 1pt solid #000;">$[.amount]</td>
</tr>
</whilerow>
</table>
</div>
</table>
<sql>select * from payments where invoice_id=$[@_invoice_id]</sql>
<whilerow>
<div style="margin-top: 12px; text-align: right; color: #8d8c92; font-size: 12px;">
Credit Card: $[.card_brand] ending in $[.last_4_digits] expires $[.exp_month]/$[.exp_year]
</div>
</whilerow>
</div>
@@ -0,0 +1,13 @@
<page>
<title>barant.com - JET Extension Tags</title>
<contents>
<if value1="$[ARGS]" value2="" type="eq">
<include file="jet_overview.section">
<else>
<set name="subpage" expr="substring('$[ARGS]', 2)">
<include file="jet_$[subpage].section">
</if>
</contents>
</page>
-67
View File
@@ -1,67 +0,0 @@
<page secure="yes" loggedin="no">
<title>JUKEBOX</title>
<contents>
<script>
var index = 0;
const paths = [];
const songs = [];
function onselection(path,selection) {
var name = path + '/' + selection;
var player = document.getElementById('player');
var audio = document.getElementById('audio');
var title = document.getElementById('title');
player.src = name;
title.textContent = selection;
audio.load();
audio.play();
}
function selectNext() {
var index = Math.floor(Math.random()*songs.length) + 1;
onselection(paths[index],songs[index]);
}
</script>
<retain name="download_file">
<div style="display: inline-block;">
<audio id="audio" controls onended="selectNext();">
<source id="player" type="audio/mp3">
</audio>
</div>
<div style="font-size: 20px; display: inline-block;" id="title">Click on a title below</div>
<sectionframe title="Old Library">
<div style="height: 300px; overflow-y: scroll;">
<whiledir name="file" dir="musiclink/library">
<if expr="left('$[file]',1) != '.' ">
<div style="cursor: pointer;" onclick="onselection('musiclink/library','$[file]');">$[file]</div>
<script>
paths[index]='musiclink/library';
songs[index++]='$[file]';
</script>
</if>
</whiledir>
</div>
<script>
</script>
</sectionframe>
<sectionframe title="Ian's Library">
<div style="height: 300px; overflow-y: scroll;">
<whiledir name="file" dir="musiclink/ianslibrary">
<if expr="left('$[file]',1) != '.' ">
<div style="cursor: pointer;" onclick="onselection('musiclink/ianslibrary','$[file]');">$[file]</div>
<script>
paths[index]='musiclink/ianslibrary';
songs[index++]='$[file]';
</script>
</if>
</whiledir>
</div>
</sectionframe>
<script>
function printName(name) {
document.write(name + '\n');
}
//songs.forEach(printName);
</script>
</contents>
</page>
+19 -6
View File
@@ -8,13 +8,26 @@
<set name="login_email" value="$[login_email]">
<set name="login_type" value="$[.type]">
<set name="login_uuid" value="$[.uuid]">
<setenv name="_login_id">$[login_id]</setenv>
<setenv name="_login_name">$[login_name]</setenv>
<setenv name="_login_email">$[login_email]</setenv>
<setenv name="_login_type">$[login_type]</setenv>
<setenv name="_login_uuid">$[login_uuid]</setenv>
<set name="_login_id" value="$[login_id]"><set name="_login_id" value="$[login_id]" scope="session">
<set name="_login_name" value="$[login_name]"><set name="_login_name" value="$[login_name]" scope="session">
<set name="_login_email" value="$[login_email]"><set name="_login_email" value="$[login_email]" scope="session">
<set name="_login_type" value="$[login_type]"><set name="_login_type" value="$[login_type]" scope="session">
<set name="_login_uuid" value="$[login_uuid]"><set name="_login_uuid" value="$[login_uuid]" scope="session">
<sql>update users set last_login=now() where id=$[login_id]</sql>
<if value1="$[@start]" value2="" type="eq">
<sql>select group_concat(to_base64(host),':',to_base64(email),':',to_base64(password) order by id separator ';') as accounts_list,
(select host from email_accounts where user_id=$[login_id] order by id limit 1) as first_host,
(select email from email_accounts where user_id=$[login_id] order by id limit 1) as first_email,
(select password from email_accounts where user_id=$[login_id] order by id limit 1) as first_password
from email_accounts where user_id=$[login_id]</sql>
<ifrow>
<if value1="$[.accounts_list]" value2="" type="ne">
<set name="@_imap_accounts" value="$[.accounts_list]">
<set name="@_imap_host" value="$[.first_host]">
<set name="@_imap_user" value="$[.first_email]">
<set name="@_imap_password" value="$[.first_password]">
</if>
</ifrow>
<if value1="$[@start]" value2="" type="eq">
<setpage name="account">
<else>
<setpage name="$[@start]">
+1 -1
View File
@@ -1,7 +1,7 @@
<page>
<title>LOGIN</title>
<contents>
<setenv name="start">$[start:0]</setenv>
<set name="start" value="$[start:0]"><set name="start" value="$[start:0]" scope="session">
<sectionframe title="LOGIN">
<p>Please enter your information below to login.</p>
+26
View File
@@ -0,0 +1,26 @@
#api POST /admin/mail-invoice
<set name="host" value="localhost">
<set name="database" value="barant">
<set name="user" value="barant">
<set name="password" value="uversa1960">
<database name="$[database]" host="$[host]" user="$[user]" password="$[password]" sessionid="">
<header name="Content-Type" value="application/json">
<if value1="$[@_login_type]" value2="admin" type="ne">
{"ok":false,"error":"Not authorized."}
<else>
<if value1="$[@_invoice_id]" value2="" type="eq">
{"ok":false,"error":"No invoice selected."}
<else>
<if value1="$[email]" value2="" type="eq">
{"ok":false,"error":"Please enter an e-mail address."}
<else>
<try>
<set name="_invoice_email_override" value="$[email]">
<include file="send_invoice_email.method">{"ok":true}
<catch name="_mailerr">
{"ok":false,"error":"$[_mailerr]"}
</try>
</if>
</if>
</if>
</database>
+43
View File
@@ -0,0 +1,43 @@
#api POST /admin/add-mail-account
#api POST /admin/remove-mail-account
<set name="host" value="localhost">
<set name="database" value="barant">
<set name="user" value="barant">
<set name="password" value="uversa1960">
<database name="$[database]" host="$[host]" user="$[user]" password="$[password]" sessionid="">
<header name="Content-Type" value="application/json">
<if value1="$[@_login_type]" value2="admin" type="ne">
{"ok":false,"error":"Not authorized."}
<else>
<if value1="$[REQUEST_URI]" value2="/admin/add-mail-account" type="eq">
<if value1="$[mail_host]" value2="" type="eq">
{"ok":false,"error":"Please enter a mail server."}
<else>
<if value1="$[mail_email]" value2="" type="eq">
{"ok":false,"error":"Please enter an e-mail address."}
<else>
<if value1="$[mail_password]" value2="" type="eq">
{"ok":false,"error":"Please enter a password."}
<else>
<try>
<imap config="./email.cfg" host="$[mail_host]" user="$[mail_email]" password="$[mail_password]" sessionid="">
</imap>
<sql>insert into email_accounts (user_id,email,host,password) values ($[@_login_id],'$[mail_email]','$[mail_host]','$[mail_password]')
on duplicate key update host='$[mail_host]', password='$[mail_password]'</sql>
{"ok":true}
<catch name="_imaperr">
{"ok":false,"error":"Could not connect with those credentials: $[_imaperr]"}
</try>
</if>
</if>
</if>
<else>
<if value1="$[account_id]" value2="" type="eq">
{"ok":false,"error":"No account specified."}
<else>
<sql>delete from email_accounts where id=$[account_id] and user_id=$[@_login_id]</sql>
{"ok":true}
</if>
</if>
</if>
</database>
@@ -0,0 +1,7 @@
<retain name="download_file">
<sectionframe title="Ian's Library">
<div class="music-song-list" id="music-list-ianslibrary"></div>
</sectionframe>
<script>
__renderMusicFolder('music-list-ianslibrary', 'ianslibrary', '/assets/musiclink/ianslibrary');
</script>
@@ -0,0 +1,7 @@
<retain name="download_file">
<sectionframe title="Old Library">
<div class="music-song-list" id="music-list-library"></div>
</sectionframe>
<script>
__renderMusicFolder('music-list-library', 'library', '/assets/musiclink/library');
</script>
+7
View File
@@ -0,0 +1,7 @@
<retain name="download_file">
<sectionframe title="BARANT Audio Experiments">
<div class="music-song-list" id="music-list-bae"></div>
</sectionframe>
<script>
__renderMusicFolder('music-list-bae', 'bae', '/assets/musiclink/bae');
</script>
@@ -0,0 +1,23 @@
<sectionframe title="Welcome to BARANT Systems">
<div style="width: 48%;">
<p>We are BARANT Technology Group. Contact us for information on how we can
help you with your technical objectives.</p>
<h1>Modular1 VST Synthesizer</h1>
<p>Check out our <a href="/vst">Modular1 VST3
Synthesizer</a> If you appreciate the art of modular analog
synthesizers then you will really enjoy the Modular1 with all the
features of an analog modular synthesizer put into a single VST3
instrument. With the added features of polyphony and patches that
change instantaneously this synthesizer is truly a powerhouse in the
audio toolbox.</p>
<a href="/vst"><img src="/assets/modular1.png" style="width: 200px;" align="left"></a>
<p>Excellent quality and technical performance provide a performance level
instrument for musicians or students who wish to learn sound wave
synthesis techniques or for musicians to enable that old analog sound
in their DAW recording system..</p>
<p>Checkout the product page for more information on the capabilities
of the Modular1 synthesizer.</p>
</div>
</sectionframe>
+24 -2
View File
@@ -1,7 +1,29 @@
<sectionframe title="MAIN">
<if value1="$[SUBPAGE]" value2="" type="eq">
<linkbutton page="main" class="submenuitem-active">OVERVIEW</linkbutton><br>
<else>
<linkbutton page="main">OVERVIEW</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="music" type="eq">
<linkbutton page="main" subpage="music" class="submenuitem-active">MUSIC</linkbutton><br>
<else>
<linkbutton page="main" subpage="music">MUSIC</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="library" type="eq">
<linkbutton page="main" subpage="library" class="submenuitem-active">MATT'S LIBRARY</linkbutton><br>
<else>
<linkbutton page="main" subpage="library">MATT'S LIBRARY</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="ianslibrary" type="eq">
<linkbutton page="main" subpage="ianslibrary" class="submenuitem-active">IAN'S LIBRARY</linkbutton><br>
<else>
<linkbutton page="main" subpage="ianslibrary">IAN'S LIBRARY</linkbutton><br>
</if>
</sectionframe>
<sectionframe title="QUICK LINKS">
<linkbutton page="services">SERVICES</linkbutton><br>
<linkbutton page="hosting">HOSTING</linkbutton><br>
<linkbutton page="siptrunk">SIP TRUNKING</linkbutton><br>
<linkbutton page="services" subpage="hosting">HOSTING</linkbutton><br>
<linkbutton page="services" subpage="siptrunking">SIP TRUNKING</linkbutton><br>
<linkbutton page="opensource">OPEN SOURCE</linkbutton><br>
<linkbutton page="contact">CONTACT</linkbutton>
</sectionframe>
+12 -24
View File
@@ -1,29 +1,17 @@
<page>
<title>BARANT Technology Group</title>
<contents>
<setenv name="_menubar"></setenv>
<sectionframe title="Welcome to BARANT Systems">
<div style="width: 48%;">
<p>We are BARANT Technology Group. Contact us for information on how we can
help you with your technical objectives.</p>
<h1>Modular1 VST Synthesizer</h1>
<p>Check out our <a href="/vst">Modular1 VST3
Synthesizer</a> If you appreciate the art of modular analog
synthesizers then you will really enjoy the Modular1 with all the
features of an analog modular synthesizer put into a single VST3
instrument. With the added features of polyphony and patches that
change instantaneously this synthesizer is truly a powerhouse in the
audio toolbox.</p>
<a href="/vst"><img src="/assets/modular1.png" style="width: 200px;" align="left"></a>
<p>Excellent quality and technical performance provide a performance level
instrument for musicians or students who wish to learn sound wave
synthesis techniques or for musicians to enable that old analog sound
in their DAW recording system..</p>
<p>Checkout the product page for more information on the capabilities
of the Modular1 synthesizer.</p>
</div>
</sectionframe>
<set name="_menubar" value=""><set name="_menubar" value="" scope="session">
<div id="main-subpage">
<if value1="$[SUBPAGE]" value2="" type="eq">
<include file="main-overview.subpage">
<else>
<try>
<include file="main-$[SUBPAGE].subpage">
<catch>
<p>That page doesn't exist.</p>
</try>
</if>
</div>
</contents>
</page>
+747 -6
View File
@@ -72,7 +72,7 @@ $[_BODY]
<html lang="en">
<head>
<title>BARANT Technology Group</title>
<link rel="stylesheet" href="/assets/main.css?v=20260906a">
<link rel="stylesheet" href="/assets/main.css?v=20261006a">
<link rel="stylesheet" href="/assets/control.css?v=20260902">
</head>
<body>
@@ -88,13 +88,753 @@ $[_BODY]
<div class="pageclass">
<div class="heading">
<div style="display: inline-block; width: 500px;">
<a href="https://barant.com"><img style="width: 60px; height: 60px; margin: 10px; background-color: #000; border-radius: 6px; padding: 4px; box-sizing: border-box;" align="left" src="/assets/btglogo.png"></a>
<div style="padding-top: 15px;">
<div style="left: 80px; color: #c5a45a; font-size: 20pt; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600;">BARANT TECHNOLOGY GROUP</div>
</div>
<a href="https://barant.com"><img style="height: 100px; width: auto; margin: 10px; border-radius: 6px; box-sizing: border-box;" align="left" src="/assets/btglogo.png"></a>
</div>
<div id="loginmenu" style="float: right; text-align: right; margin-right: 10px; margin-top: 5px;"><include file="login.menu"></div>
</div>
<div id="globalplayer-band" class="globalplayer-band">
<div id="globalplayer-playpause" class="globalplayer-btn" title="Play/Pause" onclick="__playerTogglePause();">
<svg id="globalplayer-playicon" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>
<svg id="globalplayer-pauseicon" viewBox="0 0 24 24" fill="currentColor" style="display:none;"><path d="M6 5h4v14H6zM14 5h4v14h-4z"/></svg>
</div>
<div id="globalplayer-stop" class="globalplayer-btn" title="Stop" onclick="__playerStop();">
<svg viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12"/></svg>
</div>
<div id="globalplayer-skip" class="globalplayer-btn" title="Skip" onclick="__playerAdvance();">
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M6 5v14l8-7zM16 5h2v14h-2z"/></svg>
</div>
<div id="globalplayer-title" class="globalplayer-title">
<div id="globalplayer-duration" class="globalplayer-duration"></div>
<div id="globalplayer-random-indicator" class="globalplayer-random-indicator">RANDOM</div>
<div id="globalplayer-title-text" class="globalplayer-title-text">Not Playing</div>
<div id="globalplayer-progress" class="globalplayer-progress"><div id="globalplayer-progress-fill" class="globalplayer-progress-fill"></div><div id="globalplayer-progress-handle" class="globalplayer-progress-handle"></div></div>
</div>
<input type="range" id="globalplayer-volume" class="globalplayer-volume" min="0" max="100" value="<if value1="$[@_player_volume]" value2="" type="eq">100<else>$[@_player_volume]</if>" title="Volume" oninput="__playerSetVolume(this.value);" onchange="__playerPersistVolume(this.value);">
<canvas id="globalplayer-eq" class="globalplayer-eq" width="60" height="32"></canvas>
<div id="globalplayer-queue-toggle" class="globalplayer-btn globalplayer-btn-text" title="Playlist" onclick="__playerToggleQueue();">RANDOM</div>
<audio id="globalaudio" style="display:none;"></audio>
</div>
<script type="application/json" id="globalplayer-saved-state">$[@_player_state]</script>
<div id="globalplayer-queue" class="globalplayer-queue"></div>
<script>
// Global, persistent music player + playlist queue - lives here (outside
// the #content area) specifically so it survives spa.js's per-navigation
// content.innerHTML swap: this whole full-page-load branch of
// mainpagetemplate.jet only ever renders once per real browser
// navigation, never again on a client-side SPA page change (the
// fragment branch further below renders none of this) - so this
// audio element and the playlist array it drives keep running
// uninterrupted across every subsequent in-app page click, exactly
// like the request asked for (as long as you do not leave the domain).
var __playlist = [];
var __currentIndex = -1;
var __isIdle = true;
var __playToken = 0;
// Turned on by clicking RANDOM while nothing is queued, turned back
// off by clicking the same button (now showing HALT) - while on, the
// queue auto-refills with another random pick instead of going idle
// or sitting empty whenever it runs out, rather than that one click
// only ever adding a single song.
var __autoRandomMode = false;
// Display-only - the real audio.src below still uses entry.file in
// full, extension included, since that is what the server actually
// needs to find the right file on disk.
function __stripExtension(filename) {
var dot = filename.lastIndexOf('.');
return dot > 0 ? filename.substring(0, dot) : filename;
}
function __playerLoad(entry) {
var audio = document.getElementById('globalaudio');
var title = document.getElementById('globalplayer-title-text');
document.getElementById('globalplayer-band').classList.add('globalplayer-open');
__setProgress(0);
document.getElementById('globalplayer-duration').textContent = '0:00';
var myToken = ++__playToken;
audio.src = entry.path + '/' + entry.file;
title.textContent = __stripExtension(entry.file);
audio.load();
audio.play().catch(function(err) {
// Same AbortError race already solved once for the old per-page
// player (see the history of main-music.subpage) - a later selection
// already owns recovery if it has since bumped __playToken.
if (myToken === __playToken) __playerAdvance();
});
}
function __goIdle() {
var audio = document.getElementById('globalaudio');
audio.pause();
__isIdle = true;
document.getElementById('globalplayer-band').classList.remove('globalplayer-open');
document.getElementById('globalplayer-title-text').textContent = 'Not Playing';
__setProgress(0);
document.getElementById('globalplayer-duration').textContent = '';
}
// The song-picker row stays marked (checkmark + flash) via addToPlaylist
// for as long as its entry is actually sitting in __playlist - this
// clears that mark once a song is no longer there, whether it finished
// naturally or was deleted via the remove button. Matches by data-path/
// data-file rather than building a CSS attribute-selector string, since
// real filenames can contain quotes/other characters that would need
// escaping to use safely in one.
function __unmarkSongRow(path, file) {
document.querySelectorAll('.music-song-row').forEach(function(row) {
if (row.dataset.path === path && row.dataset.file === file) {
row.classList.remove('song-queued');
row.classList.remove('song-queued-flash');
}
});
}
// Shared by __playerAdvance and __removeFromPlaylist - whichever path
// the queue became empty through, the same rule applies: auto-random
// mode refills it with another pick instead of actually going idle.
function __goIdleOrAutoFill() {
if (__autoRandomMode) {
__isIdle = true;
__playRandomSong();
} else {
__goIdle();
}
}
function __playerAdvance() {
var finished = __playlist[__currentIndex];
if (__currentIndex + 1 < __playlist.length) {
__currentIndex++;
__playerLoad(__playlist[__currentIndex]);
} else {
__goIdleOrAutoFill();
}
if (finished) __unmarkSongRow(finished.path, finished.file);
__renderQueue();
}
// Removing a not-yet-played entry just drops it. Removing the
// CURRENTLY playing one is treated like a skip: splice it out, then
// whatever was queued right behind it has shifted down into this same
// index, so loading __playlist[__currentIndex] again (unchanged value,
// now pointing at a different entry) picks it up - or goes idle if
// that was the last one left. A row for anything already played is
// never rendered in the dropdown in the first place (see __renderQueue
// - it only shows current-and-later), so there is no "delete history"
// case to handle here.
function __removeFromPlaylist(index) {
var removed = __playlist[index];
if (index === __currentIndex) {
__playlist.splice(index, 1);
if (index < __playlist.length) {
__playerLoad(__playlist[__currentIndex]);
} else {
__goIdleOrAutoFill();
}
} else if (index > __currentIndex) {
__playlist.splice(index, 1);
}
if (removed) __unmarkSongRow(removed.path, removed.file);
__renderQueue();
}
// Only ever called with indices from rows actually rendered in the
// dropdown, which (see __renderQueue's own comment) never include the
// currently-playing entry - so this only ever reorders the upcoming
// portion of the queue, never disturbs __currentIndex itself.
function __reorderPlaylist(fromIndex, toIndex) {
if (fromIndex === toIndex) return;
var item = __playlist.splice(fromIndex, 1)[0];
__playlist.splice(toIndex, 0, item);
__renderQueue();
}
function __setProgress(ratio) {
var pct = (Math.max(0, Math.min(1, ratio)) * 100) + '%';
document.getElementById('globalplayer-progress-fill').style.width = pct;
document.getElementById('globalplayer-progress-handle').style.left = pct;
}
function __updateTimeDisplay(current, total) {
document.getElementById('globalplayer-duration').textContent = __formatTime(current) + ' / ' + __formatTime(total);
}
// Shared with the music/jukebox subpages' own song-picker lists (not
// just the playlist dropdown) - a lightweight metadata-only probe so
// each row can show its own track length without needing to play it
// first.
// All duration probes (both this and addToPlaylist's own) funnel
// through one strictly-sequential queue - a song list can easily have
// 100+ rows, and firing a probe per row all at once was saturating the
// browser's per-origin connection limit (6 concurrent, in most
// browsers) with background metadata fetches. A real click to actually
// play something queues up behind whichever of those happened to grab
// a connection first, which is what made selecting a song "not work or
// take a long time" - processing one probe at a time, each starting
// only once the previous finishes, keeps the other 5 connection slots
// free for an actual user-initiated request at all times.
var __durationQueue = [];
var __durationQueueRunning = false;
function __queueDurationProbe(path, file, onReady) {
__durationQueue.push({path: path, file: file, onReady: onReady});
__runDurationQueue();
}
function __runDurationQueue() {
if (__durationQueueRunning || __durationQueue.length === 0) return;
__durationQueueRunning = true;
var item = __durationQueue.shift();
var probe = new Audio();
probe.preload = 'metadata';
function done() {
__durationQueueRunning = false;
__runDurationQueue();
}
probe.addEventListener('loadedmetadata', function() {
item.onReady(probe.duration);
done();
});
probe.addEventListener('error', done);
probe.src = item.path + '/' + item.file;
}
function __loadSongDuration(path, file, el) {
if (!el) return;
__queueDurationProbe(path, file, function(duration) {
el.textContent = __formatTime(duration);
});
}
function __formatTime(seconds) {
if (!seconds || isNaN(seconds) || !isFinite(seconds)) return '0:00';
seconds = Math.floor(seconds);
var h = Math.floor(seconds / 3600);
var m = Math.floor((seconds % 3600) / 60);
var s = seconds % 60;
var sStr = (s < 10 ? '0' : '') + s;
if (h > 0) {
var mStr = (m < 10 ? '0' : '') + m;
return h + ':' + mStr + ':' + sStr;
}
return m + ':' + sStr;
}
function __escapeHtml(s) {
return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
// Builds a music subpage's song list client-side from the fast JSON
// listing route (GET /assets/musiclist/{subfolder}), rather than having
// the server render one row per file via a directory-loop tag - that
// path was genuinely slow for these particular folders (~1200+ files
// each), since every literal HTML element inside a Jet loop body costs
// real, compounding interpreter overhead per iteration. The container
// appears instantly (empty) on navigation; this fills it in shortly
// after via one fetch, in small batches via requestAnimationFrame
// rather than one giant synchronous DOM write, so the list visibly
// populates rather than the page just sitting blank until everything
// is ready at once.
function __renderMusicFolder(containerId, subfolder, basePath) {
var container = document.getElementById(containerId);
if (!container) return;
fetch('/assets/musiclist/' + subfolder)
.then(function(r) { return r.json(); })
.then(function(data) {
var files = data.files || [];
var i = 0;
function appendBatch() {
var end = Math.min(i + 100, files.length);
for (; i < end; i++) {
var file = files[i];
var row = document.createElement('div');
row.className = 'music-song-row';
row.dataset.path = basePath;
row.dataset.file = file;
var nameSpan = document.createElement('span');
nameSpan.className = 'music-song-name';
nameSpan.textContent = __stripExtension(file);
var durSpan = document.createElement('span');
durSpan.className = 'music-song-duration';
row.appendChild(nameSpan);
row.appendChild(durSpan);
row.addEventListener('click', (function(rowEl, path, fname) {
return function() { addToPlaylist(rowEl, path, fname); };
})(row, basePath, file));
container.appendChild(row);
__loadSongDuration(basePath, file, durSpan);
}
if (i < files.length) requestAnimationFrame(appendBatch);
}
appendBatch();
})
.catch(function(err) {
container.textContent = 'Could not load the song list.';
});
}
function __playerSetVolume(val) {
document.getElementById('globalaudio').volume = val / 100;
}
// Only persists on change (slider release), not on every input event
// while dragging, so dragging does not fire a request per pixel moved.
function __playerPersistVolume(val) {
fetch(window.location.pathname, {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: 'PROCESS=setvolume&volume=' + encodeURIComponent(val)
});
}
// While idle (nothing playing, nothing queued) there is nothing for a
// playlist dropdown to show, so the same button instead offers to pick
// something at random - its label reflects whichever of those two
// things it would actually do right now, recomputed any time the open/
// closed state or __isIdle changes (see __renderQueue's own call to
// this).
function __updateQueueButtonLabel() {
var btn = document.getElementById('globalplayer-queue-toggle');
var queueOpen = document.getElementById('globalplayer-queue').classList.contains('globalplayer-queue-open');
if (queueOpen) {
btn.textContent = 'CLOSE';
} else if (__autoRandomMode) {
btn.textContent = 'HALT';
} else if (!__hasQueuedSongs()) {
btn.textContent = 'RANDOM';
} else {
btn.textContent = 'PLAYLIST';
}
document.getElementById('globalplayer-random-indicator').classList.toggle('globalplayer-random-indicator-visible', __autoRandomMode);
}
function __hasQueuedSongs() {
return !__isIdle && __currentIndex !== -1 && (__currentIndex + 1 < __playlist.length);
}
function __playerToggleQueue() {
// Already in auto-random mode - this button's only job right now is
// to turn it back off (does not stop whatever is currently playing,
// just stops it from auto-refilling once that finishes).
if (__autoRandomMode) {
__autoRandomMode = false;
__updateQueueButtonLabel();
return;
}
// Nothing queued (whether idle or something is already playing) -
// turn auto-random mode on and queue the first pick right away rather
// than making this a one-shot "add one song" click.
if (!__hasQueuedSongs()) {
__autoRandomMode = true;
__playRandomSong();
return;
}
document.getElementById('globalplayer-queue').classList.toggle('globalplayer-queue-open');
__updateQueueButtonLabel();
}
// Picks from whatever song-picker rows happen to be rendered on the
// CURRENT page (music/jukebox's own .music-song-row elements) - there
// is no server-side "list all songs" endpoint to fall back on, so this
// only has songs to choose from when the page you are actually on has
// some. Reuses addToPlaylist exactly as a real click would (same
// element, same path/file), so the row's own checkmark/flash feedback
// and the queue button's label both update exactly as they would for a
// manual click.
function __playRandomSong() {
var rows = document.querySelectorAll('.music-song-row');
if (rows.length === 0) return;
var row = rows[Math.floor(Math.random() * rows.length)];
addToPlaylist(row, row.dataset.path, row.dataset.file, true);
}
// Shows the current song as the first entry, followed by whatever is
// still queued up behind it - not a play history, just now-playing
// plus up-next, rebuilt every time the queue or current position changes.
// The currently-playing entry is deliberately left out of this list -
// it's already shown up in the LCD title/progress bar, so the dropdown
// now only ever shows what's queued up NEXT, not what's already
// playing.
// Session persistence - survives a real full-page navigation/reload
// the same way the volume slider's own session variable already does
// (see setvolume.proc), using one JSON blob (one session variable,
// one .proc) rather than several separate ones so the whole player
// state saves/restores atomically together.
// Runs once, at setup - reads the JSON a real full-page load embedded
// server-side (see the script#globalplayer-saved-state tag, rendered
// from the same session variable setplayerstate.proc writes) and picks
// playback back up from there. A plain text node's content needs none
// of the quote-escaping embedding this directly inside a JS string
// literal would have required, since real song filenames/paths can
// contain characters (quotes, etc.) that would otherwise have to be
// escaped correctly to avoid corrupting the surrounding script.
function __restoreSavedPlayerState() {
var stateEl = document.getElementById('globalplayer-saved-state');
if (!stateEl) return;
var raw = stateEl.textContent.trim();
if (!raw) return;
var saved;
try {
saved = JSON.parse(atob(raw));
} catch (e) {
return;
}
if (!saved || !saved.playlist || !saved.playlist.length) return;
__playlist = saved.playlist.map(function(p) { return {path: p.path, file: p.file, duration: null}; });
__currentIndex = Math.min(Math.max(0, saved.currentIndex || 0), __playlist.length - 1);
__isIdle = false;
__autoRandomMode = !!saved.autoRandomMode;
var entry = __playlist[__currentIndex];
var audio = document.getElementById('globalaudio');
document.getElementById('globalplayer-band').classList.add('globalplayer-open');
document.getElementById('globalplayer-title-text').textContent = __stripExtension(entry.file);
audio.src = entry.path + '/' + entry.file;
audio.load();
function onceReady() {
audio.removeEventListener('loadedmetadata', onceReady);
if (saved.position) audio.currentTime = saved.position;
if (saved.playing) {
// Browsers block unprompted autoplay without a real user gesture -
// if that happens, this just stays loaded and paused at the
// restored position instead of erroring, the same tolerance the
// normal play()-failure handling elsewhere already has.
audio.play().catch(function() {});
}
}
audio.addEventListener('loadedmetadata', onceReady);
}
function __buildPlayerState() {
var audio = document.getElementById('globalaudio');
return {
playlist: __playlist.map(function(p) { return {path: p.path, file: p.file}; }),
currentIndex: __currentIndex,
position: audio.currentTime || 0,
playing: !audio.paused,
autoRandomMode: __autoRandomMode
};
}
// base64-encoded before it ever reaches the server, not just plain
// JSON - the session store is itself JSON-backed (JFile), and a raw
// JSON string containing quote characters round-trips back out of
// the player-state session variable with its quotes re-escaped - the
// text node ends up holding broken, double-escaped JSON rather than
// the original. Base64 has no quote characters to collide with that
// escaping in the first place, so this sidesteps the whole problem
// rather than trying to out-guess exactly how many times to un-escape
// it.
function __persistPlayerState() {
fetch(window.location.pathname, {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: 'PROCESS=setplayerstate&state=' + encodeURIComponent(btoa(JSON.stringify(__buildPlayerState())))
});
}
function __renderQueue() {
var queue = document.getElementById('globalplayer-queue');
var html = '';
if (!__hasQueuedSongs()) {
// Nothing to show either way (idle, or playing with nothing queued
// behind it) - leave it empty and force it closed rather than
// displaying a placeholder message, matching __playerToggleQueue's
// own refusal to open it in this state.
queue.classList.remove('globalplayer-queue-open');
} else {
for (var i = __currentIndex + 1; i < __playlist.length; i++) {
var name = __escapeHtml(__stripExtension(__playlist[i].file));
var dur = (__playlist[i].duration != null) ? __formatTime(__playlist[i].duration) : '';
html += '<div class="globalplayer-queue-item" draggable="true" data-index="' + i + '">'
+ '<span class="globalplayer-queue-left">'
+ '<span class="globalplayer-queue-handle" title="Drag to reorder"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><path d="M4 7h16M4 12h16M4 17h16"/></svg></span>'
+ '<span class="globalplayer-queue-name">' + name + '</span>'
+ '</span>'
+ '<span class="globalplayer-queue-right">'
+ '<span class="globalplayer-queue-duration">' + dur + '</span>'
+ '<button type="button" class="globalplayer-queue-remove" title="Remove" onclick="__removeFromPlaylist(' + i + ');"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16"/><path d="M9 7V4h6v3"/><path d="M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"/><path d="M10 11v6M14 11v6"/></svg></button>'
+ '</span>'
+ '</div>';
}
}
queue.innerHTML = html;
__updateQueueButtonLabel();
__persistPlayerState();
}
function __playerTogglePause() {
if (__isIdle) return;
var audio = document.getElementById('globalaudio');
if (audio.paused) {
audio.play();
} else {
audio.pause();
}
}
// Distinct from pause: pause just halts playback in place with the
// band staying open (see __playerTogglePause/the pause listener's own
// comment) - stop clears the queue entirely and closes the band, a
// genuine "shut the player off" rather than a resumable pause.
function __playerStop() {
__playlist = [];
__currentIndex = -1;
__goIdle();
__renderQueue();
}
// Shared entry point every music/jukebox subpage calls on a song click -
// appends to the queue, and only starts playback immediately if the
// queue was otherwise idle (nothing already playing/queued).
// isAutoRandom is only ever true when __playRandomSong() itself is the
// caller (a manual click on a song-picker row never passes it) -
// picking a specific song yourself is a clear signal you want to take
// back manual control, so that turns auto-random mode back off rather
// than leaving the button stuck on HALT while a real, manually-chosen
// entry sits in the queue underneath it.
function addToPlaylist(el, path, file, isAutoRandom) {
if (!isAutoRandom) __autoRandomMode = false;
var entry = {path: path, file: file, duration: null};
__playlist.push(entry);
// The queue only ever stores path/file - duration is not otherwise
// known until something actually plays it, so a lightweight probe
// (metadata only, not the full file) fetches just enough to learn it
// for the playlist dropdown's own display - shares the same
// one-at-a-time queue the song-picker list's own probes use (see
// __queueDurationProbe's own comment for why that matters).
__queueDurationProbe(path, file, function(duration) {
entry.duration = duration;
__renderQueue();
});
if (__isIdle) {
__isIdle = false;
__currentIndex = __playlist.length - 1;
__playerLoad(__playlist[__currentIndex]);
}
__renderQueue();
if (el) {
el.classList.add('song-queued');
el.classList.remove('song-queued-flash');
// Force a reflow so re-adding the flash class restarts the animation
// even if this same row was already flashed once before.
void el.offsetWidth;
el.classList.add('song-queued-flash');
}
}
(function() {
var audio = document.getElementById('globalaudio');
var band = document.getElementById('globalplayer-band');
var playIcon = document.getElementById('globalplayer-playicon');
var pauseIcon = document.getElementById('globalplayer-pauseicon');
var eqCanvas = document.getElementById('globalplayer-eq');
var progressBar = document.getElementById('globalplayer-progress');
// Delegated on the queue container itself rather than attached per-row,
// since __renderQueue() rebuilds every row's markup via innerHTML on
// every change - listeners bound directly to a row would be destroyed
// and need re-attaching on every single re-render. The container
// element itself is never replaced, only its children, so binding here
// once at setup survives any number of re-renders.
var queueEl = document.getElementById('globalplayer-queue');
var __dragSrcIndex = null;
queueEl.addEventListener('dragstart', function(e) {
var row = e.target.closest('.globalplayer-queue-item');
if (!row || row.dataset.index === undefined) return;
__dragSrcIndex = parseInt(row.dataset.index, 10);
e.dataTransfer.effectAllowed = 'move';
row.classList.add('globalplayer-queue-dragging');
});
queueEl.addEventListener('dragover', function(e) {
var row = e.target.closest('.globalplayer-queue-item');
if (!row || row.dataset.index === undefined) return;
e.preventDefault();
queueEl.querySelectorAll('.globalplayer-queue-dragover').forEach(function(el) {
el.classList.remove('globalplayer-queue-dragover');
});
row.classList.add('globalplayer-queue-dragover');
});
queueEl.addEventListener('dragleave', function(e) {
var row = e.target.closest('.globalplayer-queue-item');
if (row) row.classList.remove('globalplayer-queue-dragover');
});
queueEl.addEventListener('drop', function(e) {
var row = e.target.closest('.globalplayer-queue-item');
e.preventDefault();
if (row && row.dataset.index !== undefined && __dragSrcIndex !== null) {
__reorderPlaylist(__dragSrcIndex, parseInt(row.dataset.index, 10));
}
__dragSrcIndex = null;
});
queueEl.addEventListener('dragend', function() {
queueEl.querySelectorAll('.globalplayer-queue-dragging, .globalplayer-queue-dragover').forEach(function(el) {
el.classList.remove('globalplayer-queue-dragging', 'globalplayer-queue-dragover');
});
__dragSrcIndex = null;
});
// Click-or-drag seeking: setPointerCapture means every subsequent
// move/up for this same pointer keeps routing here even once the
// cursor leaves the bar's own bounds while still held down - the
// standard way a scrubber stays grabbed mid-drag rather than losing
// the gesture the moment the mouse strays off the (thin, 8px) bar.
function seekFromEvent(e) {
if (!audio.duration || isNaN(audio.duration)) return;
var rect = progressBar.getBoundingClientRect();
var ratio = (e.clientX - rect.left) / rect.width;
ratio = Math.max(0, Math.min(1, ratio));
audio.currentTime = ratio * audio.duration;
__setProgress(ratio);
__updateTimeDisplay(audio.currentTime, audio.duration);
}
progressBar.addEventListener('pointerdown', function(e) {
progressBar.classList.add('globalplayer-progress-dragging');
progressBar.setPointerCapture(e.pointerId);
seekFromEvent(e);
});
progressBar.addEventListener('pointermove', function(e) {
if (progressBar.classList.contains('globalplayer-progress-dragging'))
seekFromEvent(e);
});
progressBar.addEventListener('pointerup', function(e) {
progressBar.classList.remove('globalplayer-progress-dragging');
progressBar.releasePointerCapture(e.pointerId);
});
var eqCtx = eqCanvas.getContext('2d');
audio.volume = document.getElementById('globalplayer-volume').value / 100;
audio.addEventListener('ended', function() { __playerAdvance(); });
audio.addEventListener('loadedmetadata', function() {
__updateTimeDisplay(audio.currentTime, audio.duration);
});
var __lastPersistTime = 0;
audio.addEventListener('timeupdate', function() {
if (!progressBar.classList.contains('globalplayer-progress-dragging') && audio.duration && !isNaN(audio.duration)) {
__setProgress(audio.currentTime / audio.duration);
__updateTimeDisplay(audio.currentTime, audio.duration);
}
// Position alone is not worth persisting on every tick (several
// times a second) - throttled here rather than through
// __renderQueue(), which only runs on actual playlist/track changes,
// not on ordinary mid-song progress.
var now = Date.now();
if (now - __lastPersistTime > 5000) {
__lastPersistTime = now;
__persistPlayerState();
}
});
// Stereo FFT-style bar graph in the band itself. Web Audio requires a
// real user gesture before an AudioContext will actually run, which a
// play event always is - built lazily here, once, on the first real
// play rather than up front at page load. A ChannelSplitter feeds one
// AnalyserNode per channel so left and right are genuinely independent
// readings, not the same mono data mirrored twice.
var audioCtx = null, leftAnalyser = null, rightAnalyser = null;
function setupAudioAnalysis() {
if (audioCtx) return;
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var source = audioCtx.createMediaElementSource(audio);
var splitter = audioCtx.createChannelSplitter(2);
leftAnalyser = audioCtx.createAnalyser();
rightAnalyser = audioCtx.createAnalyser();
leftAnalyser.fftSize = 128;
rightAnalyser.fftSize = 128;
leftAnalyser.smoothingTimeConstant = 0.7;
rightAnalyser.smoothingTimeConstant = 0.7;
// createMediaElementSource() reroutes the audio element's own output
// through the Web Audio graph exclusively - it no longer reaches
// speakers on its own past this point, so this connection to
// destination is what keeps playback audible, not optional wiring.
source.connect(audioCtx.destination);
source.connect(splitter);
splitter.connect(leftAnalyser, 0);
splitter.connect(rightAnalyser, 1);
requestAnimationFrame(drawEQ);
}
// Picks bars on a log scale rather than evenly across the raw bin
// range - real music concentrates nearly all of its energy in the
// first few linearly-indexed bins, so evenly-spaced bins beyond those
// read as flat/empty and the whole graph reads as one solid block
// instead of a varied spectrum. Spacing bar selection logarithmically
// (the same way a real hardware equalizer's bands are laid out) picks
// bins that are far enough apart in the actual data to show real
// variation bar to bar.
function logBin(i, count, bufferLength) {
var t = (i + 1) / count;
return Math.max(0, Math.min(bufferLength - 1, Math.floor(Math.pow(bufferLength, t)) - 1));
}
function drawEQ() {
requestAnimationFrame(drawEQ);
var w = eqCanvas.width, h = eqCanvas.height;
eqCtx.clearRect(0, 0, w, h);
if (!leftAnalyser || !rightAnalyser || audio.paused) return;
var bufferLength = leftAnalyser.frequencyBinCount;
var leftData = new Uint8Array(bufferLength);
var rightData = new Uint8Array(bufferLength);
leftAnalyser.getByteFrequencyData(leftData);
rightAnalyser.getByteFrequencyData(rightData);
// Two separate bar groups, left channel and right channel, each
// rising from the bottom with a visible gap between bars and between
// the two groups - reads as two independent stereo meters rather
// than one shape mirrored around a center line.
var barsPerChannel = 5;
var gap = 2;
var channelWidth = (w - gap) / 2;
var barWidth = (channelWidth - gap * (barsPerChannel - 1)) / barsPerChannel;
eqCtx.fillStyle = '#1a8fc4';
for (var i = 0; i < barsPerChannel; i++) {
var bin = logBin(i, barsPerChannel, bufferLength);
var barH = Math.max(2, (leftData[bin] / 255) * h);
eqCtx.fillRect(i * (barWidth + gap), h - barH, barWidth, barH);
}
for (var i = 0; i < barsPerChannel; i++) {
var bin = logBin(i, barsPerChannel, bufferLength);
var barH = Math.max(2, (rightData[bin] / 255) * h);
eqCtx.fillRect(channelWidth + gap * 2 + i * (barWidth + gap), h - barH, barWidth, barH);
}
}
audio.addEventListener('play', function() {
playIcon.style.display = 'none';
pauseIcon.style.display = '';
if (!audioCtx) setupAudioAnalysis();
else if (audioCtx.state === 'suspended') audioCtx.resume();
__persistPlayerState();
});
audio.addEventListener('pause', function() {
// Deliberately does NOT close the band - that is tied to __isIdle
// (see __playerLoad/__goIdle) rather than the raw play/pause events,
// so pausing just shows the paused icon with the band, LCD, and
// scrubber all staying visible. It used to close here, which made a
// plain pause look like the whole player had reset.
playIcon.style.display = '';
pauseIcon.style.display = 'none';
__persistPlayerState();
});
// A regular fetch() made this late in a page's life is not reliably
// delivered by the browser - sendBeacon exists specifically to still
// get a small POST out as the page is actually going away, so a
// reload/tab-close/navigation right after a timeupdate tick does not
// lose up to 5 seconds of position progress.
window.addEventListener('pagehide', function() {
var body = 'PROCESS=setplayerstate&state=' + encodeURIComponent(btoa(JSON.stringify(__buildPlayerState())));
navigator.sendBeacon(window.location.pathname, new Blob([body], {type: 'application/x-www-form-urlencoded'}));
});
__restoreSavedPlayerState();
__renderQueue();
})();
</script>
<div class="menubar" id="menubar">
<include file="menu.bar">
</div>
@@ -115,6 +855,7 @@ $[_BODY]
<div style="clear: both;"></div>
</div>
</div>
<div id="spa-loading-indicator" class="spa-loading-indicator">Retrieving content...</div>
<div class="footer" style="clear: both;">&copy; 1999-2026 BARANT Systems, All Rights Reserved</div>
</div>
</form>
@@ -131,7 +872,7 @@ $[_BODY]
<div id="filemgr-list"><div id="filemgr-empty">No transfers yet.</div></div>
</div>
</div>
<script src="/assets/spa.js?v=20260906a"></script>
<script src="/assets/spa.js?v=20261006"></script>
<script src="/assets/documents.js?v=20260906a"></script>
</body>
</html>
+1 -1
View File
@@ -52,7 +52,7 @@ Payment already processed.
</sql>
<sql>select last_insert_id() as invoice_id</sql>
<set name="invoice_id" value="$[.invoice_id]">
<setenv name="_invoice_id">$[invoice_id]</setenv>
<set name="_invoice_id" value="$[invoice_id]"><set name="_invoice_id" value="$[invoice_id]" scope="session">
<call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.status" input="$[payment]" name="card_charged">
<call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.card_details.card.card_brand" input="$[payment]" name="card_brand">
<call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.card_details.card.last_4" input="$[payment]" name="last_4_digits">
+7 -8
View File
@@ -9,10 +9,7 @@
<td style="border-bottom: 1pt solid #bbb; width: 20px;">&nbsp;</td>
<tab page="main"><a href="/main">HOME</a></tab>
<tab page="services"><a href="/services">SERVICES</a></tab>
<tab page="hosting"><a href="/hosting">HOSTING</a></tab>
<tab page="store"><a href="/store/createstore">CREATE STORE</a></tab>
<tab page="documents"><a href="/documents">DOCUMENT MGMT</a></tab>
<tab page="siptrunk"><a href="/siptrunk">SIP TRUNKING</a></tab>
<tab page="vst"><a href="/vst">VST</a></tab>
<tab page="wordpress"><a href="/wordpress">WORDPRESS</a></tab>
<tab page="opensource"><a href="/opensource">OPEN SOURCE</a></tab>
@@ -21,16 +18,18 @@
<sql>select count(*) as count from cart_item where session_uuid='$[_session_id]'</sql>
<ifrow>
<if expr="$[.count] > 0">
<tab page="cart"><a href="/cart">CART</a></tab>
<tab page="cart"><a href="/cart">CART</a></tab>
</if>
</ifrow>
</if>
<if value1="$[_login_id]" value2="" type="ne">
<tab page="account"><a href="/account">ACCOUNT</a></tab>
<tab page="admin"><a href="/admin">ADMIN</a></tab>
<tab page="account"><a href="/account">ACCOUNT</a></tab>
<if value1="$[_login_type]" value2="admin" type="eq">
<tab page="admin"><a href="/admin">ADMIN</a></tab>
</if>
<else>
<tab page="login"><a href="/login">LOGIN</a></tab>
<tab page="login"><a href="/login">LOGIN</a></tab>
</if>
<td style="border-bottom: 1pt solid #bbb; width: 10px;">&nbsp;</td>
<td style="border-bottom: 1pt solid #bbb; width: 10px;">&nbsp;</td>
</tr>
</table>
+3 -3
View File
@@ -3,8 +3,8 @@
<contents>
<script>
var index = 0;
const paths = [];
const songs = [];
var paths = [];
var songs = [];
function onselection(id) {
var name = '/get_modular_sample.cgi?id=' + id;
var player = document.getElementById('player');
@@ -16,7 +16,7 @@
audio.play();
}
</script>
<setenv name="_menubar"></setenv>
<set name="_menubar" value=""><set name="_menubar" value="" scope="session">
<sectionframe title="Modular1 Patches">
<div style="width: 48%;">
-47
View File
@@ -1,47 +0,0 @@
<page secure="yes" loggedin="no">
<title>BAE MUSIC</title>
<contents>
<script>
var index = 0;
const paths = [];
const songs = [];
function onselection(path,selection) {
var name = path + '/' + selection;
var player = document.getElementById('player');
var audio = document.getElementById('audio');
var title = document.getElementById('title');
player.src = name;
title.textContent = selection;
audio.load();
audio.play();
}
function selectNext() {
var index = Math.floor(Math.random()*songs.length) + 1;
onselection(paths[index],songs[index]);
}
</script>
<retain name="download_file">
<div style="display: inline-block;">
<audio id="audio" controls onended="selectNext();">
<source id="player" type="audio/mp3">
</audio>
</div>
<div style="font-size: 20px; display: inline-block;" id="title">Click on a title below</div>
<sectionframe title="BARANT Audio Experiments">
<div>
<whiledir name="file" dir="musiclink/bae">
<if expr="left('$[file]',1) != '.' ">
<div style="cursor: pointer;" onclick="onselection('musiclink/bae','$[file]');">$[file]</div>
<script>
paths[index]='musiclink/bae';
songs[index++]='$[file]';
</script>
</if>
</whiledir>
</div>
<script>
</script>
</sectionframe>
</contents>
</page>
@@ -0,0 +1,4 @@
<sectionframe title="Git Repository">
<iframe src="https://git.barant.com" style="width:100%; height:80vh; border:1px solid var(--bond-line-soft); border-radius:3px; background:var(--bond-panel);"></iframe>
</sectionframe>
+35 -6
View File
@@ -1,8 +1,37 @@
<sectionframe title="OPEN SOURCE PROJECTS">
<linkbutton page="opensource">OVERVIEW</linkbutton><br>
<linkbutton page="opensource" subpage="barantmail">BARANTMAIL</linkbutton><br>
<linkbutton page="opensource" subpage="jet">JET</linkbutton><br>
<linkbutton page="opensource" subpage="synthmax">SYNTHMAX</linkbutton><br>
<linkbutton page="opensource" subpage="serverframework">SERVER CORE FRAMEWORK</linkbutton>
<linkbutton page="opensource" subpage="asm1802">ASM/MCH 1802 SIMULATOR</linkbutton><br>
<if value1="$[SUBPAGE]" value2="" type="eq">
<linkbutton page="opensource" class="submenuitem-active">OVERVIEW</linkbutton><br>
<else>
<linkbutton page="opensource">OVERVIEW</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="barantmail" type="eq">
<linkbutton page="opensource" subpage="barantmail" class="submenuitem-active">BARANTMAIL</linkbutton><br>
<else>
<linkbutton page="opensource" subpage="barantmail">BARANTMAIL</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="jet" type="eq">
<linkbutton page="opensource" subpage="jet" class="submenuitem-active">JET</linkbutton><br>
<else>
<linkbutton page="opensource" subpage="jet">JET</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="synthmax" type="eq">
<linkbutton page="opensource" subpage="synthmax" class="submenuitem-active">SYNTHMAX</linkbutton><br>
<else>
<linkbutton page="opensource" subpage="synthmax">SYNTHMAX</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="serverframework" type="eq">
<linkbutton page="opensource" subpage="serverframework" class="submenuitem-active">SERVER CORE FRAMEWORK</linkbutton>
<else>
<linkbutton page="opensource" subpage="serverframework">SERVER CORE FRAMEWORK</linkbutton>
</if>
<if value1="$[SUBPAGE]" value2="asm1802" type="eq">
<linkbutton page="opensource" subpage="asm1802" class="submenuitem-active">ASM/MCH 1802 SIMULATOR</linkbutton><br>
<else>
<linkbutton page="opensource" subpage="asm1802">ASM/MCH 1802 SIMULATOR</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="git" type="eq">
<linkbutton page="opensource" subpage="git" class="submenuitem-active">GIT REPOSITORY</linkbutton><br>
<else>
<linkbutton page="opensource" subpage="git">GIT REPOSITORY</linkbutton><br>
</if>
</sectionframe>
+10 -5
View File
@@ -1,7 +1,7 @@
<page secure="yes" loggedin="yes">
<title>PAY INVOICE</title>
<script src="https://sandbox.web.squarecdn.com/v1/square.js></script>
<contents>
<script src="https://sandbox.web.squarecdn.com/v1/square.js"></script>
<sectionframe title="Pay Invoice">
<entryform>
<sql>select * from invoices where id=$[_invoice_id]</sql>
@@ -10,8 +10,8 @@
<formdata prompt="Date:" data="$[created]">
<formdata prompt="Amount Due:" data="$[amount]">
<script>
const appId = 'sandbox-sq0idb-GGY04gvAQJAmneJHgn_p8Q';
const locationId = 'LEMFWBZPEE9ST';
var appId = 'sandbox-sq0idb-GGY04gvAQJAmneJHgn_p8Q';
var locationId = 'LEMFWBZPEE9ST';
async function initializeCard(payments) {
const card = await payments.card();
@@ -74,7 +74,7 @@
statusContainer.style.visibility = 'visible';
}
document.addEventListener('DOMContentLoaded', async function () {
async function initPayInvoice() {
if (!window.Square) {
throw new Error('Square.js failed to load properly');
}
@@ -122,7 +122,12 @@
cardButton.addEventListener('click', async function (event) {
await handlePaymentMethodSubmission(event, card);
});
});
}
if (document.readyState === 'loading')
document.addEventListener('DOMContentLoaded', initPayInvoice);
else
initPayInvoice();
</script>
<div id="card-container"></div>
+35 -15
View File
@@ -1,5 +1,5 @@
<script src="https://web.squarecdn.com/v1/square.js"></script>
<script>
<script>
function processCardForm(token) {
xhr = new XMLHttpRequest();
xhr.open('POST', '/pi.cgi', true);
@@ -8,40 +8,60 @@
console.log(">" + this.responseText + "<");
if(this.responseText == "OK\n") {
document.forms[0].PAGE.value = 'thankyou';
document.forms[0].submit();
} else {
message.innerText = this.responseText;
document.forms[0].requestSubmit();
} else {
var payBtn = document.getElementById('pay');
payBtn.disabled = false;
var processbanner = document.getElementById('process');
processbanner.style.visibility = 'hidden';
message.innerText = this.responseText;
}
};
let data = 'id=$[_session_id]&token=' + token + '&tranonce=$[tranonce]';
xhr.send(data);
xhr.send(data);
}
var card;
async function buildForm() {
// let payments = Square.payments('sandbox-sq0idb-GGY04gvAQJAmneJHgn_p8Q','LEMFWBZPEE9ST');
let payments = Square.payments('sq0idp-V4R4vEferpF9kr7d5x5abQ','LV0MRENX5ED3Z');
const card = await payments.card({
style: {
'.input-container.is-focus': { borderColor: '#006AFF' },
'.message-text.is-error': { color: '#BF0020' }
input: {
backgroundColor: '#1c1c24',
color: '#e7e4dc',
fontSize: '14px'
},
'input::placeholder': { color: '#8d8c92' },
'.input-container': { borderColor: 'rgba(197, 164, 90, 0.28)' },
'.input-container.is-focus': { borderColor: '#c5a45a' },
'.input-container.is-error': { borderColor: '#a13a3a' },
'.message-text': { color: '#8d8c92' },
'.message-text.is-error': { color: '#a13a3a' }
}
});
await card.attach('#card');
let button = document.getElementById('pay');
button.addEventListener('click', async () => {
message.innerText = '';
let result = await card.tokenize();
if (result.status === 'OK') {
button.disabled = true;
let processbanner = document.getElementById('process');
processbanner.style.visibility = 'visible';
processCardForm(result.token);
} else {
let errorMessage = 'Please check your card details and try again.';
if (result.errors && result.errors.length && result.errors[0].message)
errorMessage = result.errors[0].message;
message.innerText = errorMessage;
}
});
}
buildForm();
buildForm();
</script>
<div>Please enter your payment information:</div>
<div id="card" style="background-color: #ddd;width: 300px; padding: 5px;"></div>
<div style="padding: 5px;"><button id= "pay" type="button">Pay</button></div>
<div id="process" style="background-color: #0f0; border: 2px solid #000; padding:
5px; display: block-inline; margin: 10px; visibility: hidden;"> Processing Payment - Please wait... </div>
<div id="message" style="color: #f00; margin-top: 20px;"></div>
<div class="checkout-pay-wrap">
<div class="checkout-pay-label">Card Details</div>
<div id="card" class="checkout-card-input"></div>
<button id="pay" type="button" class="button checkout-pay-btn">Pay $$[amount]</button>
<div id="process" class="checkout-processing">Processing Payment &mdash; Please wait&hellip;</div>
<div id="message" class="checkout-error"></div>
</div>
+5 -2
View File
@@ -1,3 +1,5 @@
<sql>select extensions.id as 'X', extensions.exten as 'Phone Number' from phones.extensions where extensions.user_id=$[@_login_id]</sql>
<ifrow>
<sectionframe title="Phones">
<button>
@@ -7,7 +9,8 @@
<showtable page="request" process="selectrequest" name="request_id" value="X">
select extensions.id as 'X',
extensions.exten as 'Phone Number'
from phones.extensions
from phones.extensions where extensions.user_id=$[@_login_id]
</showtable>
</sectionframe>
</sectionframe>
</ifrow>
+1 -1
View File
@@ -3,7 +3,7 @@
<title>PROJECT MANAGER</title>
<contents>
<retain name="project_id">
<setenv name="_menubar">projman.bar</setenv>
<set name="_menubar" value="projman.bar"><set name="_menubar" value="projman.bar" scope="session">
<sectionframe title="Project Manager">
<p>An advanced project management methodology not unlike Agile but
with a better definition towards software development and the release
+1 -1
View File
@@ -1,3 +1,3 @@
<process>
<setenv name="_invoice_id">$[invoice_id]</setenv>
<set name="@_invoice_id" value="$[invoice_id]">
</process>
+1 -1
View File
@@ -1,3 +1,3 @@
<process>
<setenv name="_product_sku">$[sku]</setenv>
<set name="_product_sku" value="$[sku]"><set name="_product_sku" value="$[sku]" scope="session">
</process>
+3 -3
View File
@@ -6,7 +6,7 @@
join users on projects.owner_id=users.id
where projects.id=$[project_id]
</sql>$[sqlerror]
<setenv name="_project_id">$[project_id]</setenv>
<setenv name="_project_title">$[projman.text]</setenv>
<setenv name="_menubar">projman.bar</setenv>
<set name="_project_id" value="$[project_id]"><set name="_project_id" value="$[project_id]" scope="session">
<set name="_project_title" value="$[projman.text]"><set name="_project_title" value="$[projman.text]" scope="session">
<set name="_menubar" value="projman.bar"><set name="_menubar" value="projman.bar" scope="session">
</process>
+1 -1
View File
@@ -1,3 +1,3 @@
<process>
<setenv name="_request_id">$[request_id]</setenv>
<set name="_request_id" value="$[request_id]"><set name="_request_id" value="$[request_id]" scope="session">
</process>
+4 -4
View File
@@ -9,8 +9,8 @@
join projects on requests.project_id=projects.id
where tasks.id=$[task_id]
</sql>
<setenv name="_task_id">$[task_id]</setenv>
<setenv name="_request_id">$[projman.request_id]</setenv>
<setenv name="_project_id">$[projman.project_id]</setenv>
<setenv name="_project_title">$[projman.title]</setenv>
<set name="_task_id" value="$[task_id]"><set name="_task_id" value="$[task_id]" scope="session">
<set name="_request_id" value="$[projman.request_id]"><set name="_request_id" value="$[projman.request_id]" scope="session">
<set name="_project_id" value="$[projman.project_id]"><set name="_project_id" value="$[projman.project_id]" scope="session">
<set name="_project_title" value="$[projman.title]"><set name="_project_title" value="$[projman.title]" scope="session">
</process>
@@ -0,0 +1,27 @@
<set name="_send_invoice_id" value="$[invoice_id]">
<if value1="$[_send_invoice_id]" value2="" type="eq">
<set name="_send_invoice_id" value="$[@_invoice_id]">
</if>
<sql>select u.email as email, u.name as name from invoices i join users u on i.user_id=u.id where i.id=$[_send_invoice_id]</sql>
<ifrow>
<set name="_invoice_email_to" value="$[.email]">
<if value1="$[_invoice_email_override]" value2="" type="ne">
<set name="_invoice_email_to" value="$[_invoice_email_override]">
</if>
<set name="_invoice_id" value="$[_send_invoice_id]">
<eval name="_invoice_html">
<include file="invoice.method">
</eval>
<eval name="_invoice_email_body">
<html>
<head></head>
<body style="margin: 0; padding: 30px 10px; background: #0a0a0d; font-family: Arial, Helvetica, sans-serif;">
$[_invoice_html]
<p style="text-align: center; color: #8d8c92; font-size: 11px; margin-top: 20px;">BARANT Technology Group</p>
</body>
</html>
</eval>
<eval name="_invoice_smtpsend_discard">
<smtpsend config="./email.cfg" user="noreply@barant.com" password="NgCe0RolitzgBKVHz2HKfnTd" to="$[_invoice_email_to]" subject="Your BARANT Technology Group Invoice #$[_send_invoice_id]" html="$[_invoice_email_body]">
</eval>
</ifrow>
@@ -0,0 +1,44 @@
<page>
<title>Server Core Framework</title>
<contents>
<sectionframe title="Server Core Framework">
<p>It is finally here! The Server Core Framework is now available. The
framework offers support for just about any server you can devise.</p>
<p>Now why would I want to go and build a server when there are all
sorts of frameworks out there for supporting server activity? All I
can say is top notch performance. The Server Core is all C++ and is
built on the epoll structure of the Linux operating system.</p>
<ul>
<li>TCP and/or UDP server capabilities.</li>
<li>Straight socket or TLS connections.</li>
</ul>
<p>Using the Server Core you can build out server elements for
embedded systems or massively publicly accessible servers with simple
code. Use the Server Core for:</p>
<ul>
<li>Micro-services engine for code generators.</li>
<li>Game servers of all types.</li>
<li>E-Mail services (checkout barantmail project).</li>
<li>SIP telephony server.</li>
<li>HTTP/HTTPS for embedded web sites.</li>
<li>Streaming server for online radio stations.</li>
<li>Any other TCP or UDP based server.</li>
</ul>
<p>For the game server we will be offering client modules for both
Unty 3D and for the Unreal Engine 4 with drop in and play options that
can be heavily modified to support unique game features. Offers
support for mySQL backends.</p>
<img src="/assets/ServerCoreMap.png" width="80%">
<br>
<code>
git clone https://barant.com/git@ServerCore.git
</code>
</sectionframe>
</contents>
</page>
@@ -1,5 +1,3 @@
<page>
<title>Document Management</title>
<style>
.price {display: table-cell;
background-color: #fff;
@@ -32,7 +30,6 @@
#documents-list td a:hover, #documents-list td .documents-action:hover { text-decoration: underline; }
#documents-empty { color: var(--bond-text-dim); padding: 10px 0; }
</style>
<contents>
<sectionframe title="Document Management">
<h1>Online Document Management</h1>
<p>BARANT Technology Group now offers document management storage and
@@ -52,5 +49,3 @@ documents for any activity with that account.</p>
</sectionframe>
<script src="/assets/documents-page.js?v=20260906a"></script>
</if>
</contents>
</page>
@@ -1,6 +1,3 @@
<page>
<title>HOSTING</title>
<contents>
<retain name="sku">
<sectionframe title="Virtual Machine Hosting">
@@ -17,7 +14,7 @@ redundancy and fire protection.</p>
<hr>
<h2>Ubuntu 24.04 Host</h2>
<p>Full Ubuntu 24.04 host with memory, CPU and storage size pricing
tiers. Both monthly and annual rates available.</p>
tiers. Both monthly and annual rates available.</p>
<p>All our servers use SSD for high performance.</p>
<table border="1">
<tr>
@@ -56,10 +53,8 @@ bandwidth and 50GB storage for voice-mail and recordings. Full root
access. Full service support contacts available to maintain your
phones and other VoIP devices. </p>
<p>$49.95/month</p>
<p>See our SIP trunking pricing and DID line options as well for a complete
<p>See our <linkbutton page="services" subpage="siptrunking">SIP trunking pricing</linkbutton> and DID line options as well for a complete
telephony solution.</p>
<hr>
</sectionframe>
<set name="pagemenu" value="davidarant">
</contents>
</page>
@@ -0,0 +1,45 @@
<sectionframe title="Welcome to BARANT Systems">
<div style="width: 48%;">
<p>We are BARANT Technology Group. Contact us for information on how we can
help you with your technical objectives.</p>
<h1>Our Services</h1>
<ul>
<li>Software architecture and development on many platforms.
<ul>
<li>40+ years on IBM System/3x, AS/400, i Series and IBM i platform.</li>
<li>20+ years .NET Web and Winform application development.</li>
<li>10+ Android mobile development.</li>
</ul>
</li><br>
<li>Database architecture and development on many platforms.
<ul>
<li>DB2/400</li>
<li>Oracle</li>
<li>MySQL</li>
<li>PostgreSQL</li>
<li>MSSQL</li>
<li>Amazon Aurora</li>
<li>Amazon DynamoDB</li>
<li>MongoDB</li>
</ul>
</li><br>
<li>Telephony and Call Center Solutions
<ul>
<li>25+ years in call center development and application integration.</li>
<li>15+ years on open source FreePBX development and maintenance.</li>
<li>10+ as <linkbutton page="services" subpage="siptrunking">SIP trunk provider</linkbutton> offering very competitive rates.</li>
</ul>
</li><br>
<li>Audio Engineering products and projects
<ul>
<li>Product offering for VST synthesizers for modular analog simulation.</li>
<li>Module development for super clean digitally pure wave harmonics.</li>
</ul>
</li>
</ul>
</div>
</sectionframe>
@@ -1,10 +1,8 @@
<page>
<title>SIP Trunking</title>
<style>
.price {display: table-cell;
background-color: #fff;
background-color: #fff;
width: 100px;
height: 100px;
height: 100px;
text-align: center;
vertical-align: middle;
border: 1px solid #000;
@@ -12,7 +10,6 @@
}
.number {font-size: 30px;}
</style>
<contents>
<sectionframe title="SIP Trunking">
<h1>For PBX Systems</h1>
<p>Some of the best prices around for adding trunks to your PBX. We
@@ -40,11 +37,9 @@ use these devices on our networks.</p>
If your organization does not have or need a PBX but wish to have a
phone for 1 or 2 lines then you can just ask for our individual phone
service for any VoIP phone or VoIP converter for any old standard
phone line. Please contact us for more information.
phone line. Please contact us for more information.
<h1>Don't have a PBX but want one?</h1>
We can also host a PBX for you as well. Complete functionality
utilizing FreePBX can be provided on the internet so you do not need
to worry about the hardware. We manage and maintain everything for you.
</sectionframe>
</contents>
</page>
+22
View File
@@ -0,0 +1,22 @@
<sectionframe title="SERVICES">
<if value1="$[SUBPAGE]" value2="" type="eq">
<linkbutton page="services" class="submenuitem-active">OVERVIEW</linkbutton><br>
<else>
<linkbutton page="services">OVERVIEW</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="hosting" type="eq">
<linkbutton page="services" subpage="hosting" class="submenuitem-active">HOSTING</linkbutton><br>
<else>
<linkbutton page="services" subpage="hosting">HOSTING</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="siptrunking" type="eq">
<linkbutton page="services" subpage="siptrunking" class="submenuitem-active">SIP TRUNKING</linkbutton><br>
<else>
<linkbutton page="services" subpage="siptrunking">SIP TRUNKING</linkbutton><br>
</if>
<if value1="$[SUBPAGE]" value2="documents" type="eq">
<linkbutton page="services" subpage="documents" class="submenuitem-active">DOCUMENTS</linkbutton><br>
<else>
<linkbutton page="services" subpage="documents">DOCUMENTS</linkbutton><br>
</if>
</sectionframe>
Loaded 100 of 473 files, more files were not shown because too many files have changed in this diff. Show more