diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-10-04 08:04:40 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-10-04 08:04:40 +0000 |
commit | 724a6edec24e0b01c30d61d75a5da044a024aeb9 (patch) | |
tree | f22d37a03b12418c7077976739a2f31362fb1bee /weblog-model.lua | |
parent | aab583bbe2fbb87281c8b0c8adff6cd091977bfa (diff) | |
download | acf-weblog-724a6edec24e0b01c30d61d75a5da044a024aeb9.tar.bz2 acf-weblog-724a6edec24e0b01c30d61d75a5da044a024aeb9.tar.xz |
Truncate squid clientuserid before importing
Diffstat (limited to 'weblog-model.lua')
-rw-r--r-- | weblog-model.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/weblog-model.lua b/weblog-model.lua index 2222815..78b2ea0 100644 --- a/weblog-model.lua +++ b/weblog-model.lua @@ -60,9 +60,10 @@ local function assert (v, m) return v, m end --- Escape special characters in sql statements -local escape = function(sql) +-- Escape special characters in sql statements and truncate to length +local escape = function(sql, length) sql = sql or "" + if length then sql = string.sub(sql, 1, length) end sql = string.gsub(sql, "'", "''") return string.gsub(sql, "\\", "\\\\") end @@ -181,7 +182,7 @@ end local importsquidlog = function(entry, sourcename) if entry then local sql = string.format("INSERT INTO weblog VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", - escape(sourcename), escape(entry.clientip), escape(entry.clientuserid):lower(), + escape(sourcename), escape(entry.clientip), escape(entry.clientuserid, 64):lower(), escape(entry.logdatetime), escape(entry.URL), escape(entry.bytes)) local res = assert (con:execute(sql)) end @@ -190,7 +191,7 @@ end local importdglog = function(entry, sourcename) if entry then local sql = string.format("INSERT INTO blocklog VALUES ('%s', '0.0.0.0', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", - escape(sourcename), escape(entry.clientuserid:lower()), escape(entry.logdatetime), escape(entry.URL), + escape(sourcename), escape(entry.clientuserid:lower(), 64), escape(entry.logdatetime), escape(entry.URL), escape(entry.bytes), escape(entry.reason), escape(entry.score or "0"), escape(entry.shortreason)) local res = assert (con:execute(sql)) end |