diff options
27 files changed, 319 insertions, 7 deletions
diff --git a/doc/context/documents/general/qrcs/setup-cs.pdf b/doc/context/documents/general/qrcs/setup-cs.pdf Binary files differindex 39b65c25f..a16ac7c7f 100644 --- a/doc/context/documents/general/qrcs/setup-cs.pdf +++ b/doc/context/documents/general/qrcs/setup-cs.pdf diff --git a/doc/context/documents/general/qrcs/setup-de.pdf b/doc/context/documents/general/qrcs/setup-de.pdf Binary files differindex b88a2ce5b..e73757bcb 100644 --- a/doc/context/documents/general/qrcs/setup-de.pdf +++ b/doc/context/documents/general/qrcs/setup-de.pdf diff --git a/doc/context/documents/general/qrcs/setup-en.pdf b/doc/context/documents/general/qrcs/setup-en.pdf Binary files differindex 1a29d501f..ac301f450 100644 --- a/doc/context/documents/general/qrcs/setup-en.pdf +++ b/doc/context/documents/general/qrcs/setup-en.pdf diff --git a/doc/context/documents/general/qrcs/setup-fr.pdf b/doc/context/documents/general/qrcs/setup-fr.pdf Binary files differindex f8ce8df34..49aab661d 100644 --- a/doc/context/documents/general/qrcs/setup-fr.pdf +++ b/doc/context/documents/general/qrcs/setup-fr.pdf diff --git a/doc/context/documents/general/qrcs/setup-it.pdf b/doc/context/documents/general/qrcs/setup-it.pdf Binary files differindex 7f19e1a8b..644d59f13 100644 --- a/doc/context/documents/general/qrcs/setup-it.pdf +++ b/doc/context/documents/general/qrcs/setup-it.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf Binary files differindex bc5c0c3fa..846c88051 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-cs.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-cs.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-de.pdf b/doc/context/documents/general/qrcs/setup-mapping-de.pdf Binary files differindex a42ae2c59..c22f14ecb 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-de.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-de.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-en.pdf b/doc/context/documents/general/qrcs/setup-mapping-en.pdf Binary files differindex 9cd6213a1..fd92bf8cb 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-en.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-en.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf Binary files differindex 50ef94736..ae14bc0aa 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-fr.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-fr.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-it.pdf b/doc/context/documents/general/qrcs/setup-mapping-it.pdf Binary files differindex de703533b..ff7fb5ba1 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-it.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-it.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf Binary files differindex 40c331291..1e275416d 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-nl.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-nl.pdf diff --git a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf Binary files differindex 630269a81..3db6a6009 100644 --- a/doc/context/documents/general/qrcs/setup-mapping-ro.pdf +++ b/doc/context/documents/general/qrcs/setup-mapping-ro.pdf diff --git a/doc/context/documents/general/qrcs/setup-nl.pdf b/doc/context/documents/general/qrcs/setup-nl.pdf Binary files differindex 84dbda522..b7cb3b39e 100644 --- a/doc/context/documents/general/qrcs/setup-nl.pdf +++ b/doc/context/documents/general/qrcs/setup-nl.pdf diff --git a/doc/context/documents/general/qrcs/setup-ro.pdf b/doc/context/documents/general/qrcs/setup-ro.pdf Binary files differindex a330fc2e8..5e0a18b0a 100644 --- a/doc/context/documents/general/qrcs/setup-ro.pdf +++ b/doc/context/documents/general/qrcs/setup-ro.pdf diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 64f238b14..55741083b 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.03.06 14:59} +\newcontextversion{2018.03.07 12:18} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 59c766e6d..f2fce340e 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2018.03.06 14:59} +\edef\contextversion{2018.03.07 12:18} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-de.mkii b/tex/context/base/mkii/mult-de.mkii index 8e79e3856..a5269ff3f 100644 --- a/tex/context/base/mkii/mult-de.mkii +++ b/tex/context/base/mkii/mult-de.mkii @@ -1077,6 +1077,7 @@ \setinterfaceconstant{preview}{vorschau} \setinterfaceconstant{previous}{vorige} \setinterfaceconstant{previousnumber}{vorigenummer} +\setinterfaceconstant{print}{print} \setinterfaceconstant{printable}{druckbar} \setinterfaceconstant{process}{process} \setinterfaceconstant{profile}{profile} @@ -1162,6 +1163,7 @@ \setinterfaceconstant{sidemethod}{sidemethod} \setinterfaceconstant{sidespaceafter}{nebennachspatium} \setinterfaceconstant{sidespacebefore}{nebenvorspatium} +\setinterfaceconstant{sidespaceinbetween}{sidespaceinbetween} \setinterfaceconstant{sidethreshold}{sidethreshold} \setinterfaceconstant{sign}{zeichen} \setinterfaceconstant{simplecommand}{simplecommand} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 185b10341..ae8748f0f 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.03.06 14:59} +\newcontextversion{2018.03.07 12:18} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 2fc4222bb..8cf5eff00 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -42,7 +42,7 @@ %D has to match \type {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2018.03.06 14:59} +\edef\contextversion{2018.03.07 12:18} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 1693e5e85..b5094c116 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex f63b33d65..5ee29c774 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/util-sql-imp-ffi.lua b/tex/context/base/mkiv/util-sql-imp-ffi.lua index adda02107..07c4752cd 100644 --- a/tex/context/base/mkiv/util-sql-imp-ffi.lua +++ b/tex/context/base/mkiv/util-sql-imp-ffi.lua @@ -144,7 +144,8 @@ ffi.cdef [[ local sql = utilities.sql ----- mysql = ffi.load(os.name == "windows" and "libmysql" or "libmysqlclient") -local mysql = ffilib(os.name == "windows" and "libmysql" or "libmysqlclient") +----- mysql = ffilib(os.name == "windows" and "libmysql" or "libmysqlclient") +local mysql = ffilib(os.name == "windows" and "libmysql" or "libmysql") if not mysql then report_state("unable to load library") @@ -508,7 +509,8 @@ local function execute(specification) end local wraptemplate = [[ -local mysql = ffi.load(os.name == "windows" and "libmysql" or "libmysqlclient") +----- mysql = ffi.load(os.name == "windows" and "libmysql" or "libmysqlclient") +local mysql = ffi.load(os.name == "windows" and "libmysql" or "libmysql") local mysql_fetch_row = mysql.mysql_fetch_row local ffi_tostring = ffi.string diff --git a/tex/context/base/mkiv/util-sql-logins.lua b/tex/context/base/mkiv/util-sql-logins.lua new file mode 100644 index 000000000..e4329ecc2 --- /dev/null +++ b/tex/context/base/mkiv/util-sql-logins.lua @@ -0,0 +1,306 @@ +if not modules then modules = { } end modules ['util-sql-logins'] = { + version = 1.001, + comment = "companion to lmx-*", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +if not utilities.sql then require("util-sql") end + +local sql = utilities.sql +local sqlexecute = sql.execute +local sqlmakeconverter = sql.makeconverter + +local format = string.format +local ostime = os.time +local formatter = string.formatter + +local trace_logins = true +local report_logins = logs.reporter("sql","logins") + +local logins = sql.logins or { } +sql.logins = logins + +logins.maxnoflogins = logins.maxnoflogins or 10 +logins.cooldowntime = logins.cooldowntime or 10 * 60 +logins.purgetime = logins.purgetime or 1 * 60 * 60 +logins.autopurge = true + +local template_create = [[ +CREATE TABLE + `logins` + ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8_bin NOT NULL, + `time` int(11) DEFAULT '0', + `n` int(11) DEFAULT '0', + `state` int(11) DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `id_UNIQUE` (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) + ) + ENGINE=InnoDB + DEFAULT CHARSET=utf8 + COLLATE=utf8_bin + COMMENT='state: 0=unset 1=known 2=unknown' +]] + +local states = { + [0] = "unset", + [1] = "known", + [2] = "unknown", +} + +local converter_fetch, fields_fetch = sqlmakeconverter { + { name = "id", type = "number" }, + { name = "name", type = "string" }, + { name = "time", type = "number" }, + { name = "n", type = "number" }, + { name = "state", type = "number" }, -- faster than mapping +} + +local template_fetch = format( [[ + SELECT + %s + FROM + `logins` + WHERE + `name` = '%%[name]%%' +]], fields_fetch ) + +local template_insert = [[ + INSERT INTO `logins` + ( `name`, `state`, `time`, `n`) + VALUES + ('%[name]%', %state%, %time%, %n%) +]] + +local template_update = [[ + UPDATE + `logins` + SET + `state` = %state%, + `time` = %time%, + `n` = %n% + WHERE + `name` = '%[name]%' +]] + +local template_delete = [[ + DELETE FROM + `logins` + WHERE + `name` = '%[name]%' +]] + +local template_purge = [[ + DELETE FROM + `logins` + WHERE + `time` < '%time%' +]] + +-- todo: auto cleanup (when new attempt) + +local cache = { } setmetatable(cache, { __mode = 'v' }) + +local function usercreate(presets) + sqlexecute { + template = template_create, + presets = presets, + } +end + +local function userunknown(presets,name) + local d = { + name = name, + state = 2, + time = ostime(), + n = 0, + } + sqlexecute { + template = template_update, + presets = presets, + variables = d, + } + cache[name] = d + report_logins("user %a is registered as unknown",name) +end + +local function userknown(presets,name) + local d = { + name = name, + state = 1, + time = ostime(), + n = 0, + } + sqlexecute { + template = template_update, + presets = presets, + variables = d, + } + cache[name] = d + report_logins("user %a is registered as known",name) +end + +local function userreset(presets,name) + sqlexecute { + template = template_delete, + presets = presets, + } + cache[name] = nil + report_logins("user %a is reset",name) +end + +local function userpurge(presets,delay) + sqlexecute { + template = template_purge, + presets = presets, + variables = { + time = ostime() - (delay or logins.purgetime), + } + } + cache = { } + report_logins("users are purged") +end + +local function verdict(okay,...) + if not trace_logins then + -- no tracing + elseif okay then + report_logins("%s, granted",formatter(...)) + else + report_logins("%s, blocked",formatter(...)) + end + return okay +end + +local lasttime = 0 + +local function userpermitted(presets,name) + local currenttime = ostime() + if logins.autopurge and (lasttime == 0 or (currenttime - lasttime > logins.purgetime)) then + report_logins("automatic purge triggered") + userpurge(presets) + lasttime = currenttime + end + local data = cache[name] + if data then + report_logins("user %a is cached",name) + else + report_logins("user %a is fetched",name) + data = sqlexecute { + template = template_fetch, + presets = presets, + converter = converter_fetch, + variables = { + name = name, + } + } + end + if not data or not data.name then + local d = { + name = name, + state = 0, + time = currenttime, + n = 1, + } + sqlexecute { + template = template_insert, + presets = presets, + variables = d, + } + cache[name] = d + return verdict(true,"creating new entry for %a",name) + end + cache[name] = data[1] + local state = data.state + if state == 2 then -- unknown + return verdict(false,"user %a has state %a",name,states[state]) + end + local n = data.n + local m = logins.maxnoflogins + if n > m then + local deltatime = currenttime - data.time + local cooldowntime = logins.cooldowntime + if deltatime < cooldowntime then + return verdict(false,"user %a is blocked for %s seconds out of %s",name,cooldowntime-deltatime,cooldowntime) + else + n = 0 + end + end + if n == 0 then + local d = { + name = name, + state = 0, + time = currenttime, + n = 1, + } + sqlexecute { + template = template_update, + presets = presets, + variables = d, + } + cache[name] = d + return verdict(true,"user %a gets a first chance",name) + else + local d = { + name = name, + state = 0, + time = currenttime, + n = n + 1, + } + sqlexecute { + template = template_update, + presets = presets, + variables = d, + } + cache[name] = d + return verdict(true,"user %a gets a new chance, %s attempts out of %s done",name,n,m) + end +end + +logins.create = usercreate +logins.known = userknown +logins.unknown = userunknown +logins.reset = userreset +logins.purge = userpurge +logins.permitted = userpermitted + +return logins + +-- -- + +-- sql.setmethod("client") + +-- local presets = { +-- database = "test", +-- username = "root", +-- password = "something", +-- } + +-- logins.cooldowntime = 2*60 +-- logins.maxnoflogins = 3 + +-- sql.logins.purge(presets,0) + +-- for i=1,6 do +-- print("") +-- sql.logins.permitted(presets,"hans") +-- sql.logins.permitted(presets,"kees") +-- sql.logins.permitted(presets,"ton") +-- if i == 1 then +-- -- sql.logins.unknown(presets,"hans") +-- -- sql.logins.known(presets,"kees") +-- end +-- end + +-- if loginpermitted(presets,username) then +-- if validlogin(username,...) then +-- -- sql.logins.known(presets,username) +-- elseif unknownuser(username) then +-- sql.logins.unknown(presets,username) +-- end +-- end + diff --git a/tex/context/interface/mkii/keys-de.xml b/tex/context/interface/mkii/keys-de.xml index 449d46fa6..f399f128a 100644 --- a/tex/context/interface/mkii/keys-de.xml +++ b/tex/context/interface/mkii/keys-de.xml @@ -1083,6 +1083,7 @@ <cd:constant name='preview' value='vorschau'/> <cd:constant name='previous' value='vorige'/> <cd:constant name='previousnumber' value='vorigenummer'/> + <cd:constant name='print' value='print'/> <cd:constant name='printable' value='druckbar'/> <cd:constant name='process' value='process'/> <cd:constant name='profile' value='profile'/> @@ -1168,6 +1169,7 @@ <cd:constant name='sidemethod' value='sidemethod'/> <cd:constant name='sidespaceafter' value='nebennachspatium'/> <cd:constant name='sidespacebefore' value='nebenvorspatium'/> + <cd:constant name='sidespaceinbetween' value='sidespaceinbetween'/> <cd:constant name='sidethreshold' value='sidethreshold'/> <cd:constant name='sign' value='zeichen'/> <cd:constant name='simplecommand' value='simplecommand'/> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 1a29d501f..ac301f450 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 47eb69524..d7c363731 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 42f791da2..1670e68e3 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 03/06/18 14:59:23 +-- merge date : 03/07/18 12:18:24 do -- begin closure to overcome local limits and interference |