Warning: session_start(): open(/var/lib/php/sessions/sess_ou0a86ejch0uh8t9e9v2hud89o, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
concept Page { S url; }
concept Entry { new Ref page; int count; S key, value; S ip; }
static int lines;
p {
dbIndexingCI(Page, 'url);
lines = countLines(mySource());
}
set flag NoNanoHTTPD. html {
S url = domain() + dropTrailingSlash(uri);
Page page, bool newPage = unpair uniqCI2_sync(Page, +url);
S top = p(hsnippetimg(#1101682, width := 565/5, height := 800/5,
title := "Robot by Peerro @ DeviantArt"))
+ p(small(b(ahref("http://www.agi.blue", "agi.blue"))
+ " | " + targetBlank(progLink(), "source code") + " of this web site (" + nLines(lines) + ")"));
if (eqicOneOf(url, "agi.blue", "www.agi.blue"))
ret hhtml(hhead_title("agi.blue Overview")
+ hbody_fullcenter(top + h1("agi.blue Overview")
+ ul(map(func(S _url) -> S {
ahref("http://" + _url, htmlEncode2(_url))
}, collect url(list(Page))))
));
S key = trim(params.get('key)), value = trim(params.get('value));
L entries = withDBLock(func -> L {
L entries = findBackRefs(page, Entry);
print("Entries: " + l(entries));
if (nempty(key) && nempty(value)) {
S ip = subBot_clientIP();
if (!hasWhereIC(entries, +key, +value, +ip)) {
print("SAVING");
entries.add(cnew Entry(+page, +key, +value, +ip, count := l(entries) + 1));
}
}
ret entries;
});
sortByFieldInPlace created(entries);
numberEntriesInConceptField count(entries);
S get = params.get('get);
if (nempty(get)) {
Entry e = firstWhereIC(entries, key := get);
ret serveText(jsonEncode(collect value(llNotNulls(e))));
}
// input reset
S key2 = key, value2 = value;
if (nempty(key) && nempty(value)) key2 = value2 = "";
new Set hide;
if (!eq(params.get('withHidden), "1")) for (Entry e : entries) if (eqic(e.key, 'hide) && isSquareBracketedInt(e.value)) addAll(hide, e.count, parseInt(unSquareBracket(e.value)));
new MultiMap mmMeta;
for (Entry e : entries) if (isSquareBracketedInt(e.key)) mmMeta.put(parseInt(unSquareBracket(e.key)), e.value);
new MultiMap mm;
for (Entry e : entries) mm.put(e.key, e.value);
S name = or2(/* ouch */ mm.getFirst("read as"), /* end ouch */ unpackAGIDomain(page.url), page.url);
ret hhtml(
hhead_title(url)
+ hbody_fullcenter(
top + h1(ahref_unstyled("http://" + url, htmlEncode2(name)) + (newPage ? " [huh????]" : ""))
+ p(nlToBr(lines(map(entries, func(Entry e) -> S {
hide.contains(e.count) ? "" : "[" + e.count + "] " +
htmlencode2(e.key) + ": " + b(
isURL(e.value)
|| cic(mmMeta.get(e.count), "is a URL")
|| isAGIDomain(e.value)
? ahref(absoluteURL(e.value), htmlencode2(e.value))
: htmlencode2(e.value)
) }))))
+ hpostform(
h3("Add an entry")
+ "Key: " + hinputfield(key := key2) + " Value: " + hinputfield(value := value2) + "
" + hsubmit("Add")
)
));
}