diff options
Diffstat (limited to 'weblog-viewweblog-html.lsp')
-rw-r--r-- | weblog-viewweblog-html.lsp | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/weblog-viewweblog-html.lsp b/weblog-viewweblog-html.lsp index a03c3e6..5aaabea 100644 --- a/weblog-viewweblog-html.lsp +++ b/weblog-viewweblog-html.lsp @@ -1,6 +1,31 @@ <% local data, viewlibrary, page_info, session = ... %> <% require("viewfunctions")%> -<% require("weblogviewfunctions")%> + +<% +-- Insert a string into another string +function string_insert(value, insert, place) + if place == nil then + place = string.len(value)+1 + end + + return string.sub(value, 1,place-1) .. tostring(insert) .. string.sub(value, place, string.len(value)) +end + +--Highlight occurences of a word in a string +function string_highlight(txtvalue, searchval, fcolour, bcolour) + if txtvalue ~=nil and searchval ~= nil then + sStart = string.find(string.lower(txtvalue),string.lower(searchval)) + if sStart ~= nil then + sEnd = sStart + string.len(searchval) + txtvalue = string.insert(txtvalue,"</font>", sEnd) + txtvalue = string.insert(txtvalue,"<font style='color:"..fcolour.."; background-color:"..bcolour..";'>", sStart) + end + end + + return txtvalue +end +%> + <% if data.value.focus.value ~= "" then %> <script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"></script> <script type="text/javascript"> @@ -33,6 +58,7 @@ #content table tr.mark { background: #E9E9E9; } #content table tr.selected { background: #FC9A01; } </style> + <H1>Search Parameters</H1> <DL> <% if data.errtxt then %><p class="error"><%= html.html_escape(data.errtxt) %></p><% end %> @@ -170,23 +196,23 @@ end <TD <% if data.value.clientip.value == watch.clientip then %> style="font-weight:bold;" <% end %> ><%= html.html_escape(watch.clientip) %></TD> <TD <% if data.value.clientuserid.value == watch.clientuserid then %> style="font-weight:bold;" <% end %> ><%= html.html_escape(watch.clientuserid) %></TD> <TD><%= html.html_escape(watch.bytes) %></TD> - <TD WIDTH="2%"><% if watch.badyesno == "1" then %><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/dodgy.gif' width='13' height='13'><% end %></TD> - <TD WIDTH="2%"><% if watch.deniedyesno ~= "0" then %> <IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/denied.gif' width='13' height='13'><% end %></TD> - <TD WIDTH="2%"><% if watch.bypassyesno ~= "0" then %> <IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/bypass.gif' width='13' height='13'><% end %></TD> + <TD WIDTH="2%"><% if watch.badyesno == "1" then %><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/dodgy.png' width='13' height='13'><% end %></TD> + <TD WIDTH="2%"><% if watch.deniedyesno ~= "0" then %> <IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/denied.png' width='13' height='13'><% end %></TD> + <TD WIDTH="2%"><% if watch.bypassyesno ~= "0" then %> <IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/bypass.png' width='13' height='13'><% end %></TD> <TD><%= html.html_escape(watch.score) %></TD> <TD><%= html.html_escape(watch.reason) %></TD> - <TD style="word-wrap: break-word" width="500"><% highlight_uri=html.html_escape(watch.uri) - if watch.wordloc ~= nil then - if string.find(watch.wordloc,"|") then - badwords = split(watch.wordloc,"|") - for key,wrd in pairs(badwords) do - highlight_uri = string.highlight(highlight_uri, wrd, "yellow","red") - end - else - highlight_uri = string.highlight(highlight_uri, watch.wordloc, "yellow","red") - end - end %> - <%= highlight_uri %></TD> + <TD style="word-wrap: break-word" width="500"><% highlight_uri=html.html_escape(watch.uri) + if watch.wordloc ~= nil then + if string.find(watch.wordloc, "|") then + badwords = format.string_to_table(watch.wordloc, "|") + for key,wrd in ipairs(badwords) do + highlight_uri = string_highlight(highlight_uri, wrd, "yellow", "red") + end + else + highlight_uri = string_highlight(highlight_uri, watch.wordloc, "yellow", "red") + end + end %> + <%= highlight_uri %></TD> <TD><%= watch.wordloc %></TD> </TR> <% end %> |